| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 393 |
| 394 v8::Local<v8::String> profile_name = | 394 v8::Local<v8::String> profile_name = |
| 395 v8::String::NewFromUtf8(env->GetIsolate(), "test"); | 395 v8::String::NewFromUtf8(env->GetIsolate(), "test"); |
| 396 cpu_profiler->StartCpuProfiling(profile_name); | 396 cpu_profiler->StartCpuProfiling(profile_name); |
| 397 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); | 397 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); |
| 398 CHECK(profile->GetStartTime() <= profile->GetEndTime()); | 398 CHECK(profile->GetStartTime() <= profile->GetEndTime()); |
| 399 } | 399 } |
| 400 | 400 |
| 401 | 401 |
| 402 static const v8::CpuProfile* RunProfiler( | 402 static const v8::CpuProfile* RunProfiler( |
| 403 LocalContext& env, v8::Handle<v8::Function> function, | 403 v8::Handle<v8::Context> env, v8::Handle<v8::Function> function, |
| 404 v8::Handle<v8::Value> argv[], int argc, | 404 v8::Handle<v8::Value> argv[], int argc, |
| 405 unsigned min_js_samples) { | 405 unsigned min_js_samples) { |
| 406 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 406 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 407 v8::Local<v8::String> profile_name = | 407 v8::Local<v8::String> profile_name = |
| 408 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile"); | 408 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile"); |
| 409 | 409 |
| 410 cpu_profiler->StartCpuProfiling(profile_name); | 410 cpu_profiler->StartCpuProfiling(profile_name); |
| 411 | 411 |
| 412 i::Sampler* sampler = | 412 i::Sampler* sampler = |
| 413 reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler(); | 413 reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler(); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | 547 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
| 548 cpu_profiler_test_source))->Run(); | 548 cpu_profiler_test_source))->Run(); |
| 549 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 549 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 550 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 550 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
| 551 | 551 |
| 552 int32_t profiling_interval_ms = 200; | 552 int32_t profiling_interval_ms = 200; |
| 553 v8::Handle<v8::Value> args[] = { | 553 v8::Handle<v8::Value> args[] = { |
| 554 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) | 554 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) |
| 555 }; | 555 }; |
| 556 const v8::CpuProfile* profile = | 556 const v8::CpuProfile* profile = |
| 557 RunProfiler(env, function, args, ARRAY_SIZE(args), 200); | 557 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200); |
| 558 function->Call(env->Global(), ARRAY_SIZE(args), args); | 558 function->Call(env->Global(), ARRAY_SIZE(args), args); |
| 559 | 559 |
| 560 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 560 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 561 | 561 |
| 562 ScopedVector<v8::Handle<v8::String> > names(3); | 562 ScopedVector<v8::Handle<v8::String> > names(3); |
| 563 names[0] = v8::String::NewFromUtf8( | 563 names[0] = v8::String::NewFromUtf8( |
| 564 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 564 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
| 565 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 565 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
| 566 ProfileGenerator::kProgramEntryName); | 566 ProfileGenerator::kProgramEntryName); |
| 567 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 567 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 | 621 |
| 622 int32_t repeat_count = 100; | 622 int32_t repeat_count = 100; |
| 623 #if defined(USE_SIMULATOR) | 623 #if defined(USE_SIMULATOR) |
| 624 // Simulators are much slower. | 624 // Simulators are much slower. |
| 625 repeat_count = 1; | 625 repeat_count = 1; |
| 626 #endif | 626 #endif |
| 627 v8::Handle<v8::Value> args[] = { | 627 v8::Handle<v8::Value> args[] = { |
| 628 v8::Integer::New(env->GetIsolate(), repeat_count) | 628 v8::Integer::New(env->GetIsolate(), repeat_count) |
| 629 }; | 629 }; |
| 630 const v8::CpuProfile* profile = | 630 const v8::CpuProfile* profile = |
| 631 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 631 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); |
| 632 | 632 |
| 633 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 633 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 634 | 634 |
| 635 ScopedVector<v8::Handle<v8::String> > names(3); | 635 ScopedVector<v8::Handle<v8::String> > names(3); |
| 636 names[0] = v8::String::NewFromUtf8( | 636 names[0] = v8::String::NewFromUtf8( |
| 637 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 637 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
| 638 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 638 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
| 639 ProfileGenerator::kProgramEntryName); | 639 ProfileGenerator::kProgramEntryName); |
| 640 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 640 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
| 641 CheckChildrenNames(root, names); | 641 CheckChildrenNames(root, names); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 | 741 |
| 742 v8::Script::Compile( | 742 v8::Script::Compile( |
| 743 v8::String::NewFromUtf8(isolate, native_accessor_test_source)) | 743 v8::String::NewFromUtf8(isolate, native_accessor_test_source)) |
| 744 ->Run(); | 744 ->Run(); |
| 745 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 745 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 746 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | 746 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); |
| 747 | 747 |
| 748 int32_t repeat_count = 1; | 748 int32_t repeat_count = 1; |
| 749 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 749 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; |
| 750 const v8::CpuProfile* profile = | 750 const v8::CpuProfile* profile = |
| 751 RunProfiler(env, function, args, ARRAY_SIZE(args), 180); | 751 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 180); |
| 752 | 752 |
| 753 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 753 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 754 const v8::CpuProfileNode* startNode = | 754 const v8::CpuProfileNode* startNode = |
| 755 GetChild(isolate, root, "start"); | 755 GetChild(isolate, root, "start"); |
| 756 GetChild(isolate, startNode, "get foo"); | 756 GetChild(isolate, startNode, "get foo"); |
| 757 GetChild(isolate, startNode, "set foo"); | 757 GetChild(isolate, startNode, "set foo"); |
| 758 | 758 |
| 759 const_cast<v8::CpuProfile*>(profile)->Delete(); | 759 const_cast<v8::CpuProfile*>(profile)->Delete(); |
| 760 } | 760 } |
| 761 | 761 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 v8::Handle<v8::Value> args[] = { | 798 v8::Handle<v8::Value> args[] = { |
| 799 v8::Integer::New(isolate, warm_up_iterations) | 799 v8::Integer::New(isolate, warm_up_iterations) |
| 800 }; | 800 }; |
| 801 function->Call(env->Global(), ARRAY_SIZE(args), args); | 801 function->Call(env->Global(), ARRAY_SIZE(args), args); |
| 802 accessors.set_warming_up(false); | 802 accessors.set_warming_up(false); |
| 803 } | 803 } |
| 804 | 804 |
| 805 int32_t repeat_count = 100; | 805 int32_t repeat_count = 100; |
| 806 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 806 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; |
| 807 const v8::CpuProfile* profile = | 807 const v8::CpuProfile* profile = |
| 808 RunProfiler(env, function, args, ARRAY_SIZE(args), 200); | 808 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200); |
| 809 | 809 |
| 810 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 810 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 811 const v8::CpuProfileNode* startNode = | 811 const v8::CpuProfileNode* startNode = |
| 812 GetChild(isolate, root, "start"); | 812 GetChild(isolate, root, "start"); |
| 813 GetChild(isolate, startNode, "get foo"); | 813 GetChild(isolate, startNode, "get foo"); |
| 814 GetChild(isolate, startNode, "set foo"); | 814 GetChild(isolate, startNode, "set foo"); |
| 815 | 815 |
| 816 const_cast<v8::CpuProfile*>(profile)->Delete(); | 816 const_cast<v8::CpuProfile*>(profile)->Delete(); |
| 817 } | 817 } |
| 818 | 818 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 instance); | 852 instance); |
| 853 | 853 |
| 854 v8::Script::Compile(v8::String::NewFromUtf8( | 854 v8::Script::Compile(v8::String::NewFromUtf8( |
| 855 isolate, native_method_test_source))->Run(); | 855 isolate, native_method_test_source))->Run(); |
| 856 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 856 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 857 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); | 857 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start"))); |
| 858 | 858 |
| 859 int32_t repeat_count = 1; | 859 int32_t repeat_count = 1; |
| 860 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 860 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; |
| 861 const v8::CpuProfile* profile = | 861 const v8::CpuProfile* profile = |
| 862 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 862 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); |
| 863 | 863 |
| 864 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 864 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 865 const v8::CpuProfileNode* startNode = | 865 const v8::CpuProfileNode* startNode = |
| 866 GetChild(isolate, root, "start"); | 866 GetChild(isolate, root, "start"); |
| 867 GetChild(isolate, startNode, "fooMethod"); | 867 GetChild(isolate, startNode, "fooMethod"); |
| 868 | 868 |
| 869 const_cast<v8::CpuProfile*>(profile)->Delete(); | 869 const_cast<v8::CpuProfile*>(profile)->Delete(); |
| 870 } | 870 } |
| 871 | 871 |
| 872 | 872 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 v8::Handle<v8::Value> args[] = { | 909 v8::Handle<v8::Value> args[] = { |
| 910 v8::Integer::New(isolate, warm_up_iterations) | 910 v8::Integer::New(isolate, warm_up_iterations) |
| 911 }; | 911 }; |
| 912 function->Call(env->Global(), ARRAY_SIZE(args), args); | 912 function->Call(env->Global(), ARRAY_SIZE(args), args); |
| 913 callbacks.set_warming_up(false); | 913 callbacks.set_warming_up(false); |
| 914 } | 914 } |
| 915 | 915 |
| 916 int32_t repeat_count = 100; | 916 int32_t repeat_count = 100; |
| 917 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; | 917 v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; |
| 918 const v8::CpuProfile* profile = | 918 const v8::CpuProfile* profile = |
| 919 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 919 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); |
| 920 | 920 |
| 921 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 921 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 922 GetChild(isolate, root, "start"); | 922 GetChild(isolate, root, "start"); |
| 923 const v8::CpuProfileNode* startNode = | 923 const v8::CpuProfileNode* startNode = |
| 924 GetChild(isolate, root, "start"); | 924 GetChild(isolate, root, "start"); |
| 925 GetChild(isolate, startNode, "fooMethod"); | 925 GetChild(isolate, startNode, "fooMethod"); |
| 926 | 926 |
| 927 const_cast<v8::CpuProfile*>(profile)->Delete(); | 927 const_cast<v8::CpuProfile*>(profile)->Delete(); |
| 928 } | 928 } |
| 929 | 929 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 950 v8::String::NewFromUtf8(env->GetIsolate(), bound_function_test_source)) | 950 v8::String::NewFromUtf8(env->GetIsolate(), bound_function_test_source)) |
| 951 ->Run(); | 951 ->Run(); |
| 952 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 952 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 953 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 953 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
| 954 | 954 |
| 955 int32_t duration_ms = 100; | 955 int32_t duration_ms = 100; |
| 956 v8::Handle<v8::Value> args[] = { | 956 v8::Handle<v8::Value> args[] = { |
| 957 v8::Integer::New(env->GetIsolate(), duration_ms) | 957 v8::Integer::New(env->GetIsolate(), duration_ms) |
| 958 }; | 958 }; |
| 959 const v8::CpuProfile* profile = | 959 const v8::CpuProfile* profile = |
| 960 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 960 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); |
| 961 | 961 |
| 962 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 962 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 963 ScopedVector<v8::Handle<v8::String> > names(3); | 963 ScopedVector<v8::Handle<v8::String> > names(3); |
| 964 names[0] = v8::String::NewFromUtf8( | 964 names[0] = v8::String::NewFromUtf8( |
| 965 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 965 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
| 966 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 966 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
| 967 ProfileGenerator::kProgramEntryName); | 967 ProfileGenerator::kProgramEntryName); |
| 968 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 968 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
| 969 // Don't allow |foo| node to be at the top level. | 969 // Don't allow |foo| node to be at the top level. |
| 970 CheckChildrenNames(root, names); | 970 CheckChildrenNames(root, names); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 v8::Script::Compile(v8::String::NewFromUtf8( | 1011 v8::Script::Compile(v8::String::NewFromUtf8( |
| 1012 env->GetIsolate(), call_function_test_source))->Run(); | 1012 env->GetIsolate(), call_function_test_source))->Run(); |
| 1013 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 1013 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 1014 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 1014 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
| 1015 | 1015 |
| 1016 int32_t duration_ms = 100; | 1016 int32_t duration_ms = 100; |
| 1017 v8::Handle<v8::Value> args[] = { | 1017 v8::Handle<v8::Value> args[] = { |
| 1018 v8::Integer::New(env->GetIsolate(), duration_ms) | 1018 v8::Integer::New(env->GetIsolate(), duration_ms) |
| 1019 }; | 1019 }; |
| 1020 const v8::CpuProfile* profile = | 1020 const v8::CpuProfile* profile = |
| 1021 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 1021 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); |
| 1022 | 1022 |
| 1023 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1023 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1024 { | 1024 { |
| 1025 ScopedVector<v8::Handle<v8::String> > names(4); | 1025 ScopedVector<v8::Handle<v8::String> > names(4); |
| 1026 names[0] = v8::String::NewFromUtf8( | 1026 names[0] = v8::String::NewFromUtf8( |
| 1027 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1027 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
| 1028 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1028 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
| 1029 ProfileGenerator::kProgramEntryName); | 1029 ProfileGenerator::kProgramEntryName); |
| 1030 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 1030 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
| 1031 names[3] = v8::String::NewFromUtf8( | 1031 names[3] = v8::String::NewFromUtf8( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 ->Run(); | 1094 ->Run(); |
| 1095 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 1095 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 1096 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); | 1096 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); |
| 1097 | 1097 |
| 1098 int32_t duration_ms = 100; | 1098 int32_t duration_ms = 100; |
| 1099 v8::Handle<v8::Value> args[] = { | 1099 v8::Handle<v8::Value> args[] = { |
| 1100 v8::Integer::New(env->GetIsolate(), duration_ms) | 1100 v8::Integer::New(env->GetIsolate(), duration_ms) |
| 1101 }; | 1101 }; |
| 1102 | 1102 |
| 1103 const v8::CpuProfile* profile = | 1103 const v8::CpuProfile* profile = |
| 1104 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); | 1104 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); |
| 1105 | 1105 |
| 1106 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1106 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1107 { | 1107 { |
| 1108 ScopedVector<v8::Handle<v8::String> > names(3); | 1108 ScopedVector<v8::Handle<v8::String> > names(3); |
| 1109 names[0] = v8::String::NewFromUtf8( | 1109 names[0] = v8::String::NewFromUtf8( |
| 1110 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); | 1110 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); |
| 1111 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), | 1111 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), |
| 1112 ProfileGenerator::kProgramEntryName); | 1112 ProfileGenerator::kProgramEntryName); |
| 1113 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); | 1113 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start"); |
| 1114 // Don't allow |test|, |bar| and |apply| nodes to be at the top level. | 1114 // Don't allow |test|, |bar| and |apply| nodes to be at the top level. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 | 1180 |
| 1181 | 1181 |
| 1182 // [Top down]: | 1182 // [Top down]: |
| 1183 // 58 0 (root) #0 1 | 1183 // 58 0 (root) #0 1 |
| 1184 // 2 2 (program) #0 2 | 1184 // 2 2 (program) #0 2 |
| 1185 // 56 1 start #16 3 | 1185 // 56 1 start #16 3 |
| 1186 // 55 0 CallJsFunction #0 4 | 1186 // 55 0 CallJsFunction #0 4 |
| 1187 // 55 1 bar #16 5 | 1187 // 55 1 bar #16 5 |
| 1188 // 54 54 foo #16 6 | 1188 // 54 54 foo #16 6 |
| 1189 TEST(JsNativeJsSample) { | 1189 TEST(JsNativeJsSample) { |
| 1190 const char* extensions[] = { "v8/profiler" }; | 1190 v8::HandleScope scope(CcTest::isolate()); |
| 1191 v8::ExtensionConfiguration config(1, extensions); | 1191 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1192 LocalContext env(&config); | 1192 v8::Context::Scope context_scope(env); |
| 1193 v8::HandleScope scope(env->GetIsolate()); | |
| 1194 | 1193 |
| 1195 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( | 1194 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( |
| 1196 env->GetIsolate(), CallJsFunction); | 1195 env->GetIsolate(), CallJsFunction); |
| 1197 v8::Local<v8::Function> func = func_template->GetFunction(); | 1196 v8::Local<v8::Function> func = func_template->GetFunction(); |
| 1198 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction")); | 1197 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction")); |
| 1199 env->Global()->Set( | 1198 env->Global()->Set( |
| 1200 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); | 1199 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); |
| 1201 | 1200 |
| 1202 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | 1201 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
| 1203 js_native_js_test_source))->Run(); | 1202 js_native_js_test_source))->Run(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 | 1264 |
| 1266 | 1265 |
| 1267 // [Top down]: | 1266 // [Top down]: |
| 1268 // 57 0 (root) #0 1 | 1267 // 57 0 (root) #0 1 |
| 1269 // 55 1 start #16 3 | 1268 // 55 1 start #16 3 |
| 1270 // 54 0 CallJsFunction #0 4 | 1269 // 54 0 CallJsFunction #0 4 |
| 1271 // 54 3 bar #16 5 | 1270 // 54 3 bar #16 5 |
| 1272 // 51 51 foo #16 6 | 1271 // 51 51 foo #16 6 |
| 1273 // 2 2 (program) #0 2 | 1272 // 2 2 (program) #0 2 |
| 1274 TEST(JsNativeJsRuntimeJsSample) { | 1273 TEST(JsNativeJsRuntimeJsSample) { |
| 1275 const char* extensions[] = { "v8/profiler" }; | 1274 v8::HandleScope scope(CcTest::isolate()); |
| 1276 v8::ExtensionConfiguration config(1, extensions); | 1275 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1277 LocalContext env(&config); | 1276 v8::Context::Scope context_scope(env); |
| 1278 v8::HandleScope scope(env->GetIsolate()); | |
| 1279 | 1277 |
| 1280 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( | 1278 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( |
| 1281 env->GetIsolate(), CallJsFunction); | 1279 env->GetIsolate(), CallJsFunction); |
| 1282 v8::Local<v8::Function> func = func_template->GetFunction(); | 1280 v8::Local<v8::Function> func = func_template->GetFunction(); |
| 1283 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction")); | 1281 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction")); |
| 1284 env->Global()->Set( | 1282 env->Global()->Set( |
| 1285 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); | 1283 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); |
| 1286 | 1284 |
| 1287 v8::Script::Compile( | 1285 v8::Script::Compile( |
| 1288 v8::String::NewFromUtf8(env->GetIsolate(), | 1286 v8::String::NewFromUtf8(env->GetIsolate(), |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 | 1352 |
| 1355 // [Top down]: | 1353 // [Top down]: |
| 1356 // 57 0 (root) #0 1 | 1354 // 57 0 (root) #0 1 |
| 1357 // 55 1 start #16 3 | 1355 // 55 1 start #16 3 |
| 1358 // 54 0 CallJsFunction1 #0 4 | 1356 // 54 0 CallJsFunction1 #0 4 |
| 1359 // 54 0 bar #16 5 | 1357 // 54 0 bar #16 5 |
| 1360 // 54 0 CallJsFunction2 #0 6 | 1358 // 54 0 CallJsFunction2 #0 6 |
| 1361 // 54 54 foo #16 7 | 1359 // 54 54 foo #16 7 |
| 1362 // 2 2 (program) #0 2 | 1360 // 2 2 (program) #0 2 |
| 1363 TEST(JsNative1JsNative2JsSample) { | 1361 TEST(JsNative1JsNative2JsSample) { |
| 1364 const char* extensions[] = { "v8/profiler" }; | 1362 v8::HandleScope scope(CcTest::isolate()); |
| 1365 v8::ExtensionConfiguration config(1, extensions); | 1363 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1366 LocalContext env(&config); | 1364 v8::Context::Scope context_scope(env); |
| 1367 v8::HandleScope scope(env->GetIsolate()); | |
| 1368 | 1365 |
| 1369 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( | 1366 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( |
| 1370 env->GetIsolate(), CallJsFunction); | 1367 env->GetIsolate(), CallJsFunction); |
| 1371 v8::Local<v8::Function> func1 = func_template->GetFunction(); | 1368 v8::Local<v8::Function> func1 = func_template->GetFunction(); |
| 1372 func1->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1")); | 1369 func1->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1")); |
| 1373 env->Global()->Set( | 1370 env->Global()->Set( |
| 1374 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"), func1); | 1371 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"), func1); |
| 1375 | 1372 |
| 1376 v8::Local<v8::Function> func2 = v8::FunctionTemplate::New( | 1373 v8::Local<v8::Function> func2 = v8::FunctionTemplate::New( |
| 1377 env->GetIsolate(), CallJsFunction2)->GetFunction(); | 1374 env->GetIsolate(), CallJsFunction2)->GetFunction(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 node->GetFunctionName()); | 1484 node->GetFunctionName()); |
| 1488 CHECK_EQ(v8::String::NewFromUtf8(isolate, script_name), | 1485 CHECK_EQ(v8::String::NewFromUtf8(isolate, script_name), |
| 1489 node->GetScriptResourceName()); | 1486 node->GetScriptResourceName()); |
| 1490 CHECK_EQ(script_id, node->GetScriptId()); | 1487 CHECK_EQ(script_id, node->GetScriptId()); |
| 1491 CHECK_EQ(line, node->GetLineNumber()); | 1488 CHECK_EQ(line, node->GetLineNumber()); |
| 1492 CHECK_EQ(column, node->GetColumnNumber()); | 1489 CHECK_EQ(column, node->GetColumnNumber()); |
| 1493 } | 1490 } |
| 1494 | 1491 |
| 1495 | 1492 |
| 1496 TEST(FunctionDetails) { | 1493 TEST(FunctionDetails) { |
| 1497 const char* extensions[] = { "v8/profiler" }; | 1494 v8::HandleScope scope(CcTest::isolate()); |
| 1498 v8::ExtensionConfiguration config(1, extensions); | 1495 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1499 LocalContext env(&config); | 1496 v8::Context::Scope context_scope(env); |
| 1500 v8::HandleScope handleScope(env->GetIsolate()); | |
| 1501 | 1497 |
| 1502 v8::Handle<v8::Script> script_a = v8::Script::Compile( | 1498 v8::Handle<v8::Script> script_a = v8::Script::Compile( |
| 1503 v8::String::NewFromUtf8( | 1499 v8::String::NewFromUtf8( |
| 1504 env->GetIsolate(), | 1500 env->GetIsolate(), |
| 1505 " function foo\n() { try { bar(); } catch(e) {} }\n" | 1501 " function foo\n() { try { bar(); } catch(e) {} }\n" |
| 1506 " function bar() { startProfiling(); }\n"), | 1502 " function bar() { startProfiling(); }\n"), |
| 1507 v8::String::NewFromUtf8(env->GetIsolate(), "script_a")); | 1503 v8::String::NewFromUtf8(env->GetIsolate(), "script_a")); |
| 1508 script_a->Run(); | 1504 script_a->Run(); |
| 1509 v8::Handle<v8::Script> script_b = v8::Script::Compile( | 1505 v8::Handle<v8::Script> script_b = v8::Script::Compile( |
| 1510 v8::String::NewFromUtf8( | 1506 v8::String::NewFromUtf8( |
| 1511 env->GetIsolate(), | 1507 env->GetIsolate(), |
| 1512 "\n\n function baz() { try { foo(); } catch(e) {} }\n" | 1508 "\n\n function baz() { try { foo(); } catch(e) {} }\n" |
| 1513 "\n\nbaz();\n" | 1509 "\n\nbaz();\n" |
| 1514 "stopProfiling();\n"), | 1510 "stopProfiling();\n"), |
| 1515 v8::String::NewFromUtf8(env->GetIsolate(), "script_b")); | 1511 v8::String::NewFromUtf8(env->GetIsolate(), "script_b")); |
| 1516 script_b->Run(); | 1512 script_b->Run(); |
| 1517 const v8::CpuProfile* profile = ProfilerExtension::last_profile; | 1513 const v8::CpuProfile* profile = i::ProfilerExtension::last_profile; |
| 1518 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); | 1514 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); |
| 1519 reinterpret_cast<ProfileNode*>( | 1515 reinterpret_cast<ProfileNode*>( |
| 1520 const_cast<v8::CpuProfileNode*>(current))->Print(0); | 1516 const_cast<v8::CpuProfileNode*>(current))->Print(0); |
| 1521 // The tree should look like this: | 1517 // The tree should look like this: |
| 1522 // 0 (root) 0 #1 | 1518 // 0 (root) 0 #1 |
| 1523 // 0 (anonymous function) 19 #2 no reason script_b:1 | 1519 // 0 (anonymous function) 19 #2 no reason script_b:1 |
| 1524 // 0 baz 19 #3 TryCatchStatement script_b:3 | 1520 // 0 baz 19 #3 TryCatchStatement script_b:3 |
| 1525 // 0 foo 18 #4 TryCatchStatement script_a:2 | 1521 // 0 foo 18 #4 TryCatchStatement script_a:2 |
| 1526 // 1 bar 18 #5 no reason script_a:3 | 1522 // 1 bar 18 #5 no reason script_a:3 |
| 1527 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 1523 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 1528 const v8::CpuProfileNode* script = GetChild(env->GetIsolate(), root, | 1524 const v8::CpuProfileNode* script = GetChild(env->GetIsolate(), root, |
| 1529 ProfileGenerator::kAnonymousFunctionName); | 1525 ProfileGenerator::kAnonymousFunctionName); |
| 1530 CheckFunctionDetails(env->GetIsolate(), script, | 1526 CheckFunctionDetails(env->GetIsolate(), script, |
| 1531 ProfileGenerator::kAnonymousFunctionName, "script_b", | 1527 ProfileGenerator::kAnonymousFunctionName, "script_b", |
| 1532 script_b->GetId(), 1, 1); | 1528 script_b->GetId(), 1, 1); |
| 1533 const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz"); | 1529 const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz"); |
| 1534 CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b", | 1530 CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b", |
| 1535 script_b->GetId(), 3, 16); | 1531 script_b->GetId(), 3, 16); |
| 1536 const v8::CpuProfileNode* foo = GetChild(env->GetIsolate(), baz, "foo"); | 1532 const v8::CpuProfileNode* foo = GetChild(env->GetIsolate(), baz, "foo"); |
| 1537 CheckFunctionDetails(env->GetIsolate(), foo, "foo", "script_a", | 1533 CheckFunctionDetails(env->GetIsolate(), foo, "foo", "script_a", |
| 1538 script_a->GetId(), 2, 1); | 1534 script_a->GetId(), 2, 1); |
| 1539 const v8::CpuProfileNode* bar = GetChild(env->GetIsolate(), foo, "bar"); | 1535 const v8::CpuProfileNode* bar = GetChild(env->GetIsolate(), foo, "bar"); |
| 1540 CheckFunctionDetails(env->GetIsolate(), bar, "bar", "script_a", | 1536 CheckFunctionDetails(env->GetIsolate(), bar, "bar", "script_a", |
| 1541 script_a->GetId(), 3, 14); | 1537 script_a->GetId(), 3, 14); |
| 1542 } | 1538 } |
| 1543 | 1539 |
| 1544 | 1540 |
| 1545 TEST(DontStopOnFinishedProfileDelete) { | 1541 TEST(DontStopOnFinishedProfileDelete) { |
| 1546 const char* extensions[] = { "v8/profiler" }; | 1542 v8::HandleScope scope(CcTest::isolate()); |
| 1547 v8::ExtensionConfiguration config(1, extensions); | 1543 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1548 LocalContext env(&config); | 1544 v8::Context::Scope context_scope(env); |
| 1549 v8::Isolate* isolate = env->GetIsolate(); | 1545 v8::Isolate* isolate = env->GetIsolate(); |
| 1550 v8::HandleScope handleScope(isolate); | |
| 1551 | 1546 |
| 1552 v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); | 1547 v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); |
| 1553 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler); | 1548 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler); |
| 1554 | 1549 |
| 1555 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1550 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1556 v8::Handle<v8::String> outer = v8::String::NewFromUtf8(isolate, "outer"); | 1551 v8::Handle<v8::String> outer = v8::String::NewFromUtf8(isolate, "outer"); |
| 1557 profiler->StartCpuProfiling(outer); | 1552 profiler->StartCpuProfiling(outer); |
| 1558 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1553 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1559 | 1554 |
| 1560 v8::Handle<v8::String> inner = v8::String::NewFromUtf8(isolate, "inner"); | 1555 v8::Handle<v8::String> inner = v8::String::NewFromUtf8(isolate, "inner"); |
| 1561 profiler->StartCpuProfiling(inner); | 1556 profiler->StartCpuProfiling(inner); |
| 1562 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1557 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1563 | 1558 |
| 1564 const v8::CpuProfile* inner_profile = profiler->StopCpuProfiling(inner); | 1559 const v8::CpuProfile* inner_profile = profiler->StopCpuProfiling(inner); |
| 1565 CHECK(inner_profile); | 1560 CHECK(inner_profile); |
| 1566 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 1561 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
| 1567 const_cast<v8::CpuProfile*>(inner_profile)->Delete(); | 1562 const_cast<v8::CpuProfile*>(inner_profile)->Delete(); |
| 1568 inner_profile = NULL; | 1563 inner_profile = NULL; |
| 1569 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1564 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1570 | 1565 |
| 1571 const v8::CpuProfile* outer_profile = profiler->StopCpuProfiling(outer); | 1566 const v8::CpuProfile* outer_profile = profiler->StopCpuProfiling(outer); |
| 1572 CHECK(outer_profile); | 1567 CHECK(outer_profile); |
| 1573 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 1568 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
| 1574 const_cast<v8::CpuProfile*>(outer_profile)->Delete(); | 1569 const_cast<v8::CpuProfile*>(outer_profile)->Delete(); |
| 1575 outer_profile = NULL; | 1570 outer_profile = NULL; |
| 1576 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1571 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1577 } | 1572 } |
| OLD | NEW |