| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 return NULL; | 462 return NULL; |
| 463 } | 463 } |
| 464 | 464 |
| 465 | 465 |
| 466 static const v8::CpuProfileNode* GetChild(v8::Isolate* isolate, | 466 static const v8::CpuProfileNode* GetChild(v8::Isolate* isolate, |
| 467 const v8::CpuProfileNode* node, | 467 const v8::CpuProfileNode* node, |
| 468 const char* name) { | 468 const char* name) { |
| 469 const v8::CpuProfileNode* result = FindChild(isolate, node, name); | 469 const v8::CpuProfileNode* result = FindChild(isolate, node, name); |
| 470 if (!result) { | 470 if (!result) { |
| 471 char buffer[100]; | 471 char buffer[100]; |
| 472 i::SNPrintF(Vector<char>(buffer, ARRAY_SIZE(buffer)), | 472 i::SNPrintF(Vector<char>(buffer, arraysize(buffer)), |
| 473 "Failed to GetChild: %s", name); | 473 "Failed to GetChild: %s", name); |
| 474 FATAL(buffer); | 474 FATAL(buffer); |
| 475 } | 475 } |
| 476 return result; | 476 return result; |
| 477 } | 477 } |
| 478 | 478 |
| 479 | 479 |
| 480 static void CheckSimpleBranch(v8::Isolate* isolate, | 480 static void CheckSimpleBranch(v8::Isolate* isolate, |
| 481 const v8::CpuProfileNode* node, | 481 const v8::CpuProfileNode* node, |
| 482 const char* names[], int length) { | 482 const char* names[], int length) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | 545 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
| 546 cpu_profiler_test_source))->Run(); | 546 cpu_profiler_test_source))->Run(); |
| 547 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 547 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 548 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 548 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
| 549 | 549 |
| 550 int32_t profiling_interval_ms = 200; | 550 int32_t profiling_interval_ms = 200; |
| 551 v8::Handle<v8::Value> args[] = { | 551 v8::Handle<v8::Value> args[] = { |
| 552 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) | 552 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) |
| 553 }; | 553 }; |
| 554 v8::CpuProfile* profile = | 554 v8::CpuProfile* profile = |
| 555 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200); | 555 RunProfiler(env.local(), function, args, arraysize(args), 200); |
| 556 function->Call(env->Global(), ARRAY_SIZE(args), args); | 556 function->Call(env->Global(), arraysize(args), args); |
| 557 | 557 |
| 558 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 558 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 559 | 559 |
| 560 ScopedVector<v8::Handle<v8::String> > names(3); | 560 ScopedVector<v8::Handle<v8::String> > names(3); |
| 561 names[0] = v8::String::NewFromUtf8( | 561 names[0] = v8::String::NewFromUtf8( |
| 562 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 562 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
| 563 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 563 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
| 564 ProfileGenerator::kProgramEntryName); | 564 ProfileGenerator::kProgramEntryName); |
| 565 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 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 |
| 576 const char* barBranch[] = { "bar", "delay", "loop" }; | 576 const char* barBranch[] = { "bar", "delay", "loop" }; |
| 577 CheckSimpleBranch(env->GetIsolate(), fooNode, barBranch, | 577 CheckSimpleBranch(env->GetIsolate(), fooNode, barBranch, |
| 578 ARRAY_SIZE(barBranch)); | 578 arraysize(barBranch)); |
| 579 const char* bazBranch[] = { "baz", "delay", "loop" }; | 579 const char* bazBranch[] = { "baz", "delay", "loop" }; |
| 580 CheckSimpleBranch(env->GetIsolate(), fooNode, bazBranch, | 580 CheckSimpleBranch(env->GetIsolate(), fooNode, bazBranch, |
| 581 ARRAY_SIZE(bazBranch)); | 581 arraysize(bazBranch)); |
| 582 const char* delayBranch[] = { "delay", "loop" }; | 582 const char* delayBranch[] = { "delay", "loop" }; |
| 583 CheckSimpleBranch(env->GetIsolate(), fooNode, delayBranch, | 583 CheckSimpleBranch(env->GetIsolate(), fooNode, delayBranch, |
| 584 ARRAY_SIZE(delayBranch)); | 584 arraysize(delayBranch)); |
| 585 | 585 |
| 586 profile->Delete(); | 586 profile->Delete(); |
| 587 } | 587 } |
| 588 | 588 |
| 589 | 589 |
| 590 static const char* hot_deopt_no_frame_entry_test_source = | 590 static const char* hot_deopt_no_frame_entry_test_source = |
| 591 "function foo(a, b) {\n" | 591 "function foo(a, b) {\n" |
| 592 " try {\n" | 592 " try {\n" |
| 593 " return a + b;\n" | 593 " return a + b;\n" |
| 594 " } catch (e) { }\n" | 594 " } catch (e) { }\n" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 623 env->GetIsolate(), | 623 env->GetIsolate(), |
| 624 hot_deopt_no_frame_entry_test_source))->Run(); | 624 hot_deopt_no_frame_entry_test_source))->Run(); |
| 625 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 625 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 626 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 626 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
| 627 | 627 |
| 628 int32_t profiling_interval_ms = 200; | 628 int32_t profiling_interval_ms = 200; |
| 629 v8::Handle<v8::Value> args[] = { | 629 v8::Handle<v8::Value> args[] = { |
| 630 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) | 630 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) |
| 631 }; | 631 }; |
| 632 v8::CpuProfile* profile = | 632 v8::CpuProfile* profile = |
| 633 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200); | 633 RunProfiler(env.local(), function, args, arraysize(args), 200); |
| 634 function->Call(env->Global(), ARRAY_SIZE(args), args); | 634 function->Call(env->Global(), arraysize(args), args); |
| 635 | 635 |
| 636 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 636 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 637 | 637 |
| 638 ScopedVector<v8::Handle<v8::String> > names(3); | 638 ScopedVector<v8::Handle<v8::String> > names(3); |
| 639 names[0] = v8::String::NewFromUtf8( | 639 names[0] = v8::String::NewFromUtf8( |
| 640 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 640 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
| 641 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 641 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
| 642 ProfileGenerator::kProgramEntryName); | 642 ProfileGenerator::kProgramEntryName); |
| 643 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 643 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
| 644 CheckChildrenNames(root, names); | 644 CheckChildrenNames(root, names); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 660 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | 660 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
| 661 cpu_profiler_test_source))->Run(); | 661 cpu_profiler_test_source))->Run(); |
| 662 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 662 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 663 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 663 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
| 664 | 664 |
| 665 int32_t profiling_interval_ms = 200; | 665 int32_t profiling_interval_ms = 200; |
| 666 v8::Handle<v8::Value> args[] = { | 666 v8::Handle<v8::Value> args[] = { |
| 667 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) | 667 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) |
| 668 }; | 668 }; |
| 669 v8::CpuProfile* profile = | 669 v8::CpuProfile* profile = |
| 670 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200, true); | 670 RunProfiler(env.local(), function, args, arraysize(args), 200, true); |
| 671 | 671 |
| 672 CHECK_LE(200, profile->GetSamplesCount()); | 672 CHECK_LE(200, profile->GetSamplesCount()); |
| 673 uint64_t end_time = profile->GetEndTime(); | 673 uint64_t end_time = profile->GetEndTime(); |
| 674 uint64_t current_time = profile->GetStartTime(); | 674 uint64_t current_time = profile->GetStartTime(); |
| 675 CHECK_LE(current_time, end_time); | 675 CHECK_LE(current_time, end_time); |
| 676 for (int i = 0; i < profile->GetSamplesCount(); i++) { | 676 for (int i = 0; i < profile->GetSamplesCount(); i++) { |
| 677 CHECK_NE(NULL, profile->GetSample(i)); | 677 CHECK_NE(NULL, profile->GetSample(i)); |
| 678 uint64_t timestamp = profile->GetSampleTimestamp(i); | 678 uint64_t timestamp = profile->GetSampleTimestamp(i); |
| 679 CHECK_LE(current_time, timestamp); | 679 CHECK_LE(current_time, timestamp); |
| 680 CHECK_LE(timestamp, end_time); | 680 CHECK_LE(timestamp, end_time); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 | 716 |
| 717 int32_t repeat_count = 100; | 717 int32_t repeat_count = 100; |
| 718 #if defined(USE_SIMULATOR) | 718 #if defined(USE_SIMULATOR) |
| 719 // Simulators are much slower. | 719 // Simulators are much slower. |
| 720 repeat_count = 1; | 720 repeat_count = 1; |
| 721 #endif | 721 #endif |
| 722 v8::Handle<v8::Value> args[] = { | 722 v8::Handle<v8::Value> args[] = { |
| 723 v8::Integer::New(env->GetIsolate(), repeat_count) | 723 v8::Integer::New(env->GetIsolate(), repeat_count) |
| 724 }; | 724 }; |
| 725 v8::CpuProfile* profile = | 725 v8::CpuProfile* profile = |
| 726 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); | 726 RunProfiler(env.local(), function, args, arraysize(args), 100); |
| 727 | 727 |
| 728 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 728 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 729 | 729 |
| 730 ScopedVector<v8::Handle<v8::String> > names(3); | 730 ScopedVector<v8::Handle<v8::String> > names(3); |
| 731 names[0] = v8::String::NewFromUtf8( | 731 names[0] = v8::String::NewFromUtf8( |
| 732 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 732 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
| 733 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 733 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
| 734 ProfileGenerator::kProgramEntryName); | 734 ProfileGenerator::kProgramEntryName); |
| 735 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 735 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
| 736 CheckChildrenNames(root, names); | 736 CheckChildrenNames(root, names); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 | 836 |
| 837 v8::Script::Compile( | 837 v8::Script::Compile( |
| 838 v8::String::NewFromUtf8(isolate, native_accessor_test_source)) | 838 v8::String::NewFromUtf8(isolate, native_accessor_test_source)) |
| 839 ->Run(); | 839 ->Run(); |
| 840 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 840 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 841 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | 841 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); |
| 842 | 842 |
| 843 int32_t repeat_count = 1; | 843 int32_t repeat_count = 1; |
| 844 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 844 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; |
| 845 v8::CpuProfile* profile = | 845 v8::CpuProfile* profile = |
| 846 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 180); | 846 RunProfiler(env.local(), function, args, arraysize(args), 180); |
| 847 | 847 |
| 848 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 848 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 849 const v8::CpuProfileNode* startNode = | 849 const v8::CpuProfileNode* startNode = |
| 850 GetChild(isolate, root, "start"); | 850 GetChild(isolate, root, "start"); |
| 851 GetChild(isolate, startNode, "get foo"); | 851 GetChild(isolate, startNode, "get foo"); |
| 852 GetChild(isolate, startNode, "set foo"); | 852 GetChild(isolate, startNode, "set foo"); |
| 853 | 853 |
| 854 profile->Delete(); | 854 profile->Delete(); |
| 855 } | 855 } |
| 856 | 856 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 886 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | 886 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); |
| 887 | 887 |
| 888 { | 888 { |
| 889 // Make sure accessors ICs are in monomorphic state before starting | 889 // Make sure accessors ICs are in monomorphic state before starting |
| 890 // profiling. | 890 // profiling. |
| 891 accessors.set_warming_up(true); | 891 accessors.set_warming_up(true); |
| 892 int32_t warm_up_iterations = 3; | 892 int32_t warm_up_iterations = 3; |
| 893 v8::Handle<v8::Value> args[] = { | 893 v8::Handle<v8::Value> args[] = { |
| 894 v8::Integer::New(isolate, warm_up_iterations) | 894 v8::Integer::New(isolate, warm_up_iterations) |
| 895 }; | 895 }; |
| 896 function->Call(env->Global(), ARRAY_SIZE(args), args); | 896 function->Call(env->Global(), arraysize(args), args); |
| 897 accessors.set_warming_up(false); | 897 accessors.set_warming_up(false); |
| 898 } | 898 } |
| 899 | 899 |
| 900 int32_t repeat_count = 100; | 900 int32_t repeat_count = 100; |
| 901 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 901 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; |
| 902 v8::CpuProfile* profile = | 902 v8::CpuProfile* profile = |
| 903 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200); | 903 RunProfiler(env.local(), function, args, arraysize(args), 200); |
| 904 | 904 |
| 905 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 905 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 906 const v8::CpuProfileNode* startNode = | 906 const v8::CpuProfileNode* startNode = |
| 907 GetChild(isolate, root, "start"); | 907 GetChild(isolate, root, "start"); |
| 908 GetChild(isolate, startNode, "get foo"); | 908 GetChild(isolate, startNode, "get foo"); |
| 909 GetChild(isolate, startNode, "set foo"); | 909 GetChild(isolate, startNode, "set foo"); |
| 910 | 910 |
| 911 profile->Delete(); | 911 profile->Delete(); |
| 912 } | 912 } |
| 913 | 913 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 instance); | 947 instance); |
| 948 | 948 |
| 949 v8::Script::Compile(v8::String::NewFromUtf8( | 949 v8::Script::Compile(v8::String::NewFromUtf8( |
| 950 isolate, native_method_test_source))->Run(); | 950 isolate, native_method_test_source))->Run(); |
| 951 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 951 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 952 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | 952 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); |
| 953 | 953 |
| 954 int32_t repeat_count = 1; | 954 int32_t repeat_count = 1; |
| 955 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 955 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; |
| 956 v8::CpuProfile* profile = | 956 v8::CpuProfile* profile = |
| 957 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); | 957 RunProfiler(env.local(), function, args, arraysize(args), 100); |
| 958 | 958 |
| 959 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 959 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 960 const v8::CpuProfileNode* startNode = | 960 const v8::CpuProfileNode* startNode = |
| 961 GetChild(isolate, root, "start"); | 961 GetChild(isolate, root, "start"); |
| 962 GetChild(isolate, startNode, "fooMethod"); | 962 GetChild(isolate, startNode, "fooMethod"); |
| 963 | 963 |
| 964 profile->Delete(); | 964 profile->Delete(); |
| 965 } | 965 } |
| 966 | 966 |
| 967 | 967 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 997 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 997 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 998 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | 998 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); |
| 999 { | 999 { |
| 1000 // Make sure method ICs are in monomorphic state before starting | 1000 // Make sure method ICs are in monomorphic state before starting |
| 1001 // profiling. | 1001 // profiling. |
| 1002 callbacks.set_warming_up(true); | 1002 callbacks.set_warming_up(true); |
| 1003 int32_t warm_up_iterations = 3; | 1003 int32_t warm_up_iterations = 3; |
| 1004 v8::Handle<v8::Value> args[] = { | 1004 v8::Handle<v8::Value> args[] = { |
| 1005 v8::Integer::New(isolate, warm_up_iterations) | 1005 v8::Integer::New(isolate, warm_up_iterations) |
| 1006 }; | 1006 }; |
| 1007 function->Call(env->Global(), ARRAY_SIZE(args), args); | 1007 function->Call(env->Global(), arraysize(args), args); |
| 1008 callbacks.set_warming_up(false); | 1008 callbacks.set_warming_up(false); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 int32_t repeat_count = 100; | 1011 int32_t repeat_count = 100; |
| 1012 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 1012 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; |
| 1013 v8::CpuProfile* profile = | 1013 v8::CpuProfile* profile = |
| 1014 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); | 1014 RunProfiler(env.local(), function, args, arraysize(args), 100); |
| 1015 | 1015 |
| 1016 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1016 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1017 GetChild(isolate, root, "start"); | 1017 GetChild(isolate, root, "start"); |
| 1018 const v8::CpuProfileNode* startNode = | 1018 const v8::CpuProfileNode* startNode = |
| 1019 GetChild(isolate, root, "start"); | 1019 GetChild(isolate, root, "start"); |
| 1020 GetChild(isolate, startNode, "fooMethod"); | 1020 GetChild(isolate, startNode, "fooMethod"); |
| 1021 | 1021 |
| 1022 profile->Delete(); | 1022 profile->Delete(); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 v8::Script::Compile(v8::String::NewFromUtf8( | 1098 v8::Script::Compile(v8::String::NewFromUtf8( |
| 1099 env->GetIsolate(), call_function_test_source))->Run(); | 1099 env->GetIsolate(), call_function_test_source))->Run(); |
| 1100 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 1100 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 1101 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 1101 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
| 1102 | 1102 |
| 1103 int32_t duration_ms = 100; | 1103 int32_t duration_ms = 100; |
| 1104 v8::Handle<v8::Value> args[] = { | 1104 v8::Handle<v8::Value> args[] = { |
| 1105 v8::Integer::New(env->GetIsolate(), duration_ms) | 1105 v8::Integer::New(env->GetIsolate(), duration_ms) |
| 1106 }; | 1106 }; |
| 1107 v8::CpuProfile* profile = | 1107 v8::CpuProfile* profile = |
| 1108 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); | 1108 RunProfiler(env.local(), function, args, arraysize(args), 100); |
| 1109 | 1109 |
| 1110 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1110 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1111 { | 1111 { |
| 1112 ScopedVector<v8::Handle<v8::String> > names(4); | 1112 ScopedVector<v8::Handle<v8::String> > names(4); |
| 1113 names[0] = v8::String::NewFromUtf8( | 1113 names[0] = v8::String::NewFromUtf8( |
| 1114 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1114 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
| 1115 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1115 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
| 1116 ProfileGenerator::kProgramEntryName); | 1116 ProfileGenerator::kProgramEntryName); |
| 1117 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 1117 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
| 1118 names[3] = v8::String::NewFromUtf8( | 1118 names[3] = v8::String::NewFromUtf8( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 ->Run(); | 1181 ->Run(); |
| 1182 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 1182 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 1183 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 1183 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
| 1184 | 1184 |
| 1185 int32_t duration_ms = 100; | 1185 int32_t duration_ms = 100; |
| 1186 v8::Handle<v8::Value> args[] = { | 1186 v8::Handle<v8::Value> args[] = { |
| 1187 v8::Integer::New(env->GetIsolate(), duration_ms) | 1187 v8::Integer::New(env->GetIsolate(), duration_ms) |
| 1188 }; | 1188 }; |
| 1189 | 1189 |
| 1190 v8::CpuProfile* profile = | 1190 v8::CpuProfile* profile = |
| 1191 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); | 1191 RunProfiler(env.local(), function, args, arraysize(args), 100); |
| 1192 | 1192 |
| 1193 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1193 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1194 { | 1194 { |
| 1195 ScopedVector<v8::Handle<v8::String> > names(3); | 1195 ScopedVector<v8::Handle<v8::String> > names(3); |
| 1196 names[0] = v8::String::NewFromUtf8( | 1196 names[0] = v8::String::NewFromUtf8( |
| 1197 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1197 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
| 1198 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1198 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
| 1199 ProfileGenerator::kProgramEntryName); | 1199 ProfileGenerator::kProgramEntryName); |
| 1200 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 1200 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
| 1201 // Don't allow |test|, |bar| and |apply| nodes to be at the top level. | 1201 // Don't allow |test|, |bar| and |apply| nodes to be at the top level. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 "}\n" | 1314 "}\n" |
| 1315 "function start() {\n" | 1315 "function start() {\n" |
| 1316 " try {\n" | 1316 " try {\n" |
| 1317 " CallJsFunction(bar);\n" | 1317 " CallJsFunction(bar);\n" |
| 1318 " } catch(e) {}\n" | 1318 " } catch(e) {}\n" |
| 1319 "}"; | 1319 "}"; |
| 1320 | 1320 |
| 1321 static void CallJsFunction(const v8::FunctionCallbackInfo<v8::Value>& info) { | 1321 static void CallJsFunction(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 1322 v8::Handle<v8::Function> function = info[0].As<v8::Function>(); | 1322 v8::Handle<v8::Function> function = info[0].As<v8::Function>(); |
| 1323 v8::Handle<v8::Value> argv[] = { info[1] }; | 1323 v8::Handle<v8::Value> argv[] = { info[1] }; |
| 1324 function->Call(info.This(), ARRAY_SIZE(argv), argv); | 1324 function->Call(info.This(), arraysize(argv), argv); |
| 1325 } | 1325 } |
| 1326 | 1326 |
| 1327 | 1327 |
| 1328 // [Top down]: | 1328 // [Top down]: |
| 1329 // 58 0 (root) #0 1 | 1329 // 58 0 (root) #0 1 |
| 1330 // 2 2 (program) #0 2 | 1330 // 2 2 (program) #0 2 |
| 1331 // 56 1 start #16 3 | 1331 // 56 1 start #16 3 |
| 1332 // 55 0 CallJsFunction #0 4 | 1332 // 55 0 CallJsFunction #0 4 |
| 1333 // 55 1 bar #16 5 | 1333 // 55 1 bar #16 5 |
| 1334 // 54 54 foo #16 6 | 1334 // 54 54 foo #16 6 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 inner_profile = NULL; | 1674 inner_profile = NULL; |
| 1675 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1675 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1676 | 1676 |
| 1677 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); | 1677 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); |
| 1678 CHECK(outer_profile); | 1678 CHECK(outer_profile); |
| 1679 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 1679 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
| 1680 outer_profile->Delete(); | 1680 outer_profile->Delete(); |
| 1681 outer_profile = NULL; | 1681 outer_profile = NULL; |
| 1682 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1682 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1683 } | 1683 } |
| OLD | NEW |