| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 337 } |
| 338 | 338 |
| 339 private: | 339 private: |
| 340 bool old_flag_prof_browser_mode_; | 340 bool old_flag_prof_browser_mode_; |
| 341 }; | 341 }; |
| 342 | 342 |
| 343 } // namespace | 343 } // namespace |
| 344 | 344 |
| 345 TEST(RecordTickSample) { | 345 TEST(RecordTickSample) { |
| 346 TestSetup test_setup; | 346 TestSetup test_setup; |
| 347 CpuProfilesCollection profiles(CcTest::i_isolate()); | 347 i::Isolate* isolate = CcTest::i_isolate(); |
| 348 CpuProfiler profiler(CcTest::i_isolate()); | 348 CpuProfilesCollection profiles(isolate); |
| 349 CpuProfiler profiler(isolate); |
| 349 profiles.set_cpu_profiler(&profiler); | 350 profiles.set_cpu_profiler(&profiler); |
| 350 profiles.StartProfiling("", false); | 351 profiles.StartProfiling("", false); |
| 351 ProfileGenerator generator(&profiles); | 352 ProfileGenerator generator(isolate, &profiles); |
| 352 CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 353 CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); |
| 353 CodeEntry* entry2 = new CodeEntry(i::Logger::FUNCTION_TAG, "bbb"); | 354 CodeEntry* entry2 = new CodeEntry(i::Logger::FUNCTION_TAG, "bbb"); |
| 354 CodeEntry* entry3 = new CodeEntry(i::Logger::FUNCTION_TAG, "ccc"); | 355 CodeEntry* entry3 = new CodeEntry(i::Logger::FUNCTION_TAG, "ccc"); |
| 355 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); | 356 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
| 356 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); | 357 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); |
| 357 generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); | 358 generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); |
| 358 | 359 |
| 359 // We are building the following calls tree: | 360 // We are building the following calls tree: |
| 360 // -> aaa - sample1 | 361 // -> aaa - sample1 |
| 361 // aaa -> bbb -> ccc - sample2 | 362 // aaa -> bbb -> ccc - sample2 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 static void CheckNodeIds(ProfileNode* node, unsigned* expectedId) { | 410 static void CheckNodeIds(ProfileNode* node, unsigned* expectedId) { |
| 410 CHECK_EQ((*expectedId)++, node->id()); | 411 CHECK_EQ((*expectedId)++, node->id()); |
| 411 for (int i = 0; i < node->children()->length(); i++) { | 412 for (int i = 0; i < node->children()->length(); i++) { |
| 412 CheckNodeIds(node->children()->at(i), expectedId); | 413 CheckNodeIds(node->children()->at(i), expectedId); |
| 413 } | 414 } |
| 414 } | 415 } |
| 415 | 416 |
| 416 | 417 |
| 417 TEST(SampleIds) { | 418 TEST(SampleIds) { |
| 418 TestSetup test_setup; | 419 TestSetup test_setup; |
| 419 CpuProfilesCollection profiles(CcTest::i_isolate()); | 420 i::Isolate* isolate = CcTest::i_isolate(); |
| 420 CpuProfiler profiler(CcTest::i_isolate()); | 421 CpuProfilesCollection profiles(isolate); |
| 422 CpuProfiler profiler(isolate); |
| 421 profiles.set_cpu_profiler(&profiler); | 423 profiles.set_cpu_profiler(&profiler); |
| 422 profiles.StartProfiling("", true); | 424 profiles.StartProfiling("", true); |
| 423 ProfileGenerator generator(&profiles); | 425 ProfileGenerator generator(isolate, &profiles); |
| 424 CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 426 CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); |
| 425 CodeEntry* entry2 = new CodeEntry(i::Logger::FUNCTION_TAG, "bbb"); | 427 CodeEntry* entry2 = new CodeEntry(i::Logger::FUNCTION_TAG, "bbb"); |
| 426 CodeEntry* entry3 = new CodeEntry(i::Logger::FUNCTION_TAG, "ccc"); | 428 CodeEntry* entry3 = new CodeEntry(i::Logger::FUNCTION_TAG, "ccc"); |
| 427 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); | 429 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
| 428 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); | 430 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); |
| 429 generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); | 431 generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); |
| 430 | 432 |
| 431 // We are building the following calls tree: | 433 // We are building the following calls tree: |
| 432 // -> aaa #3 - sample1 | 434 // -> aaa #3 - sample1 |
| 433 // (root)#1 -> aaa #2 -> bbb #4 -> ccc #5 - sample2 | 435 // (root)#1 -> aaa #2 -> bbb #4 -> ccc #5 - sample2 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 } | 468 } |
| 467 | 469 |
| 468 delete entry1; | 470 delete entry1; |
| 469 delete entry2; | 471 delete entry2; |
| 470 delete entry3; | 472 delete entry3; |
| 471 } | 473 } |
| 472 | 474 |
| 473 | 475 |
| 474 TEST(NoSamples) { | 476 TEST(NoSamples) { |
| 475 TestSetup test_setup; | 477 TestSetup test_setup; |
| 476 CpuProfilesCollection profiles(CcTest::i_isolate()); | 478 i::Isolate* isolate = CcTest::i_isolate(); |
| 477 CpuProfiler profiler(CcTest::i_isolate()); | 479 CpuProfilesCollection profiles(isolate); |
| 480 CpuProfiler profiler(isolate); |
| 478 profiles.set_cpu_profiler(&profiler); | 481 profiles.set_cpu_profiler(&profiler); |
| 479 profiles.StartProfiling("", false); | 482 profiles.StartProfiling("", false); |
| 480 ProfileGenerator generator(&profiles); | 483 ProfileGenerator generator(isolate, &profiles); |
| 481 CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 484 CodeEntry* entry1 = new CodeEntry(i::Logger::FUNCTION_TAG, "aaa"); |
| 482 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); | 485 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
| 483 | 486 |
| 484 // We are building the following calls tree: | 487 // We are building the following calls tree: |
| 485 // (root)#1 -> aaa #2 -> aaa #3 - sample1 | 488 // (root)#1 -> aaa #2 -> aaa #3 - sample1 |
| 486 TickSample sample1; | 489 TickSample sample1; |
| 487 sample1.pc = ToAddress(0x1600); | 490 sample1.pc = ToAddress(0x1600); |
| 488 sample1.stack[0] = ToAddress(0x1510); | 491 sample1.stack[0] = ToAddress(0x1510); |
| 489 sample1.frames_count = 1; | 492 sample1.frames_count = 1; |
| 490 generator.RecordTickSample(sample1); | 493 generator.RecordTickSample(sample1); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 // (root) | 721 // (root) |
| 719 // "" | 722 // "" |
| 720 // kDebuggerStatement | 723 // kDebuggerStatement |
| 721 current = PickChild(current, ""); | 724 current = PickChild(current, ""); |
| 722 CHECK(const_cast<v8::CpuProfileNode*>(current)); | 725 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
| 723 | 726 |
| 724 current = PickChild(current, "Debugger"); | 727 current = PickChild(current, "Debugger"); |
| 725 CHECK(const_cast<v8::CpuProfileNode*>(current)); | 728 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
| 726 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason())); | 729 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason())); |
| 727 } | 730 } |
| OLD | NEW |