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