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
This commit is contained in:
yangguo@chromium.org 2011-09-08 08:54:28 +00:00
parent 0b1225a5aa
commit ca67c5a23d
2 changed files with 20 additions and 0 deletions

View File

@ -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) { Handle<Value> Shell::Read(const Arguments& args) {
String::Utf8Value file(args[0]); String::Utf8Value file(args[0]);
if (*file == NULL) { 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("load"), FunctionTemplate::New(Load));
global_template->Set(String::New("quit"), FunctionTemplate::New(Quit)); global_template->Set(String::New("quit"), FunctionTemplate::New(Quit));
global_template->Set(String::New("version"), FunctionTemplate::New(Version)); 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. // Bind the handlers for external arrays.
global_template->Set(String::New("Int8Array"), global_template->Set(String::New("Int8Array"),

View File

@ -248,6 +248,8 @@ class Shell : public i::AllStatic {
static Handle<Value> Yield(const Arguments& args); static Handle<Value> Yield(const Arguments& args);
static Handle<Value> Quit(const Arguments& args); static Handle<Value> Quit(const Arguments& args);
static Handle<Value> Version(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> Read(const Arguments& args);
static Handle<Value> ReadLine(const Arguments& args); static Handle<Value> ReadLine(const Arguments& args);
static Handle<Value> Load(const Arguments& args); static Handle<Value> Load(const Arguments& args);