From ca67c5a23dc836ebbf6a00fb261ece7fcccfac71 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Thu, 8 Sep 2011 08:54:28 +0000 Subject: [PATCH] Functions in d8 to turn the profiler on/off (enableProfiler() and disableProfiler()). Review URL: http://codereview.chromium.org/7851011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9188 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/d8.cc | 18 ++++++++++++++++++ src/d8.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/d8.cc b/src/d8.cc index 5c60436..f1297e1 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -210,6 +210,18 @@ Handle Shell::Write(const Arguments& args) { } +Handle Shell::EnableProfiler(const Arguments& args) { + V8::ResumeProfiler(); + return Undefined(); +} + + +Handle Shell::DisableProfiler(const Arguments& args) { + V8::PauseProfiler(); + return Undefined(); +} + + Handle Shell::Read(const Arguments& args) { String::Utf8Value file(args[0]); if (*file == NULL) { @@ -656,6 +668,12 @@ Handle 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"), diff --git a/src/d8.h b/src/d8.h index 28321f5..d0267a7 100644 --- a/src/d8.h +++ b/src/d8.h @@ -248,6 +248,8 @@ class Shell : public i::AllStatic { static Handle Yield(const Arguments& args); static Handle Quit(const Arguments& args); static Handle Version(const Arguments& args); + static Handle EnableProfiler(const Arguments& args); + static Handle DisableProfiler(const Arguments& args); static Handle Read(const Arguments& args); static Handle ReadLine(const Arguments& args); static Handle Load(const Arguments& args); -- 2.7.4