Reviewers: danno,

Message:
PTAL.

Not entirely sure if I should keep it like this or have one single function
taking a boolean parameter (enableProfiler(true) and enableProfiler(false)).

Description:
Functions in d8 to turn the profiler on/off (enableProfiler() and
disableProfiler()).


Please review this at http://codereview.chromium.org/7851011/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/d8.h
  M src/d8.cc


Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 5c604368920a35c5aa81feb6818219b59c697a43..f1297e1d7b2d10c03921f4fd116227c8d8649d4c 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -210,6 +210,18 @@ Handle<Value> Shell::Write(const Arguments& args) {
 }


+Handle<Value> Shell::EnableProfiler(const Arguments& args) {
+  V8::ResumeProfiler();
+  return Undefined();
+}
+
+
+Handle<Value> Shell::DisableProfiler(const Arguments& args) {
+  V8::PauseProfiler();
+  return Undefined();
+}
+
+
 Handle<Value> Shell::Read(const Arguments& args) {
   String::Utf8Value file(args[0]);
   if (*file == NULL) {
@@ -656,6 +668,12 @@ Handle<ObjectTemplate> Shell::CreateGlobalTemplate() {
   global_template->Set(String::New("load"), FunctionTemplate::New(Load));
   global_template->Set(String::New("quit"), FunctionTemplate::New(Quit));
global_template->Set(String::New("version"), FunctionTemplate::New(Version));
+  if (i::FLAG_prof) {
+    global_template->Set(String::New("enableProfiler"),
+                         FunctionTemplate::New(EnableProfiler));
+    global_template->Set(String::New("disableProfiler"),
+                         FunctionTemplate::New(DisableProfiler));
+  }

   // Bind the handlers for external arrays.
   global_template->Set(String::New("Int8Array"),
Index: src/d8.h
diff --git a/src/d8.h b/src/d8.h
index 28321f56dae720dd2e02d56881132966f53921c7..d0267a7f2f314629f5438d78d43f2144f7611956 100644
--- a/src/d8.h
+++ b/src/d8.h
@@ -248,6 +248,8 @@ class Shell : public i::AllStatic {
   static Handle<Value> Yield(const Arguments& args);
   static Handle<Value> Quit(const Arguments& args);
   static Handle<Value> Version(const Arguments& args);
+  static Handle<Value> EnableProfiler(const Arguments& args);
+  static Handle<Value> DisableProfiler(const Arguments& args);
   static Handle<Value> Read(const Arguments& args);
   static Handle<Value> ReadLine(const Arguments& args);
   static Handle<Value> Load(const Arguments& args);


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

Reply via email to