| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 | 534 |
| 535 CHECK_EQ(0, profile->samples_count()); | 535 CHECK_EQ(0, profile->samples_count()); |
| 536 } | 536 } |
| 537 | 537 |
| 538 | 538 |
| 539 // --- P r o f i l e r E x t e n s i o n --- | 539 // --- P r o f i l e r E x t e n s i o n --- |
| 540 | 540 |
| 541 class ProfilerExtension : public v8::Extension { | 541 class ProfilerExtension : public v8::Extension { |
| 542 public: | 542 public: |
| 543 ProfilerExtension() : v8::Extension("v8/profiler", kSource) { } | 543 ProfilerExtension() : v8::Extension("v8/profiler", kSource) { } |
| 544 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 544 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 545 v8::Isolate* isolate, |
| 545 v8::Handle<v8::String> name); | 546 v8::Handle<v8::String> name); |
| 546 static void StartProfiling(const v8::FunctionCallbackInfo<v8::Value>& args); | 547 static void StartProfiling(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 547 static void StopProfiling(const v8::FunctionCallbackInfo<v8::Value>& args); | 548 static void StopProfiling(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 548 private: | 549 private: |
| 549 static const char* kSource; | 550 static const char* kSource; |
| 550 }; | 551 }; |
| 551 | 552 |
| 552 | 553 |
| 553 const char* ProfilerExtension::kSource = | 554 const char* ProfilerExtension::kSource = |
| 554 "native function startProfiling();" | 555 "native function startProfiling();" |
| 555 "native function stopProfiling();"; | 556 "native function stopProfiling();"; |
| 556 | 557 |
| 557 v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunction( | 558 v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunctionTemplate( |
| 558 v8::Handle<v8::String> name) { | 559 v8::Isolate* isolate, v8::Handle<v8::String> name) { |
| 559 if (name->Equals(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), | 560 if (name->Equals(v8::String::NewFromUtf8(isolate, "startProfiling"))) { |
| 560 "startProfiling"))) { | |
| 561 return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling); | 561 return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling); |
| 562 } else if (name->Equals(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), | 562 } else if (name->Equals(v8::String::NewFromUtf8(isolate, "stopProfiling"))) { |
| 563 "stopProfiling"))) { | |
| 564 return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling); | 563 return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling); |
| 565 } else { | 564 } else { |
| 566 CHECK(false); | 565 CHECK(false); |
| 567 return v8::Handle<v8::FunctionTemplate>(); | 566 return v8::Handle<v8::FunctionTemplate>(); |
| 568 } | 567 } |
| 569 } | 568 } |
| 570 | 569 |
| 571 | 570 |
| 572 void ProfilerExtension::StartProfiling( | 571 void ProfilerExtension::StartProfiling( |
| 573 const v8::FunctionCallbackInfo<v8::Value>& args) { | 572 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 826 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); |
| 828 | 827 |
| 829 current = PickChild(current, "TryFinally"); | 828 current = PickChild(current, "TryFinally"); |
| 830 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 829 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); |
| 831 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); | 830 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); |
| 832 | 831 |
| 833 current = PickChild(current, "TryCatch"); | 832 current = PickChild(current, "TryCatch"); |
| 834 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 833 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); |
| 835 CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason())); | 834 CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason())); |
| 836 } | 835 } |
| OLD | NEW |