Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: test/cctest/test-cpu-profiler.cc

Issue 108113002: Removed internal uses of (almost) deprecated FunctionTemplate::New version. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Whitespace. Rebased. 3rd attempt... Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-compiler.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 bool is_warming_up_; 717 bool is_warming_up_;
718 }; 718 };
719 719
720 720
721 // Test that native accessors are properly reported in the CPU profile. 721 // Test that native accessors are properly reported in the CPU profile.
722 // This test checks the case when the long-running accessors are called 722 // This test checks the case when the long-running accessors are called
723 // only once and the optimizer doesn't have chance to change the invocation 723 // only once and the optimizer doesn't have chance to change the invocation
724 // code. 724 // code.
725 TEST(NativeAccessorUninitializedIC) { 725 TEST(NativeAccessorUninitializedIC) {
726 LocalContext env; 726 LocalContext env;
727 v8::HandleScope scope(env->GetIsolate()); 727 v8::Isolate* isolate = env->GetIsolate();
728 v8::HandleScope scope(isolate);
728 729
729 730 v8::Local<v8::FunctionTemplate> func_template =
730 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); 731 v8::FunctionTemplate::New(isolate);
731 v8::Local<v8::ObjectTemplate> instance_template = 732 v8::Local<v8::ObjectTemplate> instance_template =
732 func_template->InstanceTemplate(); 733 func_template->InstanceTemplate();
733 734
734 TestApiCallbacks accessors(100); 735 TestApiCallbacks accessors(100);
735 v8::Local<v8::External> data = 736 v8::Local<v8::External> data =
736 v8::External::New(env->GetIsolate(), &accessors); 737 v8::External::New(isolate, &accessors);
737 instance_template->SetAccessor( 738 instance_template->SetAccessor(
738 v8::String::NewFromUtf8(env->GetIsolate(), "foo"), 739 v8::String::NewFromUtf8(isolate, "foo"),
739 &TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data); 740 &TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data);
740 v8::Local<v8::Function> func = func_template->GetFunction(); 741 v8::Local<v8::Function> func = func_template->GetFunction();
741 v8::Local<v8::Object> instance = func->NewInstance(); 742 v8::Local<v8::Object> instance = func->NewInstance();
742 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), 743 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
743 instance); 744 instance);
744 745
745 v8::Script::Compile( 746 v8::Script::Compile(
746 v8::String::NewFromUtf8(env->GetIsolate(), native_accessor_test_source)) 747 v8::String::NewFromUtf8(isolate, native_accessor_test_source))
747 ->Run(); 748 ->Run();
748 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 749 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
749 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); 750 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
750 751
751 int32_t repeat_count = 1; 752 int32_t repeat_count = 1;
752 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) }; 753 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
753 const v8::CpuProfile* profile = 754 const v8::CpuProfile* profile =
754 RunProfiler(env, function, args, ARRAY_SIZE(args), 180); 755 RunProfiler(env, function, args, ARRAY_SIZE(args), 180);
755 756
756 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 757 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
757 const v8::CpuProfileNode* startNode = 758 const v8::CpuProfileNode* startNode =
758 GetChild(env->GetIsolate(), root, "start"); 759 GetChild(isolate, root, "start");
759 GetChild(env->GetIsolate(), startNode, "get foo"); 760 GetChild(isolate, startNode, "get foo");
760 GetChild(env->GetIsolate(), startNode, "set foo"); 761 GetChild(isolate, startNode, "set foo");
761 762
762 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 763 v8::CpuProfiler* cpu_profiler = isolate->GetCpuProfiler();
763 cpu_profiler->DeleteAllCpuProfiles(); 764 cpu_profiler->DeleteAllCpuProfiles();
764 } 765 }
765 766
766 767
767 // Test that native accessors are properly reported in the CPU profile. 768 // Test that native accessors are properly reported in the CPU profile.
768 // This test makes sure that the accessors are called enough times to become 769 // This test makes sure that the accessors are called enough times to become
769 // hot and to trigger optimizations. 770 // hot and to trigger optimizations.
770 TEST(NativeAccessorMonomorphicIC) { 771 TEST(NativeAccessorMonomorphicIC) {
771 LocalContext env; 772 LocalContext env;
772 v8::HandleScope scope(env->GetIsolate()); 773 v8::Isolate* isolate = env->GetIsolate();
774 v8::HandleScope scope(isolate);
773 775
774 776 v8::Local<v8::FunctionTemplate> func_template =
775 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); 777 v8::FunctionTemplate::New(isolate);
776 v8::Local<v8::ObjectTemplate> instance_template = 778 v8::Local<v8::ObjectTemplate> instance_template =
777 func_template->InstanceTemplate(); 779 func_template->InstanceTemplate();
778 780
779 TestApiCallbacks accessors(1); 781 TestApiCallbacks accessors(1);
780 v8::Local<v8::External> data = 782 v8::Local<v8::External> data =
781 v8::External::New(env->GetIsolate(), &accessors); 783 v8::External::New(isolate, &accessors);
782 instance_template->SetAccessor( 784 instance_template->SetAccessor(
783 v8::String::NewFromUtf8(env->GetIsolate(), "foo"), 785 v8::String::NewFromUtf8(isolate, "foo"),
784 &TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data); 786 &TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data);
785 v8::Local<v8::Function> func = func_template->GetFunction(); 787 v8::Local<v8::Function> func = func_template->GetFunction();
786 v8::Local<v8::Object> instance = func->NewInstance(); 788 v8::Local<v8::Object> instance = func->NewInstance();
787 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), 789 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
788 instance); 790 instance);
789 791
790 v8::Script::Compile( 792 v8::Script::Compile(
791 v8::String::NewFromUtf8(env->GetIsolate(), native_accessor_test_source)) 793 v8::String::NewFromUtf8(isolate, native_accessor_test_source))
792 ->Run(); 794 ->Run();
793 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 795 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
794 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); 796 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
795 797
796 { 798 {
797 // Make sure accessors ICs are in monomorphic state before starting 799 // Make sure accessors ICs are in monomorphic state before starting
798 // profiling. 800 // profiling.
799 accessors.set_warming_up(true); 801 accessors.set_warming_up(true);
800 int32_t warm_up_iterations = 3; 802 int32_t warm_up_iterations = 3;
801 v8::Handle<v8::Value> args[] = { v8::Integer::New(warm_up_iterations) }; 803 v8::Handle<v8::Value> args[] = { v8::Integer::New(warm_up_iterations) };
802 function->Call(env->Global(), ARRAY_SIZE(args), args); 804 function->Call(env->Global(), ARRAY_SIZE(args), args);
803 accessors.set_warming_up(false); 805 accessors.set_warming_up(false);
804 } 806 }
805 807
806 int32_t repeat_count = 100; 808 int32_t repeat_count = 100;
807 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) }; 809 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
808 const v8::CpuProfile* profile = 810 const v8::CpuProfile* profile =
809 RunProfiler(env, function, args, ARRAY_SIZE(args), 200); 811 RunProfiler(env, function, args, ARRAY_SIZE(args), 200);
810 812
811 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 813 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
812 const v8::CpuProfileNode* startNode = 814 const v8::CpuProfileNode* startNode =
813 GetChild(env->GetIsolate(), root, "start"); 815 GetChild(isolate, root, "start");
814 GetChild(env->GetIsolate(), startNode, "get foo"); 816 GetChild(isolate, startNode, "get foo");
815 GetChild(env->GetIsolate(), startNode, "set foo"); 817 GetChild(isolate, startNode, "set foo");
816 818
817 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 819 v8::CpuProfiler* cpu_profiler = isolate->GetCpuProfiler();
818 cpu_profiler->DeleteAllCpuProfiles(); 820 cpu_profiler->DeleteAllCpuProfiles();
819 } 821 }
820 822
821 823
822 static const char* native_method_test_source = "function start(count) {\n" 824 static const char* native_method_test_source = "function start(count) {\n"
823 " for (var i = 0; i < count; i++) {\n" 825 " for (var i = 0; i < count; i++) {\n"
824 " instance.fooMethod();\n" 826 " instance.fooMethod();\n"
825 " }\n" 827 " }\n"
826 "}\n"; 828 "}\n";
827 829
828 830
829 TEST(NativeMethodUninitializedIC) { 831 TEST(NativeMethodUninitializedIC) {
830 LocalContext env; 832 LocalContext env;
831 v8::HandleScope scope(env->GetIsolate()); 833 v8::Isolate* isolate = env->GetIsolate();
834 v8::HandleScope scope(isolate);
832 835
833 TestApiCallbacks callbacks(100); 836 TestApiCallbacks callbacks(100);
834 v8::Local<v8::External> data = 837 v8::Local<v8::External> data =
835 v8::External::New(env->GetIsolate(), &callbacks); 838 v8::External::New(isolate, &callbacks);
836 839
837 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); 840 v8::Local<v8::FunctionTemplate> func_template =
841 v8::FunctionTemplate::New(isolate);
838 func_template->SetClassName( 842 func_template->SetClassName(
839 v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor")); 843 v8::String::NewFromUtf8(isolate, "Test_InstanceCostructor"));
840 v8::Local<v8::ObjectTemplate> proto_template = 844 v8::Local<v8::ObjectTemplate> proto_template =
841 func_template->PrototypeTemplate(); 845 func_template->PrototypeTemplate();
842 v8::Local<v8::Signature> signature = 846 v8::Local<v8::Signature> signature =
843 v8::Signature::New(env->GetIsolate(), func_template); 847 v8::Signature::New(isolate, func_template);
844 proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"), 848 proto_template->Set(v8::String::NewFromUtf8(isolate, "fooMethod"),
845 v8::FunctionTemplate::New(&TestApiCallbacks::Callback, 849 v8::FunctionTemplate::New(isolate,
850 &TestApiCallbacks::Callback,
846 data, signature, 0)); 851 data, signature, 0));
847 852
848 v8::Local<v8::Function> func = func_template->GetFunction(); 853 v8::Local<v8::Function> func = func_template->GetFunction();
849 v8::Local<v8::Object> instance = func->NewInstance(); 854 v8::Local<v8::Object> instance = func->NewInstance();
850 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), 855 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
851 instance); 856 instance);
852 857
853 v8::Script::Compile(v8::String::NewFromUtf8( 858 v8::Script::Compile(v8::String::NewFromUtf8(
854 env->GetIsolate(), native_method_test_source))->Run(); 859 isolate, native_method_test_source))->Run();
855 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 860 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
856 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); 861 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
857 862
858 int32_t repeat_count = 1; 863 int32_t repeat_count = 1;
859 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) }; 864 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
860 const v8::CpuProfile* profile = 865 const v8::CpuProfile* profile =
861 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); 866 RunProfiler(env, function, args, ARRAY_SIZE(args), 100);
862 867
863 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 868 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
864 const v8::CpuProfileNode* startNode = 869 const v8::CpuProfileNode* startNode =
865 GetChild(env->GetIsolate(), root, "start"); 870 GetChild(isolate, root, "start");
866 GetChild(env->GetIsolate(), startNode, "fooMethod"); 871 GetChild(isolate, startNode, "fooMethod");
867 872
868 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 873 v8::CpuProfiler* cpu_profiler = isolate->GetCpuProfiler();
869 cpu_profiler->DeleteAllCpuProfiles(); 874 cpu_profiler->DeleteAllCpuProfiles();
870 } 875 }
871 876
872 877
873 TEST(NativeMethodMonomorphicIC) { 878 TEST(NativeMethodMonomorphicIC) {
874 LocalContext env; 879 LocalContext env;
875 v8::HandleScope scope(env->GetIsolate()); 880 v8::Isolate* isolate = env->GetIsolate();
881 v8::HandleScope scope(isolate);
876 882
877 TestApiCallbacks callbacks(1); 883 TestApiCallbacks callbacks(1);
878 v8::Local<v8::External> data = 884 v8::Local<v8::External> data =
879 v8::External::New(env->GetIsolate(), &callbacks); 885 v8::External::New(isolate, &callbacks);
880 886
881 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); 887 v8::Local<v8::FunctionTemplate> func_template =
888 v8::FunctionTemplate::New(isolate);
882 func_template->SetClassName( 889 func_template->SetClassName(
883 v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor")); 890 v8::String::NewFromUtf8(isolate, "Test_InstanceCostructor"));
884 v8::Local<v8::ObjectTemplate> proto_template = 891 v8::Local<v8::ObjectTemplate> proto_template =
885 func_template->PrototypeTemplate(); 892 func_template->PrototypeTemplate();
886 v8::Local<v8::Signature> signature = 893 v8::Local<v8::Signature> signature =
887 v8::Signature::New(env->GetIsolate(), func_template); 894 v8::Signature::New(isolate, func_template);
888 proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"), 895 proto_template->Set(v8::String::NewFromUtf8(isolate, "fooMethod"),
889 v8::FunctionTemplate::New(&TestApiCallbacks::Callback, 896 v8::FunctionTemplate::New(isolate,
897 &TestApiCallbacks::Callback,
890 data, signature, 0)); 898 data, signature, 0));
891 899
892 v8::Local<v8::Function> func = func_template->GetFunction(); 900 v8::Local<v8::Function> func = func_template->GetFunction();
893 v8::Local<v8::Object> instance = func->NewInstance(); 901 v8::Local<v8::Object> instance = func->NewInstance();
894 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), 902 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
895 instance); 903 instance);
896 904
897 v8::Script::Compile(v8::String::NewFromUtf8( 905 v8::Script::Compile(v8::String::NewFromUtf8(
898 env->GetIsolate(), native_method_test_source))->Run(); 906 isolate, native_method_test_source))->Run();
899 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 907 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
900 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); 908 env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
901 { 909 {
902 // Make sure method ICs are in monomorphic state before starting 910 // Make sure method ICs are in monomorphic state before starting
903 // profiling. 911 // profiling.
904 callbacks.set_warming_up(true); 912 callbacks.set_warming_up(true);
905 int32_t warm_up_iterations = 3; 913 int32_t warm_up_iterations = 3;
906 v8::Handle<v8::Value> args[] = { v8::Integer::New(warm_up_iterations) }; 914 v8::Handle<v8::Value> args[] = { v8::Integer::New(warm_up_iterations) };
907 function->Call(env->Global(), ARRAY_SIZE(args), args); 915 function->Call(env->Global(), ARRAY_SIZE(args), args);
908 callbacks.set_warming_up(false); 916 callbacks.set_warming_up(false);
909 } 917 }
910 918
911 int32_t repeat_count = 100; 919 int32_t repeat_count = 100;
912 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) }; 920 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
913 const v8::CpuProfile* profile = 921 const v8::CpuProfile* profile =
914 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); 922 RunProfiler(env, function, args, ARRAY_SIZE(args), 100);
915 923
916 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 924 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
917 GetChild(env->GetIsolate(), root, "start"); 925 GetChild(isolate, root, "start");
918 const v8::CpuProfileNode* startNode = 926 const v8::CpuProfileNode* startNode =
919 GetChild(env->GetIsolate(), root, "start"); 927 GetChild(isolate, root, "start");
920 GetChild(env->GetIsolate(), startNode, "fooMethod"); 928 GetChild(isolate, startNode, "fooMethod");
921 929
922 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 930 v8::CpuProfiler* cpu_profiler = isolate->GetCpuProfiler();
923 cpu_profiler->DeleteAllCpuProfiles(); 931 cpu_profiler->DeleteAllCpuProfiles();
924 } 932 }
925 933
926 934
927 static const char* bound_function_test_source = "function foo(iterations) {\n" 935 static const char* bound_function_test_source = "function foo(iterations) {\n"
928 " var r = 0;\n" 936 " var r = 0;\n"
929 " for (var i = 0; i < iterations; i++) { r += i; }\n" 937 " for (var i = 0; i < iterations; i++) { r += i; }\n"
930 " return r;\n" 938 " return r;\n"
931 "}\n" 939 "}\n"
932 "function start(duration) {\n" 940 "function start(duration) {\n"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 // 55 0 CallJsFunction #0 4 1187 // 55 0 CallJsFunction #0 4
1180 // 55 1 bar #16 5 1188 // 55 1 bar #16 5
1181 // 54 54 foo #16 6 1189 // 54 54 foo #16 6
1182 TEST(JsNativeJsSample) { 1190 TEST(JsNativeJsSample) {
1183 const char* extensions[] = { "v8/profiler" }; 1191 const char* extensions[] = { "v8/profiler" };
1184 v8::ExtensionConfiguration config(1, extensions); 1192 v8::ExtensionConfiguration config(1, extensions);
1185 LocalContext env(&config); 1193 LocalContext env(&config);
1186 v8::HandleScope scope(env->GetIsolate()); 1194 v8::HandleScope scope(env->GetIsolate());
1187 1195
1188 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( 1196 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
1189 CallJsFunction); 1197 env->GetIsolate(), CallJsFunction);
1190 v8::Local<v8::Function> func = func_template->GetFunction(); 1198 v8::Local<v8::Function> func = func_template->GetFunction();
1191 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction")); 1199 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"));
1192 env->Global()->Set( 1200 env->Global()->Set(
1193 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); 1201 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func);
1194 1202
1195 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), 1203 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
1196 js_native_js_test_source))->Run(); 1204 js_native_js_test_source))->Run();
1197 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 1205 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
1198 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); 1206 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
1199 1207
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 // 54 3 bar #16 5 1271 // 54 3 bar #16 5
1264 // 51 51 foo #16 6 1272 // 51 51 foo #16 6
1265 // 2 2 (program) #0 2 1273 // 2 2 (program) #0 2
1266 TEST(JsNativeJsRuntimeJsSample) { 1274 TEST(JsNativeJsRuntimeJsSample) {
1267 const char* extensions[] = { "v8/profiler" }; 1275 const char* extensions[] = { "v8/profiler" };
1268 v8::ExtensionConfiguration config(1, extensions); 1276 v8::ExtensionConfiguration config(1, extensions);
1269 LocalContext env(&config); 1277 LocalContext env(&config);
1270 v8::HandleScope scope(env->GetIsolate()); 1278 v8::HandleScope scope(env->GetIsolate());
1271 1279
1272 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( 1280 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
1273 CallJsFunction); 1281 env->GetIsolate(), CallJsFunction);
1274 v8::Local<v8::Function> func = func_template->GetFunction(); 1282 v8::Local<v8::Function> func = func_template->GetFunction();
1275 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction")); 1283 func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"));
1276 env->Global()->Set( 1284 env->Global()->Set(
1277 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func); 1285 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func);
1278 1286
1279 v8::Script::Compile( 1287 v8::Script::Compile(
1280 v8::String::NewFromUtf8(env->GetIsolate(), 1288 v8::String::NewFromUtf8(env->GetIsolate(),
1281 js_native_js_runtime_js_test_source))->Run(); 1289 js_native_js_runtime_js_test_source))->Run();
1282 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 1290 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
1283 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); 1291 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 // 54 0 CallJsFunction2 #0 6 1359 // 54 0 CallJsFunction2 #0 6
1352 // 54 54 foo #16 7 1360 // 54 54 foo #16 7
1353 // 2 2 (program) #0 2 1361 // 2 2 (program) #0 2
1354 TEST(JsNative1JsNative2JsSample) { 1362 TEST(JsNative1JsNative2JsSample) {
1355 const char* extensions[] = { "v8/profiler" }; 1363 const char* extensions[] = { "v8/profiler" };
1356 v8::ExtensionConfiguration config(1, extensions); 1364 v8::ExtensionConfiguration config(1, extensions);
1357 LocalContext env(&config); 1365 LocalContext env(&config);
1358 v8::HandleScope scope(env->GetIsolate()); 1366 v8::HandleScope scope(env->GetIsolate());
1359 1367
1360 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New( 1368 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
1361 CallJsFunction); 1369 env->GetIsolate(), CallJsFunction);
1362 v8::Local<v8::Function> func1 = func_template->GetFunction(); 1370 v8::Local<v8::Function> func1 = func_template->GetFunction();
1363 func1->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1")); 1371 func1->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"));
1364 env->Global()->Set( 1372 env->Global()->Set(
1365 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"), func1); 1373 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"), func1);
1366 1374
1367 v8::Local<v8::Function> func2 = v8::FunctionTemplate::New( 1375 v8::Local<v8::Function> func2 = v8::FunctionTemplate::New(
1368 CallJsFunction2)->GetFunction(); 1376 env->GetIsolate(), CallJsFunction2)->GetFunction();
1369 func2->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2")); 1377 func2->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"));
1370 env->Global()->Set( 1378 env->Global()->Set(
1371 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"), func2); 1379 v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"), func2);
1372 1380
1373 v8::Script::Compile( 1381 v8::Script::Compile(
1374 v8::String::NewFromUtf8(env->GetIsolate(), 1382 v8::String::NewFromUtf8(env->GetIsolate(),
1375 js_native1_js_native2_js_test_source))->Run(); 1383 js_native1_js_native2_js_test_source))->Run();
1376 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 1384 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
1377 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); 1385 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
1378 1386
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz"); 1534 const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz");
1527 CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b", 1535 CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b",
1528 script_b->GetId(), 3, 16); 1536 script_b->GetId(), 3, 16);
1529 const v8::CpuProfileNode* foo = GetChild(env->GetIsolate(), baz, "foo"); 1537 const v8::CpuProfileNode* foo = GetChild(env->GetIsolate(), baz, "foo");
1530 CheckFunctionDetails(env->GetIsolate(), foo, "foo", "script_a", 1538 CheckFunctionDetails(env->GetIsolate(), foo, "foo", "script_a",
1531 script_a->GetId(), 2, 1); 1539 script_a->GetId(), 2, 1);
1532 const v8::CpuProfileNode* bar = GetChild(env->GetIsolate(), foo, "bar"); 1540 const v8::CpuProfileNode* bar = GetChild(env->GetIsolate(), foo, "bar");
1533 CheckFunctionDetails(env->GetIsolate(), bar, "bar", "script_a", 1541 CheckFunctionDetails(env->GetIsolate(), bar, "bar", "script_a",
1534 script_a->GetId(), 3, 14); 1542 script_a->GetId(), 3, 14);
1535 } 1543 }
OLDNEW
« no previous file with comments | « test/cctest/test-compiler.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698