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

Side by Side Diff: test/cctest/test-api.cc

Issue 15791005: fix thread safety issue in FunctionTemplate test (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 months 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 CHECK((*o)->IsTheHole() || (*o)->IsUndefined()); 814 CHECK((*o)->IsTheHole() || (*o)->IsUndefined());
815 } 815 }
816 816
817 static v8::Handle<Value> handle_call(const v8::Arguments& args) { 817 static v8::Handle<Value> handle_call(const v8::Arguments& args) {
818 ApiTestFuzzer::Fuzz(); 818 ApiTestFuzzer::Fuzz();
819 CheckReturnValue(args); 819 CheckReturnValue(args);
820 args.GetReturnValue().Set(v8_str("bad value")); 820 args.GetReturnValue().Set(v8_str("bad value"));
821 return v8_num(102); 821 return v8_num(102);
822 } 822 }
823 823
824 static v8::Handle<Value> handle_call_2(const v8::Arguments& args) {
825 return handle_call(args);
826 }
827
824 static v8::Handle<Value> handle_call_indirect(const v8::Arguments& args) { 828 static v8::Handle<Value> handle_call_indirect(const v8::Arguments& args) {
825 ApiTestFuzzer::Fuzz(); 829 ApiTestFuzzer::Fuzz();
826 CheckReturnValue(args); 830 CheckReturnValue(args);
827 args.GetReturnValue().Set(v8_str("bad value")); 831 args.GetReturnValue().Set(v8_str("bad value"));
828 args.GetReturnValue().Set(v8_num(102)); 832 args.GetReturnValue().Set(v8_num(102));
829 return v8::Handle<Value>(); 833 return v8::Handle<Value>();
830 } 834 }
831 835
836 static v8::Handle<Value> handle_call_indirect_2(const v8::Arguments& args) {
837 return handle_call_indirect(args);
838 }
839
832 static void handle_callback(const v8::FunctionCallbackInfo<Value>& info) { 840 static void handle_callback(const v8::FunctionCallbackInfo<Value>& info) {
833 ApiTestFuzzer::Fuzz(); 841 ApiTestFuzzer::Fuzz();
834 CheckReturnValue(info); 842 CheckReturnValue(info);
835 info.GetReturnValue().Set(v8_str("bad value")); 843 info.GetReturnValue().Set(v8_str("bad value"));
836 info.GetReturnValue().Set(v8_num(102)); 844 info.GetReturnValue().Set(v8_num(102));
837 } 845 }
838 846
847 static void handle_callback_2(const v8::FunctionCallbackInfo<Value>& info) {
848 return handle_callback(info);
849 }
839 850
840 static v8::Handle<Value> construct_call(const v8::Arguments& args) { 851 static v8::Handle<Value> construct_call(const v8::Arguments& args) {
841 ApiTestFuzzer::Fuzz(); 852 ApiTestFuzzer::Fuzz();
842 CheckReturnValue(args); 853 CheckReturnValue(args);
843 args.This()->Set(v8_str("x"), v8_num(1)); 854 args.This()->Set(v8_str("x"), v8_num(1));
844 args.This()->Set(v8_str("y"), v8_num(2)); 855 args.This()->Set(v8_str("y"), v8_num(2));
845 args.GetReturnValue().Set(v8_str("bad value")); 856 args.GetReturnValue().Set(v8_str("bad value"));
846 return args.This(); 857 return args.This();
847 } 858 }
848 859
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 static void Return239Callback( 899 static void Return239Callback(
889 Local<String> name, const v8::PropertyCallbackInfo<Value>& info) { 900 Local<String> name, const v8::PropertyCallbackInfo<Value>& info) {
890 ApiTestFuzzer::Fuzz(); 901 ApiTestFuzzer::Fuzz();
891 CheckReturnValue(info); 902 CheckReturnValue(info);
892 info.GetReturnValue().Set(v8_str("bad value")); 903 info.GetReturnValue().Set(v8_str("bad value"));
893 info.GetReturnValue().Set(v8_num(239)); 904 info.GetReturnValue().Set(v8_num(239));
894 } 905 }
895 906
896 907
897 template<typename Handler> 908 template<typename Handler>
898 static void TestFunctionTemplateInitializer(Handler handler) { 909 static void TestFunctionTemplateInitializer(Handler handler,
910 Handler handler_2) {
899 // Test constructor calls. 911 // Test constructor calls.
900 { 912 {
901 LocalContext env; 913 LocalContext env;
902 v8::HandleScope scope(env->GetIsolate()); 914 v8::HandleScope scope(env->GetIsolate());
903 Local<v8::FunctionTemplate> fun_templ = 915 Local<v8::FunctionTemplate> fun_templ =
904 v8::FunctionTemplate::New(handler); 916 v8::FunctionTemplate::New(handler);
905 Local<Function> fun = fun_templ->GetFunction(); 917 Local<Function> fun = fun_templ->GetFunction();
906 env->Global()->Set(v8_str("obj"), fun); 918 env->Global()->Set(v8_str("obj"), fun);
907 Local<Script> script = v8_compile("obj()"); 919 Local<Script> script = v8_compile("obj()");
908 for (int i = 0; i < 30; i++) { 920 for (int i = 0; i < 30; i++) {
909 CHECK_EQ(102, script->Run()->Int32Value()); 921 CHECK_EQ(102, script->Run()->Int32Value());
910 } 922 }
911 } 923 }
912 // Blow away handler database
913 i::Isolate* isolate = i::Isolate::Current();
914 if (isolate->callback_table() != NULL) {
915 delete isolate->callback_table();
916 isolate->set_callback_table(NULL);
917 }
918 // Use SetCallHandler to initialize a function template, should work like the 924 // Use SetCallHandler to initialize a function template, should work like the
919 // previous one. 925 // previous one.
920 { 926 {
921 LocalContext env; 927 LocalContext env;
922 v8::HandleScope scope(env->GetIsolate()); 928 v8::HandleScope scope(env->GetIsolate());
923 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 929 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
924 fun_templ->SetCallHandler(handler); 930 fun_templ->SetCallHandler(handler);
925 Local<Function> fun = fun_templ->GetFunction(); 931 Local<Function> fun = fun_templ->GetFunction();
926 env->Global()->Set(v8_str("obj"), fun); 932 env->Global()->Set(v8_str("obj"), fun);
927 Local<Script> script = v8_compile("obj()"); 933 Local<Script> script = v8_compile("obj()");
(...skipping 24 matching lines...) Expand all
952 CHECK_EQ(1, script->Run()->Int32Value()); 958 CHECK_EQ(1, script->Run()->Int32Value());
953 } 959 }
954 script = v8_compile("obj_instance.m"); 960 script = v8_compile("obj_instance.m");
955 for (int i = 0; i < 30; i++) { 961 for (int i = 0; i < 30; i++) {
956 CHECK_EQ(239, script->Run()->Int32Value()); 962 CHECK_EQ(239, script->Run()->Int32Value());
957 } 963 }
958 } 964 }
959 965
960 966
961 THREADED_TEST(FunctionTemplate) { 967 THREADED_TEST(FunctionTemplate) {
962 TestFunctionTemplateInitializer(handle_call); 968 TestFunctionTemplateInitializer(handle_call, handle_call_2);
963 TestFunctionTemplateInitializer(handle_call_indirect); 969 TestFunctionTemplateInitializer(handle_call_indirect, handle_call_indirect_2);
964 TestFunctionTemplateInitializer(handle_callback); 970 TestFunctionTemplateInitializer(handle_callback, handle_callback_2);
965 971
966 TestFunctionTemplateAccessor(construct_call, Return239); 972 TestFunctionTemplateAccessor(construct_call, Return239);
967 TestFunctionTemplateAccessor(construct_call_indirect, Return239Indirect); 973 TestFunctionTemplateAccessor(construct_call_indirect, Return239Indirect);
968 TestFunctionTemplateAccessor(construct_callback, Return239Callback); 974 TestFunctionTemplateAccessor(construct_callback, Return239Callback);
969 } 975 }
970 976
971 977
972 static v8::Handle<v8::Value> SimpleDirectCallback(const v8::Arguments& args) { 978 static v8::Handle<v8::Value> SimpleDirectCallback(const v8::Arguments& args) {
973 ApiTestFuzzer::Fuzz(); 979 ApiTestFuzzer::Fuzz();
974 CheckReturnValue(args); 980 CheckReturnValue(args);
(...skipping 18333 matching lines...) Expand 10 before | Expand all | Expand 10 after
19308 i::Semaphore* sem_; 19314 i::Semaphore* sem_;
19309 volatile int sem_value_; 19315 volatile int sem_value_;
19310 }; 19316 };
19311 19317
19312 19318
19313 THREADED_TEST(SemaphoreInterruption) { 19319 THREADED_TEST(SemaphoreInterruption) {
19314 ThreadInterruptTest().RunTest(); 19320 ThreadInterruptTest().RunTest();
19315 } 19321 }
19316 19322
19317 #endif // WIN32 19323 #endif // WIN32
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698