Revision: 8454
Author:   [email protected]
Date:     Wed Jun 29 01:22:36 2011
Log:      added the --test option for d8 into tools/test.py

TEST= tools/test.py --shell d8 -v

Review URL: http://codereview.chromium.org/7272028
http://code.google.com/p/v8/source/detail?r=8454

Modified:
 /branches/bleeding_edge/src/d8.cc
 /branches/bleeding_edge/src/d8.h
 /branches/bleeding_edge/tools/test.py

=======================================
--- /branches/bleeding_edge/src/d8.cc   Fri Jun 24 13:04:32 2011
+++ /branches/bleeding_edge/src/d8.cc   Wed Jun 29 01:22:36 2011
@@ -599,8 +599,34 @@
   AddOSMethods(os_templ);
   global_template->Set(String::New("os"), os_templ);

+  Handle<ObjectTemplate> counter_templ = ObjectTemplate::New();
+  counter_templ->Set(String::New("get"),
+                     FunctionTemplate::New(CounterGetValue));
+  global_template->Set(String::New("counter"), counter_templ);
+
   return global_template;
 }
+
+
+Handle<Value> Shell::CounterGetValue(const Arguments& args){
+  if (args.Length() != 1) {
+    return ThrowException(String::New("get() takes one argument"));
+  }
+  if (args[0]->IsString()) {
+    String::AsciiValue name(args[0]);
+    Counter* counter = counter_map_->Lookup(*name);
+    if (!counter) {
+      String::AsciiValue prefixed(String::Concat(String::New("c:"),
+                                                 String::New(*name)));
+      counter = counter_map_->Lookup(*prefixed);
+      if (!counter) {
+        return ThrowException(String::New("invalid counter name"));
+      }
+    }
+    return Handle<Integer>::Cast(Integer::New(counter->count()));
+  }
+  return ThrowException(String::New("counter name must be a string"));
+}


 void Shell::Initialize(bool test_shell) {
=======================================
--- /branches/bleeding_edge/src/d8.h    Fri Jun 24 13:04:32 2011
+++ /branches/bleeding_edge/src/d8.h    Wed Jun 29 01:22:36 2011
@@ -128,6 +128,7 @@
                                size_t buckets);
   static void AddHistogramSample(void* histogram, int sample);
   static void MapCounters(const char* name);
+  static Handle<Value> CounterGetValue(const Arguments& args);
   static Handle<String> ReadFile(const char* name);
   static void Initialize(bool test_shell);
   static void RenewEvaluationContext();
=======================================
--- /branches/bleeding_edge/tools/test.py       Mon May  9 02:02:27 2011
+++ /branches/bleeding_edge/tools/test.py       Wed Jun 29 01:22:36 2011
@@ -1272,6 +1272,11 @@
       options.special_command += " --crankshaft"
     else:
       options.special_command = "@--crankshaft"
+  if options.shell == "d8":
+    if options.special_command:
+      options.special_command += " --test"
+    else:
+      options.special_command = "@--test"
   if options.noprof:
     options.scons_flags.append("prof=off")
     options.scons_flags.append("profilingsupport=off")

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to