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

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

Issue 11308197: Change deprecated semantics of function template signatures. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/stub-cache.cc ('k') | 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 8045 matching lines...) Expand 10 before | Expand all | Expand 10 after
8056 8056
8057 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(); 8057 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New();
8058 LocalContext context(NULL, global_template); 8058 LocalContext context(NULL, global_template);
8059 8059
8060 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); 8060 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
8061 t->InstanceTemplate()->SetNamedPropertyHandler(ShadowNamedGet); 8061 t->InstanceTemplate()->SetNamedPropertyHandler(ShadowNamedGet);
8062 t->InstanceTemplate()->SetIndexedPropertyHandler(ShadowIndexedGet); 8062 t->InstanceTemplate()->SetIndexedPropertyHandler(ShadowIndexedGet);
8063 Local<ObjectTemplate> proto = t->PrototypeTemplate(); 8063 Local<ObjectTemplate> proto = t->PrototypeTemplate();
8064 Local<ObjectTemplate> instance = t->InstanceTemplate(); 8064 Local<ObjectTemplate> instance = t->InstanceTemplate();
8065 8065
8066 // Only allow calls of f on instances of t.
8067 Local<v8::Signature> signature = v8::Signature::New(t);
8068 proto->Set(v8_str("f"), 8066 proto->Set(v8_str("f"),
8069 v8::FunctionTemplate::New(ShadowFunctionCallback, 8067 v8::FunctionTemplate::New(ShadowFunctionCallback, Local<Value>()));
8070 Local<Value>(),
8071 signature));
8072 proto->Set(v8_str("x"), v8_num(12)); 8068 proto->Set(v8_str("x"), v8_num(12));
8073 8069
8074 instance->SetAccessor(v8_str("y"), ShadowYGetter, ShadowYSetter); 8070 instance->SetAccessor(v8_str("y"), ShadowYGetter, ShadowYSetter);
8075 8071
8076 Local<Value> o = t->GetFunction()->NewInstance(); 8072 Local<Value> o = t->GetFunction()->NewInstance();
8077 context->Global()->Set(v8_str("__proto__"), o); 8073 context->Global()->Set(v8_str("__proto__"), o);
8078 8074
8079 Local<Value> value = 8075 Local<Value> value =
8080 Script::Compile(v8_str("this.propertyIsEnumerable(0)"))->Run(); 8076 Script::Compile(v8_str("this.propertyIsEnumerable(0)"))->Run();
8081 CHECK(value->IsBoolean()); 8077 CHECK(value->IsBoolean());
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after
9926 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) { 9922 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) {
9927 int interceptor_call_count = 0; 9923 int interceptor_call_count = 0;
9928 v8::HandleScope scope; 9924 v8::HandleScope scope;
9929 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9925 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9930 v8::Handle<v8::FunctionTemplate> method_templ = 9926 v8::Handle<v8::FunctionTemplate> method_templ =
9931 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 9927 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9932 v8_str("method_data"), 9928 v8_str("method_data"),
9933 v8::Signature::New(fun_templ)); 9929 v8::Signature::New(fun_templ));
9934 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9930 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9935 proto_templ->Set(v8_str("method"), method_templ); 9931 proto_templ->Set(v8_str("method"), method_templ);
9932 fun_templ->SetHiddenPrototype(true);
9936 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9933 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9937 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 9934 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
9938 NULL, NULL, NULL, NULL, 9935 NULL, NULL, NULL, NULL,
9939 v8::External::Wrap(&interceptor_call_count)); 9936 v8::External::Wrap(&interceptor_call_count));
9940 LocalContext context; 9937 LocalContext context;
9941 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9938 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9942 GenerateSomeGarbage(); 9939 GenerateSomeGarbage();
9943 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9940 context->Global()->Set(v8_str("o"), fun->NewInstance());
9944 CompileRun( 9941 CompileRun(
9945 "o.foo = 17;" 9942 "o.foo = 17;"
(...skipping 10 matching lines...) Expand all
9956 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { 9953 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
9957 int interceptor_call_count = 0; 9954 int interceptor_call_count = 0;
9958 v8::HandleScope scope; 9955 v8::HandleScope scope;
9959 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9956 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9960 v8::Handle<v8::FunctionTemplate> method_templ = 9957 v8::Handle<v8::FunctionTemplate> method_templ =
9961 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 9958 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9962 v8_str("method_data"), 9959 v8_str("method_data"),
9963 v8::Signature::New(fun_templ)); 9960 v8::Signature::New(fun_templ));
9964 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9961 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9965 proto_templ->Set(v8_str("method"), method_templ); 9962 proto_templ->Set(v8_str("method"), method_templ);
9963 fun_templ->SetHiddenPrototype(true);
9966 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9964 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9967 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 9965 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
9968 NULL, NULL, NULL, NULL, 9966 NULL, NULL, NULL, NULL,
9969 v8::External::Wrap(&interceptor_call_count)); 9967 v8::External::Wrap(&interceptor_call_count));
9970 LocalContext context; 9968 LocalContext context;
9971 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9969 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9972 GenerateSomeGarbage(); 9970 GenerateSomeGarbage();
9973 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9971 context->Global()->Set(v8_str("o"), fun->NewInstance());
9974 CompileRun( 9972 CompileRun(
9975 "o.foo = 17;" 9973 "o.foo = 17;"
(...skipping 16 matching lines...) Expand all
9992 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) { 9990 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) {
9993 int interceptor_call_count = 0; 9991 int interceptor_call_count = 0;
9994 v8::HandleScope scope; 9992 v8::HandleScope scope;
9995 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9993 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9996 v8::Handle<v8::FunctionTemplate> method_templ = 9994 v8::Handle<v8::FunctionTemplate> method_templ =
9997 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 9995 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9998 v8_str("method_data"), 9996 v8_str("method_data"),
9999 v8::Signature::New(fun_templ)); 9997 v8::Signature::New(fun_templ));
10000 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9998 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10001 proto_templ->Set(v8_str("method"), method_templ); 9999 proto_templ->Set(v8_str("method"), method_templ);
10000 fun_templ->SetHiddenPrototype(true);
10002 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 10001 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
10003 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 10002 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
10004 NULL, NULL, NULL, NULL, 10003 NULL, NULL, NULL, NULL,
10005 v8::External::Wrap(&interceptor_call_count)); 10004 v8::External::Wrap(&interceptor_call_count));
10006 LocalContext context; 10005 LocalContext context;
10007 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 10006 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
10008 GenerateSomeGarbage(); 10007 GenerateSomeGarbage();
10009 context->Global()->Set(v8_str("o"), fun->NewInstance()); 10008 context->Global()->Set(v8_str("o"), fun->NewInstance());
10010 CompileRun( 10009 CompileRun(
10011 "o.foo = 17;" 10010 "o.foo = 17;"
(...skipping 16 matching lines...) Expand all
10028 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) { 10027 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
10029 int interceptor_call_count = 0; 10028 int interceptor_call_count = 0;
10030 v8::HandleScope scope; 10029 v8::HandleScope scope;
10031 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 10030 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10032 v8::Handle<v8::FunctionTemplate> method_templ = 10031 v8::Handle<v8::FunctionTemplate> method_templ =
10033 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 10032 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
10034 v8_str("method_data"), 10033 v8_str("method_data"),
10035 v8::Signature::New(fun_templ)); 10034 v8::Signature::New(fun_templ));
10036 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 10035 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10037 proto_templ->Set(v8_str("method"), method_templ); 10036 proto_templ->Set(v8_str("method"), method_templ);
10037 fun_templ->SetHiddenPrototype(true);
10038 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 10038 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
10039 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 10039 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
10040 NULL, NULL, NULL, NULL, 10040 NULL, NULL, NULL, NULL,
10041 v8::External::Wrap(&interceptor_call_count)); 10041 v8::External::Wrap(&interceptor_call_count));
10042 LocalContext context; 10042 LocalContext context;
10043 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 10043 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
10044 GenerateSomeGarbage(); 10044 GenerateSomeGarbage();
10045 context->Global()->Set(v8_str("o"), fun->NewInstance()); 10045 context->Global()->Set(v8_str("o"), fun->NewInstance());
10046 v8::TryCatch try_catch; 10046 v8::TryCatch try_catch;
10047 CompileRun( 10047 CompileRun(
(...skipping 19 matching lines...) Expand all
10067 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { 10067 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
10068 int interceptor_call_count = 0; 10068 int interceptor_call_count = 0;
10069 v8::HandleScope scope; 10069 v8::HandleScope scope;
10070 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 10070 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10071 v8::Handle<v8::FunctionTemplate> method_templ = 10071 v8::Handle<v8::FunctionTemplate> method_templ =
10072 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 10072 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
10073 v8_str("method_data"), 10073 v8_str("method_data"),
10074 v8::Signature::New(fun_templ)); 10074 v8::Signature::New(fun_templ));
10075 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 10075 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10076 proto_templ->Set(v8_str("method"), method_templ); 10076 proto_templ->Set(v8_str("method"), method_templ);
10077 fun_templ->SetHiddenPrototype(true);
10077 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 10078 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
10078 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 10079 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
10079 NULL, NULL, NULL, NULL, 10080 NULL, NULL, NULL, NULL,
10080 v8::External::Wrap(&interceptor_call_count)); 10081 v8::External::Wrap(&interceptor_call_count));
10081 LocalContext context; 10082 LocalContext context;
10082 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 10083 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
10083 GenerateSomeGarbage(); 10084 GenerateSomeGarbage();
10084 context->Global()->Set(v8_str("o"), fun->NewInstance()); 10085 context->Global()->Set(v8_str("o"), fun->NewInstance());
10085 v8::TryCatch try_catch; 10086 v8::TryCatch try_catch;
10086 CompileRun( 10087 CompileRun(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
10129 10130
10130 THREADED_TEST(CallICFastApi_SimpleSignature) { 10131 THREADED_TEST(CallICFastApi_SimpleSignature) {
10131 v8::HandleScope scope; 10132 v8::HandleScope scope;
10132 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 10133 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10133 v8::Handle<v8::FunctionTemplate> method_templ = 10134 v8::Handle<v8::FunctionTemplate> method_templ =
10134 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 10135 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
10135 v8_str("method_data"), 10136 v8_str("method_data"),
10136 v8::Signature::New(fun_templ)); 10137 v8::Signature::New(fun_templ));
10137 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 10138 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10138 proto_templ->Set(v8_str("method"), method_templ); 10139 proto_templ->Set(v8_str("method"), method_templ);
10140 fun_templ->SetHiddenPrototype(true);
10139 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 10141 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
10140 CHECK(!templ.IsEmpty()); 10142 CHECK(!templ.IsEmpty());
10141 LocalContext context; 10143 LocalContext context;
10142 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 10144 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
10143 GenerateSomeGarbage(); 10145 GenerateSomeGarbage();
10144 context->Global()->Set(v8_str("o"), fun->NewInstance()); 10146 context->Global()->Set(v8_str("o"), fun->NewInstance());
10145 CompileRun( 10147 CompileRun(
10146 "o.foo = 17;" 10148 "o.foo = 17;"
10147 "var receiver = {};" 10149 "var receiver = {};"
10148 "receiver.__proto__ = o;" 10150 "receiver.__proto__ = o;"
10149 "var result = 0;" 10151 "var result = 0;"
10150 "for (var i = 0; i < 100; i++) {" 10152 "for (var i = 0; i < 100; i++) {"
10151 " result = receiver.method(41);" 10153 " result = receiver.method(41);"
10152 "}"); 10154 "}");
10153 10155
10154 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 10156 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
10155 } 10157 }
10156 10158
10157 THREADED_TEST(CallICFastApi_SimpleSignature_Miss1) { 10159 THREADED_TEST(CallICFastApi_SimpleSignature_Miss1) {
10158 v8::HandleScope scope; 10160 v8::HandleScope scope;
10159 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 10161 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10160 v8::Handle<v8::FunctionTemplate> method_templ = 10162 v8::Handle<v8::FunctionTemplate> method_templ =
10161 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 10163 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
10162 v8_str("method_data"), 10164 v8_str("method_data"),
10163 v8::Signature::New(fun_templ)); 10165 v8::Signature::New(fun_templ));
10164 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 10166 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10165 proto_templ->Set(v8_str("method"), method_templ); 10167 proto_templ->Set(v8_str("method"), method_templ);
10168 fun_templ->SetHiddenPrototype(true);
10166 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 10169 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
10167 CHECK(!templ.IsEmpty()); 10170 CHECK(!templ.IsEmpty());
10168 LocalContext context; 10171 LocalContext context;
10169 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 10172 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
10170 GenerateSomeGarbage(); 10173 GenerateSomeGarbage();
10171 context->Global()->Set(v8_str("o"), fun->NewInstance()); 10174 context->Global()->Set(v8_str("o"), fun->NewInstance());
10172 CompileRun( 10175 CompileRun(
10173 "o.foo = 17;" 10176 "o.foo = 17;"
10174 "var receiver = {};" 10177 "var receiver = {};"
10175 "receiver.__proto__ = o;" 10178 "receiver.__proto__ = o;"
(...skipping 12 matching lines...) Expand all
10188 10191
10189 THREADED_TEST(CallICFastApi_SimpleSignature_Miss2) { 10192 THREADED_TEST(CallICFastApi_SimpleSignature_Miss2) {
10190 v8::HandleScope scope; 10193 v8::HandleScope scope;
10191 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 10194 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10192 v8::Handle<v8::FunctionTemplate> method_templ = 10195 v8::Handle<v8::FunctionTemplate> method_templ =
10193 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 10196 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
10194 v8_str("method_data"), 10197 v8_str("method_data"),
10195 v8::Signature::New(fun_templ)); 10198 v8::Signature::New(fun_templ));
10196 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 10199 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10197 proto_templ->Set(v8_str("method"), method_templ); 10200 proto_templ->Set(v8_str("method"), method_templ);
10201 fun_templ->SetHiddenPrototype(true);
10198 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 10202 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
10199 CHECK(!templ.IsEmpty()); 10203 CHECK(!templ.IsEmpty());
10200 LocalContext context; 10204 LocalContext context;
10201 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 10205 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
10202 GenerateSomeGarbage(); 10206 GenerateSomeGarbage();
10203 context->Global()->Set(v8_str("o"), fun->NewInstance()); 10207 context->Global()->Set(v8_str("o"), fun->NewInstance());
10204 v8::TryCatch try_catch; 10208 v8::TryCatch try_catch;
10205 CompileRun( 10209 CompileRun(
10206 "o.foo = 17;" 10210 "o.foo = 17;"
10207 "var receiver = {};" 10211 "var receiver = {};"
10208 "receiver.__proto__ = o;" 10212 "receiver.__proto__ = o;"
10209 "var result = 0;" 10213 "var result = 0;"
10210 "var saved_result = 0;" 10214 "var saved_result = 0;"
10211 "for (var i = 0; i < 100; i++) {" 10215 "for (var i = 0; i < 100; i++) {"
10212 " result = receiver.method(41);" 10216 " result = receiver.method(41);"
10213 " if (i == 50) {" 10217 " if (i == 50) {"
10214 " saved_result = result;" 10218 " saved_result = result;"
10215 " receiver = 333;" 10219 " receiver = 333;"
10216 " }" 10220 " }"
10217 "}"); 10221 "}");
10218 CHECK(try_catch.HasCaught()); 10222 CHECK(try_catch.HasCaught());
10219 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), 10223 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"),
10220 try_catch.Exception()->ToString()); 10224 try_catch.Exception()->ToString());
10221 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 10225 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
10222 } 10226 }
10223 10227
10228 THREADED_TEST(CallICFastApi_SimpleSignature_TypeError) {
10229 v8::HandleScope scope;
10230 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10231 v8::Handle<v8::FunctionTemplate> method_templ =
10232 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
10233 v8_str("method_data"),
10234 v8::Signature::New(fun_templ));
10235 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10236 proto_templ->Set(v8_str("method"), method_templ);
10237 fun_templ->SetHiddenPrototype(true);
10238 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
10239 CHECK(!templ.IsEmpty());
10240 LocalContext context;
10241 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
10242 GenerateSomeGarbage();
10243 context->Global()->Set(v8_str("o"), fun->NewInstance());
10244 v8::TryCatch try_catch;
10245 CompileRun(
10246 "o.foo = 17;"
10247 "var receiver = {};"
10248 "receiver.__proto__ = o;"
10249 "var result = 0;"
10250 "var saved_result = 0;"
10251 "for (var i = 0; i < 100; i++) {"
10252 " result = receiver.method(41);"
10253 " if (i == 50) {"
10254 " saved_result = result;"
10255 " receiver = Object.create(receiver);"
10256 " }"
10257 "}");
10258 CHECK(try_catch.HasCaught());
10259 CHECK_EQ(v8_str("TypeError: Illegal invocation"),
10260 try_catch.Exception()->ToString());
10261 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
10262 }
10263
10224 10264
10225 v8::Handle<Value> keyed_call_ic_function; 10265 v8::Handle<Value> keyed_call_ic_function;
10226 10266
10227 static v8::Handle<Value> InterceptorKeyedCallICGetter( 10267 static v8::Handle<Value> InterceptorKeyedCallICGetter(
10228 Local<String> name, const AccessorInfo& info) { 10268 Local<String> name, const AccessorInfo& info) {
10229 ApiTestFuzzer::Fuzz(); 10269 ApiTestFuzzer::Fuzz();
10230 if (v8_str("x")->Equals(name)) { 10270 if (v8_str("x")->Equals(name)) {
10231 return keyed_call_ic_function; 10271 return keyed_call_ic_function;
10232 } 10272 }
10233 return v8::Handle<Value>(); 10273 return v8::Handle<Value>();
(...skipping 7758 matching lines...) Expand 10 before | Expand all | Expand 10 after
17992 18032
17993 i::Semaphore* sem_; 18033 i::Semaphore* sem_;
17994 volatile int sem_value_; 18034 volatile int sem_value_;
17995 }; 18035 };
17996 18036
17997 18037
17998 THREADED_TEST(SemaphoreInterruption) { 18038 THREADED_TEST(SemaphoreInterruption) {
17999 ThreadInterruptTest().RunTest(); 18039 ThreadInterruptTest().RunTest();
18000 } 18040 }
18001 #endif // WIN32 18041 #endif // WIN32
OLDNEW
« no previous file with comments | « src/stub-cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698