OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 LocalContext env; | 797 LocalContext env; |
798 v8::HandleScope scope(env->GetIsolate()); | 798 v8::HandleScope scope(env->GetIsolate()); |
799 v8::Handle<v8::Object> global = env->Global(); | 799 v8::Handle<v8::Object> global = env->Global(); |
800 global->Set(v8_str("pi"), v8_num(3.1415926)); | 800 global->Set(v8_str("pi"), v8_num(3.1415926)); |
801 Local<Value> pi = global->Get(v8_str("pi")); | 801 Local<Value> pi = global->Get(v8_str("pi")); |
802 CHECK_EQ(3.1415926, pi->NumberValue()); | 802 CHECK_EQ(3.1415926, pi->NumberValue()); |
803 } | 803 } |
804 | 804 |
805 | 805 |
806 template<typename T> | 806 template<typename T> |
807 static void CheckReturnValue(const T& t, i::Address callback) { | 807 static void CheckReturnValue(const T& t) { |
808 v8::ReturnValue<v8::Value> rv = t.GetReturnValue(); | 808 v8::ReturnValue<v8::Value> rv = t.GetReturnValue(); |
809 i::Object** o = *reinterpret_cast<i::Object***>(&rv); | 809 i::Object** o = *reinterpret_cast<i::Object***>(&rv); |
810 CHECK_EQ(v8::Isolate::GetCurrent(), t.GetIsolate()); | 810 CHECK_EQ(v8::Isolate::GetCurrent(), t.GetIsolate()); |
811 CHECK_EQ(t.GetIsolate(), rv.GetIsolate()); | 811 CHECK_EQ(t.GetIsolate(), rv.GetIsolate()); |
812 CHECK((*o)->IsTheHole() || (*o)->IsUndefined()); | 812 CHECK((*o)->IsTheHole() || (*o)->IsUndefined()); |
813 // Verify reset | 813 // Verify reset |
814 bool is_runtime = (*o)->IsTheHole(); | 814 bool is_runtime = (*o)->IsTheHole(); |
815 rv.Set(true); | 815 rv.Set(true); |
816 CHECK(!(*o)->IsTheHole() && !(*o)->IsUndefined()); | 816 CHECK(!(*o)->IsTheHole() && !(*o)->IsUndefined()); |
817 rv.Set(v8::Handle<v8::Object>()); | 817 rv.Set(v8::Handle<v8::Object>()); |
818 CHECK((*o)->IsTheHole() || (*o)->IsUndefined()); | 818 CHECK((*o)->IsTheHole() || (*o)->IsUndefined()); |
819 CHECK_EQ(is_runtime, (*o)->IsTheHole()); | 819 CHECK_EQ(is_runtime, (*o)->IsTheHole()); |
820 | |
821 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(t.GetIsolate()); | |
822 // If CPU profiler is active check that when API callback is invoked | |
823 // VMState is set to EXTERNAL. | |
824 if (isolate->cpu_profiler()->is_profiling()) { | |
825 CHECK_EQ(i::EXTERNAL, isolate->current_vm_state()); | |
826 CHECK(isolate->external_callback()); | |
827 CHECK_EQ(callback, isolate->external_callback()); | |
828 } | |
829 } | 820 } |
830 | 821 |
831 static v8::Handle<Value> handle_call_impl( | 822 static v8::Handle<Value> handle_call(const v8::Arguments& args) { |
832 const v8::Arguments& args, | |
833 i::Address callback) { | |
834 ApiTestFuzzer::Fuzz(); | 823 ApiTestFuzzer::Fuzz(); |
835 CheckReturnValue(args, callback); | 824 CheckReturnValue(args); |
836 args.GetReturnValue().Set(v8_str("bad value")); | 825 args.GetReturnValue().Set(v8_str("bad value")); |
837 return v8_num(102); | 826 return v8_num(102); |
838 } | 827 } |
839 | 828 |
840 static v8::Handle<Value> handle_call(const v8::Arguments& args) { | 829 static v8::Handle<Value> handle_call_2(const v8::Arguments& args) { |
841 return handle_call_impl(args, FUNCTION_ADDR(handle_call)); | 830 return handle_call(args); |
842 } | 831 } |
843 | 832 |
844 static v8::Handle<Value> handle_call_2(const v8::Arguments& args) { | 833 static v8::Handle<Value> handle_call_indirect(const v8::Arguments& args) { |
845 return handle_call_impl(args, FUNCTION_ADDR(handle_call_2)); | |
846 } | |
847 | |
848 static v8::Handle<Value> handle_call_indirect_impl(const v8::Arguments& args, | |
849 i::Address callback) { | |
850 ApiTestFuzzer::Fuzz(); | 834 ApiTestFuzzer::Fuzz(); |
851 CheckReturnValue(args, callback); | 835 CheckReturnValue(args); |
852 args.GetReturnValue().Set(v8_str("bad value")); | 836 args.GetReturnValue().Set(v8_str("bad value")); |
853 args.GetReturnValue().Set(v8_num(102)); | 837 args.GetReturnValue().Set(v8_num(102)); |
854 return v8::Handle<Value>(); | 838 return v8::Handle<Value>(); |
855 } | 839 } |
856 | 840 |
857 static v8::Handle<Value> handle_call_indirect(const v8::Arguments& args) { | 841 static v8::Handle<Value> handle_call_indirect_2(const v8::Arguments& args) { |
858 return handle_call_indirect_impl(args, FUNCTION_ADDR(handle_call_indirect)); | 842 return handle_call_indirect(args); |
859 } | 843 } |
860 | 844 |
861 static v8::Handle<Value> handle_call_indirect_2(const v8::Arguments& args) { | 845 static void handle_callback(const v8::FunctionCallbackInfo<Value>& info) { |
862 return handle_call_indirect_impl(args, FUNCTION_ADDR(handle_call_indirect_2)); | |
863 } | |
864 | |
865 static void handle_callback_impl(const v8::FunctionCallbackInfo<Value>& info, | |
866 i::Address callback) { | |
867 ApiTestFuzzer::Fuzz(); | 846 ApiTestFuzzer::Fuzz(); |
868 CheckReturnValue(info, callback); | 847 CheckReturnValue(info); |
869 info.GetReturnValue().Set(v8_str("bad value")); | 848 info.GetReturnValue().Set(v8_str("bad value")); |
870 info.GetReturnValue().Set(v8_num(102)); | 849 info.GetReturnValue().Set(v8_num(102)); |
871 } | 850 } |
872 | 851 |
873 static void handle_callback(const v8::FunctionCallbackInfo<Value>& info) { | |
874 return handle_callback_impl(info, FUNCTION_ADDR(handle_callback)); | |
875 } | |
876 | |
877 static void handle_callback_2(const v8::FunctionCallbackInfo<Value>& info) { | 852 static void handle_callback_2(const v8::FunctionCallbackInfo<Value>& info) { |
878 return handle_callback_impl(info, FUNCTION_ADDR(handle_callback_2)); | 853 return handle_callback(info); |
879 } | 854 } |
880 | 855 |
881 static v8::Handle<Value> construct_call(const v8::Arguments& args) { | 856 static v8::Handle<Value> construct_call(const v8::Arguments& args) { |
882 ApiTestFuzzer::Fuzz(); | 857 ApiTestFuzzer::Fuzz(); |
883 CheckReturnValue(args, FUNCTION_ADDR(construct_call)); | 858 CheckReturnValue(args); |
884 args.This()->Set(v8_str("x"), v8_num(1)); | 859 args.This()->Set(v8_str("x"), v8_num(1)); |
885 args.This()->Set(v8_str("y"), v8_num(2)); | 860 args.This()->Set(v8_str("y"), v8_num(2)); |
886 args.GetReturnValue().Set(v8_str("bad value")); | 861 args.GetReturnValue().Set(v8_str("bad value")); |
887 return args.This(); | 862 return args.This(); |
888 } | 863 } |
889 | 864 |
890 static v8::Handle<Value> construct_call_indirect(const v8::Arguments& args) { | 865 static v8::Handle<Value> construct_call_indirect(const v8::Arguments& args) { |
891 ApiTestFuzzer::Fuzz(); | 866 ApiTestFuzzer::Fuzz(); |
892 CheckReturnValue(args, FUNCTION_ADDR(construct_call_indirect)); | 867 CheckReturnValue(args); |
893 args.This()->Set(v8_str("x"), v8_num(1)); | 868 args.This()->Set(v8_str("x"), v8_num(1)); |
894 args.This()->Set(v8_str("y"), v8_num(2)); | 869 args.This()->Set(v8_str("y"), v8_num(2)); |
895 args.GetReturnValue().Set(v8_str("bad value")); | 870 args.GetReturnValue().Set(v8_str("bad value")); |
896 args.GetReturnValue().Set(args.This()); | 871 args.GetReturnValue().Set(args.This()); |
897 return v8::Handle<Value>(); | 872 return v8::Handle<Value>(); |
898 } | 873 } |
899 | 874 |
900 static void construct_callback( | 875 static void construct_callback( |
901 const v8::FunctionCallbackInfo<Value>& info) { | 876 const v8::FunctionCallbackInfo<Value>& info) { |
902 ApiTestFuzzer::Fuzz(); | 877 ApiTestFuzzer::Fuzz(); |
903 CheckReturnValue(info, FUNCTION_ADDR(construct_callback)); | 878 CheckReturnValue(info); |
904 info.This()->Set(v8_str("x"), v8_num(1)); | 879 info.This()->Set(v8_str("x"), v8_num(1)); |
905 info.This()->Set(v8_str("y"), v8_num(2)); | 880 info.This()->Set(v8_str("y"), v8_num(2)); |
906 info.GetReturnValue().Set(v8_str("bad value")); | 881 info.GetReturnValue().Set(v8_str("bad value")); |
907 info.GetReturnValue().Set(info.This()); | 882 info.GetReturnValue().Set(info.This()); |
908 } | 883 } |
909 | 884 |
910 | 885 |
911 static v8::Handle<Value> Return239( | 886 static v8::Handle<Value> Return239( |
912 Local<String> name, const AccessorInfo& info) { | 887 Local<String> name, const AccessorInfo& info) { |
913 ApiTestFuzzer::Fuzz(); | 888 ApiTestFuzzer::Fuzz(); |
914 CheckReturnValue(info, FUNCTION_ADDR(Return239)); | 889 CheckReturnValue(info); |
915 info.GetReturnValue().Set(v8_str("bad value")); | 890 info.GetReturnValue().Set(v8_str("bad value")); |
916 return v8_num(239); | 891 return v8_num(239); |
917 } | 892 } |
918 | 893 |
919 static v8::Handle<Value> Return239Indirect( | 894 static v8::Handle<Value> Return239Indirect( |
920 Local<String> name, const AccessorInfo& info) { | 895 Local<String> name, const AccessorInfo& info) { |
921 ApiTestFuzzer::Fuzz(); | 896 ApiTestFuzzer::Fuzz(); |
922 CheckReturnValue(info, FUNCTION_ADDR(Return239Indirect)); | 897 CheckReturnValue(info); |
923 Handle<Value> value = v8_num(239); | 898 Handle<Value> value = v8_num(239); |
924 info.GetReturnValue().Set(v8_str("bad value")); | 899 info.GetReturnValue().Set(v8_str("bad value")); |
925 info.GetReturnValue().Set(value); | 900 info.GetReturnValue().Set(value); |
926 return v8::Handle<Value>(); | 901 return v8::Handle<Value>(); |
927 } | 902 } |
928 | 903 |
929 static void Return239Callback( | 904 static void Return239Callback( |
930 Local<String> name, const v8::PropertyCallbackInfo<Value>& info) { | 905 Local<String> name, const v8::PropertyCallbackInfo<Value>& info) { |
931 ApiTestFuzzer::Fuzz(); | 906 ApiTestFuzzer::Fuzz(); |
932 CheckReturnValue(info, FUNCTION_ADDR(Return239Callback)); | 907 CheckReturnValue(info); |
933 info.GetReturnValue().Set(v8_str("bad value")); | 908 info.GetReturnValue().Set(v8_str("bad value")); |
934 info.GetReturnValue().Set(v8_num(239)); | 909 info.GetReturnValue().Set(v8_num(239)); |
935 } | 910 } |
936 | 911 |
937 | 912 |
938 template<typename Handler> | 913 template<typename Handler> |
939 static void TestFunctionTemplateInitializer(Handler handler, | 914 static void TestFunctionTemplateInitializer(Handler handler, |
940 Handler handler_2) { | 915 Handler handler_2) { |
941 for (int i = 0; i < 2; i++) { | 916 // Test constructor calls. |
942 bool is_profiling = (i > 0); | 917 { |
943 // Test constructor calls. | 918 LocalContext env; |
944 { | 919 v8::HandleScope scope(env->GetIsolate()); |
945 LocalContext env; | 920 Local<v8::FunctionTemplate> fun_templ = |
946 v8::HandleScope scope(env->GetIsolate()); | 921 v8::FunctionTemplate::New(handler); |
947 | 922 Local<Function> fun = fun_templ->GetFunction(); |
948 v8::Local<v8::String> profile_name = v8::String::New("my_profile1"); | 923 env->Global()->Set(v8_str("obj"), fun); |
949 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 924 Local<Script> script = v8_compile("obj()"); |
950 if (is_profiling) { | 925 for (int i = 0; i < 30; i++) { |
951 cpu_profiler->StartCpuProfiling(profile_name); | 926 CHECK_EQ(102, script->Run()->Int32Value()); |
952 } | |
953 | |
954 Local<v8::FunctionTemplate> fun_templ = | |
955 v8::FunctionTemplate::New(handler); | |
956 Local<Function> fun = fun_templ->GetFunction(); | |
957 env->Global()->Set(v8_str("obj"), fun); | |
958 Local<Script> script = v8_compile("obj()"); | |
959 for (int i = 0; i < 30; i++) { | |
960 CHECK_EQ(102, script->Run()->Int32Value()); | |
961 } | |
962 | |
963 if (is_profiling) { | |
964 cpu_profiler->StopCpuProfiling(profile_name); | |
965 } | |
966 } | 927 } |
967 // Use SetCallHandler to initialize a function template, should work like | 928 } |
968 // the previous one. | 929 // Use SetCallHandler to initialize a function template, should work like the |
969 { | 930 // previous one. |
970 LocalContext env; | 931 { |
971 v8::HandleScope scope(env->GetIsolate()); | 932 LocalContext env; |
972 | 933 v8::HandleScope scope(env->GetIsolate()); |
973 v8::Local<v8::String> profile_name = v8::String::New("my_profile2"); | 934 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
974 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 935 fun_templ->SetCallHandler(handler_2); |
975 if (is_profiling) { | 936 Local<Function> fun = fun_templ->GetFunction(); |
976 cpu_profiler->StartCpuProfiling(profile_name); | 937 env->Global()->Set(v8_str("obj"), fun); |
977 } | 938 Local<Script> script = v8_compile("obj()"); |
978 | 939 for (int i = 0; i < 30; i++) { |
979 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 940 CHECK_EQ(102, script->Run()->Int32Value()); |
980 fun_templ->SetCallHandler(handler_2); | |
981 Local<Function> fun = fun_templ->GetFunction(); | |
982 env->Global()->Set(v8_str("obj"), fun); | |
983 Local<Script> script = v8_compile("obj()"); | |
984 for (int i = 0; i < 30; i++) { | |
985 CHECK_EQ(102, script->Run()->Int32Value()); | |
986 } | |
987 | |
988 if (is_profiling) { | |
989 cpu_profiler->DeleteAllCpuProfiles(); | |
990 } | |
991 } | 941 } |
992 } | 942 } |
993 } | 943 } |
994 | 944 |
995 | 945 |
996 template<typename Constructor, typename Accessor> | 946 template<typename Constructor, typename Accessor> |
997 static void TestFunctionTemplateAccessor(Constructor constructor, | 947 static void TestFunctionTemplateAccessor(Constructor constructor, |
998 Accessor accessor) { | 948 Accessor accessor) { |
999 for (int i = 0; i < 2; i++) { | 949 LocalContext env; |
1000 bool is_profiling = (i > 0); | 950 v8::HandleScope scope(env->GetIsolate()); |
1001 LocalContext env; | 951 Local<v8::FunctionTemplate> fun_templ = |
1002 v8::HandleScope scope(env->GetIsolate()); | 952 v8::FunctionTemplate::New(constructor); |
1003 | 953 fun_templ->SetClassName(v8_str("funky")); |
1004 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 954 fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), accessor); |
1005 if (is_profiling) { | 955 Local<Function> fun = fun_templ->GetFunction(); |
1006 v8::Local<v8::String> profile_name = v8::String::New("my_profile1"); | 956 env->Global()->Set(v8_str("obj"), fun); |
1007 cpu_profiler->StartCpuProfiling(profile_name); | 957 Local<Value> result = v8_compile("(new obj()).toString()")->Run(); |
1008 } | 958 CHECK_EQ(v8_str("[object funky]"), result); |
1009 | 959 CompileRun("var obj_instance = new obj();"); |
1010 Local<v8::FunctionTemplate> fun_templ = | 960 Local<Script> script; |
1011 v8::FunctionTemplate::New(constructor); | 961 script = v8_compile("obj_instance.x"); |
1012 fun_templ->SetClassName(v8_str("funky")); | 962 for (int i = 0; i < 30; i++) { |
1013 fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), accessor); | 963 CHECK_EQ(1, script->Run()->Int32Value()); |
1014 Local<Function> fun = fun_templ->GetFunction(); | 964 } |
1015 env->Global()->Set(v8_str("obj"), fun); | 965 script = v8_compile("obj_instance.m"); |
1016 Local<Value> result = v8_compile("(new obj()).toString()")->Run(); | 966 for (int i = 0; i < 30; i++) { |
1017 CHECK_EQ(v8_str("[object funky]"), result); | 967 CHECK_EQ(239, script->Run()->Int32Value()); |
1018 CompileRun("var obj_instance = new obj();"); | |
1019 Local<Script> script; | |
1020 script = v8_compile("obj_instance.x"); | |
1021 for (int i = 0; i < 30; i++) { | |
1022 CHECK_EQ(1, script->Run()->Int32Value()); | |
1023 } | |
1024 script = v8_compile("obj_instance.m"); | |
1025 for (int i = 0; i < 30; i++) { | |
1026 CHECK_EQ(239, script->Run()->Int32Value()); | |
1027 } | |
1028 | |
1029 if (is_profiling) { | |
1030 cpu_profiler->DeleteAllCpuProfiles(); | |
1031 } | |
1032 } | 968 } |
1033 } | 969 } |
1034 | 970 |
1035 | 971 |
1036 THREADED_TEST(FunctionTemplate) { | 972 THREADED_TEST(FunctionTemplate) { |
1037 TestFunctionTemplateInitializer(handle_call, handle_call_2); | 973 TestFunctionTemplateInitializer(handle_call, handle_call_2); |
1038 TestFunctionTemplateInitializer(handle_call_indirect, handle_call_indirect_2); | 974 TestFunctionTemplateInitializer(handle_call_indirect, handle_call_indirect_2); |
1039 TestFunctionTemplateInitializer(handle_callback, handle_callback_2); | 975 TestFunctionTemplateInitializer(handle_callback, handle_callback_2); |
1040 | 976 |
1041 TestFunctionTemplateAccessor(construct_call, Return239); | 977 TestFunctionTemplateAccessor(construct_call, Return239); |
1042 TestFunctionTemplateAccessor(construct_call_indirect, Return239Indirect); | 978 TestFunctionTemplateAccessor(construct_call_indirect, Return239Indirect); |
1043 TestFunctionTemplateAccessor(construct_callback, Return239Callback); | 979 TestFunctionTemplateAccessor(construct_callback, Return239Callback); |
1044 } | 980 } |
1045 | 981 |
1046 | 982 |
1047 static v8::Handle<v8::Value> SimpleDirectCallback(const v8::Arguments& args) { | 983 static v8::Handle<v8::Value> SimpleDirectCallback(const v8::Arguments& args) { |
1048 ApiTestFuzzer::Fuzz(); | 984 ApiTestFuzzer::Fuzz(); |
1049 CheckReturnValue(args, FUNCTION_ADDR(SimpleDirectCallback)); | 985 CheckReturnValue(args); |
1050 args.GetReturnValue().Set(v8_str("bad value")); | 986 args.GetReturnValue().Set(v8_str("bad value")); |
1051 return v8_num(51423 + args.Length()); | 987 return v8_num(51423 + args.Length()); |
1052 } | 988 } |
1053 | 989 |
1054 static v8::Handle<v8::Value> SimpleIndirectCallback(const v8::Arguments& args) { | 990 static v8::Handle<v8::Value> SimpleIndirectCallback(const v8::Arguments& args) { |
1055 ApiTestFuzzer::Fuzz(); | 991 ApiTestFuzzer::Fuzz(); |
1056 CheckReturnValue(args, FUNCTION_ADDR(SimpleIndirectCallback)); | 992 CheckReturnValue(args); |
1057 args.GetReturnValue().Set(v8_num(51423 + args.Length())); | 993 args.GetReturnValue().Set(v8_num(51423 + args.Length())); |
1058 return v8::Handle<v8::Value>(); | 994 return v8::Handle<v8::Value>(); |
1059 } | 995 } |
1060 | 996 |
1061 static void SimpleCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 997 static void SimpleCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { |
1062 ApiTestFuzzer::Fuzz(); | 998 ApiTestFuzzer::Fuzz(); |
1063 CheckReturnValue(info, FUNCTION_ADDR(SimpleCallback)); | 999 CheckReturnValue(info); |
1064 info.GetReturnValue().Set(v8_num(51423 + info.Length())); | 1000 info.GetReturnValue().Set(v8_num(51423 + info.Length())); |
1065 } | 1001 } |
1066 | 1002 |
1067 | 1003 |
1068 template<typename Callback> | 1004 template<typename Callback> |
1069 static void TestSimpleCallback(Callback callback) { | 1005 static void TestSimpleCallback(Callback callback) { |
1070 for (int i = 0; i < 2; i++) { | 1006 LocalContext env; |
1071 bool is_profiling = i; | 1007 v8::HandleScope scope(env->GetIsolate()); |
1072 LocalContext env; | 1008 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); |
1073 v8::HandleScope scope(env->GetIsolate()); | 1009 object_template->Set("callback", v8::FunctionTemplate::New(callback)); |
1074 | 1010 v8::Local<v8::Object> object = object_template->NewInstance(); |
1075 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 1011 (*env)->Global()->Set(v8_str("callback_object"), object); |
1076 if (is_profiling) { | 1012 v8::Handle<v8::Script> script; |
1077 v8::Local<v8::String> profile_name = v8::String::New("my_profile1"); | 1013 script = v8_compile("callback_object.callback(17)"); |
1078 cpu_profiler->StartCpuProfiling(profile_name); | 1014 for (int i = 0; i < 30; i++) { |
1079 } | 1015 CHECK_EQ(51424, script->Run()->Int32Value()); |
1080 | 1016 } |
1081 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); | 1017 script = v8_compile("callback_object.callback(17, 24)"); |
1082 object_template->Set("callback", v8::FunctionTemplate::New(callback)); | 1018 for (int i = 0; i < 30; i++) { |
1083 v8::Local<v8::Object> object = object_template->NewInstance(); | 1019 CHECK_EQ(51425, script->Run()->Int32Value()); |
1084 (*env)->Global()->Set(v8_str("callback_object"), object); | |
1085 v8::Handle<v8::Script> script; | |
1086 script = v8_compile("callback_object.callback(17)"); | |
1087 for (int i = 0; i < 30; i++) { | |
1088 CHECK_EQ(51424, script->Run()->Int32Value()); | |
1089 } | |
1090 script = v8_compile("callback_object.callback(17, 24)"); | |
1091 for (int i = 0; i < 30; i++) { | |
1092 CHECK_EQ(51425, script->Run()->Int32Value()); | |
1093 } | |
1094 | |
1095 if (is_profiling) { | |
1096 cpu_profiler->DeleteAllCpuProfiles(); | |
1097 } | |
1098 } | 1020 } |
1099 } | 1021 } |
1100 | 1022 |
1101 | 1023 |
1102 THREADED_TEST(SimpleCallback) { | 1024 THREADED_TEST(SimpleCallback) { |
1103 TestSimpleCallback(SimpleDirectCallback); | 1025 TestSimpleCallback(SimpleDirectCallback); |
1104 TestSimpleCallback(SimpleIndirectCallback); | 1026 TestSimpleCallback(SimpleIndirectCallback); |
1105 TestSimpleCallback(SimpleCallback); | 1027 TestSimpleCallback(SimpleCallback); |
1106 } | 1028 } |
1107 | 1029 |
1108 | 1030 |
1109 template<typename T> | 1031 template<typename T> |
1110 void FastReturnValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info); | 1032 void FastReturnValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info); |
1111 | 1033 |
1112 // constant return values | 1034 // constant return values |
1113 static int32_t fast_return_value_int32 = 471; | 1035 static int32_t fast_return_value_int32 = 471; |
1114 static uint32_t fast_return_value_uint32 = 571; | 1036 static uint32_t fast_return_value_uint32 = 571; |
1115 static const double kFastReturnValueDouble = 2.7; | 1037 static const double kFastReturnValueDouble = 2.7; |
1116 // variable return values | 1038 // variable return values |
1117 static bool fast_return_value_bool = false; | 1039 static bool fast_return_value_bool = false; |
1118 enum ReturnValueOddball { | 1040 enum ReturnValueOddball { |
1119 kNullReturnValue, | 1041 kNullReturnValue, |
1120 kUndefinedReturnValue, | 1042 kUndefinedReturnValue, |
1121 kEmptyStringReturnValue | 1043 kEmptyStringReturnValue |
1122 }; | 1044 }; |
1123 static ReturnValueOddball fast_return_value_void; | 1045 static ReturnValueOddball fast_return_value_void; |
1124 static bool fast_return_value_object_is_empty = false; | 1046 static bool fast_return_value_object_is_empty = false; |
1125 | 1047 |
1126 // Helper function to avoid compiler error: insufficient contextual information | |
1127 // to determine type when applying FUNCTION_ADDR to a template function. | |
1128 static i::Address address_of(v8::FunctionCallback callback) { | |
1129 return FUNCTION_ADDR(callback); | |
1130 } | |
1131 | |
1132 template<> | 1048 template<> |
1133 void FastReturnValueCallback<int32_t>( | 1049 void FastReturnValueCallback<int32_t>( |
1134 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1050 const v8::FunctionCallbackInfo<v8::Value>& info) { |
1135 CheckReturnValue(info, address_of(FastReturnValueCallback<int32_t>)); | 1051 CheckReturnValue(info); |
1136 info.GetReturnValue().Set(fast_return_value_int32); | 1052 info.GetReturnValue().Set(fast_return_value_int32); |
1137 } | 1053 } |
1138 | 1054 |
1139 template<> | 1055 template<> |
1140 void FastReturnValueCallback<uint32_t>( | 1056 void FastReturnValueCallback<uint32_t>( |
1141 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1057 const v8::FunctionCallbackInfo<v8::Value>& info) { |
1142 CheckReturnValue(info, address_of(FastReturnValueCallback<uint32_t>)); | 1058 CheckReturnValue(info); |
1143 info.GetReturnValue().Set(fast_return_value_uint32); | 1059 info.GetReturnValue().Set(fast_return_value_uint32); |
1144 } | 1060 } |
1145 | 1061 |
1146 template<> | 1062 template<> |
1147 void FastReturnValueCallback<double>( | 1063 void FastReturnValueCallback<double>( |
1148 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1064 const v8::FunctionCallbackInfo<v8::Value>& info) { |
1149 CheckReturnValue(info, address_of(FastReturnValueCallback<double>)); | 1065 CheckReturnValue(info); |
1150 info.GetReturnValue().Set(kFastReturnValueDouble); | 1066 info.GetReturnValue().Set(kFastReturnValueDouble); |
1151 } | 1067 } |
1152 | 1068 |
1153 template<> | 1069 template<> |
1154 void FastReturnValueCallback<bool>( | 1070 void FastReturnValueCallback<bool>( |
1155 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1071 const v8::FunctionCallbackInfo<v8::Value>& info) { |
1156 CheckReturnValue(info, address_of(FastReturnValueCallback<bool>)); | 1072 CheckReturnValue(info); |
1157 info.GetReturnValue().Set(fast_return_value_bool); | 1073 info.GetReturnValue().Set(fast_return_value_bool); |
1158 } | 1074 } |
1159 | 1075 |
1160 template<> | 1076 template<> |
1161 void FastReturnValueCallback<void>( | 1077 void FastReturnValueCallback<void>( |
1162 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1078 const v8::FunctionCallbackInfo<v8::Value>& info) { |
1163 CheckReturnValue(info, address_of(FastReturnValueCallback<void>)); | 1079 CheckReturnValue(info); |
1164 switch (fast_return_value_void) { | 1080 switch (fast_return_value_void) { |
1165 case kNullReturnValue: | 1081 case kNullReturnValue: |
1166 info.GetReturnValue().SetNull(); | 1082 info.GetReturnValue().SetNull(); |
1167 break; | 1083 break; |
1168 case kUndefinedReturnValue: | 1084 case kUndefinedReturnValue: |
1169 info.GetReturnValue().SetUndefined(); | 1085 info.GetReturnValue().SetUndefined(); |
1170 break; | 1086 break; |
1171 case kEmptyStringReturnValue: | 1087 case kEmptyStringReturnValue: |
1172 info.GetReturnValue().SetEmptyString(); | 1088 info.GetReturnValue().SetEmptyString(); |
1173 break; | 1089 break; |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2130 Local<Script> script = v8_compile("obj[900]"); | 2046 Local<Script> script = v8_compile("obj[900]"); |
2131 CHECK_EQ(script->Run()->Int32Value(), 900); | 2047 CHECK_EQ(script->Run()->Int32Value(), 900); |
2132 } | 2048 } |
2133 | 2049 |
2134 | 2050 |
2135 v8::Handle<v8::Object> bottom; | 2051 v8::Handle<v8::Object> bottom; |
2136 | 2052 |
2137 static void CheckThisIndexedPropertyHandler( | 2053 static void CheckThisIndexedPropertyHandler( |
2138 uint32_t index, | 2054 uint32_t index, |
2139 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2055 const v8::PropertyCallbackInfo<v8::Value>& info) { |
2140 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyHandler)); | 2056 CheckReturnValue(info); |
2141 ApiTestFuzzer::Fuzz(); | 2057 ApiTestFuzzer::Fuzz(); |
2142 CHECK(info.This()->Equals(bottom)); | 2058 CHECK(info.This()->Equals(bottom)); |
2143 } | 2059 } |
2144 | 2060 |
2145 static void CheckThisNamedPropertyHandler( | 2061 static void CheckThisNamedPropertyHandler( |
2146 Local<String> name, | 2062 Local<String> name, |
2147 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2063 const v8::PropertyCallbackInfo<v8::Value>& info) { |
2148 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyHandler)); | 2064 CheckReturnValue(info); |
2149 ApiTestFuzzer::Fuzz(); | 2065 ApiTestFuzzer::Fuzz(); |
2150 CHECK(info.This()->Equals(bottom)); | 2066 CHECK(info.This()->Equals(bottom)); |
2151 } | 2067 } |
2152 | 2068 |
2153 void CheckThisIndexedPropertySetter( | 2069 void CheckThisIndexedPropertySetter( |
2154 uint32_t index, | 2070 uint32_t index, |
2155 Local<Value> value, | 2071 Local<Value> value, |
2156 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2072 const v8::PropertyCallbackInfo<v8::Value>& info) { |
2157 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertySetter)); | 2073 CheckReturnValue(info); |
2158 ApiTestFuzzer::Fuzz(); | 2074 ApiTestFuzzer::Fuzz(); |
2159 CHECK(info.This()->Equals(bottom)); | 2075 CHECK(info.This()->Equals(bottom)); |
2160 } | 2076 } |
2161 | 2077 |
2162 | 2078 |
2163 void CheckThisNamedPropertySetter( | 2079 void CheckThisNamedPropertySetter( |
2164 Local<String> property, | 2080 Local<String> property, |
2165 Local<Value> value, | 2081 Local<Value> value, |
2166 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2082 const v8::PropertyCallbackInfo<v8::Value>& info) { |
2167 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertySetter)); | 2083 CheckReturnValue(info); |
2168 ApiTestFuzzer::Fuzz(); | 2084 ApiTestFuzzer::Fuzz(); |
2169 CHECK(info.This()->Equals(bottom)); | 2085 CHECK(info.This()->Equals(bottom)); |
2170 } | 2086 } |
2171 | 2087 |
2172 void CheckThisIndexedPropertyQuery( | 2088 void CheckThisIndexedPropertyQuery( |
2173 uint32_t index, | 2089 uint32_t index, |
2174 const v8::PropertyCallbackInfo<v8::Integer>& info) { | 2090 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
2175 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyQuery)); | 2091 CheckReturnValue(info); |
2176 ApiTestFuzzer::Fuzz(); | 2092 ApiTestFuzzer::Fuzz(); |
2177 CHECK(info.This()->Equals(bottom)); | 2093 CHECK(info.This()->Equals(bottom)); |
2178 } | 2094 } |
2179 | 2095 |
2180 | 2096 |
2181 void CheckThisNamedPropertyQuery( | 2097 void CheckThisNamedPropertyQuery( |
2182 Local<String> property, | 2098 Local<String> property, |
2183 const v8::PropertyCallbackInfo<v8::Integer>& info) { | 2099 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
2184 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyQuery)); | 2100 CheckReturnValue(info); |
2185 ApiTestFuzzer::Fuzz(); | 2101 ApiTestFuzzer::Fuzz(); |
2186 CHECK(info.This()->Equals(bottom)); | 2102 CHECK(info.This()->Equals(bottom)); |
2187 } | 2103 } |
2188 | 2104 |
2189 | 2105 |
2190 void CheckThisIndexedPropertyDeleter( | 2106 void CheckThisIndexedPropertyDeleter( |
2191 uint32_t index, | 2107 uint32_t index, |
2192 const v8::PropertyCallbackInfo<v8::Boolean>& info) { | 2108 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
2193 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyDeleter)); | 2109 CheckReturnValue(info); |
2194 ApiTestFuzzer::Fuzz(); | 2110 ApiTestFuzzer::Fuzz(); |
2195 CHECK(info.This()->Equals(bottom)); | 2111 CHECK(info.This()->Equals(bottom)); |
2196 } | 2112 } |
2197 | 2113 |
2198 | 2114 |
2199 void CheckThisNamedPropertyDeleter( | 2115 void CheckThisNamedPropertyDeleter( |
2200 Local<String> property, | 2116 Local<String> property, |
2201 const v8::PropertyCallbackInfo<v8::Boolean>& info) { | 2117 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
2202 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyDeleter)); | 2118 CheckReturnValue(info); |
2203 ApiTestFuzzer::Fuzz(); | 2119 ApiTestFuzzer::Fuzz(); |
2204 CHECK(info.This()->Equals(bottom)); | 2120 CHECK(info.This()->Equals(bottom)); |
2205 } | 2121 } |
2206 | 2122 |
2207 | 2123 |
2208 void CheckThisIndexedPropertyEnumerator( | 2124 void CheckThisIndexedPropertyEnumerator( |
2209 const v8::PropertyCallbackInfo<v8::Array>& info) { | 2125 const v8::PropertyCallbackInfo<v8::Array>& info) { |
2210 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyEnumerator)); | 2126 CheckReturnValue(info); |
2211 ApiTestFuzzer::Fuzz(); | 2127 ApiTestFuzzer::Fuzz(); |
2212 CHECK(info.This()->Equals(bottom)); | 2128 CHECK(info.This()->Equals(bottom)); |
2213 } | 2129 } |
2214 | 2130 |
2215 | 2131 |
2216 void CheckThisNamedPropertyEnumerator( | 2132 void CheckThisNamedPropertyEnumerator( |
2217 const v8::PropertyCallbackInfo<v8::Array>& info) { | 2133 const v8::PropertyCallbackInfo<v8::Array>& info) { |
2218 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyEnumerator)); | 2134 CheckReturnValue(info); |
2219 ApiTestFuzzer::Fuzz(); | 2135 ApiTestFuzzer::Fuzz(); |
2220 CHECK(info.This()->Equals(bottom)); | 2136 CHECK(info.This()->Equals(bottom)); |
2221 } | 2137 } |
2222 | 2138 |
2223 | 2139 |
2224 THREADED_TEST(PropertyHandlerInPrototype) { | 2140 THREADED_TEST(PropertyHandlerInPrototype) { |
2225 LocalContext env; | 2141 LocalContext env; |
2226 v8::HandleScope scope(env->GetIsolate()); | 2142 v8::HandleScope scope(env->GetIsolate()); |
2227 | 2143 |
2228 // Set up a prototype chain with three interceptors. | 2144 // Set up a prototype chain with three interceptors. |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3126 Local<String> str = v8_str("str"); | 3042 Local<String> str = v8_str("str"); |
3127 global_handles = | 3043 global_handles = |
3128 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); | 3044 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); |
3129 initial_handle_count = global_handles->NumberOfGlobalHandles(); | 3045 initial_handle_count = global_handles->NumberOfGlobalHandles(); |
3130 global.Reset(isolate, str); | 3046 global.Reset(isolate, str); |
3131 } | 3047 } |
3132 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1); | 3048 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1); |
3133 String* str = global.ClearAndLeak(); | 3049 String* str = global.ClearAndLeak(); |
3134 CHECK(global.IsEmpty()); | 3050 CHECK(global.IsEmpty()); |
3135 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1); | 3051 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1); |
3136 global_handles->Destroy(reinterpret_cast<i::Object**>(str)); | 3052 v8::Persistent<String>* new_global = |
| 3053 reinterpret_cast<v8::Persistent<String>*>(&str); |
| 3054 new_global->Dispose(); |
3137 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count); | 3055 CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count); |
3138 } | 3056 } |
3139 | 3057 |
3140 | 3058 |
3141 THREADED_TEST(GlobalHandleUpcast) { | 3059 THREADED_TEST(GlobalHandleUpcast) { |
3142 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 3060 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
3143 v8::HandleScope scope(isolate); | 3061 v8::HandleScope scope(isolate); |
3144 v8::Local<String> local = v8::Local<String>::New(v8_str("str")); | 3062 v8::Local<String> local = v8::Local<String>::New(v8_str("str")); |
3145 v8::Persistent<String> global_string(isolate, local); | 3063 v8::Persistent<String> global_string(isolate, local); |
3146 #ifdef V8_USE_UNSAFE_HANDLES | 3064 #ifdef V8_USE_UNSAFE_HANDLES |
(...skipping 7565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10712 " result" | 10630 " result" |
10713 "} catch(e) {" | 10631 "} catch(e) {" |
10714 " e" | 10632 " e" |
10715 "};"); | 10633 "};"); |
10716 CHECK_EQ(239 * 10, value->Int32Value()); | 10634 CHECK_EQ(239 * 10, value->Int32Value()); |
10717 } | 10635 } |
10718 | 10636 |
10719 static v8::Handle<Value> InterceptorCallICFastApi(Local<String> name, | 10637 static v8::Handle<Value> InterceptorCallICFastApi(Local<String> name, |
10720 const AccessorInfo& info) { | 10638 const AccessorInfo& info) { |
10721 ApiTestFuzzer::Fuzz(); | 10639 ApiTestFuzzer::Fuzz(); |
10722 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi)); | 10640 CheckReturnValue(info); |
10723 int* call_count = | 10641 int* call_count = |
10724 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); | 10642 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); |
10725 ++(*call_count); | 10643 ++(*call_count); |
10726 if ((*call_count) % 20 == 0) { | 10644 if ((*call_count) % 20 == 0) { |
10727 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 10645 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
10728 } | 10646 } |
10729 return v8::Handle<Value>(); | 10647 return v8::Handle<Value>(); |
10730 } | 10648 } |
10731 | 10649 |
10732 static v8::Handle<Value> FastApiCallback_TrivialSignature( | 10650 static v8::Handle<Value> FastApiCallback_TrivialSignature( |
10733 const v8::Arguments& args) { | 10651 const v8::Arguments& args) { |
10734 ApiTestFuzzer::Fuzz(); | 10652 ApiTestFuzzer::Fuzz(); |
10735 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)); | 10653 CheckReturnValue(args); |
10736 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 10654 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
10737 CHECK_EQ(isolate, args.GetIsolate()); | 10655 CHECK_EQ(isolate, args.GetIsolate()); |
10738 CHECK_EQ(args.This(), args.Holder()); | 10656 CHECK_EQ(args.This(), args.Holder()); |
10739 CHECK(args.Data()->Equals(v8_str("method_data"))); | 10657 CHECK(args.Data()->Equals(v8_str("method_data"))); |
10740 return v8::Integer::New(args[0]->Int32Value() + 1); | 10658 return v8::Integer::New(args[0]->Int32Value() + 1); |
10741 } | 10659 } |
10742 | 10660 |
10743 static v8::Handle<Value> FastApiCallback_SimpleSignature( | 10661 static v8::Handle<Value> FastApiCallback_SimpleSignature( |
10744 const v8::Arguments& args) { | 10662 const v8::Arguments& args) { |
10745 ApiTestFuzzer::Fuzz(); | 10663 ApiTestFuzzer::Fuzz(); |
10746 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_SimpleSignature)); | 10664 CheckReturnValue(args); |
10747 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 10665 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
10748 CHECK_EQ(isolate, args.GetIsolate()); | 10666 CHECK_EQ(isolate, args.GetIsolate()); |
10749 CHECK_EQ(args.This()->GetPrototype(), args.Holder()); | 10667 CHECK_EQ(args.This()->GetPrototype(), args.Holder()); |
10750 CHECK(args.Data()->Equals(v8_str("method_data"))); | 10668 CHECK(args.Data()->Equals(v8_str("method_data"))); |
10751 // Note, we're using HasRealNamedProperty instead of Has to avoid | 10669 // Note, we're using HasRealNamedProperty instead of Has to avoid |
10752 // invoking the interceptor again. | 10670 // invoking the interceptor again. |
10753 CHECK(args.Holder()->HasRealNamedProperty(v8_str("foo"))); | 10671 CHECK(args.Holder()->HasRealNamedProperty(v8_str("foo"))); |
10754 return v8::Integer::New(args[0]->Int32Value() + 1); | 10672 return v8::Integer::New(args[0]->Int32Value() + 1); |
10755 } | 10673 } |
10756 | 10674 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10824 static Handle<Value> DoDirectGetter() { | 10742 static Handle<Value> DoDirectGetter() { |
10825 if (++p_getter_count % 3 == 0) { | 10743 if (++p_getter_count % 3 == 0) { |
10826 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 10744 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
10827 GenerateSomeGarbage(); | 10745 GenerateSomeGarbage(); |
10828 } | 10746 } |
10829 return v8_str("Direct Getter Result"); | 10747 return v8_str("Direct Getter Result"); |
10830 } | 10748 } |
10831 | 10749 |
10832 static v8::Handle<v8::Value> DirectGetter(Local<String> name, | 10750 static v8::Handle<v8::Value> DirectGetter(Local<String> name, |
10833 const v8::AccessorInfo& info) { | 10751 const v8::AccessorInfo& info) { |
10834 CheckReturnValue(info, FUNCTION_ADDR(DirectGetter)); | 10752 CheckReturnValue(info); |
10835 info.GetReturnValue().Set(v8_str("Garbage")); | 10753 info.GetReturnValue().Set(v8_str("Garbage")); |
10836 return DoDirectGetter(); | 10754 return DoDirectGetter(); |
10837 } | 10755 } |
10838 | 10756 |
10839 static v8::Handle<v8::Value> DirectGetterIndirect( | 10757 static v8::Handle<v8::Value> DirectGetterIndirect( |
10840 Local<String> name, | 10758 Local<String> name, |
10841 const v8::AccessorInfo& info) { | 10759 const v8::AccessorInfo& info) { |
10842 CheckReturnValue(info, FUNCTION_ADDR(DirectGetterIndirect)); | 10760 CheckReturnValue(info); |
10843 info.GetReturnValue().Set(DoDirectGetter()); | 10761 info.GetReturnValue().Set(DoDirectGetter()); |
10844 return v8::Handle<v8::Value>(); | 10762 return v8::Handle<v8::Value>(); |
10845 } | 10763 } |
10846 | 10764 |
10847 static void DirectGetterCallback( | 10765 static void DirectGetterCallback( |
10848 Local<String> name, | 10766 Local<String> name, |
10849 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10767 const v8::PropertyCallbackInfo<v8::Value>& info) { |
10850 CheckReturnValue(info, FUNCTION_ADDR(DirectGetterCallback)); | 10768 CheckReturnValue(info); |
10851 info.GetReturnValue().Set(DoDirectGetter()); | 10769 info.GetReturnValue().Set(DoDirectGetter()); |
10852 } | 10770 } |
10853 | 10771 |
10854 | 10772 |
10855 template<typename Accessor> | 10773 template<typename Accessor> |
10856 static void LoadICFastApi_DirectCall_GCMoveStub(Accessor accessor) { | 10774 static void LoadICFastApi_DirectCall_GCMoveStub(Accessor accessor) { |
10857 LocalContext context; | 10775 LocalContext context; |
10858 v8::HandleScope scope(context->GetIsolate()); | 10776 v8::HandleScope scope(context->GetIsolate()); |
10859 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(); | 10777 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(); |
10860 obj->SetAccessor(v8_str("p1"), accessor); | 10778 obj->SetAccessor(v8_str("p1"), accessor); |
(...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12756 v8::Isolate* isolate = outer->GetIsolate(); | 12674 v8::Isolate* isolate = outer->GetIsolate(); |
12757 v8::Persistent<v8::Context> inner; | 12675 v8::Persistent<v8::Context> inner; |
12758 { | 12676 { |
12759 v8::HandleScope scope(isolate); | 12677 v8::HandleScope scope(isolate); |
12760 inner.Reset(isolate, v8::Context::New(isolate)); | 12678 inner.Reset(isolate, v8::Context::New(isolate)); |
12761 } | 12679 } |
12762 v8::HandleScope scope(isolate); | 12680 v8::HandleScope scope(isolate); |
12763 { | 12681 { |
12764 // Don't want a handle here, so do this unsafely | 12682 // Don't want a handle here, so do this unsafely |
12765 v8::Handle<v8::Context> inner_local = | 12683 v8::Handle<v8::Context> inner_local = |
12766 v8::Utils::Convert<i::Object, v8::Context>( | 12684 *reinterpret_cast<v8::Handle<v8::Context>*>(&inner); |
12767 v8::Utils::OpenPersistent(inner)); | |
12768 inner_local->Enter(); | 12685 inner_local->Enter(); |
12769 inner.Dispose(); | 12686 inner.Dispose(); |
12770 inner.Clear(); | 12687 inner.Clear(); |
12771 inner_local->Exit(); | 12688 inner_local->Exit(); |
12772 } | 12689 } |
12773 } | 12690 } |
12774 | 12691 |
12775 | 12692 |
12776 // Regression test for issue 54, object templates with internal fields | 12693 // Regression test for issue 54, object templates with internal fields |
12777 // but no accessors or interceptors did not get their internal field | 12694 // but no accessors or interceptors did not get their internal field |
(...skipping 6675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19453 i::Semaphore* sem_; | 19370 i::Semaphore* sem_; |
19454 volatile int sem_value_; | 19371 volatile int sem_value_; |
19455 }; | 19372 }; |
19456 | 19373 |
19457 | 19374 |
19458 THREADED_TEST(SemaphoreInterruption) { | 19375 THREADED_TEST(SemaphoreInterruption) { |
19459 ThreadInterruptTest().RunTest(); | 19376 ThreadInterruptTest().RunTest(); |
19460 } | 19377 } |
19461 | 19378 |
19462 #endif // WIN32 | 19379 #endif // WIN32 |
OLD | NEW |