| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 using i::CpuProfilesCollection; | 42 using i::CpuProfilesCollection; |
| 43 using i::Heap; | 43 using i::Heap; |
| 44 using i::ProfileGenerator; | 44 using i::ProfileGenerator; |
| 45 using i::ProfileNode; | 45 using i::ProfileNode; |
| 46 using i::ProfilerEventsProcessor; | 46 using i::ProfilerEventsProcessor; |
| 47 using i::ScopedVector; | 47 using i::ScopedVector; |
| 48 using i::SmartPointer; | 48 using i::SmartPointer; |
| 49 using i::Vector; | 49 using i::Vector; |
| 50 | 50 |
| 51 | 51 |
| 52 // Helper methods |
| 53 static v8::Local<v8::Function> GetFunction(v8::Context* env, const char* name) { |
| 54 return v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str(name))); |
| 55 } |
| 56 |
| 57 |
| 52 TEST(StartStop) { | 58 TEST(StartStop) { |
| 53 i::Isolate* isolate = CcTest::i_isolate(); | 59 i::Isolate* isolate = CcTest::i_isolate(); |
| 54 CpuProfilesCollection profiles(isolate->heap()); | 60 CpuProfilesCollection profiles(isolate->heap()); |
| 55 ProfileGenerator generator(&profiles); | 61 ProfileGenerator generator(&profiles); |
| 56 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( | 62 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( |
| 57 &generator, NULL, v8::base::TimeDelta::FromMicroseconds(100))); | 63 &generator, NULL, v8::base::TimeDelta::FromMicroseconds(100))); |
| 58 processor->Start(); | 64 processor->Start(); |
| 59 processor->StopSynchronously(); | 65 processor->StopSynchronously(); |
| 60 } | 66 } |
| 61 | 67 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 i::SNPrintF(name, "function_%d", ++counter); | 113 i::SNPrintF(name, "function_%d", ++counter); |
| 108 const char* name_start = name.start(); | 114 const char* name_start = name.start(); |
| 109 i::SNPrintF(script, | 115 i::SNPrintF(script, |
| 110 "function %s() {\n" | 116 "function %s() {\n" |
| 111 "var counter = 0;\n" | 117 "var counter = 0;\n" |
| 112 "for (var i = 0; i < %d; ++i) counter += i;\n" | 118 "for (var i = 0; i < %d; ++i) counter += i;\n" |
| 113 "return '%s_' + counter;\n" | 119 "return '%s_' + counter;\n" |
| 114 "}\n" | 120 "}\n" |
| 115 "%s();\n", name_start, counter, name_start, name_start); | 121 "%s();\n", name_start, counter, name_start, name_start); |
| 116 CompileRun(script.start()); | 122 CompileRun(script.start()); |
| 117 i::Handle<i::JSFunction> fun = v8::Utils::OpenHandle( | 123 |
| 118 *v8::Local<v8::Function>::Cast( | 124 i::Handle<i::JSFunction> fun = |
| 119 (*env)->Global()->Get(v8_str(name_start)))); | 125 v8::Utils::OpenHandle(*GetFunction(**env, name_start)); |
| 120 return fun->code(); | 126 return fun->code(); |
| 121 } | 127 } |
| 122 | 128 |
| 123 | 129 |
| 124 TEST(CodeEvents) { | 130 TEST(CodeEvents) { |
| 125 CcTest::InitializeVM(); | 131 CcTest::InitializeVM(); |
| 126 LocalContext env; | 132 LocalContext env; |
| 127 i::Isolate* isolate = CcTest::i_isolate(); | 133 i::Isolate* isolate = CcTest::i_isolate(); |
| 128 i::Factory* factory = isolate->factory(); | 134 i::Factory* factory = isolate->factory(); |
| 129 TestSetup test_setup; | 135 TestSetup test_setup; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 158 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4); | 164 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4); |
| 159 | 165 |
| 160 // Enqueue a tick event to enable code events processing. | 166 // Enqueue a tick event to enable code events processing. |
| 161 EnqueueTickSampleEvent(processor.get(), aaa_code->address()); | 167 EnqueueTickSampleEvent(processor.get(), aaa_code->address()); |
| 162 | 168 |
| 163 processor->StopSynchronously(); | 169 processor->StopSynchronously(); |
| 164 | 170 |
| 165 // Check the state of profile generator. | 171 // Check the state of profile generator. |
| 166 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address()); | 172 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address()); |
| 167 CHECK(aaa); | 173 CHECK(aaa); |
| 168 CHECK_EQ(aaa_str, aaa->name()); | 174 CHECK_EQ(0, strcmp(aaa_str, aaa->name())); |
| 169 | 175 |
| 170 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address()); | 176 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address()); |
| 171 CHECK(comment); | 177 CHECK(comment); |
| 172 CHECK_EQ(0, strcmp("comment", comment->name())); | 178 CHECK_EQ(0, strcmp("comment", comment->name())); |
| 173 | 179 |
| 174 CodeEntry* args5 = generator.code_map()->FindEntry(args5_code->address()); | 180 CodeEntry* args5 = generator.code_map()->FindEntry(args5_code->address()); |
| 175 CHECK(args5); | 181 CHECK(args5); |
| 176 CHECK_EQ(0, strcmp("5", args5->name())); | 182 CHECK_EQ(0, strcmp("5", args5->name())); |
| 177 | 183 |
| 178 CHECK(!generator.code_map()->FindEntry(comment2_code->address())); | 184 CHECK(!generator.code_map()->FindEntry(comment2_code->address())); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 352 } |
| 347 | 353 |
| 348 | 354 |
| 349 TEST(DeleteCpuProfile) { | 355 TEST(DeleteCpuProfile) { |
| 350 LocalContext env; | 356 LocalContext env; |
| 351 v8::HandleScope scope(env->GetIsolate()); | 357 v8::HandleScope scope(env->GetIsolate()); |
| 352 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 358 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 353 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(cpu_profiler); | 359 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(cpu_profiler); |
| 354 | 360 |
| 355 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 361 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 356 v8::Local<v8::String> name1 = v8::String::NewFromUtf8(env->GetIsolate(), "1"); | 362 v8::Local<v8::String> name1 = v8_str("1"); |
| 357 cpu_profiler->StartProfiling(name1); | 363 cpu_profiler->StartProfiling(name1); |
| 358 v8::CpuProfile* p1 = cpu_profiler->StopProfiling(name1); | 364 v8::CpuProfile* p1 = cpu_profiler->StopProfiling(name1); |
| 359 CHECK(p1); | 365 CHECK(p1); |
| 360 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 366 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
| 361 CHECK(FindCpuProfile(cpu_profiler, p1)); | 367 CHECK(FindCpuProfile(cpu_profiler, p1)); |
| 362 p1->Delete(); | 368 p1->Delete(); |
| 363 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 369 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 364 | 370 |
| 365 v8::Local<v8::String> name2 = v8::String::NewFromUtf8(env->GetIsolate(), "2"); | 371 v8::Local<v8::String> name2 = v8_str("2"); |
| 366 cpu_profiler->StartProfiling(name2); | 372 cpu_profiler->StartProfiling(name2); |
| 367 v8::CpuProfile* p2 = cpu_profiler->StopProfiling(name2); | 373 v8::CpuProfile* p2 = cpu_profiler->StopProfiling(name2); |
| 368 CHECK(p2); | 374 CHECK(p2); |
| 369 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 375 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
| 370 CHECK(FindCpuProfile(cpu_profiler, p2)); | 376 CHECK(FindCpuProfile(cpu_profiler, p2)); |
| 371 v8::Local<v8::String> name3 = v8::String::NewFromUtf8(env->GetIsolate(), "3"); | 377 v8::Local<v8::String> name3 = v8_str("3"); |
| 372 cpu_profiler->StartProfiling(name3); | 378 cpu_profiler->StartProfiling(name3); |
| 373 v8::CpuProfile* p3 = cpu_profiler->StopProfiling(name3); | 379 v8::CpuProfile* p3 = cpu_profiler->StopProfiling(name3); |
| 374 CHECK(p3); | 380 CHECK(p3); |
| 375 CHECK_EQ(2, iprofiler->GetProfilesCount()); | 381 CHECK_EQ(2, iprofiler->GetProfilesCount()); |
| 376 CHECK_NE(p2, p3); | 382 CHECK_NE(p2, p3); |
| 377 CHECK(FindCpuProfile(cpu_profiler, p3)); | 383 CHECK(FindCpuProfile(cpu_profiler, p3)); |
| 378 CHECK(FindCpuProfile(cpu_profiler, p2)); | 384 CHECK(FindCpuProfile(cpu_profiler, p2)); |
| 379 p2->Delete(); | 385 p2->Delete(); |
| 380 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 386 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
| 381 CHECK(!FindCpuProfile(cpu_profiler, p2)); | 387 CHECK(!FindCpuProfile(cpu_profiler, p2)); |
| 382 CHECK(FindCpuProfile(cpu_profiler, p3)); | 388 CHECK(FindCpuProfile(cpu_profiler, p3)); |
| 383 p3->Delete(); | 389 p3->Delete(); |
| 384 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 390 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 385 } | 391 } |
| 386 | 392 |
| 387 | 393 |
| 388 TEST(ProfileStartEndTime) { | 394 TEST(ProfileStartEndTime) { |
| 389 LocalContext env; | 395 LocalContext env; |
| 390 v8::HandleScope scope(env->GetIsolate()); | 396 v8::HandleScope scope(env->GetIsolate()); |
| 391 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 397 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 392 | 398 |
| 393 v8::Local<v8::String> profile_name = | 399 v8::Local<v8::String> profile_name = v8_str("test"); |
| 394 v8::String::NewFromUtf8(env->GetIsolate(), "test"); | |
| 395 cpu_profiler->StartProfiling(profile_name); | 400 cpu_profiler->StartProfiling(profile_name); |
| 396 const v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); | 401 const v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); |
| 397 CHECK(profile->GetStartTime() <= profile->GetEndTime()); | 402 CHECK(profile->GetStartTime() <= profile->GetEndTime()); |
| 398 } | 403 } |
| 399 | 404 |
| 400 | 405 |
| 401 static v8::CpuProfile* RunProfiler( | 406 static v8::CpuProfile* RunProfiler( |
| 402 v8::Handle<v8::Context> env, v8::Handle<v8::Function> function, | 407 v8::Handle<v8::Context> env, v8::Handle<v8::Function> function, |
| 403 v8::Handle<v8::Value> argv[], int argc, | 408 v8::Handle<v8::Value> argv[], int argc, |
| 404 unsigned min_js_samples, bool collect_samples = false) { | 409 unsigned min_js_samples, bool collect_samples = false) { |
| 405 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 410 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 406 v8::Local<v8::String> profile_name = | 411 v8::Local<v8::String> profile_name = v8_str("my_profile"); |
| 407 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile"); | |
| 408 | 412 |
| 409 cpu_profiler->StartProfiling(profile_name, collect_samples); | 413 cpu_profiler->StartProfiling(profile_name, collect_samples); |
| 410 | 414 |
| 411 i::Sampler* sampler = | 415 i::Sampler* sampler = |
| 412 reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler(); | 416 reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler(); |
| 413 sampler->StartCountingSamples(); | 417 sampler->StartCountingSamples(); |
| 414 do { | 418 do { |
| 415 function->Call(env->Global(), argc, argv); | 419 function->Call(env->Global(), argc, argv); |
| 416 } while (sampler->js_and_external_sample_count() < min_js_samples); | 420 } while (sampler->js_and_external_sample_count() < min_js_samples); |
| 417 | 421 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 447 CHECK(!name->Equals(node->GetChild(j)->GetFunctionName())); | 451 CHECK(!name->Equals(node->GetChild(j)->GetFunctionName())); |
| 448 } | 452 } |
| 449 } | 453 } |
| 450 } | 454 } |
| 451 | 455 |
| 452 | 456 |
| 453 static const v8::CpuProfileNode* FindChild(v8::Isolate* isolate, | 457 static const v8::CpuProfileNode* FindChild(v8::Isolate* isolate, |
| 454 const v8::CpuProfileNode* node, | 458 const v8::CpuProfileNode* node, |
| 455 const char* name) { | 459 const char* name) { |
| 456 int count = node->GetChildrenCount(); | 460 int count = node->GetChildrenCount(); |
| 457 v8::Handle<v8::String> nameHandle = v8::String::NewFromUtf8(isolate, name); | 461 v8::Handle<v8::String> nameHandle = v8_str(name); |
| 458 for (int i = 0; i < count; i++) { | 462 for (int i = 0; i < count; i++) { |
| 459 const v8::CpuProfileNode* child = node->GetChild(i); | 463 const v8::CpuProfileNode* child = node->GetChild(i); |
| 460 if (nameHandle->Equals(child->GetFunctionName())) return child; | 464 if (nameHandle->Equals(child->GetFunctionName())) return child; |
| 461 } | 465 } |
| 462 return NULL; | 466 return NULL; |
| 463 } | 467 } |
| 464 | 468 |
| 465 | 469 |
| 466 static const v8::CpuProfileNode* GetChild(v8::Isolate* isolate, | 470 static const v8::CpuProfileNode* GetChild(v8::Isolate* isolate, |
| 467 const v8::CpuProfileNode* node, | 471 const v8::CpuProfileNode* node, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 // 522 522 loop [-1] | 539 // 522 522 loop [-1] |
| 536 // 263 0 bar [-1] | 540 // 263 0 bar [-1] |
| 537 // 263 1 delay [-1] | 541 // 263 1 delay [-1] |
| 538 // 262 262 loop [-1] | 542 // 262 262 loop [-1] |
| 539 // 2 2 (program) [-1] | 543 // 2 2 (program) [-1] |
| 540 // 6 6 (garbage collector) [-1] | 544 // 6 6 (garbage collector) [-1] |
| 541 TEST(CollectCpuProfile) { | 545 TEST(CollectCpuProfile) { |
| 542 LocalContext env; | 546 LocalContext env; |
| 543 v8::HandleScope scope(env->GetIsolate()); | 547 v8::HandleScope scope(env->GetIsolate()); |
| 544 | 548 |
| 545 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | 549 CompileRun(cpu_profiler_test_source); |
| 546 cpu_profiler_test_source))->Run(); | 550 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 547 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 548 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | |
| 549 | 551 |
| 550 int32_t profiling_interval_ms = 200; | 552 int32_t profiling_interval_ms = 200; |
| 551 v8::Handle<v8::Value> args[] = { | 553 v8::Handle<v8::Value> args[] = { |
| 552 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) | 554 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) |
| 553 }; | 555 }; |
| 554 v8::CpuProfile* profile = | 556 v8::CpuProfile* profile = |
| 555 RunProfiler(env.local(), function, args, arraysize(args), 200); | 557 RunProfiler(env.local(), function, args, arraysize(args), 200); |
| 556 function->Call(env->Global(), arraysize(args), args); | 558 function->Call(env->Global(), arraysize(args), args); |
| 557 | 559 |
| 558 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 560 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 559 | 561 |
| 560 ScopedVector<v8::Handle<v8::String> > names(3); | 562 ScopedVector<v8::Handle<v8::String> > names(3); |
| 561 names[0] = v8::String::NewFromUtf8( | 563 names[0] = v8_str(ProfileGenerator::kGarbageCollectorEntryName); |
| 562 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 564 names[1] = v8_str(ProfileGenerator::kProgramEntryName); |
| 563 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 565 names[2] = v8_str("start"); |
| 564 ProfileGenerator::kProgramEntryName); | |
| 565 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | |
| 566 CheckChildrenNames(root, names); | 566 CheckChildrenNames(root, names); |
| 567 | 567 |
| 568 const v8::CpuProfileNode* startNode = | 568 const v8::CpuProfileNode* startNode = |
| 569 GetChild(env->GetIsolate(), root, "start"); | 569 GetChild(env->GetIsolate(), root, "start"); |
| 570 CHECK_EQ(1, startNode->GetChildrenCount()); | 570 CHECK_EQ(1, startNode->GetChildrenCount()); |
| 571 | 571 |
| 572 const v8::CpuProfileNode* fooNode = | 572 const v8::CpuProfileNode* fooNode = |
| 573 GetChild(env->GetIsolate(), startNode, "foo"); | 573 GetChild(env->GetIsolate(), startNode, "foo"); |
| 574 CHECK_EQ(3, fooNode->GetChildrenCount()); | 574 CHECK_EQ(3, fooNode->GetChildrenCount()); |
| 575 | 575 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 // 2 2 (program) [-1] | 612 // 2 2 (program) [-1] |
| 613 // 6 6 (garbage collector) [-1] | 613 // 6 6 (garbage collector) [-1] |
| 614 // | 614 // |
| 615 // The test checks no FP ranges are present in a deoptimized funcion. | 615 // The test checks no FP ranges are present in a deoptimized funcion. |
| 616 // If 'foo' has no ranges the samples falling into the prologue will miss the | 616 // If 'foo' has no ranges the samples falling into the prologue will miss the |
| 617 // 'start' function on the stack, so 'foo' will be attached to the (root). | 617 // 'start' function on the stack, so 'foo' will be attached to the (root). |
| 618 TEST(HotDeoptNoFrameEntry) { | 618 TEST(HotDeoptNoFrameEntry) { |
| 619 LocalContext env; | 619 LocalContext env; |
| 620 v8::HandleScope scope(env->GetIsolate()); | 620 v8::HandleScope scope(env->GetIsolate()); |
| 621 | 621 |
| 622 v8::Script::Compile(v8::String::NewFromUtf8( | 622 CompileRun(hot_deopt_no_frame_entry_test_source); |
| 623 env->GetIsolate(), | 623 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 624 hot_deopt_no_frame_entry_test_source))->Run(); | |
| 625 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 626 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | |
| 627 | 624 |
| 628 int32_t profiling_interval_ms = 200; | 625 int32_t profiling_interval_ms = 200; |
| 629 v8::Handle<v8::Value> args[] = { | 626 v8::Handle<v8::Value> args[] = { |
| 630 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) | 627 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) |
| 631 }; | 628 }; |
| 632 v8::CpuProfile* profile = | 629 v8::CpuProfile* profile = |
| 633 RunProfiler(env.local(), function, args, arraysize(args), 200); | 630 RunProfiler(env.local(), function, args, arraysize(args), 200); |
| 634 function->Call(env->Global(), arraysize(args), args); | 631 function->Call(env->Global(), arraysize(args), args); |
| 635 | 632 |
| 636 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 633 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 637 | 634 |
| 638 ScopedVector<v8::Handle<v8::String> > names(3); | 635 ScopedVector<v8::Handle<v8::String> > names(3); |
| 639 names[0] = v8::String::NewFromUtf8( | 636 names[0] = v8_str(ProfileGenerator::kGarbageCollectorEntryName); |
| 640 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 637 names[1] = v8_str(ProfileGenerator::kProgramEntryName); |
| 641 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 638 names[2] = v8_str("start"); |
| 642 ProfileGenerator::kProgramEntryName); | |
| 643 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | |
| 644 CheckChildrenNames(root, names); | 639 CheckChildrenNames(root, names); |
| 645 | 640 |
| 646 const v8::CpuProfileNode* startNode = | 641 const v8::CpuProfileNode* startNode = |
| 647 GetChild(env->GetIsolate(), root, "start"); | 642 GetChild(env->GetIsolate(), root, "start"); |
| 648 CHECK_EQ(1, startNode->GetChildrenCount()); | 643 CHECK_EQ(1, startNode->GetChildrenCount()); |
| 649 | 644 |
| 650 GetChild(env->GetIsolate(), startNode, "foo"); | 645 GetChild(env->GetIsolate(), startNode, "foo"); |
| 651 | 646 |
| 652 profile->Delete(); | 647 profile->Delete(); |
| 653 } | 648 } |
| 654 | 649 |
| 655 | 650 |
| 656 TEST(CollectCpuProfileSamples) { | 651 TEST(CollectCpuProfileSamples) { |
| 657 LocalContext env; | 652 LocalContext env; |
| 658 v8::HandleScope scope(env->GetIsolate()); | 653 v8::HandleScope scope(env->GetIsolate()); |
| 659 | 654 |
| 660 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | 655 CompileRun(cpu_profiler_test_source); |
| 661 cpu_profiler_test_source))->Run(); | 656 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 662 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 663 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | |
| 664 | 657 |
| 665 int32_t profiling_interval_ms = 200; | 658 int32_t profiling_interval_ms = 200; |
| 666 v8::Handle<v8::Value> args[] = { | 659 v8::Handle<v8::Value> args[] = { |
| 667 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) | 660 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) |
| 668 }; | 661 }; |
| 669 v8::CpuProfile* profile = | 662 v8::CpuProfile* profile = |
| 670 RunProfiler(env.local(), function, args, arraysize(args), 200, true); | 663 RunProfiler(env.local(), function, args, arraysize(args), 200, true); |
| 671 | 664 |
| 672 CHECK_LE(200, profile->GetSamplesCount()); | 665 CHECK_LE(200, profile->GetSamplesCount()); |
| 673 uint64_t end_time = profile->GetEndTime(); | 666 uint64_t end_time = profile->GetEndTime(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 702 // [Top down]: | 695 // [Top down]: |
| 703 // 135 0 (root) [-1] #1 | 696 // 135 0 (root) [-1] #1 |
| 704 // 121 72 start [-1] #3 | 697 // 121 72 start [-1] #3 |
| 705 // 49 33 delay [-1] #4 | 698 // 49 33 delay [-1] #4 |
| 706 // 16 16 loop [-1] #5 | 699 // 16 16 loop [-1] #5 |
| 707 // 14 14 (program) [-1] #2 | 700 // 14 14 (program) [-1] #2 |
| 708 TEST(SampleWhenFrameIsNotSetup) { | 701 TEST(SampleWhenFrameIsNotSetup) { |
| 709 LocalContext env; | 702 LocalContext env; |
| 710 v8::HandleScope scope(env->GetIsolate()); | 703 v8::HandleScope scope(env->GetIsolate()); |
| 711 | 704 |
| 712 v8::Script::Compile(v8::String::NewFromUtf8( | 705 CompileRun(cpu_profiler_test_source2); |
| 713 env->GetIsolate(), cpu_profiler_test_source2))->Run(); | 706 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 714 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 715 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | |
| 716 | 707 |
| 717 int32_t repeat_count = 100; | 708 int32_t repeat_count = 100; |
| 718 #if defined(USE_SIMULATOR) | 709 #if defined(USE_SIMULATOR) |
| 719 // Simulators are much slower. | 710 // Simulators are much slower. |
| 720 repeat_count = 1; | 711 repeat_count = 1; |
| 721 #endif | 712 #endif |
| 722 v8::Handle<v8::Value> args[] = { | 713 v8::Handle<v8::Value> args[] = { |
| 723 v8::Integer::New(env->GetIsolate(), repeat_count) | 714 v8::Integer::New(env->GetIsolate(), repeat_count) |
| 724 }; | 715 }; |
| 725 v8::CpuProfile* profile = | 716 v8::CpuProfile* profile = |
| 726 RunProfiler(env.local(), function, args, arraysize(args), 100); | 717 RunProfiler(env.local(), function, args, arraysize(args), 100); |
| 727 | 718 |
| 728 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 719 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 729 | 720 |
| 730 ScopedVector<v8::Handle<v8::String> > names(3); | 721 ScopedVector<v8::Handle<v8::String> > names(3); |
| 731 names[0] = v8::String::NewFromUtf8( | 722 names[0] = v8_str(ProfileGenerator::kGarbageCollectorEntryName); |
| 732 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 723 names[1] = v8_str(ProfileGenerator::kProgramEntryName); |
| 733 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 724 names[2] = v8_str("start"); |
| 734 ProfileGenerator::kProgramEntryName); | |
| 735 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | |
| 736 CheckChildrenNames(root, names); | 725 CheckChildrenNames(root, names); |
| 737 | 726 |
| 738 const v8::CpuProfileNode* startNode = | 727 const v8::CpuProfileNode* startNode = |
| 739 FindChild(env->GetIsolate(), root, "start"); | 728 FindChild(env->GetIsolate(), root, "start"); |
| 740 // On slow machines there may be no meaningfull samples at all, skip the | 729 // On slow machines there may be no meaningfull samples at all, skip the |
| 741 // check there. | 730 // check there. |
| 742 if (startNode && startNode->GetChildrenCount() > 0) { | 731 if (startNode && startNode->GetChildrenCount() > 0) { |
| 743 CHECK_EQ(1, startNode->GetChildrenCount()); | 732 CHECK_EQ(1, startNode->GetChildrenCount()); |
| 744 const v8::CpuProfileNode* delayNode = | 733 const v8::CpuProfileNode* delayNode = |
| 745 GetChild(env->GetIsolate(), startNode, "delay"); | 734 GetChild(env->GetIsolate(), startNode, "delay"); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 v8::HandleScope scope(isolate); | 808 v8::HandleScope scope(isolate); |
| 820 | 809 |
| 821 v8::Local<v8::FunctionTemplate> func_template = | 810 v8::Local<v8::FunctionTemplate> func_template = |
| 822 v8::FunctionTemplate::New(isolate); | 811 v8::FunctionTemplate::New(isolate); |
| 823 v8::Local<v8::ObjectTemplate> instance_template = | 812 v8::Local<v8::ObjectTemplate> instance_template = |
| 824 func_template->InstanceTemplate(); | 813 func_template->InstanceTemplate(); |
| 825 | 814 |
| 826 TestApiCallbacks accessors(100); | 815 TestApiCallbacks accessors(100); |
| 827 v8::Local<v8::External> data = | 816 v8::Local<v8::External> data = |
| 828 v8::External::New(isolate, &accessors); | 817 v8::External::New(isolate, &accessors); |
| 829 instance_template->SetAccessor( | 818 instance_template->SetAccessor(v8_str("foo"), &TestApiCallbacks::Getter, |
| 830 v8::String::NewFromUtf8(isolate, "foo"), | 819 &TestApiCallbacks::Setter, data); |
| 831 &TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data); | |
| 832 v8::Local<v8::Function> func = func_template->GetFunction(); | 820 v8::Local<v8::Function> func = func_template->GetFunction(); |
| 833 v8::Local<v8::Object> instance = func->NewInstance(); | 821 v8::Local<v8::Object> instance = func->NewInstance(); |
| 834 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"), | 822 env->Global()->Set(v8_str("instance"), instance); |
| 835 instance); | |
| 836 | 823 |
| 837 v8::Script::Compile( | 824 CompileRun(native_accessor_test_source); |
| 838 v8::String::NewFromUtf8(isolate, native_accessor_test_source)) | 825 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 839 ->Run(); | |
| 840 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 841 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | |
| 842 | 826 |
| 843 int32_t repeat_count = 1; | 827 int32_t repeat_count = 1; |
| 844 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 828 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; |
| 845 v8::CpuProfile* profile = | 829 v8::CpuProfile* profile = |
| 846 RunProfiler(env.local(), function, args, arraysize(args), 180); | 830 RunProfiler(env.local(), function, args, arraysize(args), 180); |
| 847 | 831 |
| 848 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 832 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 849 const v8::CpuProfileNode* startNode = | 833 const v8::CpuProfileNode* startNode = |
| 850 GetChild(isolate, root, "start"); | 834 GetChild(isolate, root, "start"); |
| 851 GetChild(isolate, startNode, "get foo"); | 835 GetChild(isolate, startNode, "get foo"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 864 v8::HandleScope scope(isolate); | 848 v8::HandleScope scope(isolate); |
| 865 | 849 |
| 866 v8::Local<v8::FunctionTemplate> func_template = | 850 v8::Local<v8::FunctionTemplate> func_template = |
| 867 v8::FunctionTemplate::New(isolate); | 851 v8::FunctionTemplate::New(isolate); |
| 868 v8::Local<v8::ObjectTemplate> instance_template = | 852 v8::Local<v8::ObjectTemplate> instance_template = |
| 869 func_template->InstanceTemplate(); | 853 func_template->InstanceTemplate(); |
| 870 | 854 |
| 871 TestApiCallbacks accessors(1); | 855 TestApiCallbacks accessors(1); |
| 872 v8::Local<v8::External> data = | 856 v8::Local<v8::External> data = |
| 873 v8::External::New(isolate, &accessors); | 857 v8::External::New(isolate, &accessors); |
| 874 instance_template->SetAccessor( | 858 instance_template->SetAccessor(v8_str("foo"), &TestApiCallbacks::Getter, |
| 875 v8::String::NewFromUtf8(isolate, "foo"), | 859 &TestApiCallbacks::Setter, data); |
| 876 &TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data); | |
| 877 v8::Local<v8::Function> func = func_template->GetFunction(); | 860 v8::Local<v8::Function> func = func_template->GetFunction(); |
| 878 v8::Local<v8::Object> instance = func->NewInstance(); | 861 v8::Local<v8::Object> instance = func->NewInstance(); |
| 879 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"), | 862 env->Global()->Set(v8_str("instance"), instance); |
| 880 instance); | |
| 881 | 863 |
| 882 v8::Script::Compile( | 864 CompileRun(native_accessor_test_source); |
| 883 v8::String::NewFromUtf8(isolate, native_accessor_test_source)) | 865 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 884 ->Run(); | |
| 885 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 886 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | |
| 887 | 866 |
| 888 { | 867 { |
| 889 // Make sure accessors ICs are in monomorphic state before starting | 868 // Make sure accessors ICs are in monomorphic state before starting |
| 890 // profiling. | 869 // profiling. |
| 891 accessors.set_warming_up(true); | 870 accessors.set_warming_up(true); |
| 892 int32_t warm_up_iterations = 3; | 871 int32_t warm_up_iterations = 3; |
| 893 v8::Handle<v8::Value> args[] = { | 872 v8::Handle<v8::Value> args[] = { |
| 894 v8::Integer::New(isolate, warm_up_iterations) | 873 v8::Integer::New(isolate, warm_up_iterations) |
| 895 }; | 874 }; |
| 896 function->Call(env->Global(), arraysize(args), args); | 875 function->Call(env->Global(), arraysize(args), args); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 923 LocalContext env; | 902 LocalContext env; |
| 924 v8::Isolate* isolate = env->GetIsolate(); | 903 v8::Isolate* isolate = env->GetIsolate(); |
| 925 v8::HandleScope scope(isolate); | 904 v8::HandleScope scope(isolate); |
| 926 | 905 |
| 927 TestApiCallbacks callbacks(100); | 906 TestApiCallbacks callbacks(100); |
| 928 v8::Local<v8::External> data = | 907 v8::Local<v8::External> data = |
| 929 v8::External::New(isolate, &callbacks); | 908 v8::External::New(isolate, &callbacks); |
| 930 | 909 |
| 931 v8::Local<v8::FunctionTemplate> func_template = | 910 v8::Local<v8::FunctionTemplate> func_template = |
| 932 v8::FunctionTemplate::New(isolate); | 911 v8::FunctionTemplate::New(isolate); |
| 933 func_template->SetClassName( | 912 func_template->SetClassName(v8_str("Test_InstanceCostructor")); |
| 934 v8::String::NewFromUtf8(isolate, "Test_InstanceCostructor")); | |
| 935 v8::Local<v8::ObjectTemplate> proto_template = | 913 v8::Local<v8::ObjectTemplate> proto_template = |
| 936 func_template->PrototypeTemplate(); | 914 func_template->PrototypeTemplate(); |
| 937 v8::Local<v8::Signature> signature = | 915 v8::Local<v8::Signature> signature = |
| 938 v8::Signature::New(isolate, func_template); | 916 v8::Signature::New(isolate, func_template); |
| 939 proto_template->Set(v8::String::NewFromUtf8(isolate, "fooMethod"), | 917 proto_template->Set( |
| 940 v8::FunctionTemplate::New(isolate, | 918 v8_str("fooMethod"), |
| 941 &TestApiCallbacks::Callback, | 919 v8::FunctionTemplate::New(isolate, &TestApiCallbacks::Callback, data, |
| 942 data, signature, 0)); | 920 signature, 0)); |
| 943 | 921 |
| 944 v8::Local<v8::Function> func = func_template->GetFunction(); | 922 v8::Local<v8::Function> func = func_template->GetFunction(); |
| 945 v8::Local<v8::Object> instance = func->NewInstance(); | 923 v8::Local<v8::Object> instance = func->NewInstance(); |
| 946 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"), | 924 env->Global()->Set(v8_str("instance"), instance); |
| 947 instance); | |
| 948 | 925 |
| 949 v8::Script::Compile(v8::String::NewFromUtf8( | 926 CompileRun(native_method_test_source); |
| 950 isolate, native_method_test_source))->Run(); | 927 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 951 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 952 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | |
| 953 | 928 |
| 954 int32_t repeat_count = 1; | 929 int32_t repeat_count = 1; |
| 955 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 930 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; |
| 956 v8::CpuProfile* profile = | 931 v8::CpuProfile* profile = |
| 957 RunProfiler(env.local(), function, args, arraysize(args), 100); | 932 RunProfiler(env.local(), function, args, arraysize(args), 100); |
| 958 | 933 |
| 959 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 934 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 960 const v8::CpuProfileNode* startNode = | 935 const v8::CpuProfileNode* startNode = |
| 961 GetChild(isolate, root, "start"); | 936 GetChild(isolate, root, "start"); |
| 962 GetChild(isolate, startNode, "fooMethod"); | 937 GetChild(isolate, startNode, "fooMethod"); |
| 963 | 938 |
| 964 profile->Delete(); | 939 profile->Delete(); |
| 965 } | 940 } |
| 966 | 941 |
| 967 | 942 |
| 968 TEST(NativeMethodMonomorphicIC) { | 943 TEST(NativeMethodMonomorphicIC) { |
| 969 LocalContext env; | 944 LocalContext env; |
| 970 v8::Isolate* isolate = env->GetIsolate(); | 945 v8::Isolate* isolate = env->GetIsolate(); |
| 971 v8::HandleScope scope(isolate); | 946 v8::HandleScope scope(isolate); |
| 972 | 947 |
| 973 TestApiCallbacks callbacks(1); | 948 TestApiCallbacks callbacks(1); |
| 974 v8::Local<v8::External> data = | 949 v8::Local<v8::External> data = |
| 975 v8::External::New(isolate, &callbacks); | 950 v8::External::New(isolate, &callbacks); |
| 976 | 951 |
| 977 v8::Local<v8::FunctionTemplate> func_template = | 952 v8::Local<v8::FunctionTemplate> func_template = |
| 978 v8::FunctionTemplate::New(isolate); | 953 v8::FunctionTemplate::New(isolate); |
| 979 func_template->SetClassName( | 954 func_template->SetClassName(v8_str("Test_InstanceCostructor")); |
| 980 v8::String::NewFromUtf8(isolate, "Test_InstanceCostructor")); | |
| 981 v8::Local<v8::ObjectTemplate> proto_template = | 955 v8::Local<v8::ObjectTemplate> proto_template = |
| 982 func_template->PrototypeTemplate(); | 956 func_template->PrototypeTemplate(); |
| 983 v8::Local<v8::Signature> signature = | 957 v8::Local<v8::Signature> signature = |
| 984 v8::Signature::New(isolate, func_template); | 958 v8::Signature::New(isolate, func_template); |
| 985 proto_template->Set(v8::String::NewFromUtf8(isolate, "fooMethod"), | 959 proto_template->Set( |
| 986 v8::FunctionTemplate::New(isolate, | 960 v8_str("fooMethod"), |
| 987 &TestApiCallbacks::Callback, | 961 v8::FunctionTemplate::New(isolate, &TestApiCallbacks::Callback, data, |
| 988 data, signature, 0)); | 962 signature, 0)); |
| 989 | 963 |
| 990 v8::Local<v8::Function> func = func_template->GetFunction(); | 964 v8::Local<v8::Function> func = func_template->GetFunction(); |
| 991 v8::Local<v8::Object> instance = func->NewInstance(); | 965 v8::Local<v8::Object> instance = func->NewInstance(); |
| 992 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"), | 966 env->Global()->Set(v8_str("instance"), instance); |
| 993 instance); | |
| 994 | 967 |
| 995 v8::Script::Compile(v8::String::NewFromUtf8( | 968 CompileRun(native_method_test_source); |
| 996 isolate, native_method_test_source))->Run(); | 969 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 997 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 998 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | |
| 999 { | 970 { |
| 1000 // Make sure method ICs are in monomorphic state before starting | 971 // Make sure method ICs are in monomorphic state before starting |
| 1001 // profiling. | 972 // profiling. |
| 1002 callbacks.set_warming_up(true); | 973 callbacks.set_warming_up(true); |
| 1003 int32_t warm_up_iterations = 3; | 974 int32_t warm_up_iterations = 3; |
| 1004 v8::Handle<v8::Value> args[] = { | 975 v8::Handle<v8::Value> args[] = { |
| 1005 v8::Integer::New(isolate, warm_up_iterations) | 976 v8::Integer::New(isolate, warm_up_iterations) |
| 1006 }; | 977 }; |
| 1007 function->Call(env->Global(), arraysize(args), args); | 978 function->Call(env->Global(), arraysize(args), args); |
| 1008 callbacks.set_warming_up(false); | 979 callbacks.set_warming_up(false); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1031 " var callback = foo.bind(this);\n" | 1002 " var callback = foo.bind(this);\n" |
| 1032 " callback();\n" | 1003 " callback();\n" |
| 1033 "}"; | 1004 "}"; |
| 1034 | 1005 |
| 1035 | 1006 |
| 1036 TEST(BoundFunctionCall) { | 1007 TEST(BoundFunctionCall) { |
| 1037 v8::HandleScope scope(CcTest::isolate()); | 1008 v8::HandleScope scope(CcTest::isolate()); |
| 1038 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); | 1009 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1039 v8::Context::Scope context_scope(env); | 1010 v8::Context::Scope context_scope(env); |
| 1040 | 1011 |
| 1041 v8::Script::Compile( | 1012 CompileRun(bound_function_test_source); |
| 1042 v8::String::NewFromUtf8(env->GetIsolate(), bound_function_test_source)) | 1013 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 1043 ->Run(); | |
| 1044 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 1045 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | |
| 1046 | 1014 |
| 1047 v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0, 0); | 1015 v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0, 0); |
| 1048 | 1016 |
| 1049 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1017 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1050 ScopedVector<v8::Handle<v8::String> > names(3); | 1018 ScopedVector<v8::Handle<v8::String> > names(3); |
| 1051 names[0] = v8::String::NewFromUtf8( | 1019 names[0] = v8_str(ProfileGenerator::kGarbageCollectorEntryName); |
| 1052 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1020 names[1] = v8_str(ProfileGenerator::kProgramEntryName); |
| 1053 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1021 names[2] = v8_str("start"); |
| 1054 ProfileGenerator::kProgramEntryName); | |
| 1055 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | |
| 1056 // Don't allow |foo| node to be at the top level. | 1022 // Don't allow |foo| node to be at the top level. |
| 1057 CheckChildrenNames(root, names); | 1023 CheckChildrenNames(root, names); |
| 1058 | 1024 |
| 1059 const v8::CpuProfileNode* startNode = | 1025 const v8::CpuProfileNode* startNode = |
| 1060 GetChild(env->GetIsolate(), root, "start"); | 1026 GetChild(env->GetIsolate(), root, "start"); |
| 1061 GetChild(env->GetIsolate(), startNode, "foo"); | 1027 GetChild(env->GetIsolate(), startNode, "foo"); |
| 1062 | 1028 |
| 1063 profile->Delete(); | 1029 profile->Delete(); |
| 1064 } | 1030 } |
| 1065 | 1031 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1083 " while (m > 1) {\n" | 1049 " while (m > 1) {\n" |
| 1084 " m--;\n" | 1050 " m--;\n" |
| 1085 " n += m * m * m;\n" | 1051 " n += m * m * m;\n" |
| 1086 " }\n" | 1052 " }\n" |
| 1087 "}\n" | 1053 "}\n" |
| 1088 "%s();\n", | 1054 "%s();\n", |
| 1089 func_name, func_name); | 1055 func_name, func_name); |
| 1090 | 1056 |
| 1091 CompileRun(script.start()); | 1057 CompileRun(script.start()); |
| 1092 | 1058 |
| 1093 i::Handle<i::JSFunction> func = v8::Utils::OpenHandle( | 1059 i::Handle<i::JSFunction> func = |
| 1094 *v8::Local<v8::Function>::Cast((*env)->Global()->Get(v8_str(func_name)))); | 1060 v8::Utils::OpenHandle(*GetFunction(*env, func_name)); |
| 1095 CHECK(func->shared()); | 1061 CHECK(func->shared()); |
| 1096 CHECK(func->shared()->code()); | 1062 CHECK(func->shared()->code()); |
| 1097 i::Code* code = NULL; | 1063 i::Code* code = NULL; |
| 1098 if (func->code()->is_optimized_code()) { | 1064 if (func->code()->is_optimized_code()) { |
| 1099 code = func->code(); | 1065 code = func->code(); |
| 1100 } else { | 1066 } else { |
| 1101 CHECK(func->shared()->code() == func->code() || !i::FLAG_crankshaft); | 1067 CHECK(func->shared()->code() == func->code() || !i::FLAG_crankshaft); |
| 1102 code = func->shared()->code(); | 1068 code = func->shared()->code(); |
| 1103 } | 1069 } |
| 1104 CHECK(code); | 1070 CHECK(code); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1124 EnqueueTickSampleEvent(processor, code_address); | 1090 EnqueueTickSampleEvent(processor, code_address); |
| 1125 | 1091 |
| 1126 processor->StopSynchronously(); | 1092 processor->StopSynchronously(); |
| 1127 | 1093 |
| 1128 CpuProfile* profile = profiles->StopProfiling(""); | 1094 CpuProfile* profile = profiles->StopProfiling(""); |
| 1129 CHECK(profile); | 1095 CHECK(profile); |
| 1130 | 1096 |
| 1131 // Check the state of profile generator. | 1097 // Check the state of profile generator. |
| 1132 CodeEntry* func_entry = generator.code_map()->FindEntry(code_address); | 1098 CodeEntry* func_entry = generator.code_map()->FindEntry(code_address); |
| 1133 CHECK(func_entry); | 1099 CHECK(func_entry); |
| 1134 CHECK_EQ(func_name, func_entry->name()); | 1100 CHECK_EQ(0, strcmp(func_name, func_entry->name())); |
| 1135 const i::JITLineInfoTable* line_info = func_entry->line_info(); | 1101 const i::JITLineInfoTable* line_info = func_entry->line_info(); |
| 1136 CHECK(line_info); | 1102 CHECK(line_info); |
| 1137 CHECK(!line_info->empty()); | 1103 CHECK(!line_info->empty()); |
| 1138 | 1104 |
| 1139 // Check the hit source lines using V8 Public APIs. | 1105 // Check the hit source lines using V8 Public APIs. |
| 1140 const i::ProfileTree* tree = profile->top_down(); | 1106 const i::ProfileTree* tree = profile->top_down(); |
| 1141 ProfileNode* root = tree->root(); | 1107 ProfileNode* root = tree->root(); |
| 1142 CHECK(root); | 1108 CHECK(root); |
| 1143 ProfileNode* func_node = root->FindChild(func_entry); | 1109 ProfileNode* func_node = root->FindChild(func_entry); |
| 1144 CHECK(func_node); | 1110 CHECK(func_node); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 // 1 1 (garbage collector) [-1] #4 | 1149 // 1 1 (garbage collector) [-1] #4 |
| 1184 // 5 0 (unresolved function) [-1] #5 | 1150 // 5 0 (unresolved function) [-1] #5 |
| 1185 // 5 5 call [-1] #6 | 1151 // 5 5 call [-1] #6 |
| 1186 // 71 70 start [-1] #3 | 1152 // 71 70 start [-1] #3 |
| 1187 // 1 1 bar [-1] #7 | 1153 // 1 1 bar [-1] #7 |
| 1188 // 19 19 (program) [-1] #2 | 1154 // 19 19 (program) [-1] #2 |
| 1189 TEST(FunctionCallSample) { | 1155 TEST(FunctionCallSample) { |
| 1190 LocalContext env; | 1156 LocalContext env; |
| 1191 v8::HandleScope scope(env->GetIsolate()); | 1157 v8::HandleScope scope(env->GetIsolate()); |
| 1192 | 1158 |
| 1193 // Collect garbage that might have be generated while installing extensions. | 1159 // Collect garbage that might have be generated while installing |
| 1160 // extensions. |
| 1194 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 1161 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 1195 | 1162 |
| 1196 v8::Script::Compile(v8::String::NewFromUtf8( | 1163 CompileRun(call_function_test_source); |
| 1197 env->GetIsolate(), call_function_test_source))->Run(); | 1164 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 1198 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 1199 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | |
| 1200 | 1165 |
| 1201 int32_t duration_ms = 100; | 1166 int32_t duration_ms = 100; |
| 1202 v8::Handle<v8::Value> args[] = { | 1167 v8::Handle<v8::Value> args[] = { |
| 1203 v8::Integer::New(env->GetIsolate(), duration_ms) | 1168 v8::Integer::New(env->GetIsolate(), duration_ms) |
| 1204 }; | 1169 }; |
| 1205 v8::CpuProfile* profile = | 1170 v8::CpuProfile* profile = |
| 1206 RunProfiler(env.local(), function, args, arraysize(args), 100); | 1171 RunProfiler(env.local(), function, args, arraysize(args), 100); |
| 1207 | 1172 |
| 1208 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1173 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1209 { | 1174 { |
| 1210 ScopedVector<v8::Handle<v8::String> > names(4); | 1175 ScopedVector<v8::Handle<v8::String> > names(4); |
| 1211 names[0] = v8::String::NewFromUtf8( | 1176 names[0] = v8_str(ProfileGenerator::kGarbageCollectorEntryName); |
| 1212 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1177 names[1] = v8_str(ProfileGenerator::kProgramEntryName); |
| 1213 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1178 names[2] = v8_str("start"); |
| 1214 ProfileGenerator::kProgramEntryName); | 1179 names[3] = v8_str(i::ProfileGenerator::kUnresolvedFunctionName); |
| 1215 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | |
| 1216 names[3] = v8::String::NewFromUtf8( | |
| 1217 env->GetIsolate(), i::ProfileGenerator::kUnresolvedFunctionName); | |
| 1218 // Don't allow |bar| and |call| nodes to be at the top level. | 1180 // Don't allow |bar| and |call| nodes to be at the top level. |
| 1219 CheckChildrenNames(root, names); | 1181 CheckChildrenNames(root, names); |
| 1220 } | 1182 } |
| 1221 | 1183 |
| 1222 // In case of GC stress tests all samples may be in GC phase and there | 1184 // In case of GC stress tests all samples may be in GC phase and there |
| 1223 // won't be |start| node in the profiles. | 1185 // won't be |start| node in the profiles. |
| 1224 bool is_gc_stress_testing = | 1186 bool is_gc_stress_testing = |
| 1225 (i::FLAG_gc_interval != -1) || i::FLAG_stress_compaction; | 1187 (i::FLAG_gc_interval != -1) || i::FLAG_stress_compaction; |
| 1226 const v8::CpuProfileNode* startNode = | 1188 const v8::CpuProfileNode* startNode = |
| 1227 FindChild(env->GetIsolate(), root, "start"); | 1189 FindChild(env->GetIsolate(), root, "start"); |
| 1228 CHECK(is_gc_stress_testing || startNode); | 1190 CHECK(is_gc_stress_testing || startNode); |
| 1229 if (startNode) { | 1191 if (startNode) { |
| 1230 ScopedVector<v8::Handle<v8::String> > names(2); | 1192 ScopedVector<v8::Handle<v8::String> > names(2); |
| 1231 names[0] = v8::String::NewFromUtf8(env->GetIsolate(), "bar"); | 1193 names[0] = v8_str("bar"); |
| 1232 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), "call"); | 1194 names[1] = v8_str("call"); |
| 1233 CheckChildrenNames(startNode, names); | 1195 CheckChildrenNames(startNode, names); |
| 1234 } | 1196 } |
| 1235 | 1197 |
| 1236 const v8::CpuProfileNode* unresolvedNode = FindChild( | 1198 const v8::CpuProfileNode* unresolvedNode = FindChild( |
| 1237 env->GetIsolate(), root, i::ProfileGenerator::kUnresolvedFunctionName); | 1199 env->GetIsolate(), root, i::ProfileGenerator::kUnresolvedFunctionName); |
| 1238 if (unresolvedNode) { | 1200 if (unresolvedNode) { |
| 1239 ScopedVector<v8::Handle<v8::String> > names(1); | 1201 ScopedVector<v8::Handle<v8::String> > names(1); |
| 1240 names[0] = v8::String::NewFromUtf8(env->GetIsolate(), "call"); | 1202 names[0] = v8_str("call"); |
| 1241 CheckChildrenNames(unresolvedNode, names); | 1203 CheckChildrenNames(unresolvedNode, names); |
| 1242 } | 1204 } |
| 1243 | 1205 |
| 1244 profile->Delete(); | 1206 profile->Delete(); |
| 1245 } | 1207 } |
| 1246 | 1208 |
| 1247 | 1209 |
| 1248 static const char* function_apply_test_source = "function bar(iterations) {\n" | 1210 static const char* function_apply_test_source = |
| 1249 "}\n" | 1211 "function bar(iterations) {\n" |
| 1250 "function test() {\n" | 1212 "}\n" |
| 1251 " bar.apply(this, [10 * 1000]);\n" | 1213 "function test() {\n" |
| 1252 "}\n" | 1214 " bar.apply(this, [10 * 1000]);\n" |
| 1253 "function start(duration) {\n" | 1215 "}\n" |
| 1254 " var start = Date.now();\n" | 1216 "function start(duration) {\n" |
| 1255 " while (Date.now() - start < duration) {\n" | 1217 " var start = Date.now();\n" |
| 1256 " try {\n" | 1218 " while (Date.now() - start < duration) {\n" |
| 1257 " test();\n" | 1219 " try {\n" |
| 1258 " } catch(e) {}\n" | 1220 " test();\n" |
| 1259 " }\n" | 1221 " } catch(e) {}\n" |
| 1260 "}"; | 1222 " }\n" |
| 1223 "}"; |
| 1261 | 1224 |
| 1262 | 1225 |
| 1263 // [Top down]: | 1226 // [Top down]: |
| 1264 // 94 0 (root) [-1] #0 1 | 1227 // 94 0 (root) [-1] #0 1 |
| 1265 // 2 2 (garbage collector) [-1] #0 7 | 1228 // 2 2 (garbage collector) [-1] #0 7 |
| 1266 // 82 49 start [-1] #16 3 | 1229 // 82 49 start [-1] #16 3 |
| 1267 // 1 0 (unresolved function) [-1] #0 8 | 1230 // 1 0 (unresolved function) [-1] #0 8 |
| 1268 // 1 1 apply [-1] #0 9 | 1231 // 1 1 apply [-1] #0 9 |
| 1269 // 32 21 test [-1] #16 4 | 1232 // 32 21 test [-1] #16 4 |
| 1270 // 2 2 bar [-1] #16 6 | 1233 // 2 2 bar [-1] #16 6 |
| 1271 // 9 9 apply [-1] #0 5 | 1234 // 9 9 apply [-1] #0 5 |
| 1272 // 10 10 (program) [-1] #0 2 | 1235 // 10 10 (program) [-1] #0 2 |
| 1273 TEST(FunctionApplySample) { | 1236 TEST(FunctionApplySample) { |
| 1274 LocalContext env; | 1237 LocalContext env; |
| 1275 v8::HandleScope scope(env->GetIsolate()); | 1238 v8::HandleScope scope(env->GetIsolate()); |
| 1276 | 1239 |
| 1277 v8::Script::Compile( | 1240 CompileRun(function_apply_test_source); |
| 1278 v8::String::NewFromUtf8(env->GetIsolate(), function_apply_test_source)) | 1241 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 1279 ->Run(); | |
| 1280 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 1281 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | |
| 1282 | 1242 |
| 1283 int32_t duration_ms = 100; | 1243 int32_t duration_ms = 100; |
| 1284 v8::Handle<v8::Value> args[] = { | 1244 v8::Handle<v8::Value> args[] = { |
| 1285 v8::Integer::New(env->GetIsolate(), duration_ms) | 1245 v8::Integer::New(env->GetIsolate(), duration_ms) |
| 1286 }; | 1246 }; |
| 1287 | 1247 |
| 1288 v8::CpuProfile* profile = | 1248 v8::CpuProfile* profile = |
| 1289 RunProfiler(env.local(), function, args, arraysize(args), 100); | 1249 RunProfiler(env.local(), function, args, arraysize(args), 100); |
| 1290 | 1250 |
| 1291 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1251 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1292 { | 1252 { |
| 1293 ScopedVector<v8::Handle<v8::String> > names(3); | 1253 ScopedVector<v8::Handle<v8::String> > names(3); |
| 1294 names[0] = v8::String::NewFromUtf8( | 1254 names[0] = v8_str(ProfileGenerator::kGarbageCollectorEntryName); |
| 1295 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1255 names[1] = v8_str(ProfileGenerator::kProgramEntryName); |
| 1296 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1256 names[2] = v8_str("start"); |
| 1297 ProfileGenerator::kProgramEntryName); | |
| 1298 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | |
| 1299 // Don't allow |test|, |bar| and |apply| nodes to be at the top level. | 1257 // Don't allow |test|, |bar| and |apply| nodes to be at the top level. |
| 1300 CheckChildrenNames(root, names); | 1258 CheckChildrenNames(root, names); |
| 1301 } | 1259 } |
| 1302 | 1260 |
| 1303 const v8::CpuProfileNode* startNode = | 1261 const v8::CpuProfileNode* startNode = |
| 1304 FindChild(env->GetIsolate(), root, "start"); | 1262 FindChild(env->GetIsolate(), root, "start"); |
| 1305 if (startNode) { | 1263 if (startNode) { |
| 1306 { | 1264 { |
| 1307 ScopedVector<v8::Handle<v8::String> > names(2); | 1265 ScopedVector<v8::Handle<v8::String> > names(2); |
| 1308 names[0] = v8::String::NewFromUtf8(env->GetIsolate(), "test"); | 1266 names[0] = v8_str("test"); |
| 1309 names[1] = v8::String::NewFromUtf8( | 1267 names[1] = v8_str(ProfileGenerator::kUnresolvedFunctionName); |
| 1310 env->GetIsolate(), ProfileGenerator::kUnresolvedFunctionName); | |
| 1311 CheckChildrenNames(startNode, names); | 1268 CheckChildrenNames(startNode, names); |
| 1312 } | 1269 } |
| 1313 | 1270 |
| 1314 const v8::CpuProfileNode* testNode = | 1271 const v8::CpuProfileNode* testNode = |
| 1315 FindChild(env->GetIsolate(), startNode, "test"); | 1272 FindChild(env->GetIsolate(), startNode, "test"); |
| 1316 if (testNode) { | 1273 if (testNode) { |
| 1317 ScopedVector<v8::Handle<v8::String> > names(3); | 1274 ScopedVector<v8::Handle<v8::String> > names(3); |
| 1318 names[0] = v8::String::NewFromUtf8(env->GetIsolate(), "bar"); | 1275 names[0] = v8_str("bar"); |
| 1319 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), "apply"); | 1276 names[1] = v8_str("apply"); |
| 1320 // apply calls "get length" before invoking the function itself | 1277 // apply calls "get length" before invoking the function itself |
| 1321 // and we may get hit into it. | 1278 // and we may get hit into it. |
| 1322 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "get length"); | 1279 names[2] = v8_str("get length"); |
| 1323 CheckChildrenNames(testNode, names); | 1280 CheckChildrenNames(testNode, names); |
| 1324 } | 1281 } |
| 1325 | 1282 |
| 1326 if (const v8::CpuProfileNode* unresolvedNode = | 1283 if (const v8::CpuProfileNode* unresolvedNode = |
| 1327 FindChild(env->GetIsolate(), startNode, | 1284 FindChild(env->GetIsolate(), startNode, |
| 1328 ProfileGenerator::kUnresolvedFunctionName)) { | 1285 ProfileGenerator::kUnresolvedFunctionName)) { |
| 1329 ScopedVector<v8::Handle<v8::String> > names(1); | 1286 ScopedVector<v8::Handle<v8::String> > names(1); |
| 1330 names[0] = v8::String::NewFromUtf8(env->GetIsolate(), "apply"); | 1287 names[0] = v8_str("apply"); |
| 1331 CheckChildrenNames(unresolvedNode, names); | 1288 CheckChildrenNames(unresolvedNode, names); |
| 1332 GetChild(env->GetIsolate(), unresolvedNode, "apply"); | 1289 GetChild(env->GetIsolate(), unresolvedNode, "apply"); |
| 1333 } | 1290 } |
| 1334 } | 1291 } |
| 1335 | 1292 |
| 1336 profile->Delete(); | 1293 profile->Delete(); |
| 1337 } | 1294 } |
| 1338 | 1295 |
| 1339 | 1296 |
| 1340 static const char* cpu_profiler_deep_stack_test_source = | 1297 static const char* cpu_profiler_deep_stack_test_source = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1358 // 0 foo 21 #4 no reason | 1315 // 0 foo 21 #4 no reason |
| 1359 // 0 foo 21 #5 no reason | 1316 // 0 foo 21 #5 no reason |
| 1360 // .... | 1317 // .... |
| 1361 // 0 foo 21 #253 no reason | 1318 // 0 foo 21 #253 no reason |
| 1362 // 1 startProfiling 0 #254 | 1319 // 1 startProfiling 0 #254 |
| 1363 TEST(CpuProfileDeepStack) { | 1320 TEST(CpuProfileDeepStack) { |
| 1364 v8::HandleScope scope(CcTest::isolate()); | 1321 v8::HandleScope scope(CcTest::isolate()); |
| 1365 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); | 1322 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1366 v8::Context::Scope context_scope(env); | 1323 v8::Context::Scope context_scope(env); |
| 1367 | 1324 |
| 1368 v8::Script::Compile(v8::String::NewFromUtf8( | 1325 CompileRun(cpu_profiler_deep_stack_test_source); |
| 1369 env->GetIsolate(), cpu_profiler_deep_stack_test_source))->Run(); | 1326 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 1370 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 1371 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | |
| 1372 | 1327 |
| 1373 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 1328 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 1374 v8::Local<v8::String> profile_name = | 1329 v8::Local<v8::String> profile_name = v8_str("my_profile"); |
| 1375 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile"); | |
| 1376 function->Call(env->Global(), 0, NULL); | 1330 function->Call(env->Global(), 0, NULL); |
| 1377 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); | 1331 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); |
| 1378 CHECK(profile); | 1332 CHECK(profile); |
| 1379 // Dump collected profile to have a better diagnostic in case of failure. | 1333 // Dump collected profile to have a better diagnostic in case of failure. |
| 1380 reinterpret_cast<i::CpuProfile*>(profile)->Print(); | 1334 reinterpret_cast<i::CpuProfile*>(profile)->Print(); |
| 1381 | 1335 |
| 1382 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1336 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1383 { | 1337 { |
| 1384 ScopedVector<v8::Handle<v8::String> > names(3); | 1338 ScopedVector<v8::Handle<v8::String> > names(3); |
| 1385 names[0] = v8::String::NewFromUtf8( | 1339 names[0] = v8_str(ProfileGenerator::kGarbageCollectorEntryName); |
| 1386 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1340 names[1] = v8_str(ProfileGenerator::kProgramEntryName); |
| 1387 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1341 names[2] = v8_str("start"); |
| 1388 ProfileGenerator::kProgramEntryName); | |
| 1389 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | |
| 1390 CheckChildrenNames(root, names); | 1342 CheckChildrenNames(root, names); |
| 1391 } | 1343 } |
| 1392 | 1344 |
| 1393 const v8::CpuProfileNode* node = | 1345 const v8::CpuProfileNode* node = |
| 1394 GetChild(env->GetIsolate(), root, "start"); | 1346 GetChild(env->GetIsolate(), root, "start"); |
| 1395 for (int i = 0; i < 250; ++i) { | 1347 for (int i = 0; i < 250; ++i) { |
| 1396 node = GetChild(env->GetIsolate(), node, "foo"); | 1348 node = GetChild(env->GetIsolate(), node, "foo"); |
| 1397 } | 1349 } |
| 1398 // TODO(alph): | 1350 // TODO(alph): |
| 1399 // In theory there must be one more 'foo' and a 'startProfiling' nodes, | 1351 // In theory there must be one more 'foo' and a 'startProfiling' nodes, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 // 55 1 bar #16 5 | 1383 // 55 1 bar #16 5 |
| 1432 // 54 54 foo #16 6 | 1384 // 54 54 foo #16 6 |
| 1433 TEST(JsNativeJsSample) { | 1385 TEST(JsNativeJsSample) { |
| 1434 v8::HandleScope scope(CcTest::isolate()); | 1386 v8::HandleScope scope(CcTest::isolate()); |
| 1435 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); | 1387 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1436 v8::Context::Scope context_scope(env); | 1388 v8::Context::Scope context_scope(env); |
| 1437 | 1389 |
| 1438 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( | 1390 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( |
| 1439 env->GetIsolate(), CallJsFunction); | 1391 env->GetIsolate(), CallJsFunction); |
| 1440 v8::Local<v8::Function> func = func_template->GetFunction(); | 1392 v8::Local<v8::Function> func = func_template->GetFunction(); |
| 1441 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction")); | 1393 func->SetName(v8_str("CallJsFunction")); |
| 1442 env->Global()->Set( | 1394 env->Global()->Set(v8_str("CallJsFunction"), func); |
| 1443 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); | |
| 1444 | 1395 |
| 1445 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | 1396 CompileRun(js_native_js_test_source); |
| 1446 js_native_js_test_source))->Run(); | 1397 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 1447 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 1448 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | |
| 1449 | 1398 |
| 1450 v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0, 0); | 1399 v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0, 0); |
| 1451 | 1400 |
| 1452 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1401 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1453 { | 1402 { |
| 1454 ScopedVector<v8::Handle<v8::String> > names(3); | 1403 ScopedVector<v8::Handle<v8::String> > names(3); |
| 1455 names[0] = v8::String::NewFromUtf8( | 1404 names[0] = v8_str(ProfileGenerator::kGarbageCollectorEntryName); |
| 1456 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1405 names[1] = v8_str(ProfileGenerator::kProgramEntryName); |
| 1457 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1406 names[2] = v8_str("start"); |
| 1458 ProfileGenerator::kProgramEntryName); | |
| 1459 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | |
| 1460 CheckChildrenNames(root, names); | 1407 CheckChildrenNames(root, names); |
| 1461 } | 1408 } |
| 1462 | 1409 |
| 1463 const v8::CpuProfileNode* startNode = | 1410 const v8::CpuProfileNode* startNode = |
| 1464 GetChild(env->GetIsolate(), root, "start"); | 1411 GetChild(env->GetIsolate(), root, "start"); |
| 1465 CHECK_EQ(1, startNode->GetChildrenCount()); | 1412 CHECK_EQ(1, startNode->GetChildrenCount()); |
| 1466 const v8::CpuProfileNode* nativeFunctionNode = | 1413 const v8::CpuProfileNode* nativeFunctionNode = |
| 1467 GetChild(env->GetIsolate(), startNode, "CallJsFunction"); | 1414 GetChild(env->GetIsolate(), startNode, "CallJsFunction"); |
| 1468 | 1415 |
| 1469 CHECK_EQ(1, nativeFunctionNode->GetChildrenCount()); | 1416 CHECK_EQ(1, nativeFunctionNode->GetChildrenCount()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1500 // 51 51 foo #16 6 | 1447 // 51 51 foo #16 6 |
| 1501 // 2 2 (program) #0 2 | 1448 // 2 2 (program) #0 2 |
| 1502 TEST(JsNativeJsRuntimeJsSample) { | 1449 TEST(JsNativeJsRuntimeJsSample) { |
| 1503 v8::HandleScope scope(CcTest::isolate()); | 1450 v8::HandleScope scope(CcTest::isolate()); |
| 1504 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); | 1451 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1505 v8::Context::Scope context_scope(env); | 1452 v8::Context::Scope context_scope(env); |
| 1506 | 1453 |
| 1507 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( | 1454 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( |
| 1508 env->GetIsolate(), CallJsFunction); | 1455 env->GetIsolate(), CallJsFunction); |
| 1509 v8::Local<v8::Function> func = func_template->GetFunction(); | 1456 v8::Local<v8::Function> func = func_template->GetFunction(); |
| 1510 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction")); | 1457 func->SetName(v8_str("CallJsFunction")); |
| 1511 env->Global()->Set( | 1458 env->Global()->Set(v8_str("CallJsFunction"), func); |
| 1512 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); | |
| 1513 | 1459 |
| 1514 v8::Script::Compile( | 1460 CompileRun(js_native_js_runtime_js_test_source); |
| 1515 v8::String::NewFromUtf8(env->GetIsolate(), | 1461 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 1516 js_native_js_runtime_js_test_source))->Run(); | |
| 1517 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 1518 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | |
| 1519 | 1462 |
| 1520 v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0, 0); | 1463 v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0, 0); |
| 1521 | 1464 |
| 1522 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1465 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1523 ScopedVector<v8::Handle<v8::String> > names(3); | 1466 ScopedVector<v8::Handle<v8::String> > names(3); |
| 1524 names[0] = v8::String::NewFromUtf8( | 1467 names[0] = v8_str(ProfileGenerator::kGarbageCollectorEntryName); |
| 1525 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1468 names[1] = v8_str(ProfileGenerator::kProgramEntryName); |
| 1526 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1469 names[2] = v8_str("start"); |
| 1527 ProfileGenerator::kProgramEntryName); | |
| 1528 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | |
| 1529 CheckChildrenNames(root, names); | 1470 CheckChildrenNames(root, names); |
| 1530 | 1471 |
| 1531 const v8::CpuProfileNode* startNode = | 1472 const v8::CpuProfileNode* startNode = |
| 1532 GetChild(env->GetIsolate(), root, "start"); | 1473 GetChild(env->GetIsolate(), root, "start"); |
| 1533 CHECK_EQ(1, startNode->GetChildrenCount()); | 1474 CHECK_EQ(1, startNode->GetChildrenCount()); |
| 1534 const v8::CpuProfileNode* nativeFunctionNode = | 1475 const v8::CpuProfileNode* nativeFunctionNode = |
| 1535 GetChild(env->GetIsolate(), startNode, "CallJsFunction"); | 1476 GetChild(env->GetIsolate(), startNode, "CallJsFunction"); |
| 1536 | 1477 |
| 1537 CHECK_EQ(1, nativeFunctionNode->GetChildrenCount()); | 1478 CHECK_EQ(1, nativeFunctionNode->GetChildrenCount()); |
| 1538 const v8::CpuProfileNode* barNode = | 1479 const v8::CpuProfileNode* barNode = |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 // 54 54 foo #16 7 | 1521 // 54 54 foo #16 7 |
| 1581 // 2 2 (program) #0 2 | 1522 // 2 2 (program) #0 2 |
| 1582 TEST(JsNative1JsNative2JsSample) { | 1523 TEST(JsNative1JsNative2JsSample) { |
| 1583 v8::HandleScope scope(CcTest::isolate()); | 1524 v8::HandleScope scope(CcTest::isolate()); |
| 1584 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); | 1525 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1585 v8::Context::Scope context_scope(env); | 1526 v8::Context::Scope context_scope(env); |
| 1586 | 1527 |
| 1587 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( | 1528 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( |
| 1588 env->GetIsolate(), CallJsFunction); | 1529 env->GetIsolate(), CallJsFunction); |
| 1589 v8::Local<v8::Function> func1 = func_template->GetFunction(); | 1530 v8::Local<v8::Function> func1 = func_template->GetFunction(); |
| 1590 func1->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1")); | 1531 func1->SetName(v8_str("CallJsFunction1")); |
| 1591 env->Global()->Set( | 1532 env->Global()->Set(v8_str("CallJsFunction1"), func1); |
| 1592 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"), func1); | |
| 1593 | 1533 |
| 1594 v8::Local<v8::Function> func2 = v8::FunctionTemplate::New( | 1534 v8::Local<v8::Function> func2 = v8::FunctionTemplate::New( |
| 1595 env->GetIsolate(), CallJsFunction2)->GetFunction(); | 1535 env->GetIsolate(), CallJsFunction2)->GetFunction(); |
| 1596 func2->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2")); | 1536 func2->SetName(v8_str("CallJsFunction2")); |
| 1597 env->Global()->Set( | 1537 env->Global()->Set(v8_str("CallJsFunction2"), func2); |
| 1598 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"), func2); | |
| 1599 | 1538 |
| 1600 v8::Script::Compile( | 1539 CompileRun(js_native1_js_native2_js_test_source); |
| 1601 v8::String::NewFromUtf8(env->GetIsolate(), | 1540 v8::Local<v8::Function> function = GetFunction(*env, "start"); |
| 1602 js_native1_js_native2_js_test_source))->Run(); | |
| 1603 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | |
| 1604 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | |
| 1605 | 1541 |
| 1606 v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0, 0); | 1542 v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0, 0); |
| 1607 | 1543 |
| 1608 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1544 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1609 ScopedVector<v8::Handle<v8::String> > names(3); | 1545 ScopedVector<v8::Handle<v8::String> > names(3); |
| 1610 names[0] = v8::String::NewFromUtf8( | 1546 names[0] = v8_str(ProfileGenerator::kGarbageCollectorEntryName); |
| 1611 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1547 names[1] = v8_str(ProfileGenerator::kProgramEntryName); |
| 1612 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1548 names[2] = v8_str("start"); |
| 1613 ProfileGenerator::kProgramEntryName); | |
| 1614 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | |
| 1615 CheckChildrenNames(root, names); | 1549 CheckChildrenNames(root, names); |
| 1616 | 1550 |
| 1617 const v8::CpuProfileNode* startNode = | 1551 const v8::CpuProfileNode* startNode = |
| 1618 GetChild(env->GetIsolate(), root, "start"); | 1552 GetChild(env->GetIsolate(), root, "start"); |
| 1619 CHECK_EQ(1, startNode->GetChildrenCount()); | 1553 CHECK_EQ(1, startNode->GetChildrenCount()); |
| 1620 const v8::CpuProfileNode* nativeNode1 = | 1554 const v8::CpuProfileNode* nativeNode1 = |
| 1621 GetChild(env->GetIsolate(), startNode, "CallJsFunction1"); | 1555 GetChild(env->GetIsolate(), startNode, "CallJsFunction1"); |
| 1622 | 1556 |
| 1623 CHECK_EQ(1, nativeNode1->GetChildrenCount()); | 1557 CHECK_EQ(1, nativeNode1->GetChildrenCount()); |
| 1624 const v8::CpuProfileNode* barNode = | 1558 const v8::CpuProfileNode* barNode = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1637 | 1571 |
| 1638 // [Top down]: | 1572 // [Top down]: |
| 1639 // 6 0 (root) #0 1 | 1573 // 6 0 (root) #0 1 |
| 1640 // 3 3 (program) #0 2 | 1574 // 3 3 (program) #0 2 |
| 1641 // 3 3 (idle) #0 3 | 1575 // 3 3 (idle) #0 3 |
| 1642 TEST(IdleTime) { | 1576 TEST(IdleTime) { |
| 1643 LocalContext env; | 1577 LocalContext env; |
| 1644 v8::HandleScope scope(env->GetIsolate()); | 1578 v8::HandleScope scope(env->GetIsolate()); |
| 1645 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 1579 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 1646 | 1580 |
| 1647 v8::Local<v8::String> profile_name = | 1581 v8::Local<v8::String> profile_name = v8_str("my_profile"); |
| 1648 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile"); | |
| 1649 cpu_profiler->StartProfiling(profile_name); | 1582 cpu_profiler->StartProfiling(profile_name); |
| 1650 | 1583 |
| 1651 i::Isolate* isolate = CcTest::i_isolate(); | 1584 i::Isolate* isolate = CcTest::i_isolate(); |
| 1652 i::ProfilerEventsProcessor* processor = isolate->cpu_profiler()->processor(); | 1585 i::ProfilerEventsProcessor* processor = isolate->cpu_profiler()->processor(); |
| 1653 processor->AddCurrentStack(isolate); | 1586 processor->AddCurrentStack(isolate); |
| 1654 | 1587 |
| 1655 cpu_profiler->SetIdle(true); | 1588 cpu_profiler->SetIdle(true); |
| 1656 | 1589 |
| 1657 for (int i = 0; i < 3; i++) { | 1590 for (int i = 0; i < 3; i++) { |
| 1658 processor->AddCurrentStack(isolate); | 1591 processor->AddCurrentStack(isolate); |
| 1659 } | 1592 } |
| 1660 | 1593 |
| 1661 cpu_profiler->SetIdle(false); | 1594 cpu_profiler->SetIdle(false); |
| 1662 processor->AddCurrentStack(isolate); | 1595 processor->AddCurrentStack(isolate); |
| 1663 | 1596 |
| 1664 | 1597 |
| 1665 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); | 1598 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); |
| 1666 CHECK(profile); | 1599 CHECK(profile); |
| 1667 // Dump collected profile to have a better diagnostic in case of failure. | 1600 // Dump collected profile to have a better diagnostic in case of failure. |
| 1668 reinterpret_cast<i::CpuProfile*>(profile)->Print(); | 1601 reinterpret_cast<i::CpuProfile*>(profile)->Print(); |
| 1669 | 1602 |
| 1670 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1603 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1671 ScopedVector<v8::Handle<v8::String> > names(3); | 1604 ScopedVector<v8::Handle<v8::String> > names(3); |
| 1672 names[0] = v8::String::NewFromUtf8( | 1605 names[0] = v8_str(ProfileGenerator::kGarbageCollectorEntryName); |
| 1673 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1606 names[1] = v8_str(ProfileGenerator::kProgramEntryName); |
| 1674 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1607 names[2] = v8_str(ProfileGenerator::kIdleEntryName); |
| 1675 ProfileGenerator::kProgramEntryName); | |
| 1676 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), | |
| 1677 ProfileGenerator::kIdleEntryName); | |
| 1678 CheckChildrenNames(root, names); | 1608 CheckChildrenNames(root, names); |
| 1679 | 1609 |
| 1680 const v8::CpuProfileNode* programNode = | 1610 const v8::CpuProfileNode* programNode = |
| 1681 GetChild(env->GetIsolate(), root, ProfileGenerator::kProgramEntryName); | 1611 GetChild(env->GetIsolate(), root, ProfileGenerator::kProgramEntryName); |
| 1682 CHECK_EQ(0, programNode->GetChildrenCount()); | 1612 CHECK_EQ(0, programNode->GetChildrenCount()); |
| 1683 CHECK_GE(programNode->GetHitCount(), 3u); | 1613 CHECK_GE(programNode->GetHitCount(), 3u); |
| 1684 | 1614 |
| 1685 const v8::CpuProfileNode* idleNode = | 1615 const v8::CpuProfileNode* idleNode = |
| 1686 GetChild(env->GetIsolate(), root, ProfileGenerator::kIdleEntryName); | 1616 GetChild(env->GetIsolate(), root, ProfileGenerator::kIdleEntryName); |
| 1687 CHECK_EQ(0, idleNode->GetChildrenCount()); | 1617 CHECK_EQ(0, idleNode->GetChildrenCount()); |
| 1688 CHECK_GE(idleNode->GetHitCount(), 3u); | 1618 CHECK_GE(idleNode->GetHitCount(), 3u); |
| 1689 | 1619 |
| 1690 profile->Delete(); | 1620 profile->Delete(); |
| 1691 } | 1621 } |
| 1692 | 1622 |
| 1693 | 1623 |
| 1694 static void CheckFunctionDetails(v8::Isolate* isolate, | 1624 static void CheckFunctionDetails(v8::Isolate* isolate, |
| 1695 const v8::CpuProfileNode* node, | 1625 const v8::CpuProfileNode* node, |
| 1696 const char* name, const char* script_name, | 1626 const char* name, const char* script_name, |
| 1697 int script_id, int line, int column) { | 1627 int script_id, int line, int column) { |
| 1698 CHECK( | 1628 CHECK(v8_str(name)->Equals(node->GetFunctionName())); |
| 1699 v8::String::NewFromUtf8(isolate, name)->Equals(node->GetFunctionName())); | 1629 CHECK(v8_str(script_name)->Equals(node->GetScriptResourceName())); |
| 1700 CHECK(v8::String::NewFromUtf8(isolate, script_name) | |
| 1701 ->Equals(node->GetScriptResourceName())); | |
| 1702 CHECK_EQ(script_id, node->GetScriptId()); | 1630 CHECK_EQ(script_id, node->GetScriptId()); |
| 1703 CHECK_EQ(line, node->GetLineNumber()); | 1631 CHECK_EQ(line, node->GetLineNumber()); |
| 1704 CHECK_EQ(column, node->GetColumnNumber()); | 1632 CHECK_EQ(column, node->GetColumnNumber()); |
| 1705 } | 1633 } |
| 1706 | 1634 |
| 1707 | 1635 |
| 1708 TEST(FunctionDetails) { | 1636 TEST(FunctionDetails) { |
| 1709 v8::HandleScope scope(CcTest::isolate()); | 1637 v8::HandleScope scope(CcTest::isolate()); |
| 1710 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); | 1638 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1711 v8::Context::Scope context_scope(env); | 1639 v8::Context::Scope context_scope(env); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 const v8::CpuProfileNode* bar = GetChild(env->GetIsolate(), foo, "bar"); | 1672 const v8::CpuProfileNode* bar = GetChild(env->GetIsolate(), foo, "bar"); |
| 1745 CheckFunctionDetails(env->GetIsolate(), bar, "bar", "script_a", | 1673 CheckFunctionDetails(env->GetIsolate(), bar, "bar", "script_a", |
| 1746 script_a->GetUnboundScript()->GetId(), 3, 14); | 1674 script_a->GetUnboundScript()->GetId(), 3, 14); |
| 1747 } | 1675 } |
| 1748 | 1676 |
| 1749 | 1677 |
| 1750 TEST(DontStopOnFinishedProfileDelete) { | 1678 TEST(DontStopOnFinishedProfileDelete) { |
| 1751 v8::HandleScope scope(CcTest::isolate()); | 1679 v8::HandleScope scope(CcTest::isolate()); |
| 1752 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); | 1680 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1753 v8::Context::Scope context_scope(env); | 1681 v8::Context::Scope context_scope(env); |
| 1754 v8::Isolate* isolate = env->GetIsolate(); | |
| 1755 | 1682 |
| 1756 v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); | 1683 v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); |
| 1757 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler); | 1684 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler); |
| 1758 | 1685 |
| 1759 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1686 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1760 v8::Handle<v8::String> outer = v8::String::NewFromUtf8(isolate, "outer"); | 1687 v8::Handle<v8::String> outer = v8_str("outer"); |
| 1761 profiler->StartProfiling(outer); | 1688 profiler->StartProfiling(outer); |
| 1762 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1689 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1763 | 1690 |
| 1764 v8::Handle<v8::String> inner = v8::String::NewFromUtf8(isolate, "inner"); | 1691 v8::Handle<v8::String> inner = v8_str("inner"); |
| 1765 profiler->StartProfiling(inner); | 1692 profiler->StartProfiling(inner); |
| 1766 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1693 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1767 | 1694 |
| 1768 v8::CpuProfile* inner_profile = profiler->StopProfiling(inner); | 1695 v8::CpuProfile* inner_profile = profiler->StopProfiling(inner); |
| 1769 CHECK(inner_profile); | 1696 CHECK(inner_profile); |
| 1770 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 1697 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
| 1771 inner_profile->Delete(); | 1698 inner_profile->Delete(); |
| 1772 inner_profile = NULL; | 1699 inner_profile = NULL; |
| 1773 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1700 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1774 | 1701 |
| 1775 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); | 1702 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); |
| 1776 CHECK(outer_profile); | 1703 CHECK(outer_profile); |
| 1777 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 1704 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
| 1778 outer_profile->Delete(); | 1705 outer_profile->Delete(); |
| 1779 outer_profile = NULL; | 1706 outer_profile = NULL; |
| 1780 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1707 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1781 } | 1708 } |
| OLD | NEW |