| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 CHECK_EQ(10, signature_callback_count); | 245 CHECK_EQ(10, signature_callback_count); |
| 246 } else { | 246 } else { |
| 247 CHECK_EQ(v8_str("TypeError: Illegal invocation"), | 247 CHECK_EQ(v8_str("TypeError: Illegal invocation"), |
| 248 try_catch.Exception()->ToString()); | 248 try_catch.Exception()->ToString()); |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 | 252 |
| 253 THREADED_TEST(ReceiverSignature) { | 253 THREADED_TEST(ReceiverSignature) { |
| 254 LocalContext env; | 254 LocalContext env; |
| 255 v8::HandleScope scope(env->GetIsolate()); | 255 v8::Isolate* isolate = env->GetIsolate(); |
| 256 v8::HandleScope scope(isolate); |
| 256 // Setup templates. | 257 // Setup templates. |
| 257 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); | 258 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate); |
| 258 v8::Handle<v8::Signature> sig = v8::Signature::New(env->GetIsolate(), fun); | 259 v8::Handle<v8::Signature> sig = v8::Signature::New(isolate, fun); |
| 259 v8::Handle<v8::FunctionTemplate> callback_sig = | 260 v8::Handle<v8::FunctionTemplate> callback_sig = |
| 260 v8::FunctionTemplate::New( | 261 v8::FunctionTemplate::New( |
| 261 IncrementingSignatureCallback, Local<Value>(), sig); | 262 isolate, IncrementingSignatureCallback, Local<Value>(), sig); |
| 262 v8::Handle<v8::FunctionTemplate> callback = | 263 v8::Handle<v8::FunctionTemplate> callback = |
| 263 v8::FunctionTemplate::New(IncrementingSignatureCallback); | 264 v8::FunctionTemplate::New(isolate, IncrementingSignatureCallback); |
| 264 v8::Handle<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New(); | 265 v8::Handle<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New(isolate); |
| 265 sub_fun->Inherit(fun); | 266 sub_fun->Inherit(fun); |
| 266 v8::Handle<v8::FunctionTemplate> unrel_fun = v8::FunctionTemplate::New(); | 267 v8::Handle<v8::FunctionTemplate> unrel_fun = |
| 268 v8::FunctionTemplate::New(isolate); |
| 267 // Install properties. | 269 // Install properties. |
| 268 v8::Handle<v8::ObjectTemplate> fun_proto = fun->PrototypeTemplate(); | 270 v8::Handle<v8::ObjectTemplate> fun_proto = fun->PrototypeTemplate(); |
| 269 fun_proto->Set(v8_str("prop_sig"), callback_sig); | 271 fun_proto->Set(v8_str("prop_sig"), callback_sig); |
| 270 fun_proto->Set(v8_str("prop"), callback); | 272 fun_proto->Set(v8_str("prop"), callback); |
| 271 fun_proto->SetAccessorProperty( | 273 fun_proto->SetAccessorProperty( |
| 272 v8_str("accessor_sig"), callback_sig, callback_sig); | 274 v8_str("accessor_sig"), callback_sig, callback_sig); |
| 273 fun_proto->SetAccessorProperty(v8_str("accessor"), callback, callback); | 275 fun_proto->SetAccessorProperty(v8_str("accessor"), callback, callback); |
| 274 // Instantiate templates. | 276 // Instantiate templates. |
| 275 Local<Value> fun_instance = fun->InstanceTemplate()->NewInstance(); | 277 Local<Value> fun_instance = fun->InstanceTemplate()->NewInstance(); |
| 276 Local<Value> sub_fun_instance = sub_fun->InstanceTemplate()->NewInstance(); | 278 Local<Value> sub_fun_instance = sub_fun->InstanceTemplate()->NewInstance(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 TestSignature("test_object.accessor_sig;", test_object); | 320 TestSignature("test_object.accessor_sig;", test_object); |
| 319 TestSignature("test_object[accessor_sig_key];", test_object); | 321 TestSignature("test_object[accessor_sig_key];", test_object); |
| 320 TestSignature("test_object.accessor_sig = 1;", test_object); | 322 TestSignature("test_object.accessor_sig = 1;", test_object); |
| 321 TestSignature("test_object[accessor_sig_key] = 1;", test_object); | 323 TestSignature("test_object[accessor_sig_key] = 1;", test_object); |
| 322 } | 324 } |
| 323 } | 325 } |
| 324 | 326 |
| 325 | 327 |
| 326 THREADED_TEST(ArgumentSignature) { | 328 THREADED_TEST(ArgumentSignature) { |
| 327 LocalContext env; | 329 LocalContext env; |
| 328 v8::HandleScope scope(env->GetIsolate()); | 330 v8::Isolate* isolate = env->GetIsolate(); |
| 329 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New(); | 331 v8::HandleScope scope(isolate); |
| 332 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New(isolate); |
| 330 cons->SetClassName(v8_str("Cons")); | 333 cons->SetClassName(v8_str("Cons")); |
| 331 v8::Handle<v8::Signature> sig = v8::Signature::New( | 334 v8::Handle<v8::Signature> sig = v8::Signature::New( |
| 332 env->GetIsolate(), v8::Handle<v8::FunctionTemplate>(), 1, &cons); | 335 isolate, v8::Handle<v8::FunctionTemplate>(), 1, &cons); |
| 333 v8::Handle<v8::FunctionTemplate> fun = | 336 v8::Handle<v8::FunctionTemplate> fun = |
| 334 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), sig); | 337 v8::FunctionTemplate::New(isolate, |
| 338 SignatureCallback, |
| 339 v8::Handle<Value>(), |
| 340 sig); |
| 335 env->Global()->Set(v8_str("Cons"), cons->GetFunction()); | 341 env->Global()->Set(v8_str("Cons"), cons->GetFunction()); |
| 336 env->Global()->Set(v8_str("Fun1"), fun->GetFunction()); | 342 env->Global()->Set(v8_str("Fun1"), fun->GetFunction()); |
| 337 | 343 |
| 338 v8::Handle<Value> value1 = CompileRun("Fun1(4) == '';"); | 344 v8::Handle<Value> value1 = CompileRun("Fun1(4) == '';"); |
| 339 CHECK(value1->IsTrue()); | 345 CHECK(value1->IsTrue()); |
| 340 | 346 |
| 341 v8::Handle<Value> value2 = CompileRun("Fun1(new Cons()) == '[object Cons]';"); | 347 v8::Handle<Value> value2 = CompileRun("Fun1(new Cons()) == '[object Cons]';"); |
| 342 CHECK(value2->IsTrue()); | 348 CHECK(value2->IsTrue()); |
| 343 | 349 |
| 344 v8::Handle<Value> value3 = CompileRun("Fun1() == '';"); | 350 v8::Handle<Value> value3 = CompileRun("Fun1() == '';"); |
| 345 CHECK(value3->IsTrue()); | 351 CHECK(value3->IsTrue()); |
| 346 | 352 |
| 347 v8::Handle<v8::FunctionTemplate> cons1 = v8::FunctionTemplate::New(); | 353 v8::Handle<v8::FunctionTemplate> cons1 = v8::FunctionTemplate::New(isolate); |
| 348 cons1->SetClassName(v8_str("Cons1")); | 354 cons1->SetClassName(v8_str("Cons1")); |
| 349 v8::Handle<v8::FunctionTemplate> cons2 = v8::FunctionTemplate::New(); | 355 v8::Handle<v8::FunctionTemplate> cons2 = v8::FunctionTemplate::New(isolate); |
| 350 cons2->SetClassName(v8_str("Cons2")); | 356 cons2->SetClassName(v8_str("Cons2")); |
| 351 v8::Handle<v8::FunctionTemplate> cons3 = v8::FunctionTemplate::New(); | 357 v8::Handle<v8::FunctionTemplate> cons3 = v8::FunctionTemplate::New(isolate); |
| 352 cons3->SetClassName(v8_str("Cons3")); | 358 cons3->SetClassName(v8_str("Cons3")); |
| 353 | 359 |
| 354 v8::Handle<v8::FunctionTemplate> args[3] = { cons1, cons2, cons3 }; | 360 v8::Handle<v8::FunctionTemplate> args[3] = { cons1, cons2, cons3 }; |
| 355 v8::Handle<v8::Signature> wsig = v8::Signature::New( | 361 v8::Handle<v8::Signature> wsig = v8::Signature::New( |
| 356 env->GetIsolate(), v8::Handle<v8::FunctionTemplate>(), 3, args); | 362 isolate, v8::Handle<v8::FunctionTemplate>(), 3, args); |
| 357 v8::Handle<v8::FunctionTemplate> fun2 = | 363 v8::Handle<v8::FunctionTemplate> fun2 = |
| 358 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), wsig); | 364 v8::FunctionTemplate::New(isolate, |
| 365 SignatureCallback, |
| 366 v8::Handle<Value>(), |
| 367 wsig); |
| 359 | 368 |
| 360 env->Global()->Set(v8_str("Cons1"), cons1->GetFunction()); | 369 env->Global()->Set(v8_str("Cons1"), cons1->GetFunction()); |
| 361 env->Global()->Set(v8_str("Cons2"), cons2->GetFunction()); | 370 env->Global()->Set(v8_str("Cons2"), cons2->GetFunction()); |
| 362 env->Global()->Set(v8_str("Cons3"), cons3->GetFunction()); | 371 env->Global()->Set(v8_str("Cons3"), cons3->GetFunction()); |
| 363 env->Global()->Set(v8_str("Fun2"), fun2->GetFunction()); | 372 env->Global()->Set(v8_str("Fun2"), fun2->GetFunction()); |
| 364 v8::Handle<Value> value4 = CompileRun( | 373 v8::Handle<Value> value4 = CompileRun( |
| 365 "Fun2(new Cons1(), new Cons2(), new Cons3()) ==" | 374 "Fun2(new Cons1(), new Cons2(), new Cons3()) ==" |
| 366 "'[object Cons1],[object Cons2],[object Cons3]'"); | 375 "'[object Cons1],[object Cons2],[object Cons3]'"); |
| 367 CHECK(value4->IsTrue()); | 376 CHECK(value4->IsTrue()); |
| 368 | 377 |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 info.GetReturnValue().Set(v8_num(239)); | 1022 info.GetReturnValue().Set(v8_num(239)); |
| 1014 } | 1023 } |
| 1015 | 1024 |
| 1016 | 1025 |
| 1017 template<typename Handler> | 1026 template<typename Handler> |
| 1018 static void TestFunctionTemplateInitializer(Handler handler, | 1027 static void TestFunctionTemplateInitializer(Handler handler, |
| 1019 Handler handler_2) { | 1028 Handler handler_2) { |
| 1020 // Test constructor calls. | 1029 // Test constructor calls. |
| 1021 { | 1030 { |
| 1022 LocalContext env; | 1031 LocalContext env; |
| 1023 v8::HandleScope scope(env->GetIsolate()); | 1032 v8::Isolate* isolate = env->GetIsolate(); |
| 1033 v8::HandleScope scope(isolate); |
| 1024 | 1034 |
| 1025 Local<v8::FunctionTemplate> fun_templ = | 1035 Local<v8::FunctionTemplate> fun_templ = |
| 1026 v8::FunctionTemplate::New(handler); | 1036 v8::FunctionTemplate::New(isolate, handler); |
| 1027 Local<Function> fun = fun_templ->GetFunction(); | 1037 Local<Function> fun = fun_templ->GetFunction(); |
| 1028 env->Global()->Set(v8_str("obj"), fun); | 1038 env->Global()->Set(v8_str("obj"), fun); |
| 1029 Local<Script> script = v8_compile("obj()"); | 1039 Local<Script> script = v8_compile("obj()"); |
| 1030 for (int i = 0; i < 30; i++) { | 1040 for (int i = 0; i < 30; i++) { |
| 1031 CHECK_EQ(102, script->Run()->Int32Value()); | 1041 CHECK_EQ(102, script->Run()->Int32Value()); |
| 1032 } | 1042 } |
| 1033 } | 1043 } |
| 1034 // Use SetCallHandler to initialize a function template, should work like | 1044 // Use SetCallHandler to initialize a function template, should work like |
| 1035 // the previous one. | 1045 // the previous one. |
| 1036 { | 1046 { |
| 1037 LocalContext env; | 1047 LocalContext env; |
| 1038 v8::HandleScope scope(env->GetIsolate()); | 1048 v8::Isolate* isolate = env->GetIsolate(); |
| 1049 v8::HandleScope scope(isolate); |
| 1039 | 1050 |
| 1040 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 1051 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate); |
| 1041 fun_templ->SetCallHandler(handler_2); | 1052 fun_templ->SetCallHandler(handler_2); |
| 1042 Local<Function> fun = fun_templ->GetFunction(); | 1053 Local<Function> fun = fun_templ->GetFunction(); |
| 1043 env->Global()->Set(v8_str("obj"), fun); | 1054 env->Global()->Set(v8_str("obj"), fun); |
| 1044 Local<Script> script = v8_compile("obj()"); | 1055 Local<Script> script = v8_compile("obj()"); |
| 1045 for (int i = 0; i < 30; i++) { | 1056 for (int i = 0; i < 30; i++) { |
| 1046 CHECK_EQ(102, script->Run()->Int32Value()); | 1057 CHECK_EQ(102, script->Run()->Int32Value()); |
| 1047 } | 1058 } |
| 1048 } | 1059 } |
| 1049 } | 1060 } |
| 1050 | 1061 |
| 1051 | 1062 |
| 1052 template<typename Constructor, typename Accessor> | 1063 template<typename Constructor, typename Accessor> |
| 1053 static void TestFunctionTemplateAccessor(Constructor constructor, | 1064 static void TestFunctionTemplateAccessor(Constructor constructor, |
| 1054 Accessor accessor) { | 1065 Accessor accessor) { |
| 1055 LocalContext env; | 1066 LocalContext env; |
| 1056 v8::HandleScope scope(env->GetIsolate()); | 1067 v8::HandleScope scope(env->GetIsolate()); |
| 1057 | 1068 |
| 1058 Local<v8::FunctionTemplate> fun_templ = | 1069 Local<v8::FunctionTemplate> fun_templ = |
| 1059 v8::FunctionTemplate::New(constructor); | 1070 v8::FunctionTemplate::New(env->GetIsolate(), constructor); |
| 1060 fun_templ->SetClassName(v8_str("funky")); | 1071 fun_templ->SetClassName(v8_str("funky")); |
| 1061 fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), accessor); | 1072 fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), accessor); |
| 1062 Local<Function> fun = fun_templ->GetFunction(); | 1073 Local<Function> fun = fun_templ->GetFunction(); |
| 1063 env->Global()->Set(v8_str("obj"), fun); | 1074 env->Global()->Set(v8_str("obj"), fun); |
| 1064 Local<Value> result = v8_compile("(new obj()).toString()")->Run(); | 1075 Local<Value> result = v8_compile("(new obj()).toString()")->Run(); |
| 1065 CHECK_EQ(v8_str("[object funky]"), result); | 1076 CHECK_EQ(v8_str("[object funky]"), result); |
| 1066 CompileRun("var obj_instance = new obj();"); | 1077 CompileRun("var obj_instance = new obj();"); |
| 1067 Local<Script> script; | 1078 Local<Script> script; |
| 1068 script = v8_compile("obj_instance.x"); | 1079 script = v8_compile("obj_instance.x"); |
| 1069 for (int i = 0; i < 30; i++) { | 1080 for (int i = 0; i < 30; i++) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1089 } | 1100 } |
| 1090 | 1101 |
| 1091 | 1102 |
| 1092 template<typename Callback> | 1103 template<typename Callback> |
| 1093 static void TestSimpleCallback(Callback callback) { | 1104 static void TestSimpleCallback(Callback callback) { |
| 1094 LocalContext env; | 1105 LocalContext env; |
| 1095 v8::HandleScope scope(env->GetIsolate()); | 1106 v8::HandleScope scope(env->GetIsolate()); |
| 1096 | 1107 |
| 1097 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); | 1108 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); |
| 1098 object_template->Set(env->GetIsolate(), "callback", | 1109 object_template->Set(env->GetIsolate(), "callback", |
| 1099 v8::FunctionTemplate::New(callback)); | 1110 v8::FunctionTemplate::New(env->GetIsolate(), callback)); |
| 1100 v8::Local<v8::Object> object = object_template->NewInstance(); | 1111 v8::Local<v8::Object> object = object_template->NewInstance(); |
| 1101 (*env)->Global()->Set(v8_str("callback_object"), object); | 1112 (*env)->Global()->Set(v8_str("callback_object"), object); |
| 1102 v8::Handle<v8::Script> script; | 1113 v8::Handle<v8::Script> script; |
| 1103 script = v8_compile("callback_object.callback(17)"); | 1114 script = v8_compile("callback_object.callback(17)"); |
| 1104 for (int i = 0; i < 30; i++) { | 1115 for (int i = 0; i < 30; i++) { |
| 1105 CHECK_EQ(51424, script->Run()->Int32Value()); | 1116 CHECK_EQ(51424, script->Run()->Int32Value()); |
| 1106 } | 1117 } |
| 1107 script = v8_compile("callback_object.callback(17, 24)"); | 1118 script = v8_compile("callback_object.callback(17, 24)"); |
| 1108 for (int i = 0; i < 30; i++) { | 1119 for (int i = 0; i < 30; i++) { |
| 1109 CHECK_EQ(51425, script->Run()->Int32Value()); | 1120 CHECK_EQ(51425, script->Run()->Int32Value()); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 info.GetReturnValue().Set(object); | 1203 info.GetReturnValue().Set(object); |
| 1193 } | 1204 } |
| 1194 | 1205 |
| 1195 template<typename T> | 1206 template<typename T> |
| 1196 Handle<Value> TestFastReturnValues() { | 1207 Handle<Value> TestFastReturnValues() { |
| 1197 LocalContext env; | 1208 LocalContext env; |
| 1198 v8::EscapableHandleScope scope(env->GetIsolate()); | 1209 v8::EscapableHandleScope scope(env->GetIsolate()); |
| 1199 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); | 1210 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); |
| 1200 v8::FunctionCallback callback = &FastReturnValueCallback<T>; | 1211 v8::FunctionCallback callback = &FastReturnValueCallback<T>; |
| 1201 object_template->Set(env->GetIsolate(), "callback", | 1212 object_template->Set(env->GetIsolate(), "callback", |
| 1202 v8::FunctionTemplate::New(callback)); | 1213 v8::FunctionTemplate::New(env->GetIsolate(), callback)); |
| 1203 v8::Local<v8::Object> object = object_template->NewInstance(); | 1214 v8::Local<v8::Object> object = object_template->NewInstance(); |
| 1204 (*env)->Global()->Set(v8_str("callback_object"), object); | 1215 (*env)->Global()->Set(v8_str("callback_object"), object); |
| 1205 return scope.Escape(CompileRun("callback_object.callback()")); | 1216 return scope.Escape(CompileRun("callback_object.callback()")); |
| 1206 } | 1217 } |
| 1207 | 1218 |
| 1208 | 1219 |
| 1209 THREADED_PROFILED_TEST(FastReturnValues) { | 1220 THREADED_PROFILED_TEST(FastReturnValues) { |
| 1210 LocalContext env; | 1221 LocalContext env; |
| 1211 v8::HandleScope scope(CcTest::isolate()); | 1222 v8::HandleScope scope(CcTest::isolate()); |
| 1212 v8::Handle<v8::Value> value; | 1223 v8::Handle<v8::Value> value; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 value = TestFastReturnValues<Object>(); | 1279 value = TestFastReturnValues<Object>(); |
| 1269 CHECK(value->IsObject()); | 1280 CHECK(value->IsObject()); |
| 1270 fast_return_value_object_is_empty = true; | 1281 fast_return_value_object_is_empty = true; |
| 1271 value = TestFastReturnValues<Object>(); | 1282 value = TestFastReturnValues<Object>(); |
| 1272 CHECK(value->IsUndefined()); | 1283 CHECK(value->IsUndefined()); |
| 1273 } | 1284 } |
| 1274 | 1285 |
| 1275 | 1286 |
| 1276 THREADED_TEST(FunctionTemplateSetLength) { | 1287 THREADED_TEST(FunctionTemplateSetLength) { |
| 1277 LocalContext env; | 1288 LocalContext env; |
| 1278 v8::HandleScope scope(env->GetIsolate()); | 1289 v8::Isolate* isolate = env->GetIsolate(); |
| 1290 v8::HandleScope scope(isolate); |
| 1279 { | 1291 { |
| 1280 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New( | 1292 Local<v8::FunctionTemplate> fun_templ = |
| 1281 handle_callback, Handle<v8::Value>(), Handle<v8::Signature>(), 23); | 1293 v8::FunctionTemplate::New(isolate, |
| 1294 handle_callback, |
| 1295 Handle<v8::Value>(), |
| 1296 Handle<v8::Signature>(), |
| 1297 23); |
| 1282 Local<Function> fun = fun_templ->GetFunction(); | 1298 Local<Function> fun = fun_templ->GetFunction(); |
| 1283 env->Global()->Set(v8_str("obj"), fun); | 1299 env->Global()->Set(v8_str("obj"), fun); |
| 1284 Local<Script> script = v8_compile("obj.length"); | 1300 Local<Script> script = v8_compile("obj.length"); |
| 1285 CHECK_EQ(23, script->Run()->Int32Value()); | 1301 CHECK_EQ(23, script->Run()->Int32Value()); |
| 1286 } | 1302 } |
| 1287 { | 1303 { |
| 1288 Local<v8::FunctionTemplate> fun_templ = | 1304 Local<v8::FunctionTemplate> fun_templ = |
| 1289 v8::FunctionTemplate::New(handle_callback); | 1305 v8::FunctionTemplate::New(isolate, handle_callback); |
| 1290 fun_templ->SetLength(22); | 1306 fun_templ->SetLength(22); |
| 1291 Local<Function> fun = fun_templ->GetFunction(); | 1307 Local<Function> fun = fun_templ->GetFunction(); |
| 1292 env->Global()->Set(v8_str("obj"), fun); | 1308 env->Global()->Set(v8_str("obj"), fun); |
| 1293 Local<Script> script = v8_compile("obj.length"); | 1309 Local<Script> script = v8_compile("obj.length"); |
| 1294 CHECK_EQ(22, script->Run()->Int32Value()); | 1310 CHECK_EQ(22, script->Run()->Int32Value()); |
| 1295 } | 1311 } |
| 1296 { | 1312 { |
| 1297 // Without setting length it defaults to 0. | 1313 // Without setting length it defaults to 0. |
| 1298 Local<v8::FunctionTemplate> fun_templ = | 1314 Local<v8::FunctionTemplate> fun_templ = |
| 1299 v8::FunctionTemplate::New(handle_callback); | 1315 v8::FunctionTemplate::New(isolate, handle_callback); |
| 1300 Local<Function> fun = fun_templ->GetFunction(); | 1316 Local<Function> fun = fun_templ->GetFunction(); |
| 1301 env->Global()->Set(v8_str("obj"), fun); | 1317 env->Global()->Set(v8_str("obj"), fun); |
| 1302 Local<Script> script = v8_compile("obj.length"); | 1318 Local<Script> script = v8_compile("obj.length"); |
| 1303 CHECK_EQ(0, script->Run()->Int32Value()); | 1319 CHECK_EQ(0, script->Run()->Int32Value()); |
| 1304 } | 1320 } |
| 1305 } | 1321 } |
| 1306 | 1322 |
| 1307 | 1323 |
| 1308 static void* expected_ptr; | 1324 static void* expected_ptr; |
| 1309 static void callback(const v8::FunctionCallbackInfo<v8::Value>& args) { | 1325 static void callback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 1310 void* ptr = v8::External::Cast(*args.Data())->Value(); | 1326 void* ptr = v8::External::Cast(*args.Data())->Value(); |
| 1311 CHECK_EQ(expected_ptr, ptr); | 1327 CHECK_EQ(expected_ptr, ptr); |
| 1312 args.GetReturnValue().Set(true); | 1328 args.GetReturnValue().Set(true); |
| 1313 } | 1329 } |
| 1314 | 1330 |
| 1315 | 1331 |
| 1316 static void TestExternalPointerWrapping() { | 1332 static void TestExternalPointerWrapping() { |
| 1317 LocalContext env; | 1333 LocalContext env; |
| 1318 v8::HandleScope scope(env->GetIsolate()); | 1334 v8::Isolate* isolate = env->GetIsolate(); |
| 1335 v8::HandleScope scope(isolate); |
| 1319 | 1336 |
| 1320 v8::Handle<v8::Value> data = | 1337 v8::Handle<v8::Value> data = |
| 1321 v8::External::New(env->GetIsolate(), expected_ptr); | 1338 v8::External::New(isolate, expected_ptr); |
| 1322 | 1339 |
| 1323 v8::Handle<v8::Object> obj = v8::Object::New(); | 1340 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 1324 obj->Set(v8_str("func"), | 1341 obj->Set(v8_str("func"), |
| 1325 v8::FunctionTemplate::New(callback, data)->GetFunction()); | 1342 v8::FunctionTemplate::New(isolate, callback, data)->GetFunction()); |
| 1326 env->Global()->Set(v8_str("obj"), obj); | 1343 env->Global()->Set(v8_str("obj"), obj); |
| 1327 | 1344 |
| 1328 CHECK(CompileRun( | 1345 CHECK(CompileRun( |
| 1329 "function foo() {\n" | 1346 "function foo() {\n" |
| 1330 " for (var i = 0; i < 13; i++) obj.func();\n" | 1347 " for (var i = 0; i < 13; i++) obj.func();\n" |
| 1331 "}\n" | 1348 "}\n" |
| 1332 "foo(), true")->BooleanValue()); | 1349 "foo(), true")->BooleanValue()); |
| 1333 } | 1350 } |
| 1334 | 1351 |
| 1335 | 1352 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 TestExternalPointerWrapping(); | 1391 TestExternalPointerWrapping(); |
| 1375 | 1392 |
| 1376 expected_ptr = reinterpret_cast<void*>(0xdeadbeefdeadbeef + 1); | 1393 expected_ptr = reinterpret_cast<void*>(0xdeadbeefdeadbeef + 1); |
| 1377 TestExternalPointerWrapping(); | 1394 TestExternalPointerWrapping(); |
| 1378 #endif | 1395 #endif |
| 1379 } | 1396 } |
| 1380 | 1397 |
| 1381 | 1398 |
| 1382 THREADED_TEST(FindInstanceInPrototypeChain) { | 1399 THREADED_TEST(FindInstanceInPrototypeChain) { |
| 1383 LocalContext env; | 1400 LocalContext env; |
| 1384 v8::HandleScope scope(env->GetIsolate()); | 1401 v8::Isolate* isolate = env->GetIsolate(); |
| 1402 v8::HandleScope scope(isolate); |
| 1385 | 1403 |
| 1386 Local<v8::FunctionTemplate> base = v8::FunctionTemplate::New(); | 1404 Local<v8::FunctionTemplate> base = v8::FunctionTemplate::New(isolate); |
| 1387 Local<v8::FunctionTemplate> derived = v8::FunctionTemplate::New(); | 1405 Local<v8::FunctionTemplate> derived = v8::FunctionTemplate::New(isolate); |
| 1388 Local<v8::FunctionTemplate> other = v8::FunctionTemplate::New(); | 1406 Local<v8::FunctionTemplate> other = v8::FunctionTemplate::New(isolate); |
| 1389 derived->Inherit(base); | 1407 derived->Inherit(base); |
| 1390 | 1408 |
| 1391 Local<v8::Function> base_function = base->GetFunction(); | 1409 Local<v8::Function> base_function = base->GetFunction(); |
| 1392 Local<v8::Function> derived_function = derived->GetFunction(); | 1410 Local<v8::Function> derived_function = derived->GetFunction(); |
| 1393 Local<v8::Function> other_function = other->GetFunction(); | 1411 Local<v8::Function> other_function = other->GetFunction(); |
| 1394 | 1412 |
| 1395 Local<v8::Object> base_instance = base_function->NewInstance(); | 1413 Local<v8::Object> base_instance = base_function->NewInstance(); |
| 1396 Local<v8::Object> derived_instance = derived_function->NewInstance(); | 1414 Local<v8::Object> derived_instance = derived_function->NewInstance(); |
| 1397 Local<v8::Object> derived_instance2 = derived_function->NewInstance(); | 1415 Local<v8::Object> derived_instance2 = derived_function->NewInstance(); |
| 1398 Local<v8::Object> other_instance = other_function->NewInstance(); | 1416 Local<v8::Object> other_instance = other_function->NewInstance(); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1749 | 1767 |
| 1750 | 1768 |
| 1751 static void GetM(Local<String> name, | 1769 static void GetM(Local<String> name, |
| 1752 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1770 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1753 ApiTestFuzzer::Fuzz(); | 1771 ApiTestFuzzer::Fuzz(); |
| 1754 info.GetReturnValue().Set(v8_num(876)); | 1772 info.GetReturnValue().Set(v8_num(876)); |
| 1755 } | 1773 } |
| 1756 | 1774 |
| 1757 | 1775 |
| 1758 THREADED_TEST(GlobalPrototype) { | 1776 THREADED_TEST(GlobalPrototype) { |
| 1759 v8::HandleScope scope(CcTest::isolate()); | 1777 v8::Isolate* isolate = CcTest::isolate(); |
| 1760 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); | 1778 v8::HandleScope scope(isolate); |
| 1779 v8::Handle<v8::FunctionTemplate> func_templ = |
| 1780 v8::FunctionTemplate::New(isolate); |
| 1761 func_templ->PrototypeTemplate()->Set( | 1781 func_templ->PrototypeTemplate()->Set( |
| 1762 CcTest::isolate(), "dummy", v8::FunctionTemplate::New(DummyCallHandler)); | 1782 isolate, "dummy", v8::FunctionTemplate::New(isolate, DummyCallHandler)); |
| 1763 v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate(); | 1783 v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate(); |
| 1764 templ->Set(CcTest::isolate(), "x", v8_num(200)); | 1784 templ->Set(isolate, "x", v8_num(200)); |
| 1765 templ->SetAccessor(v8_str("m"), GetM); | 1785 templ->SetAccessor(v8_str("m"), GetM); |
| 1766 LocalContext env(0, templ); | 1786 LocalContext env(0, templ); |
| 1767 v8::Handle<Script> script(v8_compile("dummy()")); | 1787 v8::Handle<Script> script(v8_compile("dummy()")); |
| 1768 v8::Handle<Value> result(script->Run()); | 1788 v8::Handle<Value> result(script->Run()); |
| 1769 CHECK_EQ(13.4, result->NumberValue()); | 1789 CHECK_EQ(13.4, result->NumberValue()); |
| 1770 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value()); | 1790 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value()); |
| 1771 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value()); | 1791 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value()); |
| 1772 } | 1792 } |
| 1773 | 1793 |
| 1774 | 1794 |
| 1775 THREADED_TEST(ObjectTemplate) { | 1795 THREADED_TEST(ObjectTemplate) { |
| 1776 v8::HandleScope scope(CcTest::isolate()); | 1796 v8::Isolate* isolate = CcTest::isolate(); |
| 1797 v8::HandleScope scope(isolate); |
| 1777 Local<ObjectTemplate> templ1 = ObjectTemplate::New(); | 1798 Local<ObjectTemplate> templ1 = ObjectTemplate::New(); |
| 1778 templ1->Set(CcTest::isolate(), "x", v8_num(10)); | 1799 templ1->Set(isolate, "x", v8_num(10)); |
| 1779 templ1->Set(CcTest::isolate(), "y", v8_num(13)); | 1800 templ1->Set(isolate, "y", v8_num(13)); |
| 1780 LocalContext env; | 1801 LocalContext env; |
| 1781 Local<v8::Object> instance1 = templ1->NewInstance(); | 1802 Local<v8::Object> instance1 = templ1->NewInstance(); |
| 1782 env->Global()->Set(v8_str("p"), instance1); | 1803 env->Global()->Set(v8_str("p"), instance1); |
| 1783 CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue()); | 1804 CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue()); |
| 1784 CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue()); | 1805 CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue()); |
| 1785 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); | 1806 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate); |
| 1786 fun->PrototypeTemplate()->Set(CcTest::isolate(), "nirk", v8_num(123)); | 1807 fun->PrototypeTemplate()->Set(isolate, "nirk", v8_num(123)); |
| 1787 Local<ObjectTemplate> templ2 = fun->InstanceTemplate(); | 1808 Local<ObjectTemplate> templ2 = fun->InstanceTemplate(); |
| 1788 templ2->Set(CcTest::isolate(), "a", v8_num(12)); | 1809 templ2->Set(isolate, "a", v8_num(12)); |
| 1789 templ2->Set(CcTest::isolate(), "b", templ1); | 1810 templ2->Set(isolate, "b", templ1); |
| 1790 Local<v8::Object> instance2 = templ2->NewInstance(); | 1811 Local<v8::Object> instance2 = templ2->NewInstance(); |
| 1791 env->Global()->Set(v8_str("q"), instance2); | 1812 env->Global()->Set(v8_str("q"), instance2); |
| 1792 CHECK(v8_compile("(q.nirk == 123)")->Run()->BooleanValue()); | 1813 CHECK(v8_compile("(q.nirk == 123)")->Run()->BooleanValue()); |
| 1793 CHECK(v8_compile("(q.a == 12)")->Run()->BooleanValue()); | 1814 CHECK(v8_compile("(q.a == 12)")->Run()->BooleanValue()); |
| 1794 CHECK(v8_compile("(q.b.x == 10)")->Run()->BooleanValue()); | 1815 CHECK(v8_compile("(q.b.x == 10)")->Run()->BooleanValue()); |
| 1795 CHECK(v8_compile("(q.b.y == 13)")->Run()->BooleanValue()); | 1816 CHECK(v8_compile("(q.b.y == 13)")->Run()->BooleanValue()); |
| 1796 } | 1817 } |
| 1797 | 1818 |
| 1798 | 1819 |
| 1799 static void GetFlabby(const v8::FunctionCallbackInfo<v8::Value>& args) { | 1820 static void GetFlabby(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 1800 ApiTestFuzzer::Fuzz(); | 1821 ApiTestFuzzer::Fuzz(); |
| 1801 args.GetReturnValue().Set(v8_num(17.2)); | 1822 args.GetReturnValue().Set(v8_num(17.2)); |
| 1802 } | 1823 } |
| 1803 | 1824 |
| 1804 | 1825 |
| 1805 static void GetKnurd(Local<String> property, | 1826 static void GetKnurd(Local<String> property, |
| 1806 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1827 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1807 ApiTestFuzzer::Fuzz(); | 1828 ApiTestFuzzer::Fuzz(); |
| 1808 info.GetReturnValue().Set(v8_num(15.2)); | 1829 info.GetReturnValue().Set(v8_num(15.2)); |
| 1809 } | 1830 } |
| 1810 | 1831 |
| 1811 | 1832 |
| 1812 THREADED_TEST(DescriptorInheritance) { | 1833 THREADED_TEST(DescriptorInheritance) { |
| 1813 v8::HandleScope scope(CcTest::isolate()); | 1834 v8::Isolate* isolate = CcTest::isolate(); |
| 1814 v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New(); | 1835 v8::HandleScope scope(isolate); |
| 1815 super->PrototypeTemplate()->Set(CcTest::isolate(), "flabby", | 1836 v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New(isolate); |
| 1816 v8::FunctionTemplate::New(GetFlabby)); | 1837 super->PrototypeTemplate()->Set(isolate, "flabby", |
| 1817 super->PrototypeTemplate()->Set(CcTest::isolate(), "PI", v8_num(3.14)); | 1838 v8::FunctionTemplate::New(isolate, |
| 1839 GetFlabby)); |
| 1840 super->PrototypeTemplate()->Set(isolate, "PI", v8_num(3.14)); |
| 1818 | 1841 |
| 1819 super->InstanceTemplate()->SetAccessor(v8_str("knurd"), GetKnurd); | 1842 super->InstanceTemplate()->SetAccessor(v8_str("knurd"), GetKnurd); |
| 1820 | 1843 |
| 1821 v8::Handle<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New(); | 1844 v8::Handle<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New(isolate); |
| 1822 base1->Inherit(super); | 1845 base1->Inherit(super); |
| 1823 base1->PrototypeTemplate()->Set(CcTest::isolate(), "v1", v8_num(20.1)); | 1846 base1->PrototypeTemplate()->Set(isolate, "v1", v8_num(20.1)); |
| 1824 | 1847 |
| 1825 v8::Handle<v8::FunctionTemplate> base2 = v8::FunctionTemplate::New(); | 1848 v8::Handle<v8::FunctionTemplate> base2 = v8::FunctionTemplate::New(isolate); |
| 1826 base2->Inherit(super); | 1849 base2->Inherit(super); |
| 1827 base2->PrototypeTemplate()->Set(CcTest::isolate(), "v2", v8_num(10.1)); | 1850 base2->PrototypeTemplate()->Set(isolate, "v2", v8_num(10.1)); |
| 1828 | 1851 |
| 1829 LocalContext env; | 1852 LocalContext env; |
| 1830 | 1853 |
| 1831 env->Global()->Set(v8_str("s"), super->GetFunction()); | 1854 env->Global()->Set(v8_str("s"), super->GetFunction()); |
| 1832 env->Global()->Set(v8_str("base1"), base1->GetFunction()); | 1855 env->Global()->Set(v8_str("base1"), base1->GetFunction()); |
| 1833 env->Global()->Set(v8_str("base2"), base2->GetFunction()); | 1856 env->Global()->Set(v8_str("base2"), base2->GetFunction()); |
| 1834 | 1857 |
| 1835 // Checks right __proto__ chain. | 1858 // Checks right __proto__ chain. |
| 1836 CHECK(CompileRun("base1.prototype.__proto__ == s.prototype")->BooleanValue()); | 1859 CHECK(CompileRun("base1.prototype.__proto__ == s.prototype")->BooleanValue()); |
| 1837 CHECK(CompileRun("base2.prototype.__proto__ == s.prototype")->BooleanValue()); | 1860 CHECK(CompileRun("base2.prototype.__proto__ == s.prototype")->BooleanValue()); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1945 | 1968 |
| 1946 void AddInterceptor(Handle<FunctionTemplate> templ, | 1969 void AddInterceptor(Handle<FunctionTemplate> templ, |
| 1947 v8::NamedPropertyGetterCallback getter, | 1970 v8::NamedPropertyGetterCallback getter, |
| 1948 v8::NamedPropertySetterCallback setter) { | 1971 v8::NamedPropertySetterCallback setter) { |
| 1949 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); | 1972 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); |
| 1950 } | 1973 } |
| 1951 | 1974 |
| 1952 | 1975 |
| 1953 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { | 1976 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { |
| 1954 v8::HandleScope scope(CcTest::isolate()); | 1977 v8::HandleScope scope(CcTest::isolate()); |
| 1955 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 1978 Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate()); |
| 1956 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 1979 Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate()); |
| 1957 child->Inherit(parent); | 1980 child->Inherit(parent); |
| 1958 AddAccessor(parent, v8_str("age"), | 1981 AddAccessor(parent, v8_str("age"), |
| 1959 SimpleAccessorGetter, SimpleAccessorSetter); | 1982 SimpleAccessorGetter, SimpleAccessorSetter); |
| 1960 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); | 1983 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 1961 LocalContext env; | 1984 LocalContext env; |
| 1962 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 1985 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 1963 CompileRun("var child = new Child;" | 1986 CompileRun("var child = new Child;" |
| 1964 "child.age = 10;"); | 1987 "child.age = 10;"); |
| 1965 ExpectBoolean("child.hasOwnProperty('age')", false); | 1988 ExpectBoolean("child.hasOwnProperty('age')", false); |
| 1966 ExpectInt32("child.age", 10); | 1989 ExpectInt32("child.age", 10); |
| 1967 ExpectInt32("child.accessor_age", 10); | 1990 ExpectInt32("child.accessor_age", 10); |
| 1968 } | 1991 } |
| 1969 | 1992 |
| 1970 | 1993 |
| 1971 THREADED_TEST(EmptyInterceptorDoesNotShadowJSAccessors) { | 1994 THREADED_TEST(EmptyInterceptorDoesNotShadowJSAccessors) { |
| 1972 v8::HandleScope scope(CcTest::isolate()); | 1995 v8::Isolate* isolate = CcTest::isolate(); |
| 1973 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 1996 v8::HandleScope scope(isolate); |
| 1974 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 1997 Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate); |
| 1998 Handle<FunctionTemplate> child = FunctionTemplate::New(isolate); |
| 1975 child->Inherit(parent); | 1999 child->Inherit(parent); |
| 1976 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); | 2000 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 1977 LocalContext env; | 2001 LocalContext env; |
| 1978 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 2002 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 1979 CompileRun("var child = new Child;" | 2003 CompileRun("var child = new Child;" |
| 1980 "var parent = child.__proto__;" | 2004 "var parent = child.__proto__;" |
| 1981 "Object.defineProperty(parent, 'age', " | 2005 "Object.defineProperty(parent, 'age', " |
| 1982 " {get: function(){ return this.accessor_age; }, " | 2006 " {get: function(){ return this.accessor_age; }, " |
| 1983 " set: function(v){ this.accessor_age = v; }, " | 2007 " set: function(v){ this.accessor_age = v; }, " |
| 1984 " enumerable: true, configurable: true});" | 2008 " enumerable: true, configurable: true});" |
| 1985 "child.age = 10;"); | 2009 "child.age = 10;"); |
| 1986 ExpectBoolean("child.hasOwnProperty('age')", false); | 2010 ExpectBoolean("child.hasOwnProperty('age')", false); |
| 1987 ExpectInt32("child.age", 10); | 2011 ExpectInt32("child.age", 10); |
| 1988 ExpectInt32("child.accessor_age", 10); | 2012 ExpectInt32("child.accessor_age", 10); |
| 1989 } | 2013 } |
| 1990 | 2014 |
| 1991 | 2015 |
| 1992 THREADED_TEST(EmptyInterceptorDoesNotAffectJSProperties) { | 2016 THREADED_TEST(EmptyInterceptorDoesNotAffectJSProperties) { |
| 1993 v8::HandleScope scope(CcTest::isolate()); | 2017 v8::Isolate* isolate = CcTest::isolate(); |
| 1994 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 2018 v8::HandleScope scope(isolate); |
| 1995 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 2019 Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate); |
| 2020 Handle<FunctionTemplate> child = FunctionTemplate::New(isolate); |
| 1996 child->Inherit(parent); | 2021 child->Inherit(parent); |
| 1997 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); | 2022 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 1998 LocalContext env; | 2023 LocalContext env; |
| 1999 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 2024 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 2000 CompileRun("var child = new Child;" | 2025 CompileRun("var child = new Child;" |
| 2001 "var parent = child.__proto__;" | 2026 "var parent = child.__proto__;" |
| 2002 "parent.name = 'Alice';"); | 2027 "parent.name = 'Alice';"); |
| 2003 ExpectBoolean("child.hasOwnProperty('name')", false); | 2028 ExpectBoolean("child.hasOwnProperty('name')", false); |
| 2004 ExpectString("child.name", "Alice"); | 2029 ExpectString("child.name", "Alice"); |
| 2005 CompileRun("child.name = 'Bob';"); | 2030 CompileRun("child.name = 'Bob';"); |
| 2006 ExpectString("child.name", "Bob"); | 2031 ExpectString("child.name", "Bob"); |
| 2007 ExpectBoolean("child.hasOwnProperty('name')", true); | 2032 ExpectBoolean("child.hasOwnProperty('name')", true); |
| 2008 ExpectString("parent.name", "Alice"); | 2033 ExpectString("parent.name", "Alice"); |
| 2009 } | 2034 } |
| 2010 | 2035 |
| 2011 | 2036 |
| 2012 THREADED_TEST(SwitchFromInterceptorToAccessor) { | 2037 THREADED_TEST(SwitchFromInterceptorToAccessor) { |
| 2013 v8::HandleScope scope(CcTest::isolate()); | 2038 v8::HandleScope scope(CcTest::isolate()); |
| 2014 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 2039 Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); |
| 2015 AddAccessor(templ, v8_str("age"), | 2040 AddAccessor(templ, v8_str("age"), |
| 2016 SimpleAccessorGetter, SimpleAccessorSetter); | 2041 SimpleAccessorGetter, SimpleAccessorSetter); |
| 2017 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 2042 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 2018 LocalContext env; | 2043 LocalContext env; |
| 2019 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 2044 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 2020 CompileRun("var obj = new Obj;" | 2045 CompileRun("var obj = new Obj;" |
| 2021 "function setAge(i){ obj.age = i; };" | 2046 "function setAge(i){ obj.age = i; };" |
| 2022 "for(var i = 0; i <= 10000; i++) setAge(i);"); | 2047 "for(var i = 0; i <= 10000; i++) setAge(i);"); |
| 2023 // All i < 10000 go to the interceptor. | 2048 // All i < 10000 go to the interceptor. |
| 2024 ExpectInt32("obj.interceptor_age", 9999); | 2049 ExpectInt32("obj.interceptor_age", 9999); |
| 2025 // The last i goes to the accessor. | 2050 // The last i goes to the accessor. |
| 2026 ExpectInt32("obj.accessor_age", 10000); | 2051 ExpectInt32("obj.accessor_age", 10000); |
| 2027 } | 2052 } |
| 2028 | 2053 |
| 2029 | 2054 |
| 2030 THREADED_TEST(SwitchFromAccessorToInterceptor) { | 2055 THREADED_TEST(SwitchFromAccessorToInterceptor) { |
| 2031 v8::HandleScope scope(CcTest::isolate()); | 2056 v8::HandleScope scope(CcTest::isolate()); |
| 2032 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 2057 Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); |
| 2033 AddAccessor(templ, v8_str("age"), | 2058 AddAccessor(templ, v8_str("age"), |
| 2034 SimpleAccessorGetter, SimpleAccessorSetter); | 2059 SimpleAccessorGetter, SimpleAccessorSetter); |
| 2035 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 2060 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 2036 LocalContext env; | 2061 LocalContext env; |
| 2037 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 2062 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 2038 CompileRun("var obj = new Obj;" | 2063 CompileRun("var obj = new Obj;" |
| 2039 "function setAge(i){ obj.age = i; };" | 2064 "function setAge(i){ obj.age = i; };" |
| 2040 "for(var i = 20000; i >= 9999; i--) setAge(i);"); | 2065 "for(var i = 20000; i >= 9999; i--) setAge(i);"); |
| 2041 // All i >= 10000 go to the accessor. | 2066 // All i >= 10000 go to the accessor. |
| 2042 ExpectInt32("obj.accessor_age", 10000); | 2067 ExpectInt32("obj.accessor_age", 10000); |
| 2043 // The last i goes to the interceptor. | 2068 // The last i goes to the interceptor. |
| 2044 ExpectInt32("obj.interceptor_age", 9999); | 2069 ExpectInt32("obj.interceptor_age", 9999); |
| 2045 } | 2070 } |
| 2046 | 2071 |
| 2047 | 2072 |
| 2048 THREADED_TEST(SwitchFromInterceptorToAccessorWithInheritance) { | 2073 THREADED_TEST(SwitchFromInterceptorToAccessorWithInheritance) { |
| 2049 v8::HandleScope scope(CcTest::isolate()); | 2074 v8::HandleScope scope(CcTest::isolate()); |
| 2050 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 2075 Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate()); |
| 2051 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 2076 Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate()); |
| 2052 child->Inherit(parent); | 2077 child->Inherit(parent); |
| 2053 AddAccessor(parent, v8_str("age"), | 2078 AddAccessor(parent, v8_str("age"), |
| 2054 SimpleAccessorGetter, SimpleAccessorSetter); | 2079 SimpleAccessorGetter, SimpleAccessorSetter); |
| 2055 AddInterceptor(child, InterceptorGetter, InterceptorSetter); | 2080 AddInterceptor(child, InterceptorGetter, InterceptorSetter); |
| 2056 LocalContext env; | 2081 LocalContext env; |
| 2057 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 2082 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 2058 CompileRun("var child = new Child;" | 2083 CompileRun("var child = new Child;" |
| 2059 "function setAge(i){ child.age = i; };" | 2084 "function setAge(i){ child.age = i; };" |
| 2060 "for(var i = 0; i <= 10000; i++) setAge(i);"); | 2085 "for(var i = 0; i <= 10000; i++) setAge(i);"); |
| 2061 // All i < 10000 go to the interceptor. | 2086 // All i < 10000 go to the interceptor. |
| 2062 ExpectInt32("child.interceptor_age", 9999); | 2087 ExpectInt32("child.interceptor_age", 9999); |
| 2063 // The last i goes to the accessor. | 2088 // The last i goes to the accessor. |
| 2064 ExpectInt32("child.accessor_age", 10000); | 2089 ExpectInt32("child.accessor_age", 10000); |
| 2065 } | 2090 } |
| 2066 | 2091 |
| 2067 | 2092 |
| 2068 THREADED_TEST(SwitchFromAccessorToInterceptorWithInheritance) { | 2093 THREADED_TEST(SwitchFromAccessorToInterceptorWithInheritance) { |
| 2069 v8::HandleScope scope(CcTest::isolate()); | 2094 v8::HandleScope scope(CcTest::isolate()); |
| 2070 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 2095 Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate()); |
| 2071 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 2096 Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate()); |
| 2072 child->Inherit(parent); | 2097 child->Inherit(parent); |
| 2073 AddAccessor(parent, v8_str("age"), | 2098 AddAccessor(parent, v8_str("age"), |
| 2074 SimpleAccessorGetter, SimpleAccessorSetter); | 2099 SimpleAccessorGetter, SimpleAccessorSetter); |
| 2075 AddInterceptor(child, InterceptorGetter, InterceptorSetter); | 2100 AddInterceptor(child, InterceptorGetter, InterceptorSetter); |
| 2076 LocalContext env; | 2101 LocalContext env; |
| 2077 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 2102 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 2078 CompileRun("var child = new Child;" | 2103 CompileRun("var child = new Child;" |
| 2079 "function setAge(i){ child.age = i; };" | 2104 "function setAge(i){ child.age = i; };" |
| 2080 "for(var i = 20000; i >= 9999; i--) setAge(i);"); | 2105 "for(var i = 20000; i >= 9999; i--) setAge(i);"); |
| 2081 // All i >= 10000 go to the accessor. | 2106 // All i >= 10000 go to the accessor. |
| 2082 ExpectInt32("child.accessor_age", 10000); | 2107 ExpectInt32("child.accessor_age", 10000); |
| 2083 // The last i goes to the interceptor. | 2108 // The last i goes to the interceptor. |
| 2084 ExpectInt32("child.interceptor_age", 9999); | 2109 ExpectInt32("child.interceptor_age", 9999); |
| 2085 } | 2110 } |
| 2086 | 2111 |
| 2087 | 2112 |
| 2088 THREADED_TEST(SwitchFromInterceptorToJSAccessor) { | 2113 THREADED_TEST(SwitchFromInterceptorToJSAccessor) { |
| 2089 v8::HandleScope scope(CcTest::isolate()); | 2114 v8::HandleScope scope(CcTest::isolate()); |
| 2090 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 2115 Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); |
| 2091 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 2116 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 2092 LocalContext env; | 2117 LocalContext env; |
| 2093 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 2118 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 2094 CompileRun("var obj = new Obj;" | 2119 CompileRun("var obj = new Obj;" |
| 2095 "function setter(i) { this.accessor_age = i; };" | 2120 "function setter(i) { this.accessor_age = i; };" |
| 2096 "function getter() { return this.accessor_age; };" | 2121 "function getter() { return this.accessor_age; };" |
| 2097 "function setAge(i) { obj.age = i; };" | 2122 "function setAge(i) { obj.age = i; };" |
| 2098 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" | 2123 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" |
| 2099 "for(var i = 0; i <= 10000; i++) setAge(i);"); | 2124 "for(var i = 0; i <= 10000; i++) setAge(i);"); |
| 2100 // All i < 10000 go to the interceptor. | 2125 // All i < 10000 go to the interceptor. |
| 2101 ExpectInt32("obj.interceptor_age", 9999); | 2126 ExpectInt32("obj.interceptor_age", 9999); |
| 2102 // The last i goes to the JavaScript accessor. | 2127 // The last i goes to the JavaScript accessor. |
| 2103 ExpectInt32("obj.accessor_age", 10000); | 2128 ExpectInt32("obj.accessor_age", 10000); |
| 2104 // The installed JavaScript getter is still intact. | 2129 // The installed JavaScript getter is still intact. |
| 2105 // This last part is a regression test for issue 1651 and relies on the fact | 2130 // This last part is a regression test for issue 1651 and relies on the fact |
| 2106 // that both interceptor and accessor are being installed on the same object. | 2131 // that both interceptor and accessor are being installed on the same object. |
| 2107 ExpectInt32("obj.age", 10000); | 2132 ExpectInt32("obj.age", 10000); |
| 2108 ExpectBoolean("obj.hasOwnProperty('age')", true); | 2133 ExpectBoolean("obj.hasOwnProperty('age')", true); |
| 2109 ExpectUndefined("Object.getOwnPropertyDescriptor(obj, 'age').value"); | 2134 ExpectUndefined("Object.getOwnPropertyDescriptor(obj, 'age').value"); |
| 2110 } | 2135 } |
| 2111 | 2136 |
| 2112 | 2137 |
| 2113 THREADED_TEST(SwitchFromJSAccessorToInterceptor) { | 2138 THREADED_TEST(SwitchFromJSAccessorToInterceptor) { |
| 2114 v8::HandleScope scope(CcTest::isolate()); | 2139 v8::HandleScope scope(CcTest::isolate()); |
| 2115 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 2140 Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); |
| 2116 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 2141 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 2117 LocalContext env; | 2142 LocalContext env; |
| 2118 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 2143 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 2119 CompileRun("var obj = new Obj;" | 2144 CompileRun("var obj = new Obj;" |
| 2120 "function setter(i) { this.accessor_age = i; };" | 2145 "function setter(i) { this.accessor_age = i; };" |
| 2121 "function getter() { return this.accessor_age; };" | 2146 "function getter() { return this.accessor_age; };" |
| 2122 "function setAge(i) { obj.age = i; };" | 2147 "function setAge(i) { obj.age = i; };" |
| 2123 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" | 2148 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" |
| 2124 "for(var i = 20000; i >= 9999; i--) setAge(i);"); | 2149 "for(var i = 20000; i >= 9999; i--) setAge(i);"); |
| 2125 // All i >= 10000 go to the accessor. | 2150 // All i >= 10000 go to the accessor. |
| 2126 ExpectInt32("obj.accessor_age", 10000); | 2151 ExpectInt32("obj.accessor_age", 10000); |
| 2127 // The last i goes to the interceptor. | 2152 // The last i goes to the interceptor. |
| 2128 ExpectInt32("obj.interceptor_age", 9999); | 2153 ExpectInt32("obj.interceptor_age", 9999); |
| 2129 // The installed JavaScript getter is still intact. | 2154 // The installed JavaScript getter is still intact. |
| 2130 // This last part is a regression test for issue 1651 and relies on the fact | 2155 // This last part is a regression test for issue 1651 and relies on the fact |
| 2131 // that both interceptor and accessor are being installed on the same object. | 2156 // that both interceptor and accessor are being installed on the same object. |
| 2132 ExpectInt32("obj.age", 10000); | 2157 ExpectInt32("obj.age", 10000); |
| 2133 ExpectBoolean("obj.hasOwnProperty('age')", true); | 2158 ExpectBoolean("obj.hasOwnProperty('age')", true); |
| 2134 ExpectUndefined("Object.getOwnPropertyDescriptor(obj, 'age').value"); | 2159 ExpectUndefined("Object.getOwnPropertyDescriptor(obj, 'age').value"); |
| 2135 } | 2160 } |
| 2136 | 2161 |
| 2137 | 2162 |
| 2138 THREADED_TEST(SwitchFromInterceptorToProperty) { | 2163 THREADED_TEST(SwitchFromInterceptorToProperty) { |
| 2139 v8::HandleScope scope(CcTest::isolate()); | 2164 v8::HandleScope scope(CcTest::isolate()); |
| 2140 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 2165 Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate()); |
| 2141 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 2166 Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate()); |
| 2142 child->Inherit(parent); | 2167 child->Inherit(parent); |
| 2143 AddInterceptor(child, InterceptorGetter, InterceptorSetter); | 2168 AddInterceptor(child, InterceptorGetter, InterceptorSetter); |
| 2144 LocalContext env; | 2169 LocalContext env; |
| 2145 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 2170 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 2146 CompileRun("var child = new Child;" | 2171 CompileRun("var child = new Child;" |
| 2147 "function setAge(i){ child.age = i; };" | 2172 "function setAge(i){ child.age = i; };" |
| 2148 "for(var i = 0; i <= 10000; i++) setAge(i);"); | 2173 "for(var i = 0; i <= 10000; i++) setAge(i);"); |
| 2149 // All i < 10000 go to the interceptor. | 2174 // All i < 10000 go to the interceptor. |
| 2150 ExpectInt32("child.interceptor_age", 9999); | 2175 ExpectInt32("child.interceptor_age", 9999); |
| 2151 // The last i goes to child's own property. | 2176 // The last i goes to child's own property. |
| 2152 ExpectInt32("child.age", 10000); | 2177 ExpectInt32("child.age", 10000); |
| 2153 } | 2178 } |
| 2154 | 2179 |
| 2155 | 2180 |
| 2156 THREADED_TEST(SwitchFromPropertyToInterceptor) { | 2181 THREADED_TEST(SwitchFromPropertyToInterceptor) { |
| 2157 v8::HandleScope scope(CcTest::isolate()); | 2182 v8::HandleScope scope(CcTest::isolate()); |
| 2158 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 2183 Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate()); |
| 2159 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 2184 Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate()); |
| 2160 child->Inherit(parent); | 2185 child->Inherit(parent); |
| 2161 AddInterceptor(child, InterceptorGetter, InterceptorSetter); | 2186 AddInterceptor(child, InterceptorGetter, InterceptorSetter); |
| 2162 LocalContext env; | 2187 LocalContext env; |
| 2163 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 2188 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 2164 CompileRun("var child = new Child;" | 2189 CompileRun("var child = new Child;" |
| 2165 "function setAge(i){ child.age = i; };" | 2190 "function setAge(i){ child.age = i; };" |
| 2166 "for(var i = 20000; i >= 9999; i--) setAge(i);"); | 2191 "for(var i = 20000; i >= 9999; i--) setAge(i);"); |
| 2167 // All i >= 10000 go to child's own property. | 2192 // All i >= 10000 go to child's own property. |
| 2168 ExpectInt32("child.age", 10000); | 2193 ExpectInt32("child.age", 10000); |
| 2169 // The last i goes to the interceptor. | 2194 // The last i goes to the interceptor. |
| 2170 ExpectInt32("child.interceptor_age", 9999); | 2195 ExpectInt32("child.interceptor_age", 9999); |
| 2171 } | 2196 } |
| 2172 | 2197 |
| 2173 | 2198 |
| 2174 THREADED_TEST(NamedPropertyHandlerGetter) { | 2199 THREADED_TEST(NamedPropertyHandlerGetter) { |
| 2175 echo_named_call_count = 0; | 2200 echo_named_call_count = 0; |
| 2176 v8::HandleScope scope(CcTest::isolate()); | 2201 v8::HandleScope scope(CcTest::isolate()); |
| 2177 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 2202 v8::Handle<v8::FunctionTemplate> templ = |
| 2203 v8::FunctionTemplate::New(CcTest::isolate()); |
| 2178 templ->InstanceTemplate()->SetNamedPropertyHandler(EchoNamedProperty, | 2204 templ->InstanceTemplate()->SetNamedPropertyHandler(EchoNamedProperty, |
| 2179 0, 0, 0, 0, | 2205 0, 0, 0, 0, |
| 2180 v8_str("data")); | 2206 v8_str("data")); |
| 2181 LocalContext env; | 2207 LocalContext env; |
| 2182 env->Global()->Set(v8_str("obj"), | 2208 env->Global()->Set(v8_str("obj"), |
| 2183 templ->GetFunction()->NewInstance()); | 2209 templ->GetFunction()->NewInstance()); |
| 2184 CHECK_EQ(echo_named_call_count, 0); | 2210 CHECK_EQ(echo_named_call_count, 0); |
| 2185 v8_compile("obj.x")->Run(); | 2211 v8_compile("obj.x")->Run(); |
| 2186 CHECK_EQ(echo_named_call_count, 1); | 2212 CHECK_EQ(echo_named_call_count, 1); |
| 2187 const char* code = "var str = 'oddle'; obj[str] + obj.poddle;"; | 2213 const char* code = "var str = 'oddle'; obj[str] + obj.poddle;"; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2202 uint32_t index, | 2228 uint32_t index, |
| 2203 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2229 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 2204 ApiTestFuzzer::Fuzz(); | 2230 ApiTestFuzzer::Fuzz(); |
| 2205 CHECK_EQ(v8_num(637), info.Data()); | 2231 CHECK_EQ(v8_num(637), info.Data()); |
| 2206 echo_indexed_call_count++; | 2232 echo_indexed_call_count++; |
| 2207 info.GetReturnValue().Set(v8_num(index)); | 2233 info.GetReturnValue().Set(v8_num(index)); |
| 2208 } | 2234 } |
| 2209 | 2235 |
| 2210 | 2236 |
| 2211 THREADED_TEST(IndexedPropertyHandlerGetter) { | 2237 THREADED_TEST(IndexedPropertyHandlerGetter) { |
| 2212 v8::HandleScope scope(CcTest::isolate()); | 2238 v8::Isolate* isolate = CcTest::isolate(); |
| 2213 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 2239 v8::HandleScope scope(isolate); |
| 2240 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 2214 templ->InstanceTemplate()->SetIndexedPropertyHandler(EchoIndexedProperty, | 2241 templ->InstanceTemplate()->SetIndexedPropertyHandler(EchoIndexedProperty, |
| 2215 0, 0, 0, 0, | 2242 0, 0, 0, 0, |
| 2216 v8_num(637)); | 2243 v8_num(637)); |
| 2217 LocalContext env; | 2244 LocalContext env; |
| 2218 env->Global()->Set(v8_str("obj"), | 2245 env->Global()->Set(v8_str("obj"), |
| 2219 templ->GetFunction()->NewInstance()); | 2246 templ->GetFunction()->NewInstance()); |
| 2220 Local<Script> script = v8_compile("obj[900]"); | 2247 Local<Script> script = v8_compile("obj[900]"); |
| 2221 CHECK_EQ(script->Run()->Int32Value(), 900); | 2248 CHECK_EQ(script->Run()->Int32Value(), 900); |
| 2222 } | 2249 } |
| 2223 | 2250 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2306 void CheckThisNamedPropertyEnumerator( | 2333 void CheckThisNamedPropertyEnumerator( |
| 2307 const v8::PropertyCallbackInfo<v8::Array>& info) { | 2334 const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 2308 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyEnumerator)); | 2335 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyEnumerator)); |
| 2309 ApiTestFuzzer::Fuzz(); | 2336 ApiTestFuzzer::Fuzz(); |
| 2310 CHECK(info.This()->Equals(bottom)); | 2337 CHECK(info.This()->Equals(bottom)); |
| 2311 } | 2338 } |
| 2312 | 2339 |
| 2313 | 2340 |
| 2314 THREADED_PROFILED_TEST(PropertyHandlerInPrototype) { | 2341 THREADED_PROFILED_TEST(PropertyHandlerInPrototype) { |
| 2315 LocalContext env; | 2342 LocalContext env; |
| 2316 v8::HandleScope scope(env->GetIsolate()); | 2343 v8::Isolate* isolate = env->GetIsolate(); |
| 2344 v8::HandleScope scope(isolate); |
| 2317 | 2345 |
| 2318 // Set up a prototype chain with three interceptors. | 2346 // Set up a prototype chain with three interceptors. |
| 2319 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 2347 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 2320 templ->InstanceTemplate()->SetIndexedPropertyHandler( | 2348 templ->InstanceTemplate()->SetIndexedPropertyHandler( |
| 2321 CheckThisIndexedPropertyHandler, | 2349 CheckThisIndexedPropertyHandler, |
| 2322 CheckThisIndexedPropertySetter, | 2350 CheckThisIndexedPropertySetter, |
| 2323 CheckThisIndexedPropertyQuery, | 2351 CheckThisIndexedPropertyQuery, |
| 2324 CheckThisIndexedPropertyDeleter, | 2352 CheckThisIndexedPropertyDeleter, |
| 2325 CheckThisIndexedPropertyEnumerator); | 2353 CheckThisIndexedPropertyEnumerator); |
| 2326 | 2354 |
| 2327 templ->InstanceTemplate()->SetNamedPropertyHandler( | 2355 templ->InstanceTemplate()->SetNamedPropertyHandler( |
| 2328 CheckThisNamedPropertyHandler, | 2356 CheckThisNamedPropertyHandler, |
| 2329 CheckThisNamedPropertySetter, | 2357 CheckThisNamedPropertySetter, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2373 static void PrePropertyHandlerQuery( | 2401 static void PrePropertyHandlerQuery( |
| 2374 Local<String> key, | 2402 Local<String> key, |
| 2375 const v8::PropertyCallbackInfo<v8::Integer>& info) { | 2403 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
| 2376 if (v8_str("pre")->Equals(key)) { | 2404 if (v8_str("pre")->Equals(key)) { |
| 2377 info.GetReturnValue().Set(static_cast<int32_t>(v8::None)); | 2405 info.GetReturnValue().Set(static_cast<int32_t>(v8::None)); |
| 2378 } | 2406 } |
| 2379 } | 2407 } |
| 2380 | 2408 |
| 2381 | 2409 |
| 2382 THREADED_TEST(PrePropertyHandler) { | 2410 THREADED_TEST(PrePropertyHandler) { |
| 2383 v8::HandleScope scope(CcTest::isolate()); | 2411 v8::Isolate* isolate = CcTest::isolate(); |
| 2384 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); | 2412 v8::HandleScope scope(isolate); |
| 2413 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate); |
| 2385 desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet, | 2414 desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet, |
| 2386 0, | 2415 0, |
| 2387 PrePropertyHandlerQuery); | 2416 PrePropertyHandlerQuery); |
| 2388 LocalContext env(NULL, desc->InstanceTemplate()); | 2417 LocalContext env(NULL, desc->InstanceTemplate()); |
| 2389 Script::Compile(v8_str( | 2418 Script::Compile(v8_str( |
| 2390 "var pre = 'Object: pre'; var on = 'Object: on';"))->Run(); | 2419 "var pre = 'Object: pre'; var on = 'Object: on';"))->Run(); |
| 2391 v8::Handle<Value> result_pre = Script::Compile(v8_str("pre"))->Run(); | 2420 v8::Handle<Value> result_pre = Script::Compile(v8_str("pre"))->Run(); |
| 2392 CHECK_EQ(v8_str("PrePropertyHandler: pre"), result_pre); | 2421 CHECK_EQ(v8_str("PrePropertyHandler: pre"), result_pre); |
| 2393 v8::Handle<Value> result_on = Script::Compile(v8_str("on"))->Run(); | 2422 v8::Handle<Value> result_on = Script::Compile(v8_str("on"))->Run(); |
| 2394 CHECK_EQ(v8_str("Object: on"), result_on); | 2423 CHECK_EQ(v8_str("Object: on"), result_on); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2430 } | 2459 } |
| 2431 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1)); | 2460 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1)); |
| 2432 v8::Handle<Value> function = | 2461 v8::Handle<Value> function = |
| 2433 args.This()->Get(v8_str("callFunctionRecursively")); | 2462 args.This()->Get(v8_str("callFunctionRecursively")); |
| 2434 args.GetReturnValue().Set( | 2463 args.GetReturnValue().Set( |
| 2435 function.As<Function>()->Call(args.This(), 0, NULL)); | 2464 function.As<Function>()->Call(args.This(), 0, NULL)); |
| 2436 } | 2465 } |
| 2437 | 2466 |
| 2438 | 2467 |
| 2439 THREADED_TEST(DeepCrossLanguageRecursion) { | 2468 THREADED_TEST(DeepCrossLanguageRecursion) { |
| 2440 v8::HandleScope scope(CcTest::isolate()); | 2469 v8::Isolate* isolate = CcTest::isolate(); |
| 2470 v8::HandleScope scope(isolate); |
| 2441 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); | 2471 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
| 2442 global->Set(v8_str("callScriptRecursively"), | 2472 global->Set(v8_str("callScriptRecursively"), |
| 2443 v8::FunctionTemplate::New(CallScriptRecursivelyCall)); | 2473 v8::FunctionTemplate::New(isolate, CallScriptRecursivelyCall)); |
| 2444 global->Set(v8_str("callFunctionRecursively"), | 2474 global->Set(v8_str("callFunctionRecursively"), |
| 2445 v8::FunctionTemplate::New(CallFunctionRecursivelyCall)); | 2475 v8::FunctionTemplate::New(isolate, CallFunctionRecursivelyCall)); |
| 2446 LocalContext env(NULL, global); | 2476 LocalContext env(NULL, global); |
| 2447 | 2477 |
| 2448 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); | 2478 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); |
| 2449 call_recursively_script = v8_compile("callScriptRecursively()"); | 2479 call_recursively_script = v8_compile("callScriptRecursively()"); |
| 2450 call_recursively_script->Run(); | 2480 call_recursively_script->Run(); |
| 2451 call_recursively_script = v8::Handle<Script>(); | 2481 call_recursively_script = v8::Handle<Script>(); |
| 2452 | 2482 |
| 2453 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); | 2483 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); |
| 2454 Script::Compile(v8_str("callFunctionRecursively()"))->Run(); | 2484 Script::Compile(v8_str("callFunctionRecursively()"))->Run(); |
| 2455 } | 2485 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2482 v8::Handle<Value> otto = Script::Compile(v8_str( | 2512 v8::Handle<Value> otto = Script::Compile(v8_str( |
| 2483 "try { with (obj) { otto; } } catch (e) { e; }"))->Run(); | 2513 "try { with (obj) { otto; } } catch (e) { e; }"))->Run(); |
| 2484 CHECK_EQ(v8_str("otto"), otto); | 2514 CHECK_EQ(v8_str("otto"), otto); |
| 2485 v8::Handle<Value> netto = Script::Compile(v8_str( | 2515 v8::Handle<Value> netto = Script::Compile(v8_str( |
| 2486 "try { with (obj) { netto = 4; } } catch (e) { e; }"))->Run(); | 2516 "try { with (obj) { netto = 4; } } catch (e) { e; }"))->Run(); |
| 2487 CHECK_EQ(v8_str("netto"), netto); | 2517 CHECK_EQ(v8_str("netto"), netto); |
| 2488 } | 2518 } |
| 2489 | 2519 |
| 2490 | 2520 |
| 2491 THREADED_TEST(FunctionPrototype) { | 2521 THREADED_TEST(FunctionPrototype) { |
| 2492 v8::HandleScope scope(CcTest::isolate()); | 2522 v8::Isolate* isolate = CcTest::isolate(); |
| 2493 Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New(); | 2523 v8::HandleScope scope(isolate); |
| 2524 Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New(isolate); |
| 2494 Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321)); | 2525 Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321)); |
| 2495 LocalContext env; | 2526 LocalContext env; |
| 2496 env->Global()->Set(v8_str("Foo"), Foo->GetFunction()); | 2527 env->Global()->Set(v8_str("Foo"), Foo->GetFunction()); |
| 2497 Local<Script> script = Script::Compile(v8_str("Foo.prototype.plak")); | 2528 Local<Script> script = Script::Compile(v8_str("Foo.prototype.plak")); |
| 2498 CHECK_EQ(script->Run()->Int32Value(), 321); | 2529 CHECK_EQ(script->Run()->Int32Value(), 321); |
| 2499 } | 2530 } |
| 2500 | 2531 |
| 2501 | 2532 |
| 2502 THREADED_TEST(InternalFields) { | 2533 THREADED_TEST(InternalFields) { |
| 2503 LocalContext env; | 2534 LocalContext env; |
| 2504 v8::HandleScope scope(env->GetIsolate()); | 2535 v8::Isolate* isolate = env->GetIsolate(); |
| 2536 v8::HandleScope scope(isolate); |
| 2505 | 2537 |
| 2506 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 2538 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 2507 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); | 2539 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
| 2508 instance_templ->SetInternalFieldCount(1); | 2540 instance_templ->SetInternalFieldCount(1); |
| 2509 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); | 2541 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); |
| 2510 CHECK_EQ(1, obj->InternalFieldCount()); | 2542 CHECK_EQ(1, obj->InternalFieldCount()); |
| 2511 CHECK(obj->GetInternalField(0)->IsUndefined()); | 2543 CHECK(obj->GetInternalField(0)->IsUndefined()); |
| 2512 obj->SetInternalField(0, v8_num(17)); | 2544 obj->SetInternalField(0, v8_num(17)); |
| 2513 CHECK_EQ(17, obj->GetInternalField(0)->Int32Value()); | 2545 CHECK_EQ(17, obj->GetInternalField(0)->Int32Value()); |
| 2514 } | 2546 } |
| 2515 | 2547 |
| 2516 | 2548 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2542 void* value) { | 2574 void* value) { |
| 2543 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); | 2575 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); |
| 2544 obj->SetAlignedPointerInInternalField(0, value); | 2576 obj->SetAlignedPointerInInternalField(0, value); |
| 2545 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2577 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2546 CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0)); | 2578 CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0)); |
| 2547 } | 2579 } |
| 2548 | 2580 |
| 2549 | 2581 |
| 2550 THREADED_TEST(InternalFieldsAlignedPointers) { | 2582 THREADED_TEST(InternalFieldsAlignedPointers) { |
| 2551 LocalContext env; | 2583 LocalContext env; |
| 2552 v8::HandleScope scope(env->GetIsolate()); | 2584 v8::Isolate* isolate = env->GetIsolate(); |
| 2585 v8::HandleScope scope(isolate); |
| 2553 | 2586 |
| 2554 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 2587 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 2555 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); | 2588 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
| 2556 instance_templ->SetInternalFieldCount(1); | 2589 instance_templ->SetInternalFieldCount(1); |
| 2557 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); | 2590 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); |
| 2558 CHECK_EQ(1, obj->InternalFieldCount()); | 2591 CHECK_EQ(1, obj->InternalFieldCount()); |
| 2559 | 2592 |
| 2560 CheckAlignedPointerInInternalField(obj, NULL); | 2593 CheckAlignedPointerInInternalField(obj, NULL); |
| 2561 | 2594 |
| 2562 int* heap_allocated = new int[100]; | 2595 int* heap_allocated = new int[100]; |
| 2563 CheckAlignedPointerInInternalField(obj, heap_allocated); | 2596 CheckAlignedPointerInInternalField(obj, heap_allocated); |
| 2564 delete[] heap_allocated; | 2597 delete[] heap_allocated; |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3173 | 3206 |
| 3174 static bool interceptor_for_hidden_properties_called; | 3207 static bool interceptor_for_hidden_properties_called; |
| 3175 static void InterceptorForHiddenProperties( | 3208 static void InterceptorForHiddenProperties( |
| 3176 Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 3209 Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 3177 interceptor_for_hidden_properties_called = true; | 3210 interceptor_for_hidden_properties_called = true; |
| 3178 } | 3211 } |
| 3179 | 3212 |
| 3180 | 3213 |
| 3181 THREADED_TEST(HiddenPropertiesWithInterceptors) { | 3214 THREADED_TEST(HiddenPropertiesWithInterceptors) { |
| 3182 LocalContext context; | 3215 LocalContext context; |
| 3183 v8::HandleScope scope(context->GetIsolate()); | 3216 v8::Isolate* isolate = context->GetIsolate(); |
| 3217 v8::HandleScope scope(isolate); |
| 3184 | 3218 |
| 3185 interceptor_for_hidden_properties_called = false; | 3219 interceptor_for_hidden_properties_called = false; |
| 3186 | 3220 |
| 3187 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 3221 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
| 3188 | 3222 |
| 3189 // Associate an interceptor with an object and start setting hidden values. | 3223 // Associate an interceptor with an object and start setting hidden values. |
| 3190 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 3224 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate); |
| 3191 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); | 3225 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); |
| 3192 instance_templ->SetNamedPropertyHandler(InterceptorForHiddenProperties); | 3226 instance_templ->SetNamedPropertyHandler(InterceptorForHiddenProperties); |
| 3193 Local<v8::Function> function = fun_templ->GetFunction(); | 3227 Local<v8::Function> function = fun_templ->GetFunction(); |
| 3194 Local<v8::Object> obj = function->NewInstance(); | 3228 Local<v8::Object> obj = function->NewInstance(); |
| 3195 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302))); | 3229 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302))); |
| 3196 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); | 3230 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); |
| 3197 CHECK(!interceptor_for_hidden_properties_called); | 3231 CHECK(!interceptor_for_hidden_properties_called); |
| 3198 } | 3232 } |
| 3199 | 3233 |
| 3200 | 3234 |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4191 v8::EscapableHandleScope scope(args.GetIsolate()); | 4225 v8::EscapableHandleScope scope(args.GetIsolate()); |
| 4192 ApiTestFuzzer::Fuzz(); | 4226 ApiTestFuzzer::Fuzz(); |
| 4193 Local<v8::Array> result = v8::Array::New(args.GetIsolate(), args.Length()); | 4227 Local<v8::Array> result = v8::Array::New(args.GetIsolate(), args.Length()); |
| 4194 for (int i = 0; i < args.Length(); i++) | 4228 for (int i = 0; i < args.Length(); i++) |
| 4195 result->Set(i, args[i]); | 4229 result->Set(i, args[i]); |
| 4196 args.GetReturnValue().Set(scope.Escape(result)); | 4230 args.GetReturnValue().Set(scope.Escape(result)); |
| 4197 } | 4231 } |
| 4198 | 4232 |
| 4199 | 4233 |
| 4200 THREADED_TEST(Vector) { | 4234 THREADED_TEST(Vector) { |
| 4201 v8::HandleScope scope(CcTest::isolate()); | 4235 v8::Isolate* isolate = CcTest::isolate(); |
| 4236 v8::HandleScope scope(isolate); |
| 4202 Local<ObjectTemplate> global = ObjectTemplate::New(); | 4237 Local<ObjectTemplate> global = ObjectTemplate::New(); |
| 4203 global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF)); | 4238 global->Set(v8_str("f"), v8::FunctionTemplate::New(isolate, HandleF)); |
| 4204 LocalContext context(0, global); | 4239 LocalContext context(0, global); |
| 4205 | 4240 |
| 4206 const char* fun = "f()"; | 4241 const char* fun = "f()"; |
| 4207 Local<v8::Array> a0 = CompileRun(fun).As<v8::Array>(); | 4242 Local<v8::Array> a0 = CompileRun(fun).As<v8::Array>(); |
| 4208 CHECK_EQ(0, a0->Length()); | 4243 CHECK_EQ(0, a0->Length()); |
| 4209 | 4244 |
| 4210 const char* fun2 = "f(11)"; | 4245 const char* fun2 = "f(11)"; |
| 4211 Local<v8::Array> a1 = CompileRun(fun2).As<v8::Array>(); | 4246 Local<v8::Array> a1 = CompileRun(fun2).As<v8::Array>(); |
| 4212 CHECK_EQ(1, a1->Length()); | 4247 CHECK_EQ(1, a1->Length()); |
| 4213 CHECK_EQ(11, a1->Get(0)->Int32Value()); | 4248 CHECK_EQ(11, a1->Get(0)->Int32Value()); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4377 // Set heap limits. | 4412 // Set heap limits. |
| 4378 static const int K = 1024; | 4413 static const int K = 1024; |
| 4379 v8::ResourceConstraints constraints; | 4414 v8::ResourceConstraints constraints; |
| 4380 constraints.set_max_young_space_size(256 * K); | 4415 constraints.set_max_young_space_size(256 * K); |
| 4381 constraints.set_max_old_space_size(5 * K * K); | 4416 constraints.set_max_old_space_size(5 * K * K); |
| 4382 v8::SetResourceConstraints(CcTest::isolate(), &constraints); | 4417 v8::SetResourceConstraints(CcTest::isolate(), &constraints); |
| 4383 | 4418 |
| 4384 v8::HandleScope scope(CcTest::isolate()); | 4419 v8::HandleScope scope(CcTest::isolate()); |
| 4385 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4420 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4386 templ->Set(v8_str("ProvokeOutOfMemory"), | 4421 templ->Set(v8_str("ProvokeOutOfMemory"), |
| 4387 v8::FunctionTemplate::New(ProvokeOutOfMemory)); | 4422 v8::FunctionTemplate::New(CcTest::isolate(), ProvokeOutOfMemory)); |
| 4388 LocalContext context(0, templ); | 4423 LocalContext context(0, templ); |
| 4389 v8::V8::IgnoreOutOfMemoryException(); | 4424 v8::V8::IgnoreOutOfMemoryException(); |
| 4390 Local<Value> result = CompileRun( | 4425 Local<Value> result = CompileRun( |
| 4391 "var thrown = false;" | 4426 "var thrown = false;" |
| 4392 "try {" | 4427 "try {" |
| 4393 " ProvokeOutOfMemory();" | 4428 " ProvokeOutOfMemory();" |
| 4394 "} catch (e) {" | 4429 "} catch (e) {" |
| 4395 " thrown = true;" | 4430 " thrown = true;" |
| 4396 "}"); | 4431 "}"); |
| 4397 // Check for out of memory state. | 4432 // Check for out of memory state. |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4657 Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run(); | 4692 Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run(); |
| 4658 CHECK(!try_catch.HasCaught() || result.IsEmpty()); | 4693 CHECK(!try_catch.HasCaught() || result.IsEmpty()); |
| 4659 args.GetReturnValue().Set(try_catch.HasCaught()); | 4694 args.GetReturnValue().Set(try_catch.HasCaught()); |
| 4660 } | 4695 } |
| 4661 | 4696 |
| 4662 | 4697 |
| 4663 THREADED_TEST(APICatch) { | 4698 THREADED_TEST(APICatch) { |
| 4664 v8::HandleScope scope(CcTest::isolate()); | 4699 v8::HandleScope scope(CcTest::isolate()); |
| 4665 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4700 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4666 templ->Set(v8_str("ThrowFromC"), | 4701 templ->Set(v8_str("ThrowFromC"), |
| 4667 v8::FunctionTemplate::New(ThrowFromC)); | 4702 v8::FunctionTemplate::New(CcTest::isolate(), ThrowFromC)); |
| 4668 LocalContext context(0, templ); | 4703 LocalContext context(0, templ); |
| 4669 CompileRun( | 4704 CompileRun( |
| 4670 "var thrown = false;" | 4705 "var thrown = false;" |
| 4671 "try {" | 4706 "try {" |
| 4672 " ThrowFromC();" | 4707 " ThrowFromC();" |
| 4673 "} catch (e) {" | 4708 "} catch (e) {" |
| 4674 " thrown = true;" | 4709 " thrown = true;" |
| 4675 "}"); | 4710 "}"); |
| 4676 Local<Value> thrown = context->Global()->Get(v8_str("thrown")); | 4711 Local<Value> thrown = context->Global()->Get(v8_str("thrown")); |
| 4677 CHECK(thrown->BooleanValue()); | 4712 CHECK(thrown->BooleanValue()); |
| 4678 } | 4713 } |
| 4679 | 4714 |
| 4680 | 4715 |
| 4681 THREADED_TEST(APIThrowTryCatch) { | 4716 THREADED_TEST(APIThrowTryCatch) { |
| 4682 v8::HandleScope scope(CcTest::isolate()); | 4717 v8::HandleScope scope(CcTest::isolate()); |
| 4683 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4718 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4684 templ->Set(v8_str("ThrowFromC"), | 4719 templ->Set(v8_str("ThrowFromC"), |
| 4685 v8::FunctionTemplate::New(ThrowFromC)); | 4720 v8::FunctionTemplate::New(CcTest::isolate(), ThrowFromC)); |
| 4686 LocalContext context(0, templ); | 4721 LocalContext context(0, templ); |
| 4687 v8::TryCatch try_catch; | 4722 v8::TryCatch try_catch; |
| 4688 CompileRun("ThrowFromC();"); | 4723 CompileRun("ThrowFromC();"); |
| 4689 CHECK(try_catch.HasCaught()); | 4724 CHECK(try_catch.HasCaught()); |
| 4690 } | 4725 } |
| 4691 | 4726 |
| 4692 | 4727 |
| 4693 // Test that a try-finally block doesn't shadow a try-catch block | 4728 // Test that a try-finally block doesn't shadow a try-catch block |
| 4694 // when setting up an external handler. | 4729 // when setting up an external handler. |
| 4695 // | 4730 // |
| 4696 // BUG(271): Some of the exception propagation does not work on the | 4731 // BUG(271): Some of the exception propagation does not work on the |
| 4697 // ARM simulator because the simulator separates the C++ stack and the | 4732 // ARM simulator because the simulator separates the C++ stack and the |
| 4698 // JS stack. This test therefore fails on the simulator. The test is | 4733 // JS stack. This test therefore fails on the simulator. The test is |
| 4699 // not threaded to allow the threading tests to run on the simulator. | 4734 // not threaded to allow the threading tests to run on the simulator. |
| 4700 TEST(TryCatchInTryFinally) { | 4735 TEST(TryCatchInTryFinally) { |
| 4701 v8::HandleScope scope(CcTest::isolate()); | 4736 v8::HandleScope scope(CcTest::isolate()); |
| 4702 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4737 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4703 templ->Set(v8_str("CCatcher"), | 4738 templ->Set(v8_str("CCatcher"), |
| 4704 v8::FunctionTemplate::New(CCatcher)); | 4739 v8::FunctionTemplate::New(CcTest::isolate(), CCatcher)); |
| 4705 LocalContext context(0, templ); | 4740 LocalContext context(0, templ); |
| 4706 Local<Value> result = CompileRun("try {" | 4741 Local<Value> result = CompileRun("try {" |
| 4707 " try {" | 4742 " try {" |
| 4708 " CCatcher('throw 7;');" | 4743 " CCatcher('throw 7;');" |
| 4709 " } finally {" | 4744 " } finally {" |
| 4710 " }" | 4745 " }" |
| 4711 "} catch (e) {" | 4746 "} catch (e) {" |
| 4712 "}"); | 4747 "}"); |
| 4713 CHECK(result->IsTrue()); | 4748 CHECK(result->IsTrue()); |
| 4714 } | 4749 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4725 static void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4760 static void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4726 ApiTestFuzzer::Fuzz(); | 4761 ApiTestFuzzer::Fuzz(); |
| 4727 CHECK(false); | 4762 CHECK(false); |
| 4728 } | 4763 } |
| 4729 | 4764 |
| 4730 | 4765 |
| 4731 // Test that overwritten methods are not invoked on uncaught exception | 4766 // Test that overwritten methods are not invoked on uncaught exception |
| 4732 // formatting. However, they are invoked when performing normal error | 4767 // formatting. However, they are invoked when performing normal error |
| 4733 // string conversions. | 4768 // string conversions. |
| 4734 TEST(APIThrowMessageOverwrittenToString) { | 4769 TEST(APIThrowMessageOverwrittenToString) { |
| 4735 v8::HandleScope scope(CcTest::isolate()); | 4770 v8::Isolate* isolate = CcTest::isolate(); |
| 4771 v8::HandleScope scope(isolate); |
| 4736 v8::V8::AddMessageListener(check_reference_error_message); | 4772 v8::V8::AddMessageListener(check_reference_error_message); |
| 4737 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4773 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4738 templ->Set(v8_str("fail"), v8::FunctionTemplate::New(Fail)); | 4774 templ->Set(v8_str("fail"), v8::FunctionTemplate::New(isolate, Fail)); |
| 4739 LocalContext context(NULL, templ); | 4775 LocalContext context(NULL, templ); |
| 4740 CompileRun("asdf;"); | 4776 CompileRun("asdf;"); |
| 4741 CompileRun("var limit = {};" | 4777 CompileRun("var limit = {};" |
| 4742 "limit.valueOf = fail;" | 4778 "limit.valueOf = fail;" |
| 4743 "Error.stackTraceLimit = limit;"); | 4779 "Error.stackTraceLimit = limit;"); |
| 4744 CompileRun("asdf"); | 4780 CompileRun("asdf"); |
| 4745 CompileRun("Array.prototype.pop = fail;"); | 4781 CompileRun("Array.prototype.pop = fail;"); |
| 4746 CompileRun("Object.prototype.hasOwnProperty = fail;"); | 4782 CompileRun("Object.prototype.hasOwnProperty = fail;"); |
| 4747 CompileRun("Object.prototype.toString = function f() { return 'Yikes'; }"); | 4783 CompileRun("Object.prototype.toString = function f() { return 'Yikes'; }"); |
| 4748 CompileRun("Number.prototype.toString = function f() { return 'Yikes'; }"); | 4784 CompileRun("Number.prototype.toString = function f() { return 'Yikes'; }"); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4853 message_received = true; | 4889 message_received = true; |
| 4854 } | 4890 } |
| 4855 | 4891 |
| 4856 | 4892 |
| 4857 TEST(APIThrowMessage) { | 4893 TEST(APIThrowMessage) { |
| 4858 message_received = false; | 4894 message_received = false; |
| 4859 v8::HandleScope scope(CcTest::isolate()); | 4895 v8::HandleScope scope(CcTest::isolate()); |
| 4860 v8::V8::AddMessageListener(receive_message); | 4896 v8::V8::AddMessageListener(receive_message); |
| 4861 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4897 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4862 templ->Set(v8_str("ThrowFromC"), | 4898 templ->Set(v8_str("ThrowFromC"), |
| 4863 v8::FunctionTemplate::New(ThrowFromC)); | 4899 v8::FunctionTemplate::New(CcTest::isolate(), ThrowFromC)); |
| 4864 LocalContext context(0, templ); | 4900 LocalContext context(0, templ); |
| 4865 CompileRun("ThrowFromC();"); | 4901 CompileRun("ThrowFromC();"); |
| 4866 CHECK(message_received); | 4902 CHECK(message_received); |
| 4867 v8::V8::RemoveMessageListeners(receive_message); | 4903 v8::V8::RemoveMessageListeners(receive_message); |
| 4868 } | 4904 } |
| 4869 | 4905 |
| 4870 | 4906 |
| 4871 TEST(APIThrowMessageAndVerboseTryCatch) { | 4907 TEST(APIThrowMessageAndVerboseTryCatch) { |
| 4872 message_received = false; | 4908 message_received = false; |
| 4873 v8::HandleScope scope(CcTest::isolate()); | 4909 v8::HandleScope scope(CcTest::isolate()); |
| 4874 v8::V8::AddMessageListener(receive_message); | 4910 v8::V8::AddMessageListener(receive_message); |
| 4875 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4911 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4876 templ->Set(v8_str("ThrowFromC"), | 4912 templ->Set(v8_str("ThrowFromC"), |
| 4877 v8::FunctionTemplate::New(ThrowFromC)); | 4913 v8::FunctionTemplate::New(CcTest::isolate(), ThrowFromC)); |
| 4878 LocalContext context(0, templ); | 4914 LocalContext context(0, templ); |
| 4879 v8::TryCatch try_catch; | 4915 v8::TryCatch try_catch; |
| 4880 try_catch.SetVerbose(true); | 4916 try_catch.SetVerbose(true); |
| 4881 Local<Value> result = CompileRun("ThrowFromC();"); | 4917 Local<Value> result = CompileRun("ThrowFromC();"); |
| 4882 CHECK(try_catch.HasCaught()); | 4918 CHECK(try_catch.HasCaught()); |
| 4883 CHECK(result.IsEmpty()); | 4919 CHECK(result.IsEmpty()); |
| 4884 CHECK(message_received); | 4920 CHECK(message_received); |
| 4885 v8::V8::RemoveMessageListeners(receive_message); | 4921 v8::V8::RemoveMessageListeners(receive_message); |
| 4886 } | 4922 } |
| 4887 | 4923 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4898 CHECK(result.IsEmpty()); | 4934 CHECK(result.IsEmpty()); |
| 4899 CHECK(message_received); | 4935 CHECK(message_received); |
| 4900 v8::V8::RemoveMessageListeners(receive_message); | 4936 v8::V8::RemoveMessageListeners(receive_message); |
| 4901 } | 4937 } |
| 4902 | 4938 |
| 4903 | 4939 |
| 4904 THREADED_TEST(ExternalScriptException) { | 4940 THREADED_TEST(ExternalScriptException) { |
| 4905 v8::HandleScope scope(CcTest::isolate()); | 4941 v8::HandleScope scope(CcTest::isolate()); |
| 4906 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4942 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4907 templ->Set(v8_str("ThrowFromC"), | 4943 templ->Set(v8_str("ThrowFromC"), |
| 4908 v8::FunctionTemplate::New(ThrowFromC)); | 4944 v8::FunctionTemplate::New(CcTest::isolate(), ThrowFromC)); |
| 4909 LocalContext context(0, templ); | 4945 LocalContext context(0, templ); |
| 4910 | 4946 |
| 4911 v8::TryCatch try_catch; | 4947 v8::TryCatch try_catch; |
| 4912 Local<Script> script | 4948 Local<Script> script |
| 4913 = Script::Compile(v8_str("ThrowFromC(); throw 'panama';")); | 4949 = Script::Compile(v8_str("ThrowFromC(); throw 'panama';")); |
| 4914 Local<Value> result = script->Run(); | 4950 Local<Value> result = script->Run(); |
| 4915 CHECK(result.IsEmpty()); | 4951 CHECK(result.IsEmpty()); |
| 4916 CHECK(try_catch.HasCaught()); | 4952 CHECK(try_catch.HasCaught()); |
| 4917 String::Utf8Value exception_value(try_catch.Exception()); | 4953 String::Utf8Value exception_value(try_catch.Exception()); |
| 4918 CHECK_EQ("konto", *exception_value); | 4954 CHECK_EQ("konto", *exception_value); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5000 // | 5036 // |
| 5001 // Each entry is an activation, either JS or C. The index is the count at that | 5037 // Each entry is an activation, either JS or C. The index is the count at that |
| 5002 // level. Stars identify activations with exception handlers, the @ identifies | 5038 // level. Stars identify activations with exception handlers, the @ identifies |
| 5003 // the exception handler that should catch the exception. | 5039 // the exception handler that should catch the exception. |
| 5004 // | 5040 // |
| 5005 // BUG(271): Some of the exception propagation does not work on the | 5041 // BUG(271): Some of the exception propagation does not work on the |
| 5006 // ARM simulator because the simulator separates the C++ stack and the | 5042 // ARM simulator because the simulator separates the C++ stack and the |
| 5007 // JS stack. This test therefore fails on the simulator. The test is | 5043 // JS stack. This test therefore fails on the simulator. The test is |
| 5008 // not threaded to allow the threading tests to run on the simulator. | 5044 // not threaded to allow the threading tests to run on the simulator. |
| 5009 TEST(ExceptionOrder) { | 5045 TEST(ExceptionOrder) { |
| 5010 v8::HandleScope scope(CcTest::isolate()); | 5046 v8::Isolate* isolate = CcTest::isolate(); |
| 5047 v8::HandleScope scope(isolate); |
| 5011 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5048 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5012 templ->Set(v8_str("check"), v8::FunctionTemplate::New(JSCheck)); | 5049 templ->Set(v8_str("check"), v8::FunctionTemplate::New(isolate, JSCheck)); |
| 5013 templ->Set(v8_str("CThrowCountDown"), | 5050 templ->Set(v8_str("CThrowCountDown"), |
| 5014 v8::FunctionTemplate::New(CThrowCountDown)); | 5051 v8::FunctionTemplate::New(isolate, CThrowCountDown)); |
| 5015 LocalContext context(0, templ); | 5052 LocalContext context(0, templ); |
| 5016 CompileRun( | 5053 CompileRun( |
| 5017 "function JSThrowCountDown(count, jsInterval, cInterval, expected) {" | 5054 "function JSThrowCountDown(count, jsInterval, cInterval, expected) {" |
| 5018 " if (count == 0) throw 'FromJS';" | 5055 " if (count == 0) throw 'FromJS';" |
| 5019 " if (count % jsInterval == 0) {" | 5056 " if (count % jsInterval == 0) {" |
| 5020 " try {" | 5057 " try {" |
| 5021 " var value = CThrowCountDown(count - 1," | 5058 " var value = CThrowCountDown(count - 1," |
| 5022 " jsInterval," | 5059 " jsInterval," |
| 5023 " cInterval," | 5060 " cInterval," |
| 5024 " expected);" | 5061 " expected);" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5064 | 5101 |
| 5065 | 5102 |
| 5066 void ThrowValue(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5103 void ThrowValue(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 5067 ApiTestFuzzer::Fuzz(); | 5104 ApiTestFuzzer::Fuzz(); |
| 5068 CHECK_EQ(1, args.Length()); | 5105 CHECK_EQ(1, args.Length()); |
| 5069 args.GetIsolate()->ThrowException(args[0]); | 5106 args.GetIsolate()->ThrowException(args[0]); |
| 5070 } | 5107 } |
| 5071 | 5108 |
| 5072 | 5109 |
| 5073 THREADED_TEST(ThrowValues) { | 5110 THREADED_TEST(ThrowValues) { |
| 5074 v8::HandleScope scope(CcTest::isolate()); | 5111 v8::Isolate* isolate = CcTest::isolate(); |
| 5112 v8::HandleScope scope(isolate); |
| 5075 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5113 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5076 templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(ThrowValue)); | 5114 templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(isolate, ThrowValue)); |
| 5077 LocalContext context(0, templ); | 5115 LocalContext context(0, templ); |
| 5078 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 5116 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
| 5079 "function Run(obj) {" | 5117 "function Run(obj) {" |
| 5080 " try {" | 5118 " try {" |
| 5081 " Throw(obj);" | 5119 " Throw(obj);" |
| 5082 " } catch (e) {" | 5120 " } catch (e) {" |
| 5083 " return e;" | 5121 " return e;" |
| 5084 " }" | 5122 " }" |
| 5085 " return 'no exception';" | 5123 " return 'no exception';" |
| 5086 "}" | 5124 "}" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5133 } | 5171 } |
| 5134 | 5172 |
| 5135 | 5173 |
| 5136 void WithTryCatch(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5174 void WithTryCatch(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 5137 v8::TryCatch try_catch; | 5175 v8::TryCatch try_catch; |
| 5138 } | 5176 } |
| 5139 | 5177 |
| 5140 | 5178 |
| 5141 THREADED_TEST(TryCatchAndFinally) { | 5179 THREADED_TEST(TryCatchAndFinally) { |
| 5142 LocalContext context; | 5180 LocalContext context; |
| 5143 v8::HandleScope scope(context->GetIsolate()); | 5181 v8::Isolate* isolate = context->GetIsolate(); |
| 5182 v8::HandleScope scope(isolate); |
| 5144 context->Global()->Set( | 5183 context->Global()->Set( |
| 5145 v8_str("native_with_try_catch"), | 5184 v8_str("native_with_try_catch"), |
| 5146 v8::FunctionTemplate::New(WithTryCatch)->GetFunction()); | 5185 v8::FunctionTemplate::New(isolate, WithTryCatch)->GetFunction()); |
| 5147 v8::TryCatch try_catch; | 5186 v8::TryCatch try_catch; |
| 5148 CHECK(!try_catch.HasCaught()); | 5187 CHECK(!try_catch.HasCaught()); |
| 5149 CompileRun( | 5188 CompileRun( |
| 5150 "try {\n" | 5189 "try {\n" |
| 5151 " throw new Error('a');\n" | 5190 " throw new Error('a');\n" |
| 5152 "} finally {\n" | 5191 "} finally {\n" |
| 5153 " native_with_try_catch();\n" | 5192 " native_with_try_catch();\n" |
| 5154 "}\n"); | 5193 "}\n"); |
| 5155 CHECK(try_catch.HasCaught()); | 5194 CHECK(try_catch.HasCaught()); |
| 5156 } | 5195 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5202 try_catch.ReThrow(); | 5241 try_catch.ReThrow(); |
| 5203 } | 5242 } |
| 5204 | 5243 |
| 5205 | 5244 |
| 5206 // This test ensures that an outer TryCatch in the following situation: | 5245 // This test ensures that an outer TryCatch in the following situation: |
| 5207 // C++/TryCatch -> JS -> C++/TryCatch -> JS w/ SyntaxError | 5246 // C++/TryCatch -> JS -> C++/TryCatch -> JS w/ SyntaxError |
| 5208 // does not clobber the Message object generated for the inner TryCatch. | 5247 // does not clobber the Message object generated for the inner TryCatch. |
| 5209 // This exercises the ability of TryCatch.ReThrow() to restore the | 5248 // This exercises the ability of TryCatch.ReThrow() to restore the |
| 5210 // inner pending Message before throwing the exception again. | 5249 // inner pending Message before throwing the exception again. |
| 5211 TEST(TryCatchMixedNesting) { | 5250 TEST(TryCatchMixedNesting) { |
| 5212 v8::HandleScope scope(CcTest::isolate()); | 5251 v8::Isolate* isolate = CcTest::isolate(); |
| 5252 v8::HandleScope scope(isolate); |
| 5213 v8::V8::Initialize(); | 5253 v8::V8::Initialize(); |
| 5214 v8::TryCatch try_catch; | 5254 v8::TryCatch try_catch; |
| 5215 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5255 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5216 templ->Set(v8_str("TryCatchMixedNestingHelper"), | 5256 templ->Set(v8_str("TryCatchMixedNestingHelper"), |
| 5217 v8::FunctionTemplate::New(TryCatchMixedNestingHelper)); | 5257 v8::FunctionTemplate::New(isolate, TryCatchMixedNestingHelper)); |
| 5218 LocalContext context(0, templ); | 5258 LocalContext context(0, templ); |
| 5219 CompileRunWithOrigin("TryCatchMixedNestingHelper();\n", "outer", 1, 1); | 5259 CompileRunWithOrigin("TryCatchMixedNestingHelper();\n", "outer", 1, 1); |
| 5220 TryCatchMixedNestingCheck(&try_catch); | 5260 TryCatchMixedNestingCheck(&try_catch); |
| 5221 } | 5261 } |
| 5222 | 5262 |
| 5223 | 5263 |
| 5224 THREADED_TEST(Equality) { | 5264 THREADED_TEST(Equality) { |
| 5225 LocalContext context; | 5265 LocalContext context; |
| 5226 v8::Isolate* isolate = context->GetIsolate(); | 5266 v8::Isolate* isolate = context->GetIsolate(); |
| 5227 v8::HandleScope scope(context->GetIsolate()); | 5267 v8::HandleScope scope(context->GetIsolate()); |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5710 const v8::PropertyCallbackInfo<v8::Value>& info) { | 5750 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5711 // Set x on the prototype object and do not handle the get request. | 5751 // Set x on the prototype object and do not handle the get request. |
| 5712 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); | 5752 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); |
| 5713 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); | 5753 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); |
| 5714 } | 5754 } |
| 5715 | 5755 |
| 5716 | 5756 |
| 5717 // This is a regression test for http://crbug.com/20104. Map | 5757 // This is a regression test for http://crbug.com/20104. Map |
| 5718 // transitions should not interfere with post interceptor lookup. | 5758 // transitions should not interfere with post interceptor lookup. |
| 5719 THREADED_TEST(NamedInterceptorMapTransitionRead) { | 5759 THREADED_TEST(NamedInterceptorMapTransitionRead) { |
| 5720 v8::HandleScope scope(CcTest::isolate()); | 5760 v8::Isolate* isolate = CcTest::isolate(); |
| 5721 Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New(); | 5761 v8::HandleScope scope(isolate); |
| 5762 Local<v8::FunctionTemplate> function_template = |
| 5763 v8::FunctionTemplate::New(isolate); |
| 5722 Local<v8::ObjectTemplate> instance_template | 5764 Local<v8::ObjectTemplate> instance_template |
| 5723 = function_template->InstanceTemplate(); | 5765 = function_template->InstanceTemplate(); |
| 5724 instance_template->SetNamedPropertyHandler(SetXOnPrototypeGetter); | 5766 instance_template->SetNamedPropertyHandler(SetXOnPrototypeGetter); |
| 5725 LocalContext context; | 5767 LocalContext context; |
| 5726 context->Global()->Set(v8_str("F"), function_template->GetFunction()); | 5768 context->Global()->Set(v8_str("F"), function_template->GetFunction()); |
| 5727 // Create an instance of F and introduce a map transition for x. | 5769 // Create an instance of F and introduce a map transition for x. |
| 5728 CompileRun("var o = new F(); o.x = 23;"); | 5770 CompileRun("var o = new F(); o.x = 23;"); |
| 5729 // Create an instance of F and invoke the getter. The result should be 23. | 5771 // Create an instance of F and invoke the getter. The result should be 23. |
| 5730 Local<Value> result = CompileRun("o = new F(); o.x"); | 5772 Local<Value> result = CompileRun("o = new F(); o.x"); |
| 5731 CHECK_EQ(result->Int32Value(), 23); | 5773 CHECK_EQ(result->Int32Value(), 23); |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6167 " }" | 6209 " }" |
| 6168 " 'PASSED'" | 6210 " 'PASSED'" |
| 6169 "} catch(e) {" | 6211 "} catch(e) {" |
| 6170 " e" | 6212 " e" |
| 6171 "}"; | 6213 "}"; |
| 6172 ExpectString(code, "PASSED"); | 6214 ExpectString(code, "PASSED"); |
| 6173 } | 6215 } |
| 6174 | 6216 |
| 6175 | 6217 |
| 6176 THREADED_TEST(MultiContexts) { | 6218 THREADED_TEST(MultiContexts) { |
| 6177 v8::HandleScope scope(CcTest::isolate()); | 6219 v8::Isolate* isolate = CcTest::isolate(); |
| 6220 v8::HandleScope scope(isolate); |
| 6178 v8::Handle<ObjectTemplate> templ = ObjectTemplate::New(); | 6221 v8::Handle<ObjectTemplate> templ = ObjectTemplate::New(); |
| 6179 templ->Set(v8_str("dummy"), v8::FunctionTemplate::New(DummyCallHandler)); | 6222 templ->Set(v8_str("dummy"), v8::FunctionTemplate::New(isolate, |
| 6223 DummyCallHandler)); |
| 6180 | 6224 |
| 6181 Local<String> password = v8_str("Password"); | 6225 Local<String> password = v8_str("Password"); |
| 6182 | 6226 |
| 6183 // Create an environment | 6227 // Create an environment |
| 6184 LocalContext context0(0, templ); | 6228 LocalContext context0(0, templ); |
| 6185 context0->SetSecurityToken(password); | 6229 context0->SetSecurityToken(password); |
| 6186 v8::Handle<v8::Object> global0 = context0->Global(); | 6230 v8::Handle<v8::Object> global0 = context0->Global(); |
| 6187 global0->Set(v8_str("custom"), v8_num(1234)); | 6231 global0->Set(v8_str("custom"), v8_num(1234)); |
| 6188 CHECK_EQ(1234, global0->Get(v8_str("custom"))->Int32Value()); | 6232 CHECK_EQ(1234, global0->Get(v8_str("custom"))->Int32Value()); |
| 6189 | 6233 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6256 LocalContext env1; | 6300 LocalContext env1; |
| 6257 Local<Script> script1 = Script::Compile(source); | 6301 Local<Script> script1 = Script::Compile(source); |
| 6258 CHECK_EQ(8901.0, script1->Run()->NumberValue()); | 6302 CHECK_EQ(8901.0, script1->Run()->NumberValue()); |
| 6259 } | 6303 } |
| 6260 | 6304 |
| 6261 | 6305 |
| 6262 THREADED_TEST(UndetectableObject) { | 6306 THREADED_TEST(UndetectableObject) { |
| 6263 LocalContext env; | 6307 LocalContext env; |
| 6264 v8::HandleScope scope(env->GetIsolate()); | 6308 v8::HandleScope scope(env->GetIsolate()); |
| 6265 | 6309 |
| 6266 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); | 6310 Local<v8::FunctionTemplate> desc = |
| 6311 v8::FunctionTemplate::New(env->GetIsolate()); |
| 6267 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable | 6312 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable |
| 6268 | 6313 |
| 6269 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); | 6314 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); |
| 6270 env->Global()->Set(v8_str("undetectable"), obj); | 6315 env->Global()->Set(v8_str("undetectable"), obj); |
| 6271 | 6316 |
| 6272 ExpectString("undetectable.toString()", "[object Object]"); | 6317 ExpectString("undetectable.toString()", "[object Object]"); |
| 6273 ExpectString("typeof undetectable", "undefined"); | 6318 ExpectString("typeof undetectable", "undefined"); |
| 6274 ExpectString("typeof(undetectable)", "undefined"); | 6319 ExpectString("typeof(undetectable)", "undefined"); |
| 6275 ExpectBoolean("typeof undetectable == 'undefined'", true); | 6320 ExpectBoolean("typeof undetectable == 'undefined'", true); |
| 6276 ExpectBoolean("typeof undetectable == 'object'", false); | 6321 ExpectBoolean("typeof undetectable == 'object'", false); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6297 ExpectBoolean("undetectable===null", false); | 6342 ExpectBoolean("undetectable===null", false); |
| 6298 ExpectBoolean("null===undetectable", false); | 6343 ExpectBoolean("null===undetectable", false); |
| 6299 ExpectBoolean("undetectable===undefined", false); | 6344 ExpectBoolean("undetectable===undefined", false); |
| 6300 ExpectBoolean("undefined===undetectable", false); | 6345 ExpectBoolean("undefined===undetectable", false); |
| 6301 ExpectBoolean("undetectable===undetectable", true); | 6346 ExpectBoolean("undetectable===undetectable", true); |
| 6302 } | 6347 } |
| 6303 | 6348 |
| 6304 | 6349 |
| 6305 THREADED_TEST(VoidLiteral) { | 6350 THREADED_TEST(VoidLiteral) { |
| 6306 LocalContext env; | 6351 LocalContext env; |
| 6307 v8::HandleScope scope(env->GetIsolate()); | 6352 v8::Isolate* isolate = env->GetIsolate(); |
| 6353 v8::HandleScope scope(isolate); |
| 6308 | 6354 |
| 6309 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); | 6355 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate); |
| 6310 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable | 6356 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable |
| 6311 | 6357 |
| 6312 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); | 6358 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); |
| 6313 env->Global()->Set(v8_str("undetectable"), obj); | 6359 env->Global()->Set(v8_str("undetectable"), obj); |
| 6314 | 6360 |
| 6315 ExpectBoolean("undefined == void 0", true); | 6361 ExpectBoolean("undefined == void 0", true); |
| 6316 ExpectBoolean("undetectable == void 0", true); | 6362 ExpectBoolean("undetectable == void 0", true); |
| 6317 ExpectBoolean("null == void 0", true); | 6363 ExpectBoolean("null == void 0", true); |
| 6318 ExpectBoolean("undefined === void 0", true); | 6364 ExpectBoolean("undefined === void 0", true); |
| 6319 ExpectBoolean("undetectable === void 0", false); | 6365 ExpectBoolean("undetectable === void 0", false); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6340 " } catch(e) {" | 6386 " } catch(e) {" |
| 6341 " return e.toString();" | 6387 " return e.toString();" |
| 6342 " }" | 6388 " }" |
| 6343 "})()", | 6389 "})()", |
| 6344 "ReferenceError: x is not defined"); | 6390 "ReferenceError: x is not defined"); |
| 6345 } | 6391 } |
| 6346 | 6392 |
| 6347 | 6393 |
| 6348 THREADED_TEST(ExtensibleOnUndetectable) { | 6394 THREADED_TEST(ExtensibleOnUndetectable) { |
| 6349 LocalContext env; | 6395 LocalContext env; |
| 6350 v8::HandleScope scope(env->GetIsolate()); | 6396 v8::Isolate* isolate = env->GetIsolate(); |
| 6397 v8::HandleScope scope(isolate); |
| 6351 | 6398 |
| 6352 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); | 6399 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate); |
| 6353 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable | 6400 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable |
| 6354 | 6401 |
| 6355 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); | 6402 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); |
| 6356 env->Global()->Set(v8_str("undetectable"), obj); | 6403 env->Global()->Set(v8_str("undetectable"), obj); |
| 6357 | 6404 |
| 6358 Local<String> source = v8_str("undetectable.x = 42;" | 6405 Local<String> source = v8_str("undetectable.x = 42;" |
| 6359 "undetectable.x"); | 6406 "undetectable.x"); |
| 6360 | 6407 |
| 6361 Local<Script> script = Script::Compile(source); | 6408 Local<Script> script = Script::Compile(source); |
| 6362 | 6409 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6476 const v8::FunctionCallbackInfo<v8::Value>& args) { | 6523 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 6477 ApiTestFuzzer::Fuzz(); | 6524 ApiTestFuzzer::Fuzz(); |
| 6478 } | 6525 } |
| 6479 | 6526 |
| 6480 | 6527 |
| 6481 THREADED_TEST(GlobalObjectTemplate) { | 6528 THREADED_TEST(GlobalObjectTemplate) { |
| 6482 v8::Isolate* isolate = CcTest::isolate(); | 6529 v8::Isolate* isolate = CcTest::isolate(); |
| 6483 v8::HandleScope handle_scope(isolate); | 6530 v8::HandleScope handle_scope(isolate); |
| 6484 Local<ObjectTemplate> global_template = ObjectTemplate::New(); | 6531 Local<ObjectTemplate> global_template = ObjectTemplate::New(); |
| 6485 global_template->Set(v8_str("JSNI_Log"), | 6532 global_template->Set(v8_str("JSNI_Log"), |
| 6486 v8::FunctionTemplate::New(HandleLogDelegator)); | 6533 v8::FunctionTemplate::New(isolate, HandleLogDelegator)); |
| 6487 v8::Local<Context> context = Context::New(isolate, 0, global_template); | 6534 v8::Local<Context> context = Context::New(isolate, 0, global_template); |
| 6488 Context::Scope context_scope(context); | 6535 Context::Scope context_scope(context); |
| 6489 Script::Compile(v8_str("JSNI_Log('LOG')"))->Run(); | 6536 Script::Compile(v8_str("JSNI_Log('LOG')"))->Run(); |
| 6490 } | 6537 } |
| 6491 | 6538 |
| 6492 | 6539 |
| 6493 static const char* kSimpleExtensionSource = | 6540 static const char* kSimpleExtensionSource = |
| 6494 "function Foo() {" | 6541 "function Foo() {" |
| 6495 " return 4;" | 6542 " return 4;" |
| 6496 "}"; | 6543 "}"; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6709 public: | 6756 public: |
| 6710 NativeFunctionExtension(const char* name, | 6757 NativeFunctionExtension(const char* name, |
| 6711 const char* source, | 6758 const char* source, |
| 6712 v8::FunctionCallback fun = &Echo) | 6759 v8::FunctionCallback fun = &Echo) |
| 6713 : Extension(name, source), | 6760 : Extension(name, source), |
| 6714 function_(fun) { } | 6761 function_(fun) { } |
| 6715 | 6762 |
| 6716 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( | 6763 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 6717 v8::Isolate* isolate, | 6764 v8::Isolate* isolate, |
| 6718 v8::Handle<v8::String> name) { | 6765 v8::Handle<v8::String> name) { |
| 6719 return v8::FunctionTemplate::New(function_); | 6766 return v8::FunctionTemplate::New(isolate, function_); |
| 6720 } | 6767 } |
| 6721 | 6768 |
| 6722 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) { | 6769 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 6723 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]); | 6770 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]); |
| 6724 } | 6771 } |
| 6725 private: | 6772 private: |
| 6726 v8::FunctionCallback function_; | 6773 v8::FunctionCallback function_; |
| 6727 }; | 6774 }; |
| 6728 | 6775 |
| 6729 | 6776 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6839 v8::Isolate* isolate, | 6886 v8::Isolate* isolate, |
| 6840 v8::Handle<String> name); | 6887 v8::Handle<String> name); |
| 6841 }; | 6888 }; |
| 6842 | 6889 |
| 6843 | 6890 |
| 6844 static int lookup_count = 0; | 6891 static int lookup_count = 0; |
| 6845 v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate( | 6892 v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate( |
| 6846 v8::Isolate* isolate, v8::Handle<String> name) { | 6893 v8::Isolate* isolate, v8::Handle<String> name) { |
| 6847 lookup_count++; | 6894 lookup_count++; |
| 6848 if (name->Equals(v8_str("A"))) { | 6895 if (name->Equals(v8_str("A"))) { |
| 6849 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(8)); | 6896 return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(8)); |
| 6850 } else if (name->Equals(v8_str("B"))) { | 6897 } else if (name->Equals(v8_str("B"))) { |
| 6851 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(7)); | 6898 return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(7)); |
| 6852 } else if (name->Equals(v8_str("C"))) { | 6899 } else if (name->Equals(v8_str("C"))) { |
| 6853 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(6)); | 6900 return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(6)); |
| 6854 } else { | 6901 } else { |
| 6855 return v8::Handle<v8::FunctionTemplate>(); | 6902 return v8::Handle<v8::FunctionTemplate>(); |
| 6856 } | 6903 } |
| 6857 } | 6904 } |
| 6858 | 6905 |
| 6859 | 6906 |
| 6860 THREADED_TEST(FunctionLookup) { | 6907 THREADED_TEST(FunctionLookup) { |
| 6861 v8::RegisterExtension(new FunctionExtension()); | 6908 v8::RegisterExtension(new FunctionExtension()); |
| 6862 v8::HandleScope handle_scope(CcTest::isolate()); | 6909 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6863 static const char* exts[1] = { "functiontest" }; | 6910 static const char* exts[1] = { "functiontest" }; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7197 CHECK_EQ(v8::Integer::New(1, isolate), args[0]); | 7244 CHECK_EQ(v8::Integer::New(1, isolate), args[0]); |
| 7198 CHECK_EQ(v8::Integer::New(2, isolate), args[1]); | 7245 CHECK_EQ(v8::Integer::New(2, isolate), args[1]); |
| 7199 CHECK_EQ(v8::Integer::New(3, isolate), args[2]); | 7246 CHECK_EQ(v8::Integer::New(3, isolate), args[2]); |
| 7200 CHECK_EQ(v8::Undefined(isolate), args[3]); | 7247 CHECK_EQ(v8::Undefined(isolate), args[3]); |
| 7201 v8::HandleScope scope(args.GetIsolate()); | 7248 v8::HandleScope scope(args.GetIsolate()); |
| 7202 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 7249 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 7203 } | 7250 } |
| 7204 | 7251 |
| 7205 | 7252 |
| 7206 THREADED_TEST(Arguments) { | 7253 THREADED_TEST(Arguments) { |
| 7207 v8::HandleScope scope(CcTest::isolate()); | 7254 v8::Isolate* isolate = CcTest::isolate(); |
| 7255 v8::HandleScope scope(isolate); |
| 7208 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); | 7256 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
| 7209 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback)); | 7257 global->Set(v8_str("f"), |
| 7258 v8::FunctionTemplate::New(isolate, ArgumentsTestCallback)); |
| 7210 LocalContext context(NULL, global); | 7259 LocalContext context(NULL, global); |
| 7211 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); | 7260 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); |
| 7212 v8_compile("f(1, 2, 3)")->Run(); | 7261 v8_compile("f(1, 2, 3)")->Run(); |
| 7213 } | 7262 } |
| 7214 | 7263 |
| 7215 | 7264 |
| 7216 static void NoBlockGetterX(Local<String> name, | 7265 static void NoBlockGetterX(Local<String> name, |
| 7217 const v8::PropertyCallbackInfo<v8::Value>&) { | 7266 const v8::PropertyCallbackInfo<v8::Value>&) { |
| 7218 } | 7267 } |
| 7219 | 7268 |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8055 LocalContext context; | 8104 LocalContext context; |
| 8056 v8::Handle<v8::Object> holder = obj->NewInstance(); | 8105 v8::Handle<v8::Object> holder = obj->NewInstance(); |
| 8057 context->Global()->Set(v8_str("holder"), holder); | 8106 context->Global()->Set(v8_str("holder"), holder); |
| 8058 v8::Handle<Value> result = CompileRun( | 8107 v8::Handle<Value> result = CompileRun( |
| 8059 "holder.y = 11; holder.y = 12; holder.y"); | 8108 "holder.y = 11; holder.y = 12; holder.y"); |
| 8060 CHECK_EQ(12, result->Uint32Value()); | 8109 CHECK_EQ(12, result->Uint32Value()); |
| 8061 } | 8110 } |
| 8062 | 8111 |
| 8063 | 8112 |
| 8064 THREADED_TEST(TypeSwitch) { | 8113 THREADED_TEST(TypeSwitch) { |
| 8065 v8::HandleScope scope(CcTest::isolate()); | 8114 v8::Isolate* isolate = CcTest::isolate(); |
| 8066 v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(); | 8115 v8::HandleScope scope(isolate); |
| 8067 v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(); | 8116 v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate); |
| 8068 v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(); | 8117 v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate); |
| 8118 v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate); |
| 8069 v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 }; | 8119 v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 }; |
| 8070 v8::Handle<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs); | 8120 v8::Handle<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs); |
| 8071 LocalContext context; | 8121 LocalContext context; |
| 8072 v8::Handle<v8::Object> obj0 = v8::Object::New(); | 8122 v8::Handle<v8::Object> obj0 = v8::Object::New(); |
| 8073 v8::Handle<v8::Object> obj1 = templ1->GetFunction()->NewInstance(); | 8123 v8::Handle<v8::Object> obj1 = templ1->GetFunction()->NewInstance(); |
| 8074 v8::Handle<v8::Object> obj2 = templ2->GetFunction()->NewInstance(); | 8124 v8::Handle<v8::Object> obj2 = templ2->GetFunction()->NewInstance(); |
| 8075 v8::Handle<v8::Object> obj3 = templ3->GetFunction()->NewInstance(); | 8125 v8::Handle<v8::Object> obj3 = templ3->GetFunction()->NewInstance(); |
| 8076 for (int i = 0; i < 10; i++) { | 8126 for (int i = 0; i < 10; i++) { |
| 8077 CHECK_EQ(0, type_switch->match(obj0)); | 8127 CHECK_EQ(0, type_switch->match(obj0)); |
| 8078 CHECK_EQ(1, type_switch->match(obj1)); | 8128 CHECK_EQ(1, type_switch->match(obj1)); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8136 v8::Handle<Value>) { | 8186 v8::Handle<Value>) { |
| 8137 report_count++; | 8187 report_count++; |
| 8138 } | 8188 } |
| 8139 | 8189 |
| 8140 | 8190 |
| 8141 // Counts uncaught exceptions, but other tests running in parallel | 8191 // Counts uncaught exceptions, but other tests running in parallel |
| 8142 // also have uncaught exceptions. | 8192 // also have uncaught exceptions. |
| 8143 TEST(ApiUncaughtException) { | 8193 TEST(ApiUncaughtException) { |
| 8144 report_count = 0; | 8194 report_count = 0; |
| 8145 LocalContext env; | 8195 LocalContext env; |
| 8146 v8::HandleScope scope(env->GetIsolate()); | 8196 v8::Isolate* isolate = env->GetIsolate(); |
| 8197 v8::HandleScope scope(isolate); |
| 8147 v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener); | 8198 v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener); |
| 8148 | 8199 |
| 8149 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback); | 8200 Local<v8::FunctionTemplate> fun = |
| 8201 v8::FunctionTemplate::New(isolate, TroubleCallback); |
| 8150 v8::Local<v8::Object> global = env->Global(); | 8202 v8::Local<v8::Object> global = env->Global(); |
| 8151 global->Set(v8_str("trouble"), fun->GetFunction()); | 8203 global->Set(v8_str("trouble"), fun->GetFunction()); |
| 8152 | 8204 |
| 8153 Script::Compile(v8_str("function trouble_callee() {" | 8205 Script::Compile(v8_str("function trouble_callee() {" |
| 8154 " var x = null;" | 8206 " var x = null;" |
| 8155 " return x.foo;" | 8207 " return x.foo;" |
| 8156 "};" | 8208 "};" |
| 8157 "function trouble_caller() {" | 8209 "function trouble_caller() {" |
| 8158 " trouble();" | 8210 " trouble();" |
| 8159 "};"))->Run(); | 8211 "};"))->Run(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 8176 v8::String::Utf8Value name(message->GetScriptResourceName()); | 8228 v8::String::Utf8Value name(message->GetScriptResourceName()); |
| 8177 CHECK_EQ(script_resource_name, *name); | 8229 CHECK_EQ(script_resource_name, *name); |
| 8178 CHECK_EQ(3, message->GetLineNumber()); | 8230 CHECK_EQ(3, message->GetLineNumber()); |
| 8179 v8::String::Utf8Value source_line(message->GetSourceLine()); | 8231 v8::String::Utf8Value source_line(message->GetSourceLine()); |
| 8180 CHECK_EQ(" new o.foo();", *source_line); | 8232 CHECK_EQ(" new o.foo();", *source_line); |
| 8181 } | 8233 } |
| 8182 | 8234 |
| 8183 | 8235 |
| 8184 TEST(ExceptionInNativeScript) { | 8236 TEST(ExceptionInNativeScript) { |
| 8185 LocalContext env; | 8237 LocalContext env; |
| 8186 v8::HandleScope scope(env->GetIsolate()); | 8238 v8::Isolate* isolate = env->GetIsolate(); |
| 8239 v8::HandleScope scope(isolate); |
| 8187 v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener); | 8240 v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener); |
| 8188 | 8241 |
| 8189 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback); | 8242 Local<v8::FunctionTemplate> fun = |
| 8243 v8::FunctionTemplate::New(isolate, TroubleCallback); |
| 8190 v8::Local<v8::Object> global = env->Global(); | 8244 v8::Local<v8::Object> global = env->Global(); |
| 8191 global->Set(v8_str("trouble"), fun->GetFunction()); | 8245 global->Set(v8_str("trouble"), fun->GetFunction()); |
| 8192 | 8246 |
| 8193 Script::Compile( | 8247 Script::Compile( |
| 8194 v8_str( | 8248 v8_str( |
| 8195 "function trouble() {\n" | 8249 "function trouble() {\n" |
| 8196 " var o = {};\n" | 8250 " var o = {};\n" |
| 8197 " new o.foo();\n" | 8251 " new o.foo();\n" |
| 8198 "};"), | 8252 "};"), |
| 8199 v8::String::NewFromUtf8(env->GetIsolate(), script_resource_name))->Run(); | 8253 v8::String::NewFromUtf8(isolate, script_resource_name))->Run(); |
| 8200 Local<Value> trouble = global->Get(v8_str("trouble")); | 8254 Local<Value> trouble = global->Get(v8_str("trouble")); |
| 8201 CHECK(trouble->IsFunction()); | 8255 CHECK(trouble->IsFunction()); |
| 8202 Function::Cast(*trouble)->Call(global, 0, NULL); | 8256 Function::Cast(*trouble)->Call(global, 0, NULL); |
| 8203 v8::V8::RemoveMessageListeners(ExceptionInNativeScriptTestListener); | 8257 v8::V8::RemoveMessageListeners(ExceptionInNativeScriptTestListener); |
| 8204 } | 8258 } |
| 8205 | 8259 |
| 8206 | 8260 |
| 8207 TEST(CompilationErrorUsingTryCatchHandler) { | 8261 TEST(CompilationErrorUsingTryCatchHandler) { |
| 8208 LocalContext env; | 8262 LocalContext env; |
| 8209 v8::HandleScope scope(env->GetIsolate()); | 8263 v8::HandleScope scope(env->GetIsolate()); |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8722 // Add an accessor accessible by cross-domain JS code. | 8776 // Add an accessor accessible by cross-domain JS code. |
| 8723 global_template->SetAccessor( | 8777 global_template->SetAccessor( |
| 8724 v8_str("accessible_prop"), | 8778 v8_str("accessible_prop"), |
| 8725 EchoGetter, EchoSetter, | 8779 EchoGetter, EchoSetter, |
| 8726 v8::Handle<Value>(), | 8780 v8::Handle<Value>(), |
| 8727 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); | 8781 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); |
| 8728 | 8782 |
| 8729 | 8783 |
| 8730 global_template->SetAccessorProperty( | 8784 global_template->SetAccessorProperty( |
| 8731 v8_str("accessible_js_prop"), | 8785 v8_str("accessible_js_prop"), |
| 8732 v8::FunctionTemplate::New(EchoGetter), | 8786 v8::FunctionTemplate::New(isolate, EchoGetter), |
| 8733 v8::FunctionTemplate::New(EchoSetter), | 8787 v8::FunctionTemplate::New(isolate, EchoSetter), |
| 8734 v8::None, | 8788 v8::None, |
| 8735 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); | 8789 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); |
| 8736 | 8790 |
| 8737 // Add an accessor that is not accessible by cross-domain JS code. | 8791 // Add an accessor that is not accessible by cross-domain JS code. |
| 8738 global_template->SetAccessor(v8_str("blocked_prop"), | 8792 global_template->SetAccessor(v8_str("blocked_prop"), |
| 8739 UnreachableGetter, UnreachableSetter, | 8793 UnreachableGetter, UnreachableSetter, |
| 8740 v8::Handle<Value>(), | 8794 v8::Handle<Value>(), |
| 8741 v8::DEFAULT); | 8795 v8::DEFAULT); |
| 8742 | 8796 |
| 8743 global_template->SetAccessorProperty( | 8797 global_template->SetAccessorProperty( |
| 8744 v8_str("blocked_js_prop"), | 8798 v8_str("blocked_js_prop"), |
| 8745 v8::FunctionTemplate::New(UnreachableFunction), | 8799 v8::FunctionTemplate::New(isolate, UnreachableFunction), |
| 8746 v8::FunctionTemplate::New(UnreachableFunction), | 8800 v8::FunctionTemplate::New(isolate, UnreachableFunction), |
| 8747 v8::None, | 8801 v8::None, |
| 8748 v8::DEFAULT); | 8802 v8::DEFAULT); |
| 8749 | 8803 |
| 8750 // Create an environment | 8804 // Create an environment |
| 8751 v8::Local<Context> context0 = Context::New(isolate, NULL, global_template); | 8805 v8::Local<Context> context0 = Context::New(isolate, NULL, global_template); |
| 8752 context0->Enter(); | 8806 context0->Enter(); |
| 8753 | 8807 |
| 8754 v8::Handle<v8::Object> global0 = context0->Global(); | 8808 v8::Handle<v8::Object> global0 = context0->Global(); |
| 8755 | 8809 |
| 8756 // Define a property with JS getter and setter. | 8810 // Define a property with JS getter and setter. |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9169 static void ConstTenGetter(Local<String> name, | 9223 static void ConstTenGetter(Local<String> name, |
| 9170 const v8::PropertyCallbackInfo<v8::Value>& info) { | 9224 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 9171 info.GetReturnValue().Set(v8_num(10)); | 9225 info.GetReturnValue().Set(v8_num(10)); |
| 9172 } | 9226 } |
| 9173 | 9227 |
| 9174 | 9228 |
| 9175 THREADED_TEST(CrossDomainAccessors) { | 9229 THREADED_TEST(CrossDomainAccessors) { |
| 9176 v8::Isolate* isolate = CcTest::isolate(); | 9230 v8::Isolate* isolate = CcTest::isolate(); |
| 9177 v8::HandleScope handle_scope(isolate); | 9231 v8::HandleScope handle_scope(isolate); |
| 9178 | 9232 |
| 9179 v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); | 9233 v8::Handle<v8::FunctionTemplate> func_template = |
| 9234 v8::FunctionTemplate::New(isolate); |
| 9180 | 9235 |
| 9181 v8::Handle<v8::ObjectTemplate> global_template = | 9236 v8::Handle<v8::ObjectTemplate> global_template = |
| 9182 func_template->InstanceTemplate(); | 9237 func_template->InstanceTemplate(); |
| 9183 | 9238 |
| 9184 v8::Handle<v8::ObjectTemplate> proto_template = | 9239 v8::Handle<v8::ObjectTemplate> proto_template = |
| 9185 func_template->PrototypeTemplate(); | 9240 func_template->PrototypeTemplate(); |
| 9186 | 9241 |
| 9187 // Add an accessor to proto that's accessible by cross-domain JS code. | 9242 // Add an accessor to proto that's accessible by cross-domain JS code. |
| 9188 proto_template->SetAccessor(v8_str("accessible"), | 9243 proto_template->SetAccessor(v8_str("accessible"), |
| 9189 ConstTenGetter, 0, | 9244 ConstTenGetter, 0, |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9535 | 9590 |
| 9536 static void InstanceFunctionCallback( | 9591 static void InstanceFunctionCallback( |
| 9537 const v8::FunctionCallbackInfo<v8::Value>& args) { | 9592 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 9538 ApiTestFuzzer::Fuzz(); | 9593 ApiTestFuzzer::Fuzz(); |
| 9539 args.GetReturnValue().Set(v8_num(12)); | 9594 args.GetReturnValue().Set(v8_num(12)); |
| 9540 } | 9595 } |
| 9541 | 9596 |
| 9542 | 9597 |
| 9543 THREADED_TEST(InstanceProperties) { | 9598 THREADED_TEST(InstanceProperties) { |
| 9544 LocalContext context; | 9599 LocalContext context; |
| 9545 v8::HandleScope handle_scope(context->GetIsolate()); | 9600 v8::Isolate* isolate = context->GetIsolate(); |
| 9601 v8::HandleScope handle_scope(isolate); |
| 9546 | 9602 |
| 9547 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 9603 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 9548 Local<ObjectTemplate> instance = t->InstanceTemplate(); | 9604 Local<ObjectTemplate> instance = t->InstanceTemplate(); |
| 9549 | 9605 |
| 9550 instance->Set(v8_str("x"), v8_num(42)); | 9606 instance->Set(v8_str("x"), v8_num(42)); |
| 9551 instance->Set(v8_str("f"), | 9607 instance->Set(v8_str("f"), |
| 9552 v8::FunctionTemplate::New(InstanceFunctionCallback)); | 9608 v8::FunctionTemplate::New(isolate, InstanceFunctionCallback)); |
| 9553 | 9609 |
| 9554 Local<Value> o = t->GetFunction()->NewInstance(); | 9610 Local<Value> o = t->GetFunction()->NewInstance(); |
| 9555 | 9611 |
| 9556 context->Global()->Set(v8_str("i"), o); | 9612 context->Global()->Set(v8_str("i"), o); |
| 9557 Local<Value> value = Script::Compile(v8_str("i.x"))->Run(); | 9613 Local<Value> value = Script::Compile(v8_str("i.x"))->Run(); |
| 9558 CHECK_EQ(42, value->Int32Value()); | 9614 CHECK_EQ(42, value->Int32Value()); |
| 9559 | 9615 |
| 9560 value = Script::Compile(v8_str("i.f()"))->Run(); | 9616 value = Script::Compile(v8_str("i.f()"))->Run(); |
| 9561 CHECK_EQ(12, value->Int32Value()); | 9617 CHECK_EQ(12, value->Int32Value()); |
| 9562 } | 9618 } |
| 9563 | 9619 |
| 9564 | 9620 |
| 9565 static void GlobalObjectInstancePropertiesGet( | 9621 static void GlobalObjectInstancePropertiesGet( |
| 9566 Local<String> key, | 9622 Local<String> key, |
| 9567 const v8::PropertyCallbackInfo<v8::Value>&) { | 9623 const v8::PropertyCallbackInfo<v8::Value>&) { |
| 9568 ApiTestFuzzer::Fuzz(); | 9624 ApiTestFuzzer::Fuzz(); |
| 9569 } | 9625 } |
| 9570 | 9626 |
| 9571 | 9627 |
| 9572 THREADED_TEST(GlobalObjectInstanceProperties) { | 9628 THREADED_TEST(GlobalObjectInstanceProperties) { |
| 9573 v8::HandleScope handle_scope(CcTest::isolate()); | 9629 v8::Isolate* isolate = CcTest::isolate(); |
| 9630 v8::HandleScope handle_scope(isolate); |
| 9574 | 9631 |
| 9575 Local<Value> global_object; | 9632 Local<Value> global_object; |
| 9576 | 9633 |
| 9577 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 9634 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 9578 t->InstanceTemplate()->SetNamedPropertyHandler( | 9635 t->InstanceTemplate()->SetNamedPropertyHandler( |
| 9579 GlobalObjectInstancePropertiesGet); | 9636 GlobalObjectInstancePropertiesGet); |
| 9580 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 9637 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
| 9581 instance_template->Set(v8_str("x"), v8_num(42)); | 9638 instance_template->Set(v8_str("x"), v8_num(42)); |
| 9582 instance_template->Set(v8_str("f"), | 9639 instance_template->Set(v8_str("f"), |
| 9583 v8::FunctionTemplate::New(InstanceFunctionCallback)); | 9640 v8::FunctionTemplate::New(isolate, |
| 9641 InstanceFunctionCallback)); |
| 9584 | 9642 |
| 9585 // The script to check how Crankshaft compiles missing global function | 9643 // The script to check how Crankshaft compiles missing global function |
| 9586 // invocations. function g is not defined and should throw on call. | 9644 // invocations. function g is not defined and should throw on call. |
| 9587 const char* script = | 9645 const char* script = |
| 9588 "function wrapper(call) {" | 9646 "function wrapper(call) {" |
| 9589 " var x = 0, y = 1;" | 9647 " var x = 0, y = 1;" |
| 9590 " for (var i = 0; i < 1000; i++) {" | 9648 " for (var i = 0; i < 1000; i++) {" |
| 9591 " x += i * 100;" | 9649 " x += i * 100;" |
| 9592 " y += i * 100;" | 9650 " y += i * 100;" |
| 9593 " }" | 9651 " }" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 9619 CHECK_EQ(42, value->Int32Value()); | 9677 CHECK_EQ(42, value->Int32Value()); |
| 9620 value = Script::Compile(v8_str("f()"))->Run(); | 9678 value = Script::Compile(v8_str("f()"))->Run(); |
| 9621 CHECK_EQ(12, value->Int32Value()); | 9679 CHECK_EQ(12, value->Int32Value()); |
| 9622 value = Script::Compile(v8_str(script))->Run(); | 9680 value = Script::Compile(v8_str(script))->Run(); |
| 9623 CHECK_EQ(1, value->Int32Value()); | 9681 CHECK_EQ(1, value->Int32Value()); |
| 9624 } | 9682 } |
| 9625 } | 9683 } |
| 9626 | 9684 |
| 9627 | 9685 |
| 9628 THREADED_TEST(CallKnownGlobalReceiver) { | 9686 THREADED_TEST(CallKnownGlobalReceiver) { |
| 9629 v8::HandleScope handle_scope(CcTest::isolate()); | 9687 v8::Isolate* isolate = CcTest::isolate(); |
| 9688 v8::HandleScope handle_scope(isolate); |
| 9630 | 9689 |
| 9631 Local<Value> global_object; | 9690 Local<Value> global_object; |
| 9632 | 9691 |
| 9633 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 9692 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 9634 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 9693 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
| 9635 | 9694 |
| 9636 // The script to check that we leave global object not | 9695 // The script to check that we leave global object not |
| 9637 // global object proxy on stack when we deoptimize from inside | 9696 // global object proxy on stack when we deoptimize from inside |
| 9638 // arguments evaluation. | 9697 // arguments evaluation. |
| 9639 // To provoke error we need to both force deoptimization | 9698 // To provoke error we need to both force deoptimization |
| 9640 // from arguments evaluation and to force CallIC to take | 9699 // from arguments evaluation and to force CallIC to take |
| 9641 // CallIC_Miss code path that can't cope with global proxy. | 9700 // CallIC_Miss code path that can't cope with global proxy. |
| 9642 const char* script = | 9701 const char* script = |
| 9643 "function bar(x, y) { try { } finally { } }" | 9702 "function bar(x, y) { try { } finally { } }" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9698 } | 9757 } |
| 9699 | 9758 |
| 9700 | 9759 |
| 9701 static void ShadowNamedGet(Local<String> key, | 9760 static void ShadowNamedGet(Local<String> key, |
| 9702 const v8::PropertyCallbackInfo<v8::Value>&) { | 9761 const v8::PropertyCallbackInfo<v8::Value>&) { |
| 9703 } | 9762 } |
| 9704 | 9763 |
| 9705 | 9764 |
| 9706 THREADED_TEST(ShadowObject) { | 9765 THREADED_TEST(ShadowObject) { |
| 9707 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0; | 9766 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0; |
| 9708 v8::HandleScope handle_scope(CcTest::isolate()); | 9767 v8::Isolate* isolate = CcTest::isolate(); |
| 9768 v8::HandleScope handle_scope(isolate); |
| 9709 | 9769 |
| 9710 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 9770 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 9711 LocalContext context(NULL, global_template); | 9771 LocalContext context(NULL, global_template); |
| 9712 | 9772 |
| 9713 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 9773 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 9714 t->InstanceTemplate()->SetNamedPropertyHandler(ShadowNamedGet); | 9774 t->InstanceTemplate()->SetNamedPropertyHandler(ShadowNamedGet); |
| 9715 t->InstanceTemplate()->SetIndexedPropertyHandler(ShadowIndexedGet); | 9775 t->InstanceTemplate()->SetIndexedPropertyHandler(ShadowIndexedGet); |
| 9716 Local<ObjectTemplate> proto = t->PrototypeTemplate(); | 9776 Local<ObjectTemplate> proto = t->PrototypeTemplate(); |
| 9717 Local<ObjectTemplate> instance = t->InstanceTemplate(); | 9777 Local<ObjectTemplate> instance = t->InstanceTemplate(); |
| 9718 | 9778 |
| 9719 proto->Set(v8_str("f"), | 9779 proto->Set(v8_str("f"), |
| 9720 v8::FunctionTemplate::New(ShadowFunctionCallback, Local<Value>())); | 9780 v8::FunctionTemplate::New(isolate, |
| 9781 ShadowFunctionCallback, |
| 9782 Local<Value>())); |
| 9721 proto->Set(v8_str("x"), v8_num(12)); | 9783 proto->Set(v8_str("x"), v8_num(12)); |
| 9722 | 9784 |
| 9723 instance->SetAccessor(v8_str("y"), ShadowYGetter, ShadowYSetter); | 9785 instance->SetAccessor(v8_str("y"), ShadowYGetter, ShadowYSetter); |
| 9724 | 9786 |
| 9725 Local<Value> o = t->GetFunction()->NewInstance(); | 9787 Local<Value> o = t->GetFunction()->NewInstance(); |
| 9726 context->Global()->Set(v8_str("__proto__"), o); | 9788 context->Global()->Set(v8_str("__proto__"), o); |
| 9727 | 9789 |
| 9728 Local<Value> value = | 9790 Local<Value> value = |
| 9729 Script::Compile(v8_str("this.propertyIsEnumerable(0)"))->Run(); | 9791 Script::Compile(v8_str("this.propertyIsEnumerable(0)"))->Run(); |
| 9730 CHECK(value->IsBoolean()); | 9792 CHECK(value->IsBoolean()); |
| 9731 CHECK(!value->BooleanValue()); | 9793 CHECK(!value->BooleanValue()); |
| 9732 | 9794 |
| 9733 value = Script::Compile(v8_str("x"))->Run(); | 9795 value = Script::Compile(v8_str("x"))->Run(); |
| 9734 CHECK_EQ(12, value->Int32Value()); | 9796 CHECK_EQ(12, value->Int32Value()); |
| 9735 | 9797 |
| 9736 value = Script::Compile(v8_str("f()"))->Run(); | 9798 value = Script::Compile(v8_str("f()"))->Run(); |
| 9737 CHECK_EQ(42, value->Int32Value()); | 9799 CHECK_EQ(42, value->Int32Value()); |
| 9738 | 9800 |
| 9739 Script::Compile(v8_str("y = 43"))->Run(); | 9801 Script::Compile(v8_str("y = 43"))->Run(); |
| 9740 CHECK_EQ(1, shadow_y_setter_call_count); | 9802 CHECK_EQ(1, shadow_y_setter_call_count); |
| 9741 value = Script::Compile(v8_str("y"))->Run(); | 9803 value = Script::Compile(v8_str("y"))->Run(); |
| 9742 CHECK_EQ(1, shadow_y_getter_call_count); | 9804 CHECK_EQ(1, shadow_y_getter_call_count); |
| 9743 CHECK_EQ(42, value->Int32Value()); | 9805 CHECK_EQ(42, value->Int32Value()); |
| 9744 } | 9806 } |
| 9745 | 9807 |
| 9746 | 9808 |
| 9747 THREADED_TEST(HiddenPrototype) { | 9809 THREADED_TEST(HiddenPrototype) { |
| 9748 LocalContext context; | 9810 LocalContext context; |
| 9749 v8::HandleScope handle_scope(context->GetIsolate()); | 9811 v8::Isolate* isolate = context->GetIsolate(); |
| 9812 v8::HandleScope handle_scope(isolate); |
| 9750 | 9813 |
| 9751 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); | 9814 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); |
| 9752 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0)); | 9815 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0)); |
| 9753 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 9816 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
| 9754 t1->SetHiddenPrototype(true); | 9817 t1->SetHiddenPrototype(true); |
| 9755 t1->InstanceTemplate()->Set(v8_str("y"), v8_num(1)); | 9818 t1->InstanceTemplate()->Set(v8_str("y"), v8_num(1)); |
| 9756 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); | 9819 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); |
| 9757 t2->SetHiddenPrototype(true); | 9820 t2->SetHiddenPrototype(true); |
| 9758 t2->InstanceTemplate()->Set(v8_str("z"), v8_num(2)); | 9821 t2->InstanceTemplate()->Set(v8_str("z"), v8_num(2)); |
| 9759 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(); | 9822 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); |
| 9760 t3->InstanceTemplate()->Set(v8_str("u"), v8_num(3)); | 9823 t3->InstanceTemplate()->Set(v8_str("u"), v8_num(3)); |
| 9761 | 9824 |
| 9762 Local<v8::Object> o0 = t0->GetFunction()->NewInstance(); | 9825 Local<v8::Object> o0 = t0->GetFunction()->NewInstance(); |
| 9763 Local<v8::Object> o1 = t1->GetFunction()->NewInstance(); | 9826 Local<v8::Object> o1 = t1->GetFunction()->NewInstance(); |
| 9764 Local<v8::Object> o2 = t2->GetFunction()->NewInstance(); | 9827 Local<v8::Object> o2 = t2->GetFunction()->NewInstance(); |
| 9765 Local<v8::Object> o3 = t3->GetFunction()->NewInstance(); | 9828 Local<v8::Object> o3 = t3->GetFunction()->NewInstance(); |
| 9766 | 9829 |
| 9767 // Setting the prototype on an object skips hidden prototypes. | 9830 // Setting the prototype on an object skips hidden prototypes. |
| 9768 CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value()); | 9831 CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value()); |
| 9769 o0->Set(v8_str("__proto__"), o1); | 9832 o0->Set(v8_str("__proto__"), o1); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 9783 // which is o3. Therefore, z should not be defined on the prototype | 9846 // which is o3. Therefore, z should not be defined on the prototype |
| 9784 // object. | 9847 // object. |
| 9785 Local<Value> proto = o0->Get(v8_str("__proto__")); | 9848 Local<Value> proto = o0->Get(v8_str("__proto__")); |
| 9786 CHECK(proto->IsObject()); | 9849 CHECK(proto->IsObject()); |
| 9787 CHECK(proto.As<v8::Object>()->Get(v8_str("z"))->IsUndefined()); | 9850 CHECK(proto.As<v8::Object>()->Get(v8_str("z"))->IsUndefined()); |
| 9788 } | 9851 } |
| 9789 | 9852 |
| 9790 | 9853 |
| 9791 THREADED_TEST(HiddenPrototypeSet) { | 9854 THREADED_TEST(HiddenPrototypeSet) { |
| 9792 LocalContext context; | 9855 LocalContext context; |
| 9793 v8::HandleScope handle_scope(context->GetIsolate()); | 9856 v8::Isolate* isolate = context->GetIsolate(); |
| 9857 v8::HandleScope handle_scope(isolate); |
| 9794 | 9858 |
| 9795 Local<v8::FunctionTemplate> ot = v8::FunctionTemplate::New(); | 9859 Local<v8::FunctionTemplate> ot = v8::FunctionTemplate::New(isolate); |
| 9796 Local<v8::FunctionTemplate> ht = v8::FunctionTemplate::New(); | 9860 Local<v8::FunctionTemplate> ht = v8::FunctionTemplate::New(isolate); |
| 9797 ht->SetHiddenPrototype(true); | 9861 ht->SetHiddenPrototype(true); |
| 9798 Local<v8::FunctionTemplate> pt = v8::FunctionTemplate::New(); | 9862 Local<v8::FunctionTemplate> pt = v8::FunctionTemplate::New(isolate); |
| 9799 ht->InstanceTemplate()->Set(v8_str("x"), v8_num(0)); | 9863 ht->InstanceTemplate()->Set(v8_str("x"), v8_num(0)); |
| 9800 | 9864 |
| 9801 Local<v8::Object> o = ot->GetFunction()->NewInstance(); | 9865 Local<v8::Object> o = ot->GetFunction()->NewInstance(); |
| 9802 Local<v8::Object> h = ht->GetFunction()->NewInstance(); | 9866 Local<v8::Object> h = ht->GetFunction()->NewInstance(); |
| 9803 Local<v8::Object> p = pt->GetFunction()->NewInstance(); | 9867 Local<v8::Object> p = pt->GetFunction()->NewInstance(); |
| 9804 o->Set(v8_str("__proto__"), h); | 9868 o->Set(v8_str("__proto__"), h); |
| 9805 h->Set(v8_str("__proto__"), p); | 9869 h->Set(v8_str("__proto__"), p); |
| 9806 | 9870 |
| 9807 // Setting a property that exists on the hidden prototype goes there. | 9871 // Setting a property that exists on the hidden prototype goes there. |
| 9808 o->Set(v8_str("x"), v8_num(7)); | 9872 o->Set(v8_str("x"), v8_num(7)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 9827 CHECK_EQ(8, h->Get(v8_str("z"))->Int32Value()); | 9891 CHECK_EQ(8, h->Get(v8_str("z"))->Int32Value()); |
| 9828 CHECK_EQ(8, p->Get(v8_str("z"))->Int32Value()); | 9892 CHECK_EQ(8, p->Get(v8_str("z"))->Int32Value()); |
| 9829 } | 9893 } |
| 9830 | 9894 |
| 9831 | 9895 |
| 9832 // Regression test for issue 2457. | 9896 // Regression test for issue 2457. |
| 9833 THREADED_TEST(HiddenPrototypeIdentityHash) { | 9897 THREADED_TEST(HiddenPrototypeIdentityHash) { |
| 9834 LocalContext context; | 9898 LocalContext context; |
| 9835 v8::HandleScope handle_scope(context->GetIsolate()); | 9899 v8::HandleScope handle_scope(context->GetIsolate()); |
| 9836 | 9900 |
| 9837 Handle<FunctionTemplate> t = FunctionTemplate::New(); | 9901 Handle<FunctionTemplate> t = FunctionTemplate::New(context->GetIsolate()); |
| 9838 t->SetHiddenPrototype(true); | 9902 t->SetHiddenPrototype(true); |
| 9839 t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75)); | 9903 t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75)); |
| 9840 Handle<Object> p = t->GetFunction()->NewInstance(); | 9904 Handle<Object> p = t->GetFunction()->NewInstance(); |
| 9841 Handle<Object> o = Object::New(); | 9905 Handle<Object> o = Object::New(); |
| 9842 o->SetPrototype(p); | 9906 o->SetPrototype(p); |
| 9843 | 9907 |
| 9844 int hash = o->GetIdentityHash(); | 9908 int hash = o->GetIdentityHash(); |
| 9845 USE(hash); | 9909 USE(hash); |
| 9846 o->Set(v8_str("foo"), v8_num(42)); | 9910 o->Set(v8_str("foo"), v8_num(42)); |
| 9847 ASSERT_EQ(hash, o->GetIdentityHash()); | 9911 ASSERT_EQ(hash, o->GetIdentityHash()); |
| 9848 } | 9912 } |
| 9849 | 9913 |
| 9850 | 9914 |
| 9851 THREADED_TEST(SetPrototype) { | 9915 THREADED_TEST(SetPrototype) { |
| 9852 LocalContext context; | 9916 LocalContext context; |
| 9853 v8::HandleScope handle_scope(context->GetIsolate()); | 9917 v8::Isolate* isolate = context->GetIsolate(); |
| 9918 v8::HandleScope handle_scope(isolate); |
| 9854 | 9919 |
| 9855 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); | 9920 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); |
| 9856 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0)); | 9921 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0)); |
| 9857 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 9922 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
| 9858 t1->SetHiddenPrototype(true); | 9923 t1->SetHiddenPrototype(true); |
| 9859 t1->InstanceTemplate()->Set(v8_str("y"), v8_num(1)); | 9924 t1->InstanceTemplate()->Set(v8_str("y"), v8_num(1)); |
| 9860 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); | 9925 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); |
| 9861 t2->SetHiddenPrototype(true); | 9926 t2->SetHiddenPrototype(true); |
| 9862 t2->InstanceTemplate()->Set(v8_str("z"), v8_num(2)); | 9927 t2->InstanceTemplate()->Set(v8_str("z"), v8_num(2)); |
| 9863 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(); | 9928 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); |
| 9864 t3->InstanceTemplate()->Set(v8_str("u"), v8_num(3)); | 9929 t3->InstanceTemplate()->Set(v8_str("u"), v8_num(3)); |
| 9865 | 9930 |
| 9866 Local<v8::Object> o0 = t0->GetFunction()->NewInstance(); | 9931 Local<v8::Object> o0 = t0->GetFunction()->NewInstance(); |
| 9867 Local<v8::Object> o1 = t1->GetFunction()->NewInstance(); | 9932 Local<v8::Object> o1 = t1->GetFunction()->NewInstance(); |
| 9868 Local<v8::Object> o2 = t2->GetFunction()->NewInstance(); | 9933 Local<v8::Object> o2 = t2->GetFunction()->NewInstance(); |
| 9869 Local<v8::Object> o3 = t3->GetFunction()->NewInstance(); | 9934 Local<v8::Object> o3 = t3->GetFunction()->NewInstance(); |
| 9870 | 9935 |
| 9871 // Setting the prototype on an object does not skip hidden prototypes. | 9936 // Setting the prototype on an object does not skip hidden prototypes. |
| 9872 CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value()); | 9937 CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value()); |
| 9873 CHECK(o0->SetPrototype(o1)); | 9938 CHECK(o0->SetPrototype(o1)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 9904 CHECK_EQ(proto2.As<v8::Object>(), o3); | 9969 CHECK_EQ(proto2.As<v8::Object>(), o3); |
| 9905 } | 9970 } |
| 9906 | 9971 |
| 9907 | 9972 |
| 9908 // Getting property names of an object with a prototype chain that | 9973 // Getting property names of an object with a prototype chain that |
| 9909 // triggers dictionary elements in GetLocalPropertyNames() shouldn't | 9974 // triggers dictionary elements in GetLocalPropertyNames() shouldn't |
| 9910 // crash the runtime. | 9975 // crash the runtime. |
| 9911 THREADED_TEST(Regress91517) { | 9976 THREADED_TEST(Regress91517) { |
| 9912 i::FLAG_allow_natives_syntax = true; | 9977 i::FLAG_allow_natives_syntax = true; |
| 9913 LocalContext context; | 9978 LocalContext context; |
| 9914 v8::HandleScope handle_scope(context->GetIsolate()); | 9979 v8::Isolate* isolate = context->GetIsolate(); |
| 9980 v8::HandleScope handle_scope(isolate); |
| 9915 | 9981 |
| 9916 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 9982 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
| 9917 t1->SetHiddenPrototype(true); | 9983 t1->SetHiddenPrototype(true); |
| 9918 t1->InstanceTemplate()->Set(v8_str("foo"), v8_num(1)); | 9984 t1->InstanceTemplate()->Set(v8_str("foo"), v8_num(1)); |
| 9919 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); | 9985 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); |
| 9920 t2->SetHiddenPrototype(true); | 9986 t2->SetHiddenPrototype(true); |
| 9921 t2->InstanceTemplate()->Set(v8_str("fuz1"), v8_num(2)); | 9987 t2->InstanceTemplate()->Set(v8_str("fuz1"), v8_num(2)); |
| 9922 t2->InstanceTemplate()->Set(v8_str("objects"), v8::Object::New()); | 9988 t2->InstanceTemplate()->Set(v8_str("objects"), v8::Object::New()); |
| 9923 t2->InstanceTemplate()->Set(v8_str("fuz2"), v8_num(2)); | 9989 t2->InstanceTemplate()->Set(v8_str("fuz2"), v8_num(2)); |
| 9924 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(); | 9990 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); |
| 9925 t3->SetHiddenPrototype(true); | 9991 t3->SetHiddenPrototype(true); |
| 9926 t3->InstanceTemplate()->Set(v8_str("boo"), v8_num(3)); | 9992 t3->InstanceTemplate()->Set(v8_str("boo"), v8_num(3)); |
| 9927 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(); | 9993 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(isolate); |
| 9928 t4->InstanceTemplate()->Set(v8_str("baz"), v8_num(4)); | 9994 t4->InstanceTemplate()->Set(v8_str("baz"), v8_num(4)); |
| 9929 | 9995 |
| 9930 // Force dictionary-based properties. | 9996 // Force dictionary-based properties. |
| 9931 i::ScopedVector<char> name_buf(1024); | 9997 i::ScopedVector<char> name_buf(1024); |
| 9932 for (int i = 1; i <= 1000; i++) { | 9998 for (int i = 1; i <= 1000; i++) { |
| 9933 i::OS::SNPrintF(name_buf, "sdf%d", i); | 9999 i::OS::SNPrintF(name_buf, "sdf%d", i); |
| 9934 t2->InstanceTemplate()->Set(v8_str(name_buf.start()), v8_num(2)); | 10000 t2->InstanceTemplate()->Set(v8_str(name_buf.start()), v8_num(2)); |
| 9935 } | 10001 } |
| 9936 | 10002 |
| 9937 Local<v8::Object> o1 = t1->GetFunction()->NewInstance(); | 10003 Local<v8::Object> o1 = t1->GetFunction()->NewInstance(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 9954 ExpectTrue("names.indexOf(\"boo\") >= 0"); | 10020 ExpectTrue("names.indexOf(\"boo\") >= 0"); |
| 9955 ExpectTrue("names.indexOf(\"foo\") >= 0"); | 10021 ExpectTrue("names.indexOf(\"foo\") >= 0"); |
| 9956 ExpectTrue("names.indexOf(\"fuz1\") >= 0"); | 10022 ExpectTrue("names.indexOf(\"fuz1\") >= 0"); |
| 9957 ExpectTrue("names.indexOf(\"fuz2\") >= 0"); | 10023 ExpectTrue("names.indexOf(\"fuz2\") >= 0"); |
| 9958 ExpectFalse("names[1005] == undefined"); | 10024 ExpectFalse("names[1005] == undefined"); |
| 9959 } | 10025 } |
| 9960 | 10026 |
| 9961 | 10027 |
| 9962 THREADED_TEST(FunctionReadOnlyPrototype) { | 10028 THREADED_TEST(FunctionReadOnlyPrototype) { |
| 9963 LocalContext context; | 10029 LocalContext context; |
| 9964 v8::HandleScope handle_scope(context->GetIsolate()); | 10030 v8::Isolate* isolate = context->GetIsolate(); |
| 10031 v8::HandleScope handle_scope(isolate); |
| 9965 | 10032 |
| 9966 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 10033 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
| 9967 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); | 10034 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); |
| 9968 t1->ReadOnlyPrototype(); | 10035 t1->ReadOnlyPrototype(); |
| 9969 context->Global()->Set(v8_str("func1"), t1->GetFunction()); | 10036 context->Global()->Set(v8_str("func1"), t1->GetFunction()); |
| 9970 // Configured value of ReadOnly flag. | 10037 // Configured value of ReadOnly flag. |
| 9971 CHECK(CompileRun( | 10038 CHECK(CompileRun( |
| 9972 "(function() {" | 10039 "(function() {" |
| 9973 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');" | 10040 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');" |
| 9974 " return (descriptor['writable'] == false);" | 10041 " return (descriptor['writable'] == false);" |
| 9975 "})()")->BooleanValue()); | 10042 "})()")->BooleanValue()); |
| 9976 CHECK_EQ(42, CompileRun("func1.prototype.x")->Int32Value()); | 10043 CHECK_EQ(42, CompileRun("func1.prototype.x")->Int32Value()); |
| 9977 CHECK_EQ(42, | 10044 CHECK_EQ(42, |
| 9978 CompileRun("func1.prototype = {}; func1.prototype.x")->Int32Value()); | 10045 CompileRun("func1.prototype = {}; func1.prototype.x")->Int32Value()); |
| 9979 | 10046 |
| 9980 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); | 10047 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); |
| 9981 t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); | 10048 t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); |
| 9982 context->Global()->Set(v8_str("func2"), t2->GetFunction()); | 10049 context->Global()->Set(v8_str("func2"), t2->GetFunction()); |
| 9983 // Default value of ReadOnly flag. | 10050 // Default value of ReadOnly flag. |
| 9984 CHECK(CompileRun( | 10051 CHECK(CompileRun( |
| 9985 "(function() {" | 10052 "(function() {" |
| 9986 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');" | 10053 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');" |
| 9987 " return (descriptor['writable'] == true);" | 10054 " return (descriptor['writable'] == true);" |
| 9988 "})()")->BooleanValue()); | 10055 "})()")->BooleanValue()); |
| 9989 CHECK_EQ(42, CompileRun("func2.prototype.x")->Int32Value()); | 10056 CHECK_EQ(42, CompileRun("func2.prototype.x")->Int32Value()); |
| 9990 } | 10057 } |
| 9991 | 10058 |
| 9992 | 10059 |
| 9993 THREADED_TEST(SetPrototypeThrows) { | 10060 THREADED_TEST(SetPrototypeThrows) { |
| 9994 LocalContext context; | 10061 LocalContext context; |
| 9995 v8::HandleScope handle_scope(context->GetIsolate()); | 10062 v8::Isolate* isolate = context->GetIsolate(); |
| 10063 v8::HandleScope handle_scope(isolate); |
| 9996 | 10064 |
| 9997 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 10065 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 9998 | 10066 |
| 9999 Local<v8::Object> o0 = t->GetFunction()->NewInstance(); | 10067 Local<v8::Object> o0 = t->GetFunction()->NewInstance(); |
| 10000 Local<v8::Object> o1 = t->GetFunction()->NewInstance(); | 10068 Local<v8::Object> o1 = t->GetFunction()->NewInstance(); |
| 10001 | 10069 |
| 10002 CHECK(o0->SetPrototype(o1)); | 10070 CHECK(o0->SetPrototype(o1)); |
| 10003 // If setting the prototype leads to the cycle, SetPrototype should | 10071 // If setting the prototype leads to the cycle, SetPrototype should |
| 10004 // return false and keep VM in sane state. | 10072 // return false and keep VM in sane state. |
| 10005 v8::TryCatch try_catch; | 10073 v8::TryCatch try_catch; |
| 10006 CHECK(!o1->SetPrototype(o0)); | 10074 CHECK(!o1->SetPrototype(o0)); |
| 10007 CHECK(!try_catch.HasCaught()); | 10075 CHECK(!try_catch.HasCaught()); |
| 10008 ASSERT(!CcTest::i_isolate()->has_pending_exception()); | 10076 ASSERT(!CcTest::i_isolate()->has_pending_exception()); |
| 10009 | 10077 |
| 10010 CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")->Int32Value()); | 10078 CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")->Int32Value()); |
| 10011 } | 10079 } |
| 10012 | 10080 |
| 10013 | 10081 |
| 10014 THREADED_TEST(FunctionRemovePrototype) { | 10082 THREADED_TEST(FunctionRemovePrototype) { |
| 10015 LocalContext context; | 10083 LocalContext context; |
| 10016 v8::HandleScope handle_scope(context->GetIsolate()); | 10084 v8::Isolate* isolate = context->GetIsolate(); |
| 10085 v8::HandleScope handle_scope(isolate); |
| 10017 | 10086 |
| 10018 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 10087 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
| 10019 t1->RemovePrototype(); | 10088 t1->RemovePrototype(); |
| 10020 Local<v8::Function> fun = t1->GetFunction(); | 10089 Local<v8::Function> fun = t1->GetFunction(); |
| 10021 context->Global()->Set(v8_str("fun"), fun); | 10090 context->Global()->Set(v8_str("fun"), fun); |
| 10022 CHECK(!CompileRun("'prototype' in fun")->BooleanValue()); | 10091 CHECK(!CompileRun("'prototype' in fun")->BooleanValue()); |
| 10023 | 10092 |
| 10024 v8::TryCatch try_catch; | 10093 v8::TryCatch try_catch; |
| 10025 CompileRun("new fun()"); | 10094 CompileRun("new fun()"); |
| 10026 CHECK(try_catch.HasCaught()); | 10095 CHECK(try_catch.HasCaught()); |
| 10027 | 10096 |
| 10028 try_catch.Reset(); | 10097 try_catch.Reset(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 10049 x->Get(v8_str("get")); | 10118 x->Get(v8_str("get")); |
| 10050 x->Set(v8_str("set"), v8::Integer::New(8)); | 10119 x->Set(v8_str("set"), v8::Integer::New(8)); |
| 10051 x->Get(v8_str("get")); | 10120 x->Get(v8_str("get")); |
| 10052 x->Set(v8_str("set"), v8::Integer::New(8)); | 10121 x->Set(v8_str("set"), v8::Integer::New(8)); |
| 10053 x->Get(v8_str("get")); | 10122 x->Get(v8_str("get")); |
| 10054 } | 10123 } |
| 10055 | 10124 |
| 10056 | 10125 |
| 10057 THREADED_TEST(Constructor) { | 10126 THREADED_TEST(Constructor) { |
| 10058 LocalContext context; | 10127 LocalContext context; |
| 10059 v8::HandleScope handle_scope(context->GetIsolate()); | 10128 v8::Isolate* isolate = context->GetIsolate(); |
| 10060 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 10129 v8::HandleScope handle_scope(isolate); |
| 10130 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 10061 templ->SetClassName(v8_str("Fun")); | 10131 templ->SetClassName(v8_str("Fun")); |
| 10062 Local<Function> cons = templ->GetFunction(); | 10132 Local<Function> cons = templ->GetFunction(); |
| 10063 context->Global()->Set(v8_str("Fun"), cons); | 10133 context->Global()->Set(v8_str("Fun"), cons); |
| 10064 Local<v8::Object> inst = cons->NewInstance(); | 10134 Local<v8::Object> inst = cons->NewInstance(); |
| 10065 i::Handle<i::JSObject> obj(v8::Utils::OpenHandle(*inst)); | 10135 i::Handle<i::JSObject> obj(v8::Utils::OpenHandle(*inst)); |
| 10066 CHECK(obj->IsJSObject()); | 10136 CHECK(obj->IsJSObject()); |
| 10067 Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); | 10137 Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); |
| 10068 CHECK(value->BooleanValue()); | 10138 CHECK(value->BooleanValue()); |
| 10069 } | 10139 } |
| 10070 | 10140 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10217 Local<Value> args[] = { v8_num(23) }; | 10287 Local<Value> args[] = { v8_num(23) }; |
| 10218 value = instance->CallAsConstructor(1, args); | 10288 value = instance->CallAsConstructor(1, args); |
| 10219 CHECK(try_catch.HasCaught()); | 10289 CHECK(try_catch.HasCaught()); |
| 10220 String::Utf8Value exception_value2(try_catch.Exception()); | 10290 String::Utf8Value exception_value2(try_catch.Exception()); |
| 10221 CHECK_EQ("23", *exception_value2); | 10291 CHECK_EQ("23", *exception_value2); |
| 10222 try_catch.Reset(); | 10292 try_catch.Reset(); |
| 10223 } | 10293 } |
| 10224 | 10294 |
| 10225 // Check whether constructor returns with an object or non-object. | 10295 // Check whether constructor returns with an object or non-object. |
| 10226 { Local<FunctionTemplate> function_template = | 10296 { Local<FunctionTemplate> function_template = |
| 10227 FunctionTemplate::New(FakeConstructorCallback); | 10297 FunctionTemplate::New(isolate, FakeConstructorCallback); |
| 10228 Local<Function> function = function_template->GetFunction(); | 10298 Local<Function> function = function_template->GetFunction(); |
| 10229 Local<Object> instance1 = function; | 10299 Local<Object> instance1 = function; |
| 10230 context->Global()->Set(v8_str("obj4"), instance1); | 10300 context->Global()->Set(v8_str("obj4"), instance1); |
| 10231 v8::TryCatch try_catch; | 10301 v8::TryCatch try_catch; |
| 10232 Local<Value> value; | 10302 Local<Value> value; |
| 10233 CHECK(!try_catch.HasCaught()); | 10303 CHECK(!try_catch.HasCaught()); |
| 10234 | 10304 |
| 10235 CHECK(instance1->IsObject()); | 10305 CHECK(instance1->IsObject()); |
| 10236 CHECK(instance1->IsFunction()); | 10306 CHECK(instance1->IsFunction()); |
| 10237 | 10307 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 10260 Local<Value> args2[] = { v8_num(28) }; | 10330 Local<Value> args2[] = { v8_num(28) }; |
| 10261 value = instance2->CallAsConstructor(1, args2); | 10331 value = instance2->CallAsConstructor(1, args2); |
| 10262 CHECK(!try_catch.HasCaught()); | 10332 CHECK(!try_catch.HasCaught()); |
| 10263 CHECK(!value->IsObject()); | 10333 CHECK(!value->IsObject()); |
| 10264 } | 10334 } |
| 10265 } | 10335 } |
| 10266 | 10336 |
| 10267 | 10337 |
| 10268 THREADED_TEST(FunctionDescriptorException) { | 10338 THREADED_TEST(FunctionDescriptorException) { |
| 10269 LocalContext context; | 10339 LocalContext context; |
| 10270 v8::HandleScope handle_scope(context->GetIsolate()); | 10340 v8::Isolate* isolate = context->GetIsolate(); |
| 10271 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 10341 v8::HandleScope handle_scope(isolate); |
| 10342 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 10272 templ->SetClassName(v8_str("Fun")); | 10343 templ->SetClassName(v8_str("Fun")); |
| 10273 Local<Function> cons = templ->GetFunction(); | 10344 Local<Function> cons = templ->GetFunction(); |
| 10274 context->Global()->Set(v8_str("Fun"), cons); | 10345 context->Global()->Set(v8_str("Fun"), cons); |
| 10275 Local<Value> value = CompileRun( | 10346 Local<Value> value = CompileRun( |
| 10276 "function test() {" | 10347 "function test() {" |
| 10277 " try {" | 10348 " try {" |
| 10278 " (new Fun()).blah()" | 10349 " (new Fun()).blah()" |
| 10279 " } catch (e) {" | 10350 " } catch (e) {" |
| 10280 " var str = String(e);" | 10351 " var str = String(e);" |
| 10281 " if (str.indexOf('TypeError') == -1) return 1;" | 10352 " if (str.indexOf('TypeError') == -1) return 1;" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10478 static void ReturnThis(const v8::FunctionCallbackInfo<v8::Value>& args) { | 10549 static void ReturnThis(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 10479 args.GetReturnValue().Set(args.This()); | 10550 args.GetReturnValue().Set(args.This()); |
| 10480 } | 10551 } |
| 10481 | 10552 |
| 10482 | 10553 |
| 10483 // Test that a call handler can be set for objects which will allow | 10554 // Test that a call handler can be set for objects which will allow |
| 10484 // non-function objects created through the API to be called as | 10555 // non-function objects created through the API to be called as |
| 10485 // functions. | 10556 // functions. |
| 10486 THREADED_TEST(CallAsFunction) { | 10557 THREADED_TEST(CallAsFunction) { |
| 10487 LocalContext context; | 10558 LocalContext context; |
| 10488 v8::HandleScope scope(context->GetIsolate()); | 10559 v8::Isolate* isolate = context->GetIsolate(); |
| 10560 v8::HandleScope scope(isolate); |
| 10489 | 10561 |
| 10490 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 10562 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 10491 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 10563 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
| 10492 instance_template->SetCallAsFunctionHandler(call_as_function); | 10564 instance_template->SetCallAsFunctionHandler(call_as_function); |
| 10493 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 10565 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
| 10494 context->Global()->Set(v8_str("obj"), instance); | 10566 context->Global()->Set(v8_str("obj"), instance); |
| 10495 v8::TryCatch try_catch; | 10567 v8::TryCatch try_catch; |
| 10496 Local<Value> value; | 10568 Local<Value> value; |
| 10497 CHECK(!try_catch.HasCaught()); | 10569 CHECK(!try_catch.HasCaught()); |
| 10498 | 10570 |
| 10499 value = CompileRun("obj(42)"); | 10571 value = CompileRun("obj(42)"); |
| 10500 CHECK(!try_catch.HasCaught()); | 10572 CHECK(!try_catch.HasCaught()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10533 CHECK_EQ(-43, value->Int32Value()); | 10605 CHECK_EQ(-43, value->Int32Value()); |
| 10534 | 10606 |
| 10535 // Check that the call-as-function handler can be called through | 10607 // Check that the call-as-function handler can be called through |
| 10536 // the API. | 10608 // the API. |
| 10537 v8::Handle<Value> args[] = { v8_num(28) }; | 10609 v8::Handle<Value> args[] = { v8_num(28) }; |
| 10538 value = instance->CallAsFunction(instance, 1, args); | 10610 value = instance->CallAsFunction(instance, 1, args); |
| 10539 CHECK(!try_catch.HasCaught()); | 10611 CHECK(!try_catch.HasCaught()); |
| 10540 CHECK_EQ(28, value->Int32Value()); | 10612 CHECK_EQ(28, value->Int32Value()); |
| 10541 } | 10613 } |
| 10542 | 10614 |
| 10543 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 10615 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 10544 Local<ObjectTemplate> instance_template(t->InstanceTemplate()); | 10616 Local<ObjectTemplate> instance_template(t->InstanceTemplate()); |
| 10545 USE(instance_template); | 10617 USE(instance_template); |
| 10546 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 10618 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
| 10547 context->Global()->Set(v8_str("obj2"), instance); | 10619 context->Global()->Set(v8_str("obj2"), instance); |
| 10548 v8::TryCatch try_catch; | 10620 v8::TryCatch try_catch; |
| 10549 Local<Value> value; | 10621 Local<Value> value; |
| 10550 CHECK(!try_catch.HasCaught()); | 10622 CHECK(!try_catch.HasCaught()); |
| 10551 | 10623 |
| 10552 // Call an object without call-as-function handler through the JS | 10624 // Call an object without call-as-function handler through the JS |
| 10553 value = CompileRun("obj2(28)"); | 10625 value = CompileRun("obj2(28)"); |
| 10554 CHECK(value.IsEmpty()); | 10626 CHECK(value.IsEmpty()); |
| 10555 CHECK(try_catch.HasCaught()); | 10627 CHECK(try_catch.HasCaught()); |
| 10556 String::Utf8Value exception_value1(try_catch.Exception()); | 10628 String::Utf8Value exception_value1(try_catch.Exception()); |
| 10557 CHECK_EQ("TypeError: Property 'obj2' of object #<Object> is not a function", | 10629 CHECK_EQ("TypeError: Property 'obj2' of object #<Object> is not a function", |
| 10558 *exception_value1); | 10630 *exception_value1); |
| 10559 try_catch.Reset(); | 10631 try_catch.Reset(); |
| 10560 | 10632 |
| 10561 // Call an object without call-as-function handler through the API | 10633 // Call an object without call-as-function handler through the API |
| 10562 value = CompileRun("obj2(28)"); | 10634 value = CompileRun("obj2(28)"); |
| 10563 v8::Handle<Value> args[] = { v8_num(28) }; | 10635 v8::Handle<Value> args[] = { v8_num(28) }; |
| 10564 value = instance->CallAsFunction(instance, 1, args); | 10636 value = instance->CallAsFunction(instance, 1, args); |
| 10565 CHECK(value.IsEmpty()); | 10637 CHECK(value.IsEmpty()); |
| 10566 CHECK(try_catch.HasCaught()); | 10638 CHECK(try_catch.HasCaught()); |
| 10567 String::Utf8Value exception_value2(try_catch.Exception()); | 10639 String::Utf8Value exception_value2(try_catch.Exception()); |
| 10568 CHECK_EQ("TypeError: [object Object] is not a function", *exception_value2); | 10640 CHECK_EQ("TypeError: [object Object] is not a function", *exception_value2); |
| 10569 try_catch.Reset(); | 10641 try_catch.Reset(); |
| 10570 } | 10642 } |
| 10571 | 10643 |
| 10572 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 10644 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 10573 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 10645 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
| 10574 instance_template->SetCallAsFunctionHandler(ThrowValue); | 10646 instance_template->SetCallAsFunctionHandler(ThrowValue); |
| 10575 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 10647 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
| 10576 context->Global()->Set(v8_str("obj3"), instance); | 10648 context->Global()->Set(v8_str("obj3"), instance); |
| 10577 v8::TryCatch try_catch; | 10649 v8::TryCatch try_catch; |
| 10578 Local<Value> value; | 10650 Local<Value> value; |
| 10579 CHECK(!try_catch.HasCaught()); | 10651 CHECK(!try_catch.HasCaught()); |
| 10580 | 10652 |
| 10581 // Catch the exception which is thrown by call-as-function handler | 10653 // Catch the exception which is thrown by call-as-function handler |
| 10582 value = CompileRun("obj3(22)"); | 10654 value = CompileRun("obj3(22)"); |
| 10583 CHECK(try_catch.HasCaught()); | 10655 CHECK(try_catch.HasCaught()); |
| 10584 String::Utf8Value exception_value1(try_catch.Exception()); | 10656 String::Utf8Value exception_value1(try_catch.Exception()); |
| 10585 CHECK_EQ("22", *exception_value1); | 10657 CHECK_EQ("22", *exception_value1); |
| 10586 try_catch.Reset(); | 10658 try_catch.Reset(); |
| 10587 | 10659 |
| 10588 v8::Handle<Value> args[] = { v8_num(23) }; | 10660 v8::Handle<Value> args[] = { v8_num(23) }; |
| 10589 value = instance->CallAsFunction(instance, 1, args); | 10661 value = instance->CallAsFunction(instance, 1, args); |
| 10590 CHECK(try_catch.HasCaught()); | 10662 CHECK(try_catch.HasCaught()); |
| 10591 String::Utf8Value exception_value2(try_catch.Exception()); | 10663 String::Utf8Value exception_value2(try_catch.Exception()); |
| 10592 CHECK_EQ("23", *exception_value2); | 10664 CHECK_EQ("23", *exception_value2); |
| 10593 try_catch.Reset(); | 10665 try_catch.Reset(); |
| 10594 } | 10666 } |
| 10595 | 10667 |
| 10596 { v8::Isolate* isolate = context->GetIsolate(); | 10668 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 10597 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | |
| 10598 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 10669 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
| 10599 instance_template->SetCallAsFunctionHandler(ReturnThis); | 10670 instance_template->SetCallAsFunctionHandler(ReturnThis); |
| 10600 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 10671 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
| 10601 | 10672 |
| 10602 Local<v8::Value> a1 = | 10673 Local<v8::Value> a1 = |
| 10603 instance->CallAsFunction(v8::Undefined(isolate), 0, NULL); | 10674 instance->CallAsFunction(v8::Undefined(isolate), 0, NULL); |
| 10604 CHECK(a1->StrictEquals(instance)); | 10675 CHECK(a1->StrictEquals(instance)); |
| 10605 Local<v8::Value> a2 = | 10676 Local<v8::Value> a2 = |
| 10606 instance->CallAsFunction(v8::Null(isolate), 0, NULL); | 10677 instance->CallAsFunction(v8::Null(isolate), 0, NULL); |
| 10607 CHECK(a2->StrictEquals(instance)); | 10678 CHECK(a2->StrictEquals(instance)); |
| 10608 Local<v8::Value> a3 = | 10679 Local<v8::Value> a3 = |
| 10609 instance->CallAsFunction(v8_num(42), 0, NULL); | 10680 instance->CallAsFunction(v8_num(42), 0, NULL); |
| 10610 CHECK(a3->StrictEquals(instance)); | 10681 CHECK(a3->StrictEquals(instance)); |
| 10611 Local<v8::Value> a4 = | 10682 Local<v8::Value> a4 = |
| 10612 instance->CallAsFunction(v8_str("hello"), 0, NULL); | 10683 instance->CallAsFunction(v8_str("hello"), 0, NULL); |
| 10613 CHECK(a4->StrictEquals(instance)); | 10684 CHECK(a4->StrictEquals(instance)); |
| 10614 Local<v8::Value> a5 = | 10685 Local<v8::Value> a5 = |
| 10615 instance->CallAsFunction(v8::True(isolate), 0, NULL); | 10686 instance->CallAsFunction(v8::True(isolate), 0, NULL); |
| 10616 CHECK(a5->StrictEquals(instance)); | 10687 CHECK(a5->StrictEquals(instance)); |
| 10617 } | 10688 } |
| 10618 | 10689 |
| 10619 { v8::Isolate* isolate = context->GetIsolate(); | 10690 { CompileRun( |
| 10620 CompileRun( | |
| 10621 "function ReturnThisSloppy() {" | 10691 "function ReturnThisSloppy() {" |
| 10622 " return this;" | 10692 " return this;" |
| 10623 "}" | 10693 "}" |
| 10624 "function ReturnThisStrict() {" | 10694 "function ReturnThisStrict() {" |
| 10625 " 'use strict';" | 10695 " 'use strict';" |
| 10626 " return this;" | 10696 " return this;" |
| 10627 "}"); | 10697 "}"); |
| 10628 Local<Function> ReturnThisSloppy = | 10698 Local<Function> ReturnThisSloppy = |
| 10629 Local<Function>::Cast( | 10699 Local<Function>::Cast( |
| 10630 context->Global()->Get(v8_str("ReturnThisSloppy"))); | 10700 context->Global()->Get(v8_str("ReturnThisSloppy"))); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10666 Local<v8::Value> a10 = | 10736 Local<v8::Value> a10 = |
| 10667 ReturnThisStrict->CallAsFunction(v8::True(isolate), 0, NULL); | 10737 ReturnThisStrict->CallAsFunction(v8::True(isolate), 0, NULL); |
| 10668 CHECK(a10->StrictEquals(v8::True(isolate))); | 10738 CHECK(a10->StrictEquals(v8::True(isolate))); |
| 10669 } | 10739 } |
| 10670 } | 10740 } |
| 10671 | 10741 |
| 10672 | 10742 |
| 10673 // Check whether a non-function object is callable. | 10743 // Check whether a non-function object is callable. |
| 10674 THREADED_TEST(CallableObject) { | 10744 THREADED_TEST(CallableObject) { |
| 10675 LocalContext context; | 10745 LocalContext context; |
| 10676 v8::HandleScope scope(context->GetIsolate()); | 10746 v8::Isolate* isolate = context->GetIsolate(); |
| 10747 v8::HandleScope scope(isolate); |
| 10677 | 10748 |
| 10678 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); | 10749 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); |
| 10679 instance_template->SetCallAsFunctionHandler(call_as_function); | 10750 instance_template->SetCallAsFunctionHandler(call_as_function); |
| 10680 Local<Object> instance = instance_template->NewInstance(); | 10751 Local<Object> instance = instance_template->NewInstance(); |
| 10681 v8::TryCatch try_catch; | 10752 v8::TryCatch try_catch; |
| 10682 | 10753 |
| 10683 CHECK(instance->IsCallable()); | 10754 CHECK(instance->IsCallable()); |
| 10684 CHECK(!try_catch.HasCaught()); | 10755 CHECK(!try_catch.HasCaught()); |
| 10685 } | 10756 } |
| 10686 | 10757 |
| 10687 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); | 10758 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); |
| 10688 Local<Object> instance = instance_template->NewInstance(); | 10759 Local<Object> instance = instance_template->NewInstance(); |
| 10689 v8::TryCatch try_catch; | 10760 v8::TryCatch try_catch; |
| 10690 | 10761 |
| 10691 CHECK(!instance->IsCallable()); | 10762 CHECK(!instance->IsCallable()); |
| 10692 CHECK(!try_catch.HasCaught()); | 10763 CHECK(!try_catch.HasCaught()); |
| 10693 } | 10764 } |
| 10694 | 10765 |
| 10695 { Local<FunctionTemplate> function_template = | 10766 { Local<FunctionTemplate> function_template = |
| 10696 FunctionTemplate::New(call_as_function); | 10767 FunctionTemplate::New(isolate, call_as_function); |
| 10697 Local<Function> function = function_template->GetFunction(); | 10768 Local<Function> function = function_template->GetFunction(); |
| 10698 Local<Object> instance = function; | 10769 Local<Object> instance = function; |
| 10699 v8::TryCatch try_catch; | 10770 v8::TryCatch try_catch; |
| 10700 | 10771 |
| 10701 CHECK(instance->IsCallable()); | 10772 CHECK(instance->IsCallable()); |
| 10702 CHECK(!try_catch.HasCaught()); | 10773 CHECK(!try_catch.HasCaught()); |
| 10703 } | 10774 } |
| 10704 | 10775 |
| 10705 { Local<FunctionTemplate> function_template = FunctionTemplate::New(); | 10776 { Local<FunctionTemplate> function_template = FunctionTemplate::New(isolate); |
| 10706 Local<Function> function = function_template->GetFunction(); | 10777 Local<Function> function = function_template->GetFunction(); |
| 10707 Local<Object> instance = function; | 10778 Local<Object> instance = function; |
| 10708 v8::TryCatch try_catch; | 10779 v8::TryCatch try_catch; |
| 10709 | 10780 |
| 10710 CHECK(instance->IsCallable()); | 10781 CHECK(instance->IsCallable()); |
| 10711 CHECK(!try_catch.HasCaught()); | 10782 CHECK(!try_catch.HasCaught()); |
| 10712 } | 10783 } |
| 10713 } | 10784 } |
| 10714 | 10785 |
| 10715 | 10786 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10757 | 10828 |
| 10758 static void InterceptorHasOwnPropertyGetter( | 10829 static void InterceptorHasOwnPropertyGetter( |
| 10759 Local<String> name, | 10830 Local<String> name, |
| 10760 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10831 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10761 ApiTestFuzzer::Fuzz(); | 10832 ApiTestFuzzer::Fuzz(); |
| 10762 } | 10833 } |
| 10763 | 10834 |
| 10764 | 10835 |
| 10765 THREADED_TEST(InterceptorHasOwnProperty) { | 10836 THREADED_TEST(InterceptorHasOwnProperty) { |
| 10766 LocalContext context; | 10837 LocalContext context; |
| 10767 v8::HandleScope scope(context->GetIsolate()); | 10838 v8::Isolate* isolate = context->GetIsolate(); |
| 10768 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 10839 v8::HandleScope scope(isolate); |
| 10840 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate); |
| 10769 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); | 10841 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); |
| 10770 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetter); | 10842 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetter); |
| 10771 Local<Function> function = fun_templ->GetFunction(); | 10843 Local<Function> function = fun_templ->GetFunction(); |
| 10772 context->Global()->Set(v8_str("constructor"), function); | 10844 context->Global()->Set(v8_str("constructor"), function); |
| 10773 v8::Handle<Value> value = CompileRun( | 10845 v8::Handle<Value> value = CompileRun( |
| 10774 "var o = new constructor();" | 10846 "var o = new constructor();" |
| 10775 "o.hasOwnProperty('ostehaps');"); | 10847 "o.hasOwnProperty('ostehaps');"); |
| 10776 CHECK_EQ(false, value->BooleanValue()); | 10848 CHECK_EQ(false, value->BooleanValue()); |
| 10777 value = CompileRun( | 10849 value = CompileRun( |
| 10778 "o.ostehaps = 42;" | 10850 "o.ostehaps = 42;" |
| 10779 "o.hasOwnProperty('ostehaps');"); | 10851 "o.hasOwnProperty('ostehaps');"); |
| 10780 CHECK_EQ(true, value->BooleanValue()); | 10852 CHECK_EQ(true, value->BooleanValue()); |
| 10781 value = CompileRun( | 10853 value = CompileRun( |
| 10782 "var p = new constructor();" | 10854 "var p = new constructor();" |
| 10783 "p.hasOwnProperty('ostehaps');"); | 10855 "p.hasOwnProperty('ostehaps');"); |
| 10784 CHECK_EQ(false, value->BooleanValue()); | 10856 CHECK_EQ(false, value->BooleanValue()); |
| 10785 } | 10857 } |
| 10786 | 10858 |
| 10787 | 10859 |
| 10788 static void InterceptorHasOwnPropertyGetterGC( | 10860 static void InterceptorHasOwnPropertyGetterGC( |
| 10789 Local<String> name, | 10861 Local<String> name, |
| 10790 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10862 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10791 ApiTestFuzzer::Fuzz(); | 10863 ApiTestFuzzer::Fuzz(); |
| 10792 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 10864 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 10793 } | 10865 } |
| 10794 | 10866 |
| 10795 | 10867 |
| 10796 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { | 10868 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { |
| 10797 LocalContext context; | 10869 LocalContext context; |
| 10798 v8::HandleScope scope(context->GetIsolate()); | 10870 v8::Isolate* isolate = context->GetIsolate(); |
| 10799 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 10871 v8::HandleScope scope(isolate); |
| 10872 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate); |
| 10800 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); | 10873 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); |
| 10801 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetterGC); | 10874 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetterGC); |
| 10802 Local<Function> function = fun_templ->GetFunction(); | 10875 Local<Function> function = fun_templ->GetFunction(); |
| 10803 context->Global()->Set(v8_str("constructor"), function); | 10876 context->Global()->Set(v8_str("constructor"), function); |
| 10804 // Let's first make some stuff so we can be sure to get a good GC. | 10877 // Let's first make some stuff so we can be sure to get a good GC. |
| 10805 CompileRun( | 10878 CompileRun( |
| 10806 "function makestr(size) {" | 10879 "function makestr(size) {" |
| 10807 " switch (size) {" | 10880 " switch (size) {" |
| 10808 " case 1: return 'f';" | 10881 " case 1: return 'f';" |
| 10809 " case 2: return 'fo';" | 10882 " case 2: return 'fo';" |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11619 if (count++ % 3 == 0) { | 11692 if (count++ % 3 == 0) { |
| 11620 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 11693 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 11621 // This should move the stub | 11694 // This should move the stub |
| 11622 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed | 11695 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed |
| 11623 } | 11696 } |
| 11624 } | 11697 } |
| 11625 | 11698 |
| 11626 | 11699 |
| 11627 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { | 11700 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { |
| 11628 LocalContext context; | 11701 LocalContext context; |
| 11629 v8::HandleScope scope(context->GetIsolate()); | 11702 v8::Isolate* isolate = context->GetIsolate(); |
| 11703 v8::HandleScope scope(isolate); |
| 11630 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); | 11704 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); |
| 11631 nativeobject_templ->Set(context->GetIsolate(), "callback", | 11705 nativeobject_templ->Set(isolate, "callback", |
| 11632 v8::FunctionTemplate::New(DirectApiCallback)); | 11706 v8::FunctionTemplate::New(isolate, |
| 11707 DirectApiCallback)); |
| 11633 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); | 11708 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); |
| 11634 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); | 11709 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); |
| 11635 // call the api function multiple times to ensure direct call stub creation. | 11710 // call the api function multiple times to ensure direct call stub creation. |
| 11636 CompileRun( | 11711 CompileRun( |
| 11637 "function f() {" | 11712 "function f() {" |
| 11638 " for (var i = 1; i <= 30; i++) {" | 11713 " for (var i = 1; i <= 30; i++) {" |
| 11639 " nativeobject.callback();" | 11714 " nativeobject.callback();" |
| 11640 " }" | 11715 " }" |
| 11641 "}" | 11716 "}" |
| 11642 "f();"); | 11717 "f();"); |
| 11643 } | 11718 } |
| 11644 | 11719 |
| 11645 | 11720 |
| 11646 void ThrowingDirectApiCallback( | 11721 void ThrowingDirectApiCallback( |
| 11647 const v8::FunctionCallbackInfo<v8::Value>& args) { | 11722 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 11648 args.GetIsolate()->ThrowException(v8_str("g")); | 11723 args.GetIsolate()->ThrowException(v8_str("g")); |
| 11649 } | 11724 } |
| 11650 | 11725 |
| 11651 | 11726 |
| 11652 THREADED_TEST(CallICFastApi_DirectCall_Throw) { | 11727 THREADED_TEST(CallICFastApi_DirectCall_Throw) { |
| 11653 LocalContext context; | 11728 LocalContext context; |
| 11654 v8::HandleScope scope(context->GetIsolate()); | 11729 v8::Isolate* isolate = context->GetIsolate(); |
| 11655 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); | 11730 v8::HandleScope scope(isolate); |
| 11656 nativeobject_templ->Set(context->GetIsolate(), "callback", | 11731 v8::Handle<v8::ObjectTemplate> nativeobject_templ = |
| 11657 v8::FunctionTemplate::New(ThrowingDirectApiCallback)); | 11732 v8::ObjectTemplate::New(); |
| 11733 nativeobject_templ->Set(isolate, "callback", |
| 11734 v8::FunctionTemplate::New(isolate, |
| 11735 ThrowingDirectApiCallback)); |
| 11658 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); | 11736 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); |
| 11659 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); | 11737 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); |
| 11660 // call the api function multiple times to ensure direct call stub creation. | 11738 // call the api function multiple times to ensure direct call stub creation. |
| 11661 v8::Handle<Value> result = CompileRun( | 11739 v8::Handle<Value> result = CompileRun( |
| 11662 "var result = '';" | 11740 "var result = '';" |
| 11663 "function f() {" | 11741 "function f() {" |
| 11664 " for (var i = 1; i <= 5; i++) {" | 11742 " for (var i = 1; i <= 5; i++) {" |
| 11665 " try { nativeobject.callback(); } catch (e) { result += e; }" | 11743 " try { nativeobject.callback(); } catch (e) { result += e; }" |
| 11666 " }" | 11744 " }" |
| 11667 "}" | 11745 "}" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11728 "for (var i = 0; i < 5; i++) {" | 11806 "for (var i = 0; i < 5; i++) {" |
| 11729 " try { o1.p1; } catch (e) { result += e; }" | 11807 " try { o1.p1; } catch (e) { result += e; }" |
| 11730 "}" | 11808 "}" |
| 11731 "result;"); | 11809 "result;"); |
| 11732 CHECK_EQ(v8_str("ggggg"), result); | 11810 CHECK_EQ(v8_str("ggggg"), result); |
| 11733 } | 11811 } |
| 11734 | 11812 |
| 11735 | 11813 |
| 11736 THREADED_PROFILED_TEST(InterceptorCallICFastApi_TrivialSignature) { | 11814 THREADED_PROFILED_TEST(InterceptorCallICFastApi_TrivialSignature) { |
| 11737 int interceptor_call_count = 0; | 11815 int interceptor_call_count = 0; |
| 11738 v8::HandleScope scope(CcTest::isolate()); | 11816 v8::Isolate* isolate = CcTest::isolate(); |
| 11739 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11817 v8::HandleScope scope(isolate); |
| 11818 v8::Handle<v8::FunctionTemplate> fun_templ = |
| 11819 v8::FunctionTemplate::New(isolate); |
| 11740 v8::Handle<v8::FunctionTemplate> method_templ = | 11820 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11741 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, | 11821 v8::FunctionTemplate::New(isolate, |
| 11822 FastApiCallback_TrivialSignature, |
| 11742 v8_str("method_data"), | 11823 v8_str("method_data"), |
| 11743 v8::Handle<v8::Signature>()); | 11824 v8::Handle<v8::Signature>()); |
| 11744 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11825 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11745 proto_templ->Set(v8_str("method"), method_templ); | 11826 proto_templ->Set(v8_str("method"), method_templ); |
| 11746 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11827 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11747 templ->SetNamedPropertyHandler( | 11828 templ->SetNamedPropertyHandler( |
| 11748 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 11829 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11749 v8::External::New(CcTest::isolate(), &interceptor_call_count)); | 11830 v8::External::New(isolate, &interceptor_call_count)); |
| 11750 LocalContext context; | 11831 LocalContext context; |
| 11751 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11832 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11752 GenerateSomeGarbage(); | 11833 GenerateSomeGarbage(); |
| 11753 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11834 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11754 CompileRun( | 11835 CompileRun( |
| 11755 "var result = 0;" | 11836 "var result = 0;" |
| 11756 "for (var i = 0; i < 100; i++) {" | 11837 "for (var i = 0; i < 100; i++) {" |
| 11757 " result = o.method(41);" | 11838 " result = o.method(41);" |
| 11758 "}"); | 11839 "}"); |
| 11759 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11840 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11760 CHECK_EQ(100, interceptor_call_count); | 11841 CHECK_EQ(100, interceptor_call_count); |
| 11761 } | 11842 } |
| 11762 | 11843 |
| 11763 | 11844 |
| 11764 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) { | 11845 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) { |
| 11765 int interceptor_call_count = 0; | 11846 int interceptor_call_count = 0; |
| 11766 v8::HandleScope scope(CcTest::isolate()); | 11847 v8::Isolate* isolate = CcTest::isolate(); |
| 11767 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11848 v8::HandleScope scope(isolate); |
| 11849 v8::Handle<v8::FunctionTemplate> fun_templ = |
| 11850 v8::FunctionTemplate::New(isolate); |
| 11768 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( | 11851 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11769 FastApiCallback_SimpleSignature, v8_str("method_data"), | 11852 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11770 v8::Signature::New(CcTest::isolate(), fun_templ)); | 11853 v8::Signature::New(isolate, fun_templ)); |
| 11771 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11854 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11772 proto_templ->Set(v8_str("method"), method_templ); | 11855 proto_templ->Set(v8_str("method"), method_templ); |
| 11773 fun_templ->SetHiddenPrototype(true); | 11856 fun_templ->SetHiddenPrototype(true); |
| 11774 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11857 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11775 templ->SetNamedPropertyHandler( | 11858 templ->SetNamedPropertyHandler( |
| 11776 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 11859 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11777 v8::External::New(CcTest::isolate(), &interceptor_call_count)); | 11860 v8::External::New(isolate, &interceptor_call_count)); |
| 11778 LocalContext context; | 11861 LocalContext context; |
| 11779 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11862 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11780 GenerateSomeGarbage(); | 11863 GenerateSomeGarbage(); |
| 11781 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11864 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11782 CompileRun( | 11865 CompileRun( |
| 11783 "o.foo = 17;" | 11866 "o.foo = 17;" |
| 11784 "var receiver = {};" | 11867 "var receiver = {};" |
| 11785 "receiver.__proto__ = o;" | 11868 "receiver.__proto__ = o;" |
| 11786 "var result = 0;" | 11869 "var result = 0;" |
| 11787 "for (var i = 0; i < 100; i++) {" | 11870 "for (var i = 0; i < 100; i++) {" |
| 11788 " result = receiver.method(41);" | 11871 " result = receiver.method(41);" |
| 11789 "}"); | 11872 "}"); |
| 11790 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11873 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11791 CHECK_EQ(100, interceptor_call_count); | 11874 CHECK_EQ(100, interceptor_call_count); |
| 11792 } | 11875 } |
| 11793 | 11876 |
| 11794 | 11877 |
| 11795 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { | 11878 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { |
| 11796 int interceptor_call_count = 0; | 11879 int interceptor_call_count = 0; |
| 11797 v8::HandleScope scope(CcTest::isolate()); | 11880 v8::Isolate* isolate = CcTest::isolate(); |
| 11798 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11881 v8::HandleScope scope(isolate); |
| 11882 v8::Handle<v8::FunctionTemplate> fun_templ = |
| 11883 v8::FunctionTemplate::New(isolate); |
| 11799 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( | 11884 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11800 FastApiCallback_SimpleSignature, v8_str("method_data"), | 11885 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11801 v8::Signature::New(CcTest::isolate(), fun_templ)); | 11886 v8::Signature::New(isolate, fun_templ)); |
| 11802 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11887 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11803 proto_templ->Set(v8_str("method"), method_templ); | 11888 proto_templ->Set(v8_str("method"), method_templ); |
| 11804 fun_templ->SetHiddenPrototype(true); | 11889 fun_templ->SetHiddenPrototype(true); |
| 11805 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11890 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11806 templ->SetNamedPropertyHandler( | 11891 templ->SetNamedPropertyHandler( |
| 11807 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 11892 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11808 v8::External::New(CcTest::isolate(), &interceptor_call_count)); | 11893 v8::External::New(isolate, &interceptor_call_count)); |
| 11809 LocalContext context; | 11894 LocalContext context; |
| 11810 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11895 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11811 GenerateSomeGarbage(); | 11896 GenerateSomeGarbage(); |
| 11812 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11897 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11813 CompileRun( | 11898 CompileRun( |
| 11814 "o.foo = 17;" | 11899 "o.foo = 17;" |
| 11815 "var receiver = {};" | 11900 "var receiver = {};" |
| 11816 "receiver.__proto__ = o;" | 11901 "receiver.__proto__ = o;" |
| 11817 "var result = 0;" | 11902 "var result = 0;" |
| 11818 "var saved_result = 0;" | 11903 "var saved_result = 0;" |
| 11819 "for (var i = 0; i < 100; i++) {" | 11904 "for (var i = 0; i < 100; i++) {" |
| 11820 " result = receiver.method(41);" | 11905 " result = receiver.method(41);" |
| 11821 " if (i == 50) {" | 11906 " if (i == 50) {" |
| 11822 " saved_result = result;" | 11907 " saved_result = result;" |
| 11823 " receiver = {method: function(x) { return x - 1 }};" | 11908 " receiver = {method: function(x) { return x - 1 }};" |
| 11824 " }" | 11909 " }" |
| 11825 "}"); | 11910 "}"); |
| 11826 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); | 11911 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11827 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11912 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11828 CHECK_GE(interceptor_call_count, 50); | 11913 CHECK_GE(interceptor_call_count, 50); |
| 11829 } | 11914 } |
| 11830 | 11915 |
| 11831 | 11916 |
| 11832 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) { | 11917 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) { |
| 11833 int interceptor_call_count = 0; | 11918 int interceptor_call_count = 0; |
| 11834 v8::HandleScope scope(CcTest::isolate()); | 11919 v8::Isolate* isolate = CcTest::isolate(); |
| 11835 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11920 v8::HandleScope scope(isolate); |
| 11921 v8::Handle<v8::FunctionTemplate> fun_templ = |
| 11922 v8::FunctionTemplate::New(isolate); |
| 11836 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( | 11923 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11837 FastApiCallback_SimpleSignature, v8_str("method_data"), | 11924 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11838 v8::Signature::New(CcTest::isolate(), fun_templ)); | 11925 v8::Signature::New(isolate, fun_templ)); |
| 11839 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11926 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11840 proto_templ->Set(v8_str("method"), method_templ); | 11927 proto_templ->Set(v8_str("method"), method_templ); |
| 11841 fun_templ->SetHiddenPrototype(true); | 11928 fun_templ->SetHiddenPrototype(true); |
| 11842 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11929 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11843 templ->SetNamedPropertyHandler( | 11930 templ->SetNamedPropertyHandler( |
| 11844 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 11931 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11845 v8::External::New(CcTest::isolate(), &interceptor_call_count)); | 11932 v8::External::New(isolate, &interceptor_call_count)); |
| 11846 LocalContext context; | 11933 LocalContext context; |
| 11847 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11934 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11848 GenerateSomeGarbage(); | 11935 GenerateSomeGarbage(); |
| 11849 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11936 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11850 CompileRun( | 11937 CompileRun( |
| 11851 "o.foo = 17;" | 11938 "o.foo = 17;" |
| 11852 "var receiver = {};" | 11939 "var receiver = {};" |
| 11853 "receiver.__proto__ = o;" | 11940 "receiver.__proto__ = o;" |
| 11854 "var result = 0;" | 11941 "var result = 0;" |
| 11855 "var saved_result = 0;" | 11942 "var saved_result = 0;" |
| 11856 "for (var i = 0; i < 100; i++) {" | 11943 "for (var i = 0; i < 100; i++) {" |
| 11857 " result = receiver.method(41);" | 11944 " result = receiver.method(41);" |
| 11858 " if (i == 50) {" | 11945 " if (i == 50) {" |
| 11859 " saved_result = result;" | 11946 " saved_result = result;" |
| 11860 " o.method = function(x) { return x - 1 };" | 11947 " o.method = function(x) { return x - 1 };" |
| 11861 " }" | 11948 " }" |
| 11862 "}"); | 11949 "}"); |
| 11863 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); | 11950 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11864 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11951 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11865 CHECK_GE(interceptor_call_count, 50); | 11952 CHECK_GE(interceptor_call_count, 50); |
| 11866 } | 11953 } |
| 11867 | 11954 |
| 11868 | 11955 |
| 11869 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) { | 11956 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) { |
| 11870 int interceptor_call_count = 0; | 11957 int interceptor_call_count = 0; |
| 11871 v8::HandleScope scope(CcTest::isolate()); | 11958 v8::Isolate* isolate = CcTest::isolate(); |
| 11872 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11959 v8::HandleScope scope(isolate); |
| 11960 v8::Handle<v8::FunctionTemplate> fun_templ = |
| 11961 v8::FunctionTemplate::New(isolate); |
| 11873 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( | 11962 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11874 FastApiCallback_SimpleSignature, v8_str("method_data"), | 11963 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11875 v8::Signature::New(CcTest::isolate(), fun_templ)); | 11964 v8::Signature::New(isolate, fun_templ)); |
| 11876 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11965 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11877 proto_templ->Set(v8_str("method"), method_templ); | 11966 proto_templ->Set(v8_str("method"), method_templ); |
| 11878 fun_templ->SetHiddenPrototype(true); | 11967 fun_templ->SetHiddenPrototype(true); |
| 11879 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11968 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11880 templ->SetNamedPropertyHandler( | 11969 templ->SetNamedPropertyHandler( |
| 11881 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 11970 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11882 v8::External::New(CcTest::isolate(), &interceptor_call_count)); | 11971 v8::External::New(isolate, &interceptor_call_count)); |
| 11883 LocalContext context; | 11972 LocalContext context; |
| 11884 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11973 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11885 GenerateSomeGarbage(); | 11974 GenerateSomeGarbage(); |
| 11886 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11975 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11887 v8::TryCatch try_catch; | 11976 v8::TryCatch try_catch; |
| 11888 CompileRun( | 11977 CompileRun( |
| 11889 "o.foo = 17;" | 11978 "o.foo = 17;" |
| 11890 "var receiver = {};" | 11979 "var receiver = {};" |
| 11891 "receiver.__proto__ = o;" | 11980 "receiver.__proto__ = o;" |
| 11892 "var result = 0;" | 11981 "var result = 0;" |
| 11893 "var saved_result = 0;" | 11982 "var saved_result = 0;" |
| 11894 "for (var i = 0; i < 100; i++) {" | 11983 "for (var i = 0; i < 100; i++) {" |
| 11895 " result = receiver.method(41);" | 11984 " result = receiver.method(41);" |
| 11896 " if (i == 50) {" | 11985 " if (i == 50) {" |
| 11897 " saved_result = result;" | 11986 " saved_result = result;" |
| 11898 " receiver = 333;" | 11987 " receiver = 333;" |
| 11899 " }" | 11988 " }" |
| 11900 "}"); | 11989 "}"); |
| 11901 CHECK(try_catch.HasCaught()); | 11990 CHECK(try_catch.HasCaught()); |
| 11902 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), | 11991 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), |
| 11903 try_catch.Exception()->ToString()); | 11992 try_catch.Exception()->ToString()); |
| 11904 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11993 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11905 CHECK_GE(interceptor_call_count, 50); | 11994 CHECK_GE(interceptor_call_count, 50); |
| 11906 } | 11995 } |
| 11907 | 11996 |
| 11908 | 11997 |
| 11909 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { | 11998 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { |
| 11910 int interceptor_call_count = 0; | 11999 int interceptor_call_count = 0; |
| 11911 v8::HandleScope scope(CcTest::isolate()); | 12000 v8::Isolate* isolate = CcTest::isolate(); |
| 11912 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 12001 v8::HandleScope scope(isolate); |
| 12002 v8::Handle<v8::FunctionTemplate> fun_templ = |
| 12003 v8::FunctionTemplate::New(isolate); |
| 11913 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( | 12004 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11914 FastApiCallback_SimpleSignature, v8_str("method_data"), | 12005 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11915 v8::Signature::New(CcTest::isolate(), fun_templ)); | 12006 v8::Signature::New(isolate, fun_templ)); |
| 11916 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 12007 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11917 proto_templ->Set(v8_str("method"), method_templ); | 12008 proto_templ->Set(v8_str("method"), method_templ); |
| 11918 fun_templ->SetHiddenPrototype(true); | 12009 fun_templ->SetHiddenPrototype(true); |
| 11919 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 12010 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11920 templ->SetNamedPropertyHandler( | 12011 templ->SetNamedPropertyHandler( |
| 11921 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 12012 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11922 v8::External::New(CcTest::isolate(), &interceptor_call_count)); | 12013 v8::External::New(isolate, &interceptor_call_count)); |
| 11923 LocalContext context; | 12014 LocalContext context; |
| 11924 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 12015 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11925 GenerateSomeGarbage(); | 12016 GenerateSomeGarbage(); |
| 11926 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 12017 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11927 v8::TryCatch try_catch; | 12018 v8::TryCatch try_catch; |
| 11928 CompileRun( | 12019 CompileRun( |
| 11929 "o.foo = 17;" | 12020 "o.foo = 17;" |
| 11930 "var receiver = {};" | 12021 "var receiver = {};" |
| 11931 "receiver.__proto__ = o;" | 12022 "receiver.__proto__ = o;" |
| 11932 "var result = 0;" | 12023 "var result = 0;" |
| 11933 "var saved_result = 0;" | 12024 "var saved_result = 0;" |
| 11934 "for (var i = 0; i < 100; i++) {" | 12025 "for (var i = 0; i < 100; i++) {" |
| 11935 " result = receiver.method(41);" | 12026 " result = receiver.method(41);" |
| 11936 " if (i == 50) {" | 12027 " if (i == 50) {" |
| 11937 " saved_result = result;" | 12028 " saved_result = result;" |
| 11938 " receiver = {method: receiver.method};" | 12029 " receiver = {method: receiver.method};" |
| 11939 " }" | 12030 " }" |
| 11940 "}"); | 12031 "}"); |
| 11941 CHECK(try_catch.HasCaught()); | 12032 CHECK(try_catch.HasCaught()); |
| 11942 CHECK_EQ(v8_str("TypeError: Illegal invocation"), | 12033 CHECK_EQ(v8_str("TypeError: Illegal invocation"), |
| 11943 try_catch.Exception()->ToString()); | 12034 try_catch.Exception()->ToString()); |
| 11944 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 12035 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11945 CHECK_GE(interceptor_call_count, 50); | 12036 CHECK_GE(interceptor_call_count, 50); |
| 11946 } | 12037 } |
| 11947 | 12038 |
| 11948 | 12039 |
| 11949 THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature) { | 12040 THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature) { |
| 11950 v8::HandleScope scope(CcTest::isolate()); | 12041 v8::Isolate* isolate = CcTest::isolate(); |
| 11951 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 12042 v8::HandleScope scope(isolate); |
| 12043 v8::Handle<v8::FunctionTemplate> fun_templ = |
| 12044 v8::FunctionTemplate::New(isolate); |
| 11952 v8::Handle<v8::FunctionTemplate> method_templ = | 12045 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11953 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, | 12046 v8::FunctionTemplate::New(isolate, |
| 12047 FastApiCallback_TrivialSignature, |
| 11954 v8_str("method_data"), | 12048 v8_str("method_data"), |
| 11955 v8::Handle<v8::Signature>()); | 12049 v8::Handle<v8::Signature>()); |
| 11956 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 12050 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11957 proto_templ->Set(v8_str("method"), method_templ); | 12051 proto_templ->Set(v8_str("method"), method_templ); |
| 11958 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 12052 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 11959 USE(templ); | 12053 USE(templ); |
| 11960 LocalContext context; | 12054 LocalContext context; |
| 11961 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 12055 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11962 GenerateSomeGarbage(); | 12056 GenerateSomeGarbage(); |
| 11963 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 12057 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11964 CompileRun( | 12058 CompileRun( |
| 11965 "var result = 0;" | 12059 "var result = 0;" |
| 11966 "for (var i = 0; i < 100; i++) {" | 12060 "for (var i = 0; i < 100; i++) {" |
| 11967 " result = o.method(41);" | 12061 " result = o.method(41);" |
| 11968 "}"); | 12062 "}"); |
| 11969 | 12063 |
| 11970 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 12064 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11971 } | 12065 } |
| 11972 | 12066 |
| 11973 | 12067 |
| 11974 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) { | 12068 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) { |
| 11975 v8::HandleScope scope(CcTest::isolate()); | 12069 v8::Isolate* isolate = CcTest::isolate(); |
| 11976 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 12070 v8::HandleScope scope(isolate); |
| 12071 v8::Handle<v8::FunctionTemplate> fun_templ = |
| 12072 v8::FunctionTemplate::New(isolate); |
| 11977 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( | 12073 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11978 FastApiCallback_SimpleSignature, v8_str("method_data"), | 12074 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11979 v8::Signature::New(CcTest::isolate(), fun_templ)); | 12075 v8::Signature::New(isolate, fun_templ)); |
| 11980 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 12076 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11981 proto_templ->Set(v8_str("method"), method_templ); | 12077 proto_templ->Set(v8_str("method"), method_templ); |
| 11982 fun_templ->SetHiddenPrototype(true); | 12078 fun_templ->SetHiddenPrototype(true); |
| 11983 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 12079 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 11984 CHECK(!templ.IsEmpty()); | 12080 CHECK(!templ.IsEmpty()); |
| 11985 LocalContext context; | 12081 LocalContext context; |
| 11986 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 12082 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11987 GenerateSomeGarbage(); | 12083 GenerateSomeGarbage(); |
| 11988 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 12084 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11989 CompileRun( | 12085 CompileRun( |
| 11990 "o.foo = 17;" | 12086 "o.foo = 17;" |
| 11991 "var receiver = {};" | 12087 "var receiver = {};" |
| 11992 "receiver.__proto__ = o;" | 12088 "receiver.__proto__ = o;" |
| 11993 "var result = 0;" | 12089 "var result = 0;" |
| 11994 "for (var i = 0; i < 100; i++) {" | 12090 "for (var i = 0; i < 100; i++) {" |
| 11995 " result = receiver.method(41);" | 12091 " result = receiver.method(41);" |
| 11996 "}"); | 12092 "}"); |
| 11997 | 12093 |
| 11998 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 12094 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11999 } | 12095 } |
| 12000 | 12096 |
| 12001 | 12097 |
| 12002 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) { | 12098 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) { |
| 12003 v8::HandleScope scope(CcTest::isolate()); | 12099 v8::Isolate* isolate = CcTest::isolate(); |
| 12004 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 12100 v8::HandleScope scope(isolate); |
| 12101 v8::Handle<v8::FunctionTemplate> fun_templ = |
| 12102 v8::FunctionTemplate::New(isolate); |
| 12005 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( | 12103 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 12006 FastApiCallback_SimpleSignature, v8_str("method_data"), | 12104 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 12007 v8::Signature::New(CcTest::isolate(), fun_templ)); | 12105 v8::Signature::New(isolate, fun_templ)); |
| 12008 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 12106 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 12009 proto_templ->Set(v8_str("method"), method_templ); | 12107 proto_templ->Set(v8_str("method"), method_templ); |
| 12010 fun_templ->SetHiddenPrototype(true); | 12108 fun_templ->SetHiddenPrototype(true); |
| 12011 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 12109 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 12012 CHECK(!templ.IsEmpty()); | 12110 CHECK(!templ.IsEmpty()); |
| 12013 LocalContext context; | 12111 LocalContext context; |
| 12014 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 12112 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 12015 GenerateSomeGarbage(); | 12113 GenerateSomeGarbage(); |
| 12016 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 12114 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 12017 CompileRun( | 12115 CompileRun( |
| 12018 "o.foo = 17;" | 12116 "o.foo = 17;" |
| 12019 "var receiver = {};" | 12117 "var receiver = {};" |
| 12020 "receiver.__proto__ = o;" | 12118 "receiver.__proto__ = o;" |
| 12021 "var result = 0;" | 12119 "var result = 0;" |
| 12022 "var saved_result = 0;" | 12120 "var saved_result = 0;" |
| 12023 "for (var i = 0; i < 100; i++) {" | 12121 "for (var i = 0; i < 100; i++) {" |
| 12024 " result = receiver.method(41);" | 12122 " result = receiver.method(41);" |
| 12025 " if (i == 50) {" | 12123 " if (i == 50) {" |
| 12026 " saved_result = result;" | 12124 " saved_result = result;" |
| 12027 " receiver = {method: function(x) { return x - 1 }};" | 12125 " receiver = {method: function(x) { return x - 1 }};" |
| 12028 " }" | 12126 " }" |
| 12029 "}"); | 12127 "}"); |
| 12030 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); | 12128 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 12031 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 12129 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 12032 } | 12130 } |
| 12033 | 12131 |
| 12034 | 12132 |
| 12035 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) { | 12133 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) { |
| 12036 v8::HandleScope scope(CcTest::isolate()); | 12134 v8::Isolate* isolate = CcTest::isolate(); |
| 12037 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 12135 v8::HandleScope scope(isolate); |
| 12136 v8::Handle<v8::FunctionTemplate> fun_templ = |
| 12137 v8::FunctionTemplate::New(isolate); |
| 12038 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( | 12138 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 12039 FastApiCallback_SimpleSignature, v8_str("method_data"), | 12139 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 12040 v8::Signature::New(CcTest::isolate(), fun_templ)); | 12140 v8::Signature::New(isolate, fun_templ)); |
| 12041 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 12141 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 12042 proto_templ->Set(v8_str("method"), method_templ); | 12142 proto_templ->Set(v8_str("method"), method_templ); |
| 12043 fun_templ->SetHiddenPrototype(true); | 12143 fun_templ->SetHiddenPrototype(true); |
| 12044 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 12144 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 12045 CHECK(!templ.IsEmpty()); | 12145 CHECK(!templ.IsEmpty()); |
| 12046 LocalContext context; | 12146 LocalContext context; |
| 12047 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 12147 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 12048 GenerateSomeGarbage(); | 12148 GenerateSomeGarbage(); |
| 12049 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 12149 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 12050 v8::TryCatch try_catch; | 12150 v8::TryCatch try_catch; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 12062 " }" | 12162 " }" |
| 12063 "}"); | 12163 "}"); |
| 12064 CHECK(try_catch.HasCaught()); | 12164 CHECK(try_catch.HasCaught()); |
| 12065 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), | 12165 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), |
| 12066 try_catch.Exception()->ToString()); | 12166 try_catch.Exception()->ToString()); |
| 12067 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 12167 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 12068 } | 12168 } |
| 12069 | 12169 |
| 12070 | 12170 |
| 12071 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { | 12171 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { |
| 12072 v8::HandleScope scope(CcTest::isolate()); | 12172 v8::Isolate* isolate = CcTest::isolate(); |
| 12073 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 12173 v8::HandleScope scope(isolate); |
| 12174 v8::Handle<v8::FunctionTemplate> fun_templ = |
| 12175 v8::FunctionTemplate::New(isolate); |
| 12074 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( | 12176 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 12075 FastApiCallback_SimpleSignature, v8_str("method_data"), | 12177 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 12076 v8::Signature::New(CcTest::isolate(), fun_templ)); | 12178 v8::Signature::New(isolate, fun_templ)); |
| 12077 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 12179 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 12078 proto_templ->Set(v8_str("method"), method_templ); | 12180 proto_templ->Set(v8_str("method"), method_templ); |
| 12079 fun_templ->SetHiddenPrototype(true); | 12181 fun_templ->SetHiddenPrototype(true); |
| 12080 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 12182 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 12081 CHECK(!templ.IsEmpty()); | 12183 CHECK(!templ.IsEmpty()); |
| 12082 LocalContext context; | 12184 LocalContext context; |
| 12083 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 12185 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 12084 GenerateSomeGarbage(); | 12186 GenerateSomeGarbage(); |
| 12085 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 12187 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 12086 v8::TryCatch try_catch; | 12188 v8::TryCatch try_catch; |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12411 templ->Set(CcTest::isolate(), "42", v8_num(42)); | 12513 templ->Set(CcTest::isolate(), "42", v8_num(42)); |
| 12412 v8::Handle<v8::Object> obj = templ->NewInstance(); | 12514 v8::Handle<v8::Object> obj = templ->NewInstance(); |
| 12413 context->Global()->Set(v8_str("obj"), obj); | 12515 context->Global()->Set(v8_str("obj"), obj); |
| 12414 v8::Handle<Value> value = CompileRun("obj[42]"); | 12516 v8::Handle<Value> value = CompileRun("obj[42]"); |
| 12415 CHECK(value->IsInt32()); | 12517 CHECK(value->IsInt32()); |
| 12416 CHECK_EQ(42, value->Int32Value()); | 12518 CHECK_EQ(42, value->Int32Value()); |
| 12417 } | 12519 } |
| 12418 | 12520 |
| 12419 | 12521 |
| 12420 THREADED_TEST(NamedPropertyHandlerGetterAttributes) { | 12522 THREADED_TEST(NamedPropertyHandlerGetterAttributes) { |
| 12421 v8::HandleScope scope(CcTest::isolate()); | 12523 v8::Isolate* isolate = CcTest::isolate(); |
| 12422 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 12524 v8::HandleScope scope(isolate); |
| 12525 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 12423 templ->InstanceTemplate()->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 12526 templ->InstanceTemplate()->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 12424 LocalContext env; | 12527 LocalContext env; |
| 12425 env->Global()->Set(v8_str("obj"), | 12528 env->Global()->Set(v8_str("obj"), |
| 12426 templ->GetFunction()->NewInstance()); | 12529 templ->GetFunction()->NewInstance()); |
| 12427 ExpectTrue("obj.x === 42"); | 12530 ExpectTrue("obj.x === 42"); |
| 12428 ExpectTrue("!obj.propertyIsEnumerable('x')"); | 12531 ExpectTrue("!obj.propertyIsEnumerable('x')"); |
| 12429 } | 12532 } |
| 12430 | 12533 |
| 12431 | 12534 |
| 12432 static void ThrowingGetter(Local<String> name, | 12535 static void ThrowingGetter(Local<String> name, |
| 12433 const v8::PropertyCallbackInfo<v8::Value>& info) { | 12536 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 12434 ApiTestFuzzer::Fuzz(); | 12537 ApiTestFuzzer::Fuzz(); |
| 12435 info.GetIsolate()->ThrowException(Handle<Value>()); | 12538 info.GetIsolate()->ThrowException(Handle<Value>()); |
| 12436 info.GetReturnValue().SetUndefined(); | 12539 info.GetReturnValue().SetUndefined(); |
| 12437 } | 12540 } |
| 12438 | 12541 |
| 12439 | 12542 |
| 12440 THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) { | 12543 THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) { |
| 12441 LocalContext context; | 12544 LocalContext context; |
| 12442 HandleScope scope(context->GetIsolate()); | 12545 HandleScope scope(context->GetIsolate()); |
| 12443 | 12546 |
| 12444 Local<FunctionTemplate> templ = FunctionTemplate::New(); | 12547 Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); |
| 12445 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate(); | 12548 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
| 12446 instance_templ->SetAccessor(v8_str("f"), ThrowingGetter); | 12549 instance_templ->SetAccessor(v8_str("f"), ThrowingGetter); |
| 12447 | 12550 |
| 12448 Local<Object> instance = templ->GetFunction()->NewInstance(); | 12551 Local<Object> instance = templ->GetFunction()->NewInstance(); |
| 12449 | 12552 |
| 12450 Local<Object> another = Object::New(); | 12553 Local<Object> another = Object::New(); |
| 12451 another->SetPrototype(instance); | 12554 another->SetPrototype(instance); |
| 12452 | 12555 |
| 12453 Local<Object> with_js_getter = CompileRun( | 12556 Local<Object> with_js_getter = CompileRun( |
| 12454 "o = {};\n" | 12557 "o = {};\n" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12524 static void WebKitLike(Handle<Message> message, Handle<Value> data) { | 12627 static void WebKitLike(Handle<Message> message, Handle<Value> data) { |
| 12525 Handle<String> errorMessageString = message->Get(); | 12628 Handle<String> errorMessageString = message->Get(); |
| 12526 CHECK(!errorMessageString.IsEmpty()); | 12629 CHECK(!errorMessageString.IsEmpty()); |
| 12527 message->GetStackTrace(); | 12630 message->GetStackTrace(); |
| 12528 message->GetScriptResourceName(); | 12631 message->GetScriptResourceName(); |
| 12529 } | 12632 } |
| 12530 | 12633 |
| 12531 | 12634 |
| 12532 THREADED_TEST(ExceptionsDoNotPropagatePastTryCatch) { | 12635 THREADED_TEST(ExceptionsDoNotPropagatePastTryCatch) { |
| 12533 LocalContext context; | 12636 LocalContext context; |
| 12534 HandleScope scope(context->GetIsolate()); | 12637 v8::Isolate* isolate = context->GetIsolate(); |
| 12638 HandleScope scope(isolate); |
| 12535 | 12639 |
| 12536 Local<Function> func = | 12640 Local<Function> func = |
| 12537 FunctionTemplate::New(ThrowingCallbackWithTryCatch)->GetFunction(); | 12641 FunctionTemplate::New(isolate, |
| 12642 ThrowingCallbackWithTryCatch)->GetFunction(); |
| 12538 context->Global()->Set(v8_str("func"), func); | 12643 context->Global()->Set(v8_str("func"), func); |
| 12539 | 12644 |
| 12540 MessageCallback callbacks[] = | 12645 MessageCallback callbacks[] = |
| 12541 { NULL, WebKitLike, ThrowViaApi, ThrowFromJS, WithTryCatch }; | 12646 { NULL, WebKitLike, ThrowViaApi, ThrowFromJS, WithTryCatch }; |
| 12542 for (unsigned i = 0; i < sizeof(callbacks)/sizeof(callbacks[0]); i++) { | 12647 for (unsigned i = 0; i < sizeof(callbacks)/sizeof(callbacks[0]); i++) { |
| 12543 MessageCallback callback = callbacks[i]; | 12648 MessageCallback callback = callbacks[i]; |
| 12544 if (callback != NULL) { | 12649 if (callback != NULL) { |
| 12545 V8::AddMessageListener(callback); | 12650 V8::AddMessageListener(callback); |
| 12546 } | 12651 } |
| 12547 // Some small number to control number of times message handler should | 12652 // Some small number to control number of times message handler should |
| (...skipping 20 matching lines...) Expand all Loading... |
| 12568 static void ChildGetter(Local<String> name, | 12673 static void ChildGetter(Local<String> name, |
| 12569 const v8::PropertyCallbackInfo<v8::Value>& info) { | 12674 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 12570 ApiTestFuzzer::Fuzz(); | 12675 ApiTestFuzzer::Fuzz(); |
| 12571 info.GetReturnValue().Set(v8_num(42)); | 12676 info.GetReturnValue().Set(v8_num(42)); |
| 12572 } | 12677 } |
| 12573 | 12678 |
| 12574 | 12679 |
| 12575 THREADED_TEST(Overriding) { | 12680 THREADED_TEST(Overriding) { |
| 12576 i::FLAG_es5_readonly = true; | 12681 i::FLAG_es5_readonly = true; |
| 12577 LocalContext context; | 12682 LocalContext context; |
| 12578 v8::HandleScope scope(context->GetIsolate()); | 12683 v8::Isolate* isolate = context->GetIsolate(); |
| 12684 v8::HandleScope scope(isolate); |
| 12579 | 12685 |
| 12580 // Parent template. | 12686 // Parent template. |
| 12581 Local<v8::FunctionTemplate> parent_templ = v8::FunctionTemplate::New(); | 12687 Local<v8::FunctionTemplate> parent_templ = v8::FunctionTemplate::New(isolate); |
| 12582 Local<ObjectTemplate> parent_instance_templ = | 12688 Local<ObjectTemplate> parent_instance_templ = |
| 12583 parent_templ->InstanceTemplate(); | 12689 parent_templ->InstanceTemplate(); |
| 12584 parent_instance_templ->SetAccessor(v8_str("f"), ParentGetter); | 12690 parent_instance_templ->SetAccessor(v8_str("f"), ParentGetter); |
| 12585 | 12691 |
| 12586 // Template that inherits from the parent template. | 12692 // Template that inherits from the parent template. |
| 12587 Local<v8::FunctionTemplate> child_templ = v8::FunctionTemplate::New(); | 12693 Local<v8::FunctionTemplate> child_templ = v8::FunctionTemplate::New(isolate); |
| 12588 Local<ObjectTemplate> child_instance_templ = | 12694 Local<ObjectTemplate> child_instance_templ = |
| 12589 child_templ->InstanceTemplate(); | 12695 child_templ->InstanceTemplate(); |
| 12590 child_templ->Inherit(parent_templ); | 12696 child_templ->Inherit(parent_templ); |
| 12591 // Override 'f'. The child version of 'f' should get called for child | 12697 // Override 'f'. The child version of 'f' should get called for child |
| 12592 // instances. | 12698 // instances. |
| 12593 child_instance_templ->SetAccessor(v8_str("f"), ChildGetter); | 12699 child_instance_templ->SetAccessor(v8_str("f"), ChildGetter); |
| 12594 // Add 'g' twice. The 'g' added last should get called for instances. | 12700 // Add 'g' twice. The 'g' added last should get called for instances. |
| 12595 child_instance_templ->SetAccessor(v8_str("g"), ParentGetter); | 12701 child_instance_templ->SetAccessor(v8_str("g"), ParentGetter); |
| 12596 child_instance_templ->SetAccessor(v8_str("g"), ChildGetter); | 12702 child_instance_templ->SetAccessor(v8_str("g"), ChildGetter); |
| 12597 | 12703 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12631 | 12737 |
| 12632 | 12738 |
| 12633 static void IsConstructHandler( | 12739 static void IsConstructHandler( |
| 12634 const v8::FunctionCallbackInfo<v8::Value>& args) { | 12740 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 12635 ApiTestFuzzer::Fuzz(); | 12741 ApiTestFuzzer::Fuzz(); |
| 12636 args.GetReturnValue().Set(args.IsConstructCall()); | 12742 args.GetReturnValue().Set(args.IsConstructCall()); |
| 12637 } | 12743 } |
| 12638 | 12744 |
| 12639 | 12745 |
| 12640 THREADED_TEST(IsConstructCall) { | 12746 THREADED_TEST(IsConstructCall) { |
| 12641 v8::HandleScope scope(CcTest::isolate()); | 12747 v8::Isolate* isolate = CcTest::isolate(); |
| 12748 v8::HandleScope scope(isolate); |
| 12642 | 12749 |
| 12643 // Function template with call handler. | 12750 // Function template with call handler. |
| 12644 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 12751 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 12645 templ->SetCallHandler(IsConstructHandler); | 12752 templ->SetCallHandler(IsConstructHandler); |
| 12646 | 12753 |
| 12647 LocalContext context; | 12754 LocalContext context; |
| 12648 | 12755 |
| 12649 context->Global()->Set(v8_str("f"), templ->GetFunction()); | 12756 context->Global()->Set(v8_str("f"), templ->GetFunction()); |
| 12650 Local<Value> value = v8_compile("f()")->Run(); | 12757 Local<Value> value = v8_compile("f()")->Run(); |
| 12651 CHECK(!value->BooleanValue()); | 12758 CHECK(!value->BooleanValue()); |
| 12652 value = v8_compile("new f()")->Run(); | 12759 value = v8_compile("new f()")->Run(); |
| 12653 CHECK(value->BooleanValue()); | 12760 CHECK(value->BooleanValue()); |
| 12654 } | 12761 } |
| 12655 | 12762 |
| 12656 | 12763 |
| 12657 THREADED_TEST(ObjectProtoToString) { | 12764 THREADED_TEST(ObjectProtoToString) { |
| 12658 v8::HandleScope scope(CcTest::isolate()); | 12765 v8::Isolate* isolate = CcTest::isolate(); |
| 12659 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 12766 v8::HandleScope scope(isolate); |
| 12767 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 12660 templ->SetClassName(v8_str("MyClass")); | 12768 templ->SetClassName(v8_str("MyClass")); |
| 12661 | 12769 |
| 12662 LocalContext context; | 12770 LocalContext context; |
| 12663 | 12771 |
| 12664 Local<String> customized_tostring = v8_str("customized toString"); | 12772 Local<String> customized_tostring = v8_str("customized toString"); |
| 12665 | 12773 |
| 12666 // Replace Object.prototype.toString | 12774 // Replace Object.prototype.toString |
| 12667 v8_compile("Object.prototype.toString = function() {" | 12775 v8_compile("Object.prototype.toString = function() {" |
| 12668 " return 'customized toString';" | 12776 " return 'customized toString';" |
| 12669 "}")->Run(); | 12777 "}")->Run(); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12910 v8::Handle<Value> value = CompileRun(code); | 13018 v8::Handle<Value> value = CompileRun(code); |
| 12911 CHECK(value.IsEmpty()); | 13019 CHECK(value.IsEmpty()); |
| 12912 args.GetReturnValue().Set(v8_str("foo")); | 13020 args.GetReturnValue().Set(v8_str("foo")); |
| 12913 } | 13021 } |
| 12914 } | 13022 } |
| 12915 | 13023 |
| 12916 | 13024 |
| 12917 // These are locking tests that don't need to be run again | 13025 // These are locking tests that don't need to be run again |
| 12918 // as part of the locking aggregation tests. | 13026 // as part of the locking aggregation tests. |
| 12919 TEST(NestedLockers) { | 13027 TEST(NestedLockers) { |
| 12920 v8::Locker locker(CcTest::isolate()); | 13028 v8::Isolate* isolate = CcTest::isolate(); |
| 12921 CHECK(v8::Locker::IsLocked(CcTest::isolate())); | 13029 v8::Locker locker(isolate); |
| 13030 CHECK(v8::Locker::IsLocked(isolate)); |
| 12922 LocalContext env; | 13031 LocalContext env; |
| 12923 v8::HandleScope scope(env->GetIsolate()); | 13032 v8::HandleScope scope(env->GetIsolate()); |
| 12924 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(ThrowInJS); | 13033 Local<v8::FunctionTemplate> fun_templ = |
| 13034 v8::FunctionTemplate::New(isolate, ThrowInJS); |
| 12925 Local<Function> fun = fun_templ->GetFunction(); | 13035 Local<Function> fun = fun_templ->GetFunction(); |
| 12926 env->Global()->Set(v8_str("throw_in_js"), fun); | 13036 env->Global()->Set(v8_str("throw_in_js"), fun); |
| 12927 Local<Script> script = v8_compile("(function () {" | 13037 Local<Script> script = v8_compile("(function () {" |
| 12928 " try {" | 13038 " try {" |
| 12929 " throw_in_js();" | 13039 " throw_in_js();" |
| 12930 " return 42;" | 13040 " return 42;" |
| 12931 " } catch (e) {" | 13041 " } catch (e) {" |
| 12932 " return e * 13;" | 13042 " return e * 13;" |
| 12933 " }" | 13043 " }" |
| 12934 "})();"); | 13044 "})();"); |
| 12935 CHECK_EQ(91, script->Run()->Int32Value()); | 13045 CHECK_EQ(91, script->Run()->Int32Value()); |
| 12936 } | 13046 } |
| 12937 | 13047 |
| 12938 | 13048 |
| 12939 // These are locking tests that don't need to be run again | 13049 // These are locking tests that don't need to be run again |
| 12940 // as part of the locking aggregation tests. | 13050 // as part of the locking aggregation tests. |
| 12941 TEST(NestedLockersNoTryCatch) { | 13051 TEST(NestedLockersNoTryCatch) { |
| 12942 v8::Locker locker(CcTest::isolate()); | 13052 v8::Locker locker(CcTest::isolate()); |
| 12943 LocalContext env; | 13053 LocalContext env; |
| 12944 v8::HandleScope scope(env->GetIsolate()); | 13054 v8::HandleScope scope(env->GetIsolate()); |
| 12945 Local<v8::FunctionTemplate> fun_templ = | 13055 Local<v8::FunctionTemplate> fun_templ = |
| 12946 v8::FunctionTemplate::New(ThrowInJSNoCatch); | 13056 v8::FunctionTemplate::New(env->GetIsolate(), ThrowInJSNoCatch); |
| 12947 Local<Function> fun = fun_templ->GetFunction(); | 13057 Local<Function> fun = fun_templ->GetFunction(); |
| 12948 env->Global()->Set(v8_str("throw_in_js"), fun); | 13058 env->Global()->Set(v8_str("throw_in_js"), fun); |
| 12949 Local<Script> script = v8_compile("(function () {" | 13059 Local<Script> script = v8_compile("(function () {" |
| 12950 " try {" | 13060 " try {" |
| 12951 " throw_in_js();" | 13061 " throw_in_js();" |
| 12952 " return 42;" | 13062 " return 42;" |
| 12953 " } catch (e) {" | 13063 " } catch (e) {" |
| 12954 " return e * 13;" | 13064 " return e * 13;" |
| 12955 " }" | 13065 " }" |
| 12956 "})();"); | 13066 "})();"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 12972 v8::Unlocker unlocker(CcTest::isolate()); | 13082 v8::Unlocker unlocker(CcTest::isolate()); |
| 12973 } | 13083 } |
| 12974 | 13084 |
| 12975 | 13085 |
| 12976 THREADED_TEST(LockUnlockLock) { | 13086 THREADED_TEST(LockUnlockLock) { |
| 12977 { | 13087 { |
| 12978 v8::Locker locker(CcTest::isolate()); | 13088 v8::Locker locker(CcTest::isolate()); |
| 12979 v8::HandleScope scope(CcTest::isolate()); | 13089 v8::HandleScope scope(CcTest::isolate()); |
| 12980 LocalContext env; | 13090 LocalContext env; |
| 12981 Local<v8::FunctionTemplate> fun_templ = | 13091 Local<v8::FunctionTemplate> fun_templ = |
| 12982 v8::FunctionTemplate::New(UnlockForAMoment); | 13092 v8::FunctionTemplate::New(CcTest::isolate(), UnlockForAMoment); |
| 12983 Local<Function> fun = fun_templ->GetFunction(); | 13093 Local<Function> fun = fun_templ->GetFunction(); |
| 12984 env->Global()->Set(v8_str("unlock_for_a_moment"), fun); | 13094 env->Global()->Set(v8_str("unlock_for_a_moment"), fun); |
| 12985 Local<Script> script = v8_compile("(function () {" | 13095 Local<Script> script = v8_compile("(function () {" |
| 12986 " unlock_for_a_moment();" | 13096 " unlock_for_a_moment();" |
| 12987 " return 42;" | 13097 " return 42;" |
| 12988 "})();"); | 13098 "})();"); |
| 12989 CHECK_EQ(42, script->Run()->Int32Value()); | 13099 CHECK_EQ(42, script->Run()->Int32Value()); |
| 12990 } | 13100 } |
| 12991 { | 13101 { |
| 12992 v8::Locker locker(CcTest::isolate()); | 13102 v8::Locker locker(CcTest::isolate()); |
| 12993 v8::HandleScope scope(CcTest::isolate()); | 13103 v8::HandleScope scope(CcTest::isolate()); |
| 12994 LocalContext env; | 13104 LocalContext env; |
| 12995 Local<v8::FunctionTemplate> fun_templ = | 13105 Local<v8::FunctionTemplate> fun_templ = |
| 12996 v8::FunctionTemplate::New(UnlockForAMoment); | 13106 v8::FunctionTemplate::New(CcTest::isolate(), UnlockForAMoment); |
| 12997 Local<Function> fun = fun_templ->GetFunction(); | 13107 Local<Function> fun = fun_templ->GetFunction(); |
| 12998 env->Global()->Set(v8_str("unlock_for_a_moment"), fun); | 13108 env->Global()->Set(v8_str("unlock_for_a_moment"), fun); |
| 12999 Local<Script> script = v8_compile("(function () {" | 13109 Local<Script> script = v8_compile("(function () {" |
| 13000 " unlock_for_a_moment();" | 13110 " unlock_for_a_moment();" |
| 13001 " return 42;" | 13111 " return 42;" |
| 13002 "})();"); | 13112 "})();"); |
| 13003 CHECK_EQ(42, script->Run()->Int32Value()); | 13113 CHECK_EQ(42, script->Run()->Int32Value()); |
| 13004 } | 13114 } |
| 13005 } | 13115 } |
| 13006 | 13116 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13493 return invocations; | 13603 return invocations; |
| 13494 } | 13604 } |
| 13495 | 13605 |
| 13496 | 13606 |
| 13497 void SetFunctionEntryHookTest::RunLoopInNewEnv(v8::Isolate* isolate) { | 13607 void SetFunctionEntryHookTest::RunLoopInNewEnv(v8::Isolate* isolate) { |
| 13498 v8::HandleScope outer(isolate); | 13608 v8::HandleScope outer(isolate); |
| 13499 v8::Local<Context> env = Context::New(isolate); | 13609 v8::Local<Context> env = Context::New(isolate); |
| 13500 env->Enter(); | 13610 env->Enter(); |
| 13501 | 13611 |
| 13502 Local<ObjectTemplate> t = ObjectTemplate::New(); | 13612 Local<ObjectTemplate> t = ObjectTemplate::New(); |
| 13503 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(RuntimeCallback)); | 13613 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(isolate, RuntimeCallback)); |
| 13504 env->Global()->Set(v8_str("obj"), t->NewInstance()); | 13614 env->Global()->Set(v8_str("obj"), t->NewInstance()); |
| 13505 | 13615 |
| 13506 const char* script = | 13616 const char* script = |
| 13507 "function bar() {\n" | 13617 "function bar() {\n" |
| 13508 " var sum = 0;\n" | 13618 " var sum = 0;\n" |
| 13509 " for (i = 0; i < 100; ++i)\n" | 13619 " for (i = 0; i < 100; ++i)\n" |
| 13510 " sum = foo(i);\n" | 13620 " sum = foo(i);\n" |
| 13511 " return sum;\n" | 13621 " return sum;\n" |
| 13512 "}\n" | 13622 "}\n" |
| 13513 "function foo(i) { return i * i; }\n" | 13623 "function foo(i) { return i * i; }\n" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13981 | 14091 |
| 13982 static void FunctionNameCallback( | 14092 static void FunctionNameCallback( |
| 13983 const v8::FunctionCallbackInfo<v8::Value>& args) { | 14093 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 13984 ApiTestFuzzer::Fuzz(); | 14094 ApiTestFuzzer::Fuzz(); |
| 13985 args.GetReturnValue().Set(v8_num(42)); | 14095 args.GetReturnValue().Set(v8_num(42)); |
| 13986 } | 14096 } |
| 13987 | 14097 |
| 13988 | 14098 |
| 13989 THREADED_TEST(CallbackFunctionName) { | 14099 THREADED_TEST(CallbackFunctionName) { |
| 13990 LocalContext context; | 14100 LocalContext context; |
| 13991 v8::HandleScope scope(context->GetIsolate()); | 14101 v8::Isolate* isolate = context->GetIsolate(); |
| 14102 v8::HandleScope scope(isolate); |
| 13992 Local<ObjectTemplate> t = ObjectTemplate::New(); | 14103 Local<ObjectTemplate> t = ObjectTemplate::New(); |
| 13993 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback)); | 14104 t->Set(v8_str("asdf"), |
| 14105 v8::FunctionTemplate::New(isolate, FunctionNameCallback)); |
| 13994 context->Global()->Set(v8_str("obj"), t->NewInstance()); | 14106 context->Global()->Set(v8_str("obj"), t->NewInstance()); |
| 13995 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); | 14107 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); |
| 13996 CHECK(value->IsString()); | 14108 CHECK(value->IsString()); |
| 13997 v8::String::Utf8Value name(value); | 14109 v8::String::Utf8Value name(value); |
| 13998 CHECK_EQ("asdf", *name); | 14110 CHECK_EQ("asdf", *name); |
| 13999 } | 14111 } |
| 14000 | 14112 |
| 14001 | 14113 |
| 14002 THREADED_TEST(DateAccess) { | 14114 THREADED_TEST(DateAccess) { |
| 14003 LocalContext context; | 14115 LocalContext context; |
| (...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15157 | 15269 |
| 15158 // Allow cross-domain access. | 15270 // Allow cross-domain access. |
| 15159 Local<String> token = v8_str("<security token>"); | 15271 Local<String> token = v8_str("<security token>"); |
| 15160 calling_context0->SetSecurityToken(token); | 15272 calling_context0->SetSecurityToken(token); |
| 15161 calling_context1->SetSecurityToken(token); | 15273 calling_context1->SetSecurityToken(token); |
| 15162 calling_context2->SetSecurityToken(token); | 15274 calling_context2->SetSecurityToken(token); |
| 15163 | 15275 |
| 15164 // Create an object with a C++ callback in context0. | 15276 // Create an object with a C++ callback in context0. |
| 15165 calling_context0->Enter(); | 15277 calling_context0->Enter(); |
| 15166 Local<v8::FunctionTemplate> callback_templ = | 15278 Local<v8::FunctionTemplate> callback_templ = |
| 15167 v8::FunctionTemplate::New(GetCallingContextCallback); | 15279 v8::FunctionTemplate::New(isolate, GetCallingContextCallback); |
| 15168 calling_context0->Global()->Set(v8_str("callback"), | 15280 calling_context0->Global()->Set(v8_str("callback"), |
| 15169 callback_templ->GetFunction()); | 15281 callback_templ->GetFunction()); |
| 15170 calling_context0->Exit(); | 15282 calling_context0->Exit(); |
| 15171 | 15283 |
| 15172 // Expose context0 in context1 and set up a function that calls the | 15284 // Expose context0 in context1 and set up a function that calls the |
| 15173 // callback function. | 15285 // callback function. |
| 15174 calling_context1->Enter(); | 15286 calling_context1->Enter(); |
| 15175 calling_context1->Global()->Set(v8_str("context0"), | 15287 calling_context1->Global()->Set(v8_str("context0"), |
| 15176 calling_context0->Global()); | 15288 calling_context0->Global()); |
| 15177 CompileRun("function f() { context0.callback() }"); | 15289 CompileRun("function f() { context0.callback() }"); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 15204 } | 15316 } |
| 15205 | 15317 |
| 15206 | 15318 |
| 15207 // Regression test for issue 398. | 15319 // Regression test for issue 398. |
| 15208 // If a function is added to an object, creating a constant function | 15320 // If a function is added to an object, creating a constant function |
| 15209 // field, and the result is cloned, replacing the constant function on the | 15321 // field, and the result is cloned, replacing the constant function on the |
| 15210 // original should not affect the clone. | 15322 // original should not affect the clone. |
| 15211 // See http://code.google.com/p/v8/issues/detail?id=398 | 15323 // See http://code.google.com/p/v8/issues/detail?id=398 |
| 15212 THREADED_TEST(ReplaceConstantFunction) { | 15324 THREADED_TEST(ReplaceConstantFunction) { |
| 15213 LocalContext context; | 15325 LocalContext context; |
| 15214 v8::HandleScope scope(context->GetIsolate()); | 15326 v8::Isolate* isolate = context->GetIsolate(); |
| 15327 v8::HandleScope scope(isolate); |
| 15215 v8::Handle<v8::Object> obj = v8::Object::New(); | 15328 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 15216 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); | 15329 v8::Handle<v8::FunctionTemplate> func_templ = |
| 15330 v8::FunctionTemplate::New(isolate); |
| 15217 v8::Handle<v8::String> foo_string = | 15331 v8::Handle<v8::String> foo_string = |
| 15218 v8::String::NewFromUtf8(context->GetIsolate(), "foo"); | 15332 v8::String::NewFromUtf8(isolate, "foo"); |
| 15219 obj->Set(foo_string, func_templ->GetFunction()); | 15333 obj->Set(foo_string, func_templ->GetFunction()); |
| 15220 v8::Handle<v8::Object> obj_clone = obj->Clone(); | 15334 v8::Handle<v8::Object> obj_clone = obj->Clone(); |
| 15221 obj_clone->Set(foo_string, | 15335 obj_clone->Set(foo_string, |
| 15222 v8::String::NewFromUtf8(context->GetIsolate(), "Hello")); | 15336 v8::String::NewFromUtf8(isolate, "Hello")); |
| 15223 CHECK(!obj->Get(foo_string)->IsUndefined()); | 15337 CHECK(!obj->Get(foo_string)->IsUndefined()); |
| 15224 } | 15338 } |
| 15225 | 15339 |
| 15226 | 15340 |
| 15227 // Regression test for http://crbug.com/16276. | 15341 // Regression test for http://crbug.com/16276. |
| 15228 THREADED_TEST(Regress16276) { | 15342 THREADED_TEST(Regress16276) { |
| 15229 LocalContext context; | 15343 LocalContext context; |
| 15230 v8::HandleScope scope(context->GetIsolate()); | 15344 v8::HandleScope scope(context->GetIsolate()); |
| 15231 // Force the IC in f to be a dictionary load IC. | 15345 // Force the IC in f to be a dictionary load IC. |
| 15232 CompileRun("function f(obj) { return obj.x; }\n" | 15346 CompileRun("function f(obj) { return obj.x; }\n" |
| (...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16631 | 16745 |
| 16632 CHECK(stackTrace->AsArray()->IsArray()); | 16746 CHECK(stackTrace->AsArray()->IsArray()); |
| 16633 } | 16747 } |
| 16634 } | 16748 } |
| 16635 | 16749 |
| 16636 | 16750 |
| 16637 // Tests the C++ StackTrace API. | 16751 // Tests the C++ StackTrace API. |
| 16638 // TODO(3074796): Reenable this as a THREADED_TEST once it passes. | 16752 // TODO(3074796): Reenable this as a THREADED_TEST once it passes. |
| 16639 // THREADED_TEST(CaptureStackTrace) { | 16753 // THREADED_TEST(CaptureStackTrace) { |
| 16640 TEST(CaptureStackTrace) { | 16754 TEST(CaptureStackTrace) { |
| 16641 v8::HandleScope scope(CcTest::isolate()); | 16755 v8::Isolate* isolate = CcTest::isolate(); |
| 16756 v8::HandleScope scope(isolate); |
| 16642 v8::Handle<v8::String> origin = | 16757 v8::Handle<v8::String> origin = |
| 16643 v8::String::NewFromUtf8(CcTest::isolate(), "capture-stack-trace-test"); | 16758 v8::String::NewFromUtf8(isolate, "capture-stack-trace-test"); |
| 16644 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16759 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16645 templ->Set(v8_str("AnalyzeStackInNativeCode"), | 16760 templ->Set(v8_str("AnalyzeStackInNativeCode"), |
| 16646 v8::FunctionTemplate::New(AnalyzeStackInNativeCode)); | 16761 v8::FunctionTemplate::New(isolate, AnalyzeStackInNativeCode)); |
| 16647 LocalContext context(0, templ); | 16762 LocalContext context(0, templ); |
| 16648 | 16763 |
| 16649 // Test getting OVERVIEW information. Should ignore information that is not | 16764 // Test getting OVERVIEW information. Should ignore information that is not |
| 16650 // script name, function name, line number, and column offset. | 16765 // script name, function name, line number, and column offset. |
| 16651 const char *overview_source = | 16766 const char *overview_source = |
| 16652 "function bar() {\n" | 16767 "function bar() {\n" |
| 16653 " var y; AnalyzeStackInNativeCode(1);\n" | 16768 " var y; AnalyzeStackInNativeCode(1);\n" |
| 16654 "}\n" | 16769 "}\n" |
| 16655 "function foo() {\n" | 16770 "function foo() {\n" |
| 16656 "\n" | 16771 "\n" |
| 16657 " bar();\n" | 16772 " bar();\n" |
| 16658 "}\n" | 16773 "}\n" |
| 16659 "var x;eval('new foo();');"; | 16774 "var x;eval('new foo();');"; |
| 16660 v8::Handle<v8::String> overview_src = | 16775 v8::Handle<v8::String> overview_src = |
| 16661 v8::String::NewFromUtf8(CcTest::isolate(), overview_source); | 16776 v8::String::NewFromUtf8(isolate, overview_source); |
| 16662 v8::Handle<Value> overview_result( | 16777 v8::Handle<Value> overview_result( |
| 16663 v8::Script::New(overview_src, origin)->Run()); | 16778 v8::Script::New(overview_src, origin)->Run()); |
| 16664 CHECK(!overview_result.IsEmpty()); | 16779 CHECK(!overview_result.IsEmpty()); |
| 16665 CHECK(overview_result->IsObject()); | 16780 CHECK(overview_result->IsObject()); |
| 16666 | 16781 |
| 16667 // Test getting DETAILED information. | 16782 // Test getting DETAILED information. |
| 16668 const char *detailed_source = | 16783 const char *detailed_source = |
| 16669 "function bat() {AnalyzeStackInNativeCode(2);\n" | 16784 "function bat() {AnalyzeStackInNativeCode(2);\n" |
| 16670 "}\n" | 16785 "}\n" |
| 16671 "\n" | 16786 "\n" |
| 16672 "function baz() {\n" | 16787 "function baz() {\n" |
| 16673 " bat();\n" | 16788 " bat();\n" |
| 16674 "}\n" | 16789 "}\n" |
| 16675 "eval('new baz();');"; | 16790 "eval('new baz();');"; |
| 16676 v8::Handle<v8::String> detailed_src = | 16791 v8::Handle<v8::String> detailed_src = |
| 16677 v8::String::NewFromUtf8(CcTest::isolate(), detailed_source); | 16792 v8::String::NewFromUtf8(isolate, detailed_source); |
| 16678 // Make the script using a non-zero line and column offset. | 16793 // Make the script using a non-zero line and column offset. |
| 16679 v8::Handle<v8::Integer> line_offset = v8::Integer::New(3); | 16794 v8::Handle<v8::Integer> line_offset = v8::Integer::New(3); |
| 16680 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5); | 16795 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5); |
| 16681 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset); | 16796 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset); |
| 16682 v8::Handle<v8::Script> detailed_script( | 16797 v8::Handle<v8::Script> detailed_script( |
| 16683 v8::Script::New(detailed_src, &detailed_origin)); | 16798 v8::Script::New(detailed_src, &detailed_origin)); |
| 16684 v8::Handle<Value> detailed_result(detailed_script->Run()); | 16799 v8::Handle<Value> detailed_result(detailed_script->Run()); |
| 16685 CHECK(!detailed_result.IsEmpty()); | 16800 CHECK(!detailed_result.IsEmpty()); |
| 16686 CHECK(detailed_result->IsObject()); | 16801 CHECK(detailed_result->IsObject()); |
| 16687 } | 16802 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16883 for (int i = 0; i < 3; i++) { | 16998 for (int i = 0; i < 3; i++) { |
| 16884 v8::Handle<v8::String> name = | 16999 v8::Handle<v8::String> name = |
| 16885 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 17000 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
| 16886 CHECK(!name.IsEmpty()); | 17001 CHECK(!name.IsEmpty()); |
| 16887 CHECK_EQ(url, name); | 17002 CHECK_EQ(url, name); |
| 16888 } | 17003 } |
| 16889 } | 17004 } |
| 16890 | 17005 |
| 16891 | 17006 |
| 16892 TEST(SourceURLInStackTrace) { | 17007 TEST(SourceURLInStackTrace) { |
| 16893 v8::HandleScope scope(CcTest::isolate()); | 17008 v8::Isolate* isolate = CcTest::isolate(); |
| 17009 v8::HandleScope scope(isolate); |
| 16894 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 17010 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16895 templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"), | 17011 templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"), |
| 16896 v8::FunctionTemplate::New(AnalyzeStackOfEvalWithSourceURL)); | 17012 v8::FunctionTemplate::New(isolate, |
| 17013 AnalyzeStackOfEvalWithSourceURL)); |
| 16897 LocalContext context(0, templ); | 17014 LocalContext context(0, templ); |
| 16898 | 17015 |
| 16899 const char *source = | 17016 const char *source = |
| 16900 "function outer() {\n" | 17017 "function outer() {\n" |
| 16901 "function bar() {\n" | 17018 "function bar() {\n" |
| 16902 " AnalyzeStackOfEvalWithSourceURL();\n" | 17019 " AnalyzeStackOfEvalWithSourceURL();\n" |
| 16903 "}\n" | 17020 "}\n" |
| 16904 "function foo() {\n" | 17021 "function foo() {\n" |
| 16905 "\n" | 17022 "\n" |
| 16906 " bar();\n" | 17023 " bar();\n" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 16925 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( | 17042 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( |
| 16926 args.GetIsolate(), 10, v8::StackTrace::kScriptId); | 17043 args.GetIsolate(), 10, v8::StackTrace::kScriptId); |
| 16927 CHECK_EQ(2, stackTrace->GetFrameCount()); | 17044 CHECK_EQ(2, stackTrace->GetFrameCount()); |
| 16928 for (int i = 0; i < 2; i++) { | 17045 for (int i = 0; i < 2; i++) { |
| 16929 scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId(); | 17046 scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId(); |
| 16930 } | 17047 } |
| 16931 } | 17048 } |
| 16932 | 17049 |
| 16933 | 17050 |
| 16934 TEST(ScriptIdInStackTrace) { | 17051 TEST(ScriptIdInStackTrace) { |
| 16935 v8::HandleScope scope(CcTest::isolate()); | 17052 v8::Isolate* isolate = CcTest::isolate(); |
| 17053 v8::HandleScope scope(isolate); |
| 16936 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 17054 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16937 templ->Set(v8_str("AnalyzeScriptIdInStack"), | 17055 templ->Set(v8_str("AnalyzeScriptIdInStack"), |
| 16938 v8::FunctionTemplate::New(AnalyzeScriptIdInStack)); | 17056 v8::FunctionTemplate::New(isolate, AnalyzeScriptIdInStack)); |
| 16939 LocalContext context(0, templ); | 17057 LocalContext context(0, templ); |
| 16940 | 17058 |
| 16941 v8::Handle<v8::String> scriptSource = v8::String::NewFromUtf8( | 17059 v8::Handle<v8::String> scriptSource = v8::String::NewFromUtf8( |
| 16942 CcTest::isolate(), | 17060 isolate, |
| 16943 "function foo() {\n" | 17061 "function foo() {\n" |
| 16944 " AnalyzeScriptIdInStack();" | 17062 " AnalyzeScriptIdInStack();" |
| 16945 "}\n" | 17063 "}\n" |
| 16946 "foo();\n"); | 17064 "foo();\n"); |
| 16947 v8::ScriptOrigin origin = | 17065 v8::ScriptOrigin origin = |
| 16948 v8::ScriptOrigin(v8::String::NewFromUtf8(CcTest::isolate(), "test")); | 17066 v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "test")); |
| 16949 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); | 17067 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); |
| 16950 script->Run(); | 17068 script->Run(); |
| 16951 for (int i = 0; i < 2; i++) { | 17069 for (int i = 0; i < 2; i++) { |
| 16952 CHECK(scriptIdInStack[i] != v8::Message::kNoScriptIdInfo); | 17070 CHECK(scriptIdInStack[i] != v8::Message::kNoScriptIdInfo); |
| 16953 CHECK_EQ(scriptIdInStack[i], script->GetId()); | 17071 CHECK_EQ(scriptIdInStack[i], script->GetId()); |
| 16954 } | 17072 } |
| 16955 } | 17073 } |
| 16956 | 17074 |
| 16957 | 17075 |
| 16958 void AnalyzeStackOfInlineScriptWithSourceURL( | 17076 void AnalyzeStackOfInlineScriptWithSourceURL( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 16969 CHECK_EQ(url, name); | 17087 CHECK_EQ(url, name); |
| 16970 } | 17088 } |
| 16971 } | 17089 } |
| 16972 | 17090 |
| 16973 | 17091 |
| 16974 TEST(InlineScriptWithSourceURLInStackTrace) { | 17092 TEST(InlineScriptWithSourceURLInStackTrace) { |
| 16975 v8::HandleScope scope(CcTest::isolate()); | 17093 v8::HandleScope scope(CcTest::isolate()); |
| 16976 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 17094 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16977 templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), | 17095 templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), |
| 16978 v8::FunctionTemplate::New( | 17096 v8::FunctionTemplate::New( |
| 16979 AnalyzeStackOfInlineScriptWithSourceURL)); | 17097 CcTest::isolate(), AnalyzeStackOfInlineScriptWithSourceURL)); |
| 16980 LocalContext context(0, templ); | 17098 LocalContext context(0, templ); |
| 16981 | 17099 |
| 16982 const char *source = | 17100 const char *source = |
| 16983 "function outer() {\n" | 17101 "function outer() {\n" |
| 16984 "function bar() {\n" | 17102 "function bar() {\n" |
| 16985 " AnalyzeStackOfInlineScriptWithSourceURL();\n" | 17103 " AnalyzeStackOfInlineScriptWithSourceURL();\n" |
| 16986 "}\n" | 17104 "}\n" |
| 16987 "function foo() {\n" | 17105 "function foo() {\n" |
| 16988 "\n" | 17106 "\n" |
| 16989 " bar();\n" | 17107 " bar();\n" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 17014 CHECK_EQ(url, name); | 17132 CHECK_EQ(url, name); |
| 17015 } | 17133 } |
| 17016 } | 17134 } |
| 17017 | 17135 |
| 17018 | 17136 |
| 17019 TEST(DynamicWithSourceURLInStackTrace) { | 17137 TEST(DynamicWithSourceURLInStackTrace) { |
| 17020 v8::HandleScope scope(CcTest::isolate()); | 17138 v8::HandleScope scope(CcTest::isolate()); |
| 17021 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 17139 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 17022 templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), | 17140 templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), |
| 17023 v8::FunctionTemplate::New( | 17141 v8::FunctionTemplate::New( |
| 17024 AnalyzeStackOfDynamicScriptWithSourceURL)); | 17142 CcTest::isolate(), AnalyzeStackOfDynamicScriptWithSourceURL)); |
| 17025 LocalContext context(0, templ); | 17143 LocalContext context(0, templ); |
| 17026 | 17144 |
| 17027 const char *source = | 17145 const char *source = |
| 17028 "function outer() {\n" | 17146 "function outer() {\n" |
| 17029 "function bar() {\n" | 17147 "function bar() {\n" |
| 17030 " AnalyzeStackOfDynamicScriptWithSourceURL();\n" | 17148 " AnalyzeStackOfDynamicScriptWithSourceURL();\n" |
| 17031 "}\n" | 17149 "}\n" |
| 17032 "function foo() {\n" | 17150 "function foo() {\n" |
| 17033 "\n" | 17151 "\n" |
| 17034 " bar();\n" | 17152 " bar();\n" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17188 | 17306 |
| 17189 // Set stack limit. | 17307 // Set stack limit. |
| 17190 v8::ResourceConstraints constraints; | 17308 v8::ResourceConstraints constraints; |
| 17191 constraints.set_stack_limit(set_limit); | 17309 constraints.set_stack_limit(set_limit); |
| 17192 CHECK(v8::SetResourceConstraints(CcTest::isolate(), &constraints)); | 17310 CHECK(v8::SetResourceConstraints(CcTest::isolate(), &constraints)); |
| 17193 | 17311 |
| 17194 // Execute a script. | 17312 // Execute a script. |
| 17195 LocalContext env; | 17313 LocalContext env; |
| 17196 v8::HandleScope scope(env->GetIsolate()); | 17314 v8::HandleScope scope(env->GetIsolate()); |
| 17197 Local<v8::FunctionTemplate> fun_templ = | 17315 Local<v8::FunctionTemplate> fun_templ = |
| 17198 v8::FunctionTemplate::New(GetStackLimitCallback); | 17316 v8::FunctionTemplate::New(env->GetIsolate(), GetStackLimitCallback); |
| 17199 Local<Function> fun = fun_templ->GetFunction(); | 17317 Local<Function> fun = fun_templ->GetFunction(); |
| 17200 env->Global()->Set(v8_str("get_stack_limit"), fun); | 17318 env->Global()->Set(v8_str("get_stack_limit"), fun); |
| 17201 CompileRun("get_stack_limit();"); | 17319 CompileRun("get_stack_limit();"); |
| 17202 | 17320 |
| 17203 CHECK(stack_limit == set_limit); | 17321 CHECK(stack_limit == set_limit); |
| 17204 } | 17322 } |
| 17205 | 17323 |
| 17206 | 17324 |
| 17207 TEST(SetResourceConstraintsInThread) { | 17325 TEST(SetResourceConstraintsInThread) { |
| 17208 uint32_t* set_limit; | 17326 uint32_t* set_limit; |
| 17209 { | 17327 { |
| 17210 v8::Locker locker(CcTest::isolate()); | 17328 v8::Locker locker(CcTest::isolate()); |
| 17211 set_limit = ComputeStackLimit(stack_breathing_room); | 17329 set_limit = ComputeStackLimit(stack_breathing_room); |
| 17212 | 17330 |
| 17213 // Set stack limit. | 17331 // Set stack limit. |
| 17214 v8::ResourceConstraints constraints; | 17332 v8::ResourceConstraints constraints; |
| 17215 constraints.set_stack_limit(set_limit); | 17333 constraints.set_stack_limit(set_limit); |
| 17216 CHECK(v8::SetResourceConstraints(CcTest::isolate(), &constraints)); | 17334 CHECK(v8::SetResourceConstraints(CcTest::isolate(), &constraints)); |
| 17217 | 17335 |
| 17218 // Execute a script. | 17336 // Execute a script. |
| 17219 v8::HandleScope scope(CcTest::isolate()); | 17337 v8::HandleScope scope(CcTest::isolate()); |
| 17220 LocalContext env; | 17338 LocalContext env; |
| 17221 Local<v8::FunctionTemplate> fun_templ = | 17339 Local<v8::FunctionTemplate> fun_templ = |
| 17222 v8::FunctionTemplate::New(GetStackLimitCallback); | 17340 v8::FunctionTemplate::New(CcTest::isolate(), GetStackLimitCallback); |
| 17223 Local<Function> fun = fun_templ->GetFunction(); | 17341 Local<Function> fun = fun_templ->GetFunction(); |
| 17224 env->Global()->Set(v8_str("get_stack_limit"), fun); | 17342 env->Global()->Set(v8_str("get_stack_limit"), fun); |
| 17225 CompileRun("get_stack_limit();"); | 17343 CompileRun("get_stack_limit();"); |
| 17226 | 17344 |
| 17227 CHECK(stack_limit == set_limit); | 17345 CHECK(stack_limit == set_limit); |
| 17228 } | 17346 } |
| 17229 { | 17347 { |
| 17230 v8::Locker locker(CcTest::isolate()); | 17348 v8::Locker locker(CcTest::isolate()); |
| 17231 CHECK(stack_limit == set_limit); | 17349 CHECK(stack_limit == set_limit); |
| 17232 } | 17350 } |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17464 v8::Handle<v8::String> str(args[0]->ToString()); | 17582 v8::Handle<v8::String> str(args[0]->ToString()); |
| 17465 USE(str); | 17583 USE(str); |
| 17466 if (tc.HasCaught()) | 17584 if (tc.HasCaught()) |
| 17467 tc.ReThrow(); | 17585 tc.ReThrow(); |
| 17468 } | 17586 } |
| 17469 | 17587 |
| 17470 | 17588 |
| 17471 // Test that an exception can be propagated down through a spaghetti | 17589 // Test that an exception can be propagated down through a spaghetti |
| 17472 // stack using ReThrow. | 17590 // stack using ReThrow. |
| 17473 THREADED_TEST(SpaghettiStackReThrow) { | 17591 THREADED_TEST(SpaghettiStackReThrow) { |
| 17474 v8::HandleScope scope(CcTest::isolate()); | 17592 v8::Isolate* isolate = CcTest::isolate(); |
| 17593 v8::HandleScope scope(isolate); |
| 17475 LocalContext context; | 17594 LocalContext context; |
| 17476 context->Global()->Set( | 17595 context->Global()->Set( |
| 17477 v8::String::NewFromUtf8(CcTest::isolate(), "s"), | 17596 v8::String::NewFromUtf8(isolate, "s"), |
| 17478 v8::FunctionTemplate::New(SpaghettiIncident)->GetFunction()); | 17597 v8::FunctionTemplate::New(isolate, SpaghettiIncident)->GetFunction()); |
| 17479 v8::TryCatch try_catch; | 17598 v8::TryCatch try_catch; |
| 17480 CompileRun( | 17599 CompileRun( |
| 17481 "var i = 0;" | 17600 "var i = 0;" |
| 17482 "var o = {" | 17601 "var o = {" |
| 17483 " toString: function () {" | 17602 " toString: function () {" |
| 17484 " if (i == 10) {" | 17603 " if (i == 10) {" |
| 17485 " throw 'Hey!';" | 17604 " throw 'Hey!';" |
| 17486 " } else {" | 17605 " } else {" |
| 17487 " i++;" | 17606 " i++;" |
| 17488 " return s(o);" | 17607 " return s(o);" |
| (...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19148 Set(v8_str("context_id"), v8::Integer::New(id)); | 19267 Set(v8_str("context_id"), v8::Integer::New(id)); |
| 19149 } | 19268 } |
| 19150 | 19269 |
| 19151 | 19270 |
| 19152 static void CheckContextId(v8::Handle<Object> object, int expected) { | 19271 static void CheckContextId(v8::Handle<Object> object, int expected) { |
| 19153 CHECK_EQ(expected, object->Get(v8_str("context_id"))->Int32Value()); | 19272 CHECK_EQ(expected, object->Get(v8_str("context_id"))->Int32Value()); |
| 19154 } | 19273 } |
| 19155 | 19274 |
| 19156 | 19275 |
| 19157 THREADED_TEST(CreationContext) { | 19276 THREADED_TEST(CreationContext) { |
| 19158 HandleScope handle_scope(CcTest::isolate()); | 19277 v8::Isolate* isolate = CcTest::isolate(); |
| 19159 Handle<Context> context1 = Context::New(CcTest::isolate()); | 19278 HandleScope handle_scope(isolate); |
| 19279 Handle<Context> context1 = Context::New(isolate); |
| 19160 InstallContextId(context1, 1); | 19280 InstallContextId(context1, 1); |
| 19161 Handle<Context> context2 = Context::New(CcTest::isolate()); | 19281 Handle<Context> context2 = Context::New(isolate); |
| 19162 InstallContextId(context2, 2); | 19282 InstallContextId(context2, 2); |
| 19163 Handle<Context> context3 = Context::New(CcTest::isolate()); | 19283 Handle<Context> context3 = Context::New(isolate); |
| 19164 InstallContextId(context3, 3); | 19284 InstallContextId(context3, 3); |
| 19165 | 19285 |
| 19166 Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); | 19286 Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(isolate); |
| 19167 | 19287 |
| 19168 Local<Object> object1; | 19288 Local<Object> object1; |
| 19169 Local<Function> func1; | 19289 Local<Function> func1; |
| 19170 { | 19290 { |
| 19171 Context::Scope scope(context1); | 19291 Context::Scope scope(context1); |
| 19172 object1 = Object::New(); | 19292 object1 = Object::New(); |
| 19173 func1 = tmpl->GetFunction(); | 19293 func1 = tmpl->GetFunction(); |
| 19174 } | 19294 } |
| 19175 | 19295 |
| 19176 Local<Object> object2; | 19296 Local<Object> object2; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19476 CHECK(expected_message->Equals(actual_message)); | 19596 CHECK(expected_message->Equals(actual_message)); |
| 19477 } | 19597 } |
| 19478 | 19598 |
| 19479 | 19599 |
| 19480 static void NonObjectThis(const v8::FunctionCallbackInfo<v8::Value>& args) { | 19600 static void NonObjectThis(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 19481 } | 19601 } |
| 19482 | 19602 |
| 19483 | 19603 |
| 19484 THREADED_TEST(CallAPIFunctionOnNonObject) { | 19604 THREADED_TEST(CallAPIFunctionOnNonObject) { |
| 19485 LocalContext context; | 19605 LocalContext context; |
| 19486 v8::HandleScope scope(context->GetIsolate()); | 19606 v8::Isolate* isolate = context->GetIsolate(); |
| 19487 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); | 19607 v8::HandleScope scope(isolate); |
| 19608 Handle<FunctionTemplate> templ = |
| 19609 v8::FunctionTemplate::New(isolate, NonObjectThis); |
| 19488 Handle<Function> function = templ->GetFunction(); | 19610 Handle<Function> function = templ->GetFunction(); |
| 19489 context->Global()->Set(v8_str("f"), function); | 19611 context->Global()->Set(v8_str("f"), function); |
| 19490 TryCatch try_catch; | 19612 TryCatch try_catch; |
| 19491 CompileRun("f.call(2)"); | 19613 CompileRun("f.call(2)"); |
| 19492 } | 19614 } |
| 19493 | 19615 |
| 19494 | 19616 |
| 19495 // Regression test for issue 1470. | 19617 // Regression test for issue 1470. |
| 19496 THREADED_TEST(ReadOnlyIndexedProperties) { | 19618 THREADED_TEST(ReadOnlyIndexedProperties) { |
| 19497 v8::HandleScope scope(CcTest::isolate()); | 19619 v8::HandleScope scope(CcTest::isolate()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19563 HandleScope scope(isolate); | 19685 HandleScope scope(isolate); |
| 19564 | 19686 |
| 19565 // Template for object with security check. | 19687 // Template for object with security check. |
| 19566 Local<ObjectTemplate> no_proto_template = v8::ObjectTemplate::New(); | 19688 Local<ObjectTemplate> no_proto_template = v8::ObjectTemplate::New(); |
| 19567 // We don't do indexing, so any callback can be used for that. | 19689 // We don't do indexing, so any callback can be used for that. |
| 19568 no_proto_template->SetAccessCheckCallbacks( | 19690 no_proto_template->SetAccessCheckCallbacks( |
| 19569 BlockProtoNamedSecurityTestCallback, | 19691 BlockProtoNamedSecurityTestCallback, |
| 19570 IndexedSecurityTestCallback); | 19692 IndexedSecurityTestCallback); |
| 19571 | 19693 |
| 19572 // Templates for objects with hidden prototypes and possibly security check. | 19694 // Templates for objects with hidden prototypes and possibly security check. |
| 19573 Local<FunctionTemplate> hidden_proto_template = v8::FunctionTemplate::New(); | 19695 Local<FunctionTemplate> hidden_proto_template = |
| 19696 v8::FunctionTemplate::New(isolate); |
| 19574 hidden_proto_template->SetHiddenPrototype(true); | 19697 hidden_proto_template->SetHiddenPrototype(true); |
| 19575 | 19698 |
| 19576 Local<FunctionTemplate> protected_hidden_proto_template = | 19699 Local<FunctionTemplate> protected_hidden_proto_template = |
| 19577 v8::FunctionTemplate::New(); | 19700 v8::FunctionTemplate::New(isolate); |
| 19578 protected_hidden_proto_template->InstanceTemplate()->SetAccessCheckCallbacks( | 19701 protected_hidden_proto_template->InstanceTemplate()->SetAccessCheckCallbacks( |
| 19579 BlockProtoNamedSecurityTestCallback, | 19702 BlockProtoNamedSecurityTestCallback, |
| 19580 IndexedSecurityTestCallback); | 19703 IndexedSecurityTestCallback); |
| 19581 protected_hidden_proto_template->SetHiddenPrototype(true); | 19704 protected_hidden_proto_template->SetHiddenPrototype(true); |
| 19582 | 19705 |
| 19583 // Context for "foreign" objects used in test. | 19706 // Context for "foreign" objects used in test. |
| 19584 Local<Context> context = v8::Context::New(isolate); | 19707 Local<Context> context = v8::Context::New(isolate); |
| 19585 context->Enter(); | 19708 context->Enter(); |
| 19586 | 19709 |
| 19587 // Plain object, no security check. | 19710 // Plain object, no security check. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19643 CHECK(result5->Equals( | 19766 CHECK(result5->Equals( |
| 19644 object_with_hidden->GetPrototype()->ToObject()->GetPrototype())); | 19767 object_with_hidden->GetPrototype()->ToObject()->GetPrototype())); |
| 19645 | 19768 |
| 19646 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); | 19769 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); |
| 19647 CHECK(result6->Equals(Undefined(isolate))); | 19770 CHECK(result6->Equals(Undefined(isolate))); |
| 19648 } | 19771 } |
| 19649 | 19772 |
| 19650 | 19773 |
| 19651 THREADED_TEST(Regress125988) { | 19774 THREADED_TEST(Regress125988) { |
| 19652 v8::HandleScope scope(CcTest::isolate()); | 19775 v8::HandleScope scope(CcTest::isolate()); |
| 19653 Handle<FunctionTemplate> intercept = FunctionTemplate::New(); | 19776 Handle<FunctionTemplate> intercept = FunctionTemplate::New(CcTest::isolate()); |
| 19654 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter); | 19777 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 19655 LocalContext env; | 19778 LocalContext env; |
| 19656 env->Global()->Set(v8_str("Intercept"), intercept->GetFunction()); | 19779 env->Global()->Set(v8_str("Intercept"), intercept->GetFunction()); |
| 19657 CompileRun("var a = new Object();" | 19780 CompileRun("var a = new Object();" |
| 19658 "var b = new Intercept();" | 19781 "var b = new Intercept();" |
| 19659 "var c = new Object();" | 19782 "var c = new Object();" |
| 19660 "c.__proto__ = b;" | 19783 "c.__proto__ = b;" |
| 19661 "b.__proto__ = a;" | 19784 "b.__proto__ = a;" |
| 19662 "a.x = 23;" | 19785 "a.x = 23;" |
| 19663 "for (var i = 0; i < 3; i++) c.x;"); | 19786 "for (var i = 0; i < 3; i++) c.x;"); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19805 i::OS::Print("Recursion ends.\n"); | 19928 i::OS::Print("Recursion ends.\n"); |
| 19806 CHECK_EQ(0, callback_fired); | 19929 CHECK_EQ(0, callback_fired); |
| 19807 } | 19930 } |
| 19808 } | 19931 } |
| 19809 | 19932 |
| 19810 | 19933 |
| 19811 TEST(CallCompletedCallback) { | 19934 TEST(CallCompletedCallback) { |
| 19812 LocalContext env; | 19935 LocalContext env; |
| 19813 v8::HandleScope scope(env->GetIsolate()); | 19936 v8::HandleScope scope(env->GetIsolate()); |
| 19814 v8::Handle<v8::FunctionTemplate> recursive_runtime = | 19937 v8::Handle<v8::FunctionTemplate> recursive_runtime = |
| 19815 v8::FunctionTemplate::New(RecursiveCall); | 19938 v8::FunctionTemplate::New(env->GetIsolate(), RecursiveCall); |
| 19816 env->Global()->Set(v8_str("recursion"), | 19939 env->Global()->Set(v8_str("recursion"), |
| 19817 recursive_runtime->GetFunction()); | 19940 recursive_runtime->GetFunction()); |
| 19818 // Adding the same callback a second time has no effect. | 19941 // Adding the same callback a second time has no effect. |
| 19819 v8::V8::AddCallCompletedCallback(CallCompletedCallback1); | 19942 v8::V8::AddCallCompletedCallback(CallCompletedCallback1); |
| 19820 v8::V8::AddCallCompletedCallback(CallCompletedCallback1); | 19943 v8::V8::AddCallCompletedCallback(CallCompletedCallback1); |
| 19821 v8::V8::AddCallCompletedCallback(CallCompletedCallback2); | 19944 v8::V8::AddCallCompletedCallback(CallCompletedCallback2); |
| 19822 i::OS::Print("--- Script (1) ---\n"); | 19945 i::OS::Print("--- Script (1) ---\n"); |
| 19823 Local<Script> script = v8::Script::Compile( | 19946 Local<Script> script = v8::Script::Compile( |
| 19824 v8::String::NewFromUtf8(env->GetIsolate(), "recursion(0)")); | 19947 v8::String::NewFromUtf8(env->GetIsolate(), "recursion(0)")); |
| 19825 script->Run(); | 19948 script->Run(); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20102 "%DeoptimizeFunction(test_set);" | 20225 "%DeoptimizeFunction(test_set);" |
| 20103 "%ClearFunctionTypeFeedback(test_set);"); | 20226 "%ClearFunctionTypeFeedback(test_set);"); |
| 20104 } | 20227 } |
| 20105 | 20228 |
| 20106 | 20229 |
| 20107 THREADED_TEST(InstanceCheckOnInstanceAccessor) { | 20230 THREADED_TEST(InstanceCheckOnInstanceAccessor) { |
| 20108 v8::internal::FLAG_allow_natives_syntax = true; | 20231 v8::internal::FLAG_allow_natives_syntax = true; |
| 20109 LocalContext context; | 20232 LocalContext context; |
| 20110 v8::HandleScope scope(context->GetIsolate()); | 20233 v8::HandleScope scope(context->GetIsolate()); |
| 20111 | 20234 |
| 20112 Local<FunctionTemplate> templ = FunctionTemplate::New(); | 20235 Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate()); |
| 20113 Local<ObjectTemplate> inst = templ->InstanceTemplate(); | 20236 Local<ObjectTemplate> inst = templ->InstanceTemplate(); |
| 20114 inst->SetAccessor(v8_str("foo"), | 20237 inst->SetAccessor(v8_str("foo"), |
| 20115 InstanceCheckedGetter, InstanceCheckedSetter, | 20238 InstanceCheckedGetter, InstanceCheckedSetter, |
| 20116 Handle<Value>(), | 20239 Handle<Value>(), |
| 20117 v8::DEFAULT, | 20240 v8::DEFAULT, |
| 20118 v8::None, | 20241 v8::None, |
| 20119 v8::AccessorSignature::New(context->GetIsolate(), templ)); | 20242 v8::AccessorSignature::New(context->GetIsolate(), templ)); |
| 20120 context->Global()->Set(v8_str("f"), templ->GetFunction()); | 20243 context->Global()->Set(v8_str("f"), templ->GetFunction()); |
| 20121 | 20244 |
| 20122 printf("Testing positive ...\n"); | 20245 printf("Testing positive ...\n"); |
| 20123 CompileRun("var obj = new f();"); | 20246 CompileRun("var obj = new f();"); |
| 20124 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); | 20247 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); |
| 20125 CheckInstanceCheckedAccessors(true); | 20248 CheckInstanceCheckedAccessors(true); |
| 20126 | 20249 |
| 20127 printf("Testing negative ...\n"); | 20250 printf("Testing negative ...\n"); |
| 20128 CompileRun("var obj = {};" | 20251 CompileRun("var obj = {};" |
| 20129 "obj.__proto__ = new f();"); | 20252 "obj.__proto__ = new f();"); |
| 20130 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj")))); | 20253 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj")))); |
| 20131 CheckInstanceCheckedAccessors(false); | 20254 CheckInstanceCheckedAccessors(false); |
| 20132 } | 20255 } |
| 20133 | 20256 |
| 20134 | 20257 |
| 20135 THREADED_TEST(InstanceCheckOnInstanceAccessorWithInterceptor) { | 20258 THREADED_TEST(InstanceCheckOnInstanceAccessorWithInterceptor) { |
| 20136 v8::internal::FLAG_allow_natives_syntax = true; | 20259 v8::internal::FLAG_allow_natives_syntax = true; |
| 20137 LocalContext context; | 20260 LocalContext context; |
| 20138 v8::HandleScope scope(context->GetIsolate()); | 20261 v8::HandleScope scope(context->GetIsolate()); |
| 20139 | 20262 |
| 20140 Local<FunctionTemplate> templ = FunctionTemplate::New(); | 20263 Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate()); |
| 20141 Local<ObjectTemplate> inst = templ->InstanceTemplate(); | 20264 Local<ObjectTemplate> inst = templ->InstanceTemplate(); |
| 20142 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); | 20265 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 20143 inst->SetAccessor(v8_str("foo"), | 20266 inst->SetAccessor(v8_str("foo"), |
| 20144 InstanceCheckedGetter, InstanceCheckedSetter, | 20267 InstanceCheckedGetter, InstanceCheckedSetter, |
| 20145 Handle<Value>(), | 20268 Handle<Value>(), |
| 20146 v8::DEFAULT, | 20269 v8::DEFAULT, |
| 20147 v8::None, | 20270 v8::None, |
| 20148 v8::AccessorSignature::New(context->GetIsolate(), templ)); | 20271 v8::AccessorSignature::New(context->GetIsolate(), templ)); |
| 20149 context->Global()->Set(v8_str("f"), templ->GetFunction()); | 20272 context->Global()->Set(v8_str("f"), templ->GetFunction()); |
| 20150 | 20273 |
| 20151 printf("Testing positive ...\n"); | 20274 printf("Testing positive ...\n"); |
| 20152 CompileRun("var obj = new f();"); | 20275 CompileRun("var obj = new f();"); |
| 20153 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); | 20276 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); |
| 20154 CheckInstanceCheckedAccessors(true); | 20277 CheckInstanceCheckedAccessors(true); |
| 20155 | 20278 |
| 20156 printf("Testing negative ...\n"); | 20279 printf("Testing negative ...\n"); |
| 20157 CompileRun("var obj = {};" | 20280 CompileRun("var obj = {};" |
| 20158 "obj.__proto__ = new f();"); | 20281 "obj.__proto__ = new f();"); |
| 20159 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj")))); | 20282 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj")))); |
| 20160 CheckInstanceCheckedAccessors(false); | 20283 CheckInstanceCheckedAccessors(false); |
| 20161 } | 20284 } |
| 20162 | 20285 |
| 20163 | 20286 |
| 20164 THREADED_TEST(InstanceCheckOnPrototypeAccessor) { | 20287 THREADED_TEST(InstanceCheckOnPrototypeAccessor) { |
| 20165 v8::internal::FLAG_allow_natives_syntax = true; | 20288 v8::internal::FLAG_allow_natives_syntax = true; |
| 20166 LocalContext context; | 20289 LocalContext context; |
| 20167 v8::HandleScope scope(context->GetIsolate()); | 20290 v8::HandleScope scope(context->GetIsolate()); |
| 20168 | 20291 |
| 20169 Local<FunctionTemplate> templ = FunctionTemplate::New(); | 20292 Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate()); |
| 20170 Local<ObjectTemplate> proto = templ->PrototypeTemplate(); | 20293 Local<ObjectTemplate> proto = templ->PrototypeTemplate(); |
| 20171 proto->SetAccessor(v8_str("foo"), | 20294 proto->SetAccessor(v8_str("foo"), |
| 20172 InstanceCheckedGetter, InstanceCheckedSetter, | 20295 InstanceCheckedGetter, InstanceCheckedSetter, |
| 20173 Handle<Value>(), | 20296 Handle<Value>(), |
| 20174 v8::DEFAULT, | 20297 v8::DEFAULT, |
| 20175 v8::None, | 20298 v8::None, |
| 20176 v8::AccessorSignature::New(context->GetIsolate(), templ)); | 20299 v8::AccessorSignature::New(context->GetIsolate(), templ)); |
| 20177 context->Global()->Set(v8_str("f"), templ->GetFunction()); | 20300 context->Global()->Set(v8_str("f"), templ->GetFunction()); |
| 20178 | 20301 |
| 20179 printf("Testing positive ...\n"); | 20302 printf("Testing positive ...\n"); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20392 TryCatch try_catch; | 20515 TryCatch try_catch; |
| 20393 try_catch.SetVerbose(true); | 20516 try_catch.SetVerbose(true); |
| 20394 CompileRun("try { throw new Error(); } finally { gc(); }"); | 20517 CompileRun("try { throw new Error(); } finally { gc(); }"); |
| 20395 CHECK(try_catch.HasCaught()); | 20518 CHECK(try_catch.HasCaught()); |
| 20396 } | 20519 } |
| 20397 | 20520 |
| 20398 | 20521 |
| 20399 THREADED_TEST(Regress149912) { | 20522 THREADED_TEST(Regress149912) { |
| 20400 LocalContext context; | 20523 LocalContext context; |
| 20401 v8::HandleScope scope(context->GetIsolate()); | 20524 v8::HandleScope scope(context->GetIsolate()); |
| 20402 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 20525 Handle<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate()); |
| 20403 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); | 20526 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 20404 context->Global()->Set(v8_str("Bug"), templ->GetFunction()); | 20527 context->Global()->Set(v8_str("Bug"), templ->GetFunction()); |
| 20405 CompileRun("Number.prototype.__proto__ = new Bug; var x = 0; x.foo();"); | 20528 CompileRun("Number.prototype.__proto__ = new Bug; var x = 0; x.foo();"); |
| 20406 } | 20529 } |
| 20407 | 20530 |
| 20408 | 20531 |
| 20409 THREADED_TEST(Regress157124) { | 20532 THREADED_TEST(Regress157124) { |
| 20410 LocalContext context; | 20533 LocalContext context; |
| 20411 v8::HandleScope scope(context->GetIsolate()); | 20534 v8::HandleScope scope(context->GetIsolate()); |
| 20412 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 20535 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 20437 Local<String> key = String::NewFromUtf8(context->GetIsolate(), "key"); | 20560 Local<String> key = String::NewFromUtf8(context->GetIsolate(), "key"); |
| 20438 obj->SetHiddenValue(key, v8::Undefined(isolate)); | 20561 obj->SetHiddenValue(key, v8::Undefined(isolate)); |
| 20439 Local<Value> value = obj->GetHiddenValue(key); | 20562 Local<Value> value = obj->GetHiddenValue(key); |
| 20440 CHECK(!value.IsEmpty()); | 20563 CHECK(!value.IsEmpty()); |
| 20441 CHECK(value->IsUndefined()); | 20564 CHECK(value->IsUndefined()); |
| 20442 } | 20565 } |
| 20443 | 20566 |
| 20444 | 20567 |
| 20445 THREADED_TEST(Regress260106) { | 20568 THREADED_TEST(Regress260106) { |
| 20446 LocalContext context; | 20569 LocalContext context; |
| 20447 v8::HandleScope scope(context->GetIsolate()); | 20570 v8::Isolate* isolate = context->GetIsolate(); |
| 20448 Local<FunctionTemplate> templ = FunctionTemplate::New(DummyCallHandler); | 20571 v8::HandleScope scope(isolate); |
| 20572 Local<FunctionTemplate> templ = FunctionTemplate::New(isolate, |
| 20573 DummyCallHandler); |
| 20449 CompileRun("for (var i = 0; i < 128; i++) Object.prototype[i] = 0;"); | 20574 CompileRun("for (var i = 0; i < 128; i++) Object.prototype[i] = 0;"); |
| 20450 Local<Function> function = templ->GetFunction(); | 20575 Local<Function> function = templ->GetFunction(); |
| 20451 CHECK(!function.IsEmpty()); | 20576 CHECK(!function.IsEmpty()); |
| 20452 CHECK(function->IsFunction()); | 20577 CHECK(function->IsFunction()); |
| 20453 } | 20578 } |
| 20454 | 20579 |
| 20455 | 20580 |
| 20456 THREADED_TEST(JSONParseObject) { | 20581 THREADED_TEST(JSONParseObject) { |
| 20457 LocalContext context; | 20582 LocalContext context; |
| 20458 HandleScope scope(context->GetIsolate()); | 20583 HandleScope scope(context->GetIsolate()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20570 // Create a context and set an x property on it's global object. | 20695 // Create a context and set an x property on it's global object. |
| 20571 LocalContext context0(NULL, global_template); | 20696 LocalContext context0(NULL, global_template); |
| 20572 v8::Handle<v8::Object> global0 = context0->Global(); | 20697 v8::Handle<v8::Object> global0 = context0->Global(); |
| 20573 global0->Set(v8_str("x"), v8_num(42)); | 20698 global0->Set(v8_str("x"), v8_num(42)); |
| 20574 ExpectString("JSON.stringify(this)", "{\"x\":42}"); | 20699 ExpectString("JSON.stringify(this)", "{\"x\":42}"); |
| 20575 | 20700 |
| 20576 for (int i = 0; i < 2; i++) { | 20701 for (int i = 0; i < 2; i++) { |
| 20577 if (i == 1) { | 20702 if (i == 1) { |
| 20578 // Install a toJSON function on the second run. | 20703 // Install a toJSON function on the second run. |
| 20579 v8::Handle<v8::FunctionTemplate> toJSON = | 20704 v8::Handle<v8::FunctionTemplate> toJSON = |
| 20580 v8::FunctionTemplate::New(UnreachableCallback); | 20705 v8::FunctionTemplate::New(CcTest::isolate(), UnreachableCallback); |
| 20581 | 20706 |
| 20582 global0->Set(v8_str("toJSON"), toJSON->GetFunction()); | 20707 global0->Set(v8_str("toJSON"), toJSON->GetFunction()); |
| 20583 } | 20708 } |
| 20584 // Create a context with a different security token so that the | 20709 // Create a context with a different security token so that the |
| 20585 // failed access check callback will be called on each access. | 20710 // failed access check callback will be called on each access. |
| 20586 LocalContext context1(NULL, global_template); | 20711 LocalContext context1(NULL, global_template); |
| 20587 context1->Global()->Set(v8_str("other"), global0); | 20712 context1->Global()->Set(v8_str("other"), global0); |
| 20588 | 20713 |
| 20589 ExpectString("JSON.stringify(other)", "{}"); | 20714 ExpectString("JSON.stringify(other)", "{}"); |
| 20590 ExpectString("JSON.stringify({ 'a' : other, 'b' : ['c'] })", | 20715 ExpectString("JSON.stringify({ 'a' : other, 'b' : ['c'] })", |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20669 LocalContext context0(NULL, global_template); | 20794 LocalContext context0(NULL, global_template); |
| 20670 context0->Global()->Set(v8_str("x"), v8_num(42)); | 20795 context0->Global()->Set(v8_str("x"), v8_num(42)); |
| 20671 v8::Handle<v8::Object> global0 = context0->Global(); | 20796 v8::Handle<v8::Object> global0 = context0->Global(); |
| 20672 | 20797 |
| 20673 // Create a context with a different security token so that the | 20798 // Create a context with a different security token so that the |
| 20674 // failed access check callback will be called on each access. | 20799 // failed access check callback will be called on each access. |
| 20675 LocalContext context1(NULL, global_template); | 20800 LocalContext context1(NULL, global_template); |
| 20676 context1->Global()->Set(v8_str("other"), global0); | 20801 context1->Global()->Set(v8_str("other"), global0); |
| 20677 | 20802 |
| 20678 v8::Handle<v8::FunctionTemplate> catcher_fun = | 20803 v8::Handle<v8::FunctionTemplate> catcher_fun = |
| 20679 v8::FunctionTemplate::New(CatcherCallback); | 20804 v8::FunctionTemplate::New(CcTest::isolate(), CatcherCallback); |
| 20680 context1->Global()->Set(v8_str("catcher"), catcher_fun->GetFunction()); | 20805 context1->Global()->Set(v8_str("catcher"), catcher_fun->GetFunction()); |
| 20681 | 20806 |
| 20682 v8::Handle<v8::FunctionTemplate> has_own_property_fun = | 20807 v8::Handle<v8::FunctionTemplate> has_own_property_fun = |
| 20683 v8::FunctionTemplate::New(HasOwnPropertyCallback); | 20808 v8::FunctionTemplate::New(CcTest::isolate(), HasOwnPropertyCallback); |
| 20684 context1->Global()->Set(v8_str("has_own_property"), | 20809 context1->Global()->Set(v8_str("has_own_property"), |
| 20685 has_own_property_fun->GetFunction()); | 20810 has_own_property_fun->GetFunction()); |
| 20686 | 20811 |
| 20687 { v8::TryCatch try_catch; | 20812 { v8::TryCatch try_catch; |
| 20688 access_check_fail_thrown = false; | 20813 access_check_fail_thrown = false; |
| 20689 CompileRun("other.x;"); | 20814 CompileRun("other.x;"); |
| 20690 CHECK(access_check_fail_thrown); | 20815 CHECK(access_check_fail_thrown); |
| 20691 CHECK(try_catch.HasCaught()); | 20816 CHECK(try_catch.HasCaught()); |
| 20692 } | 20817 } |
| 20693 | 20818 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 20712 // Reset the failed access check callback so it does not influence | 20837 // Reset the failed access check callback so it does not influence |
| 20713 // the other tests. | 20838 // the other tests. |
| 20714 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); | 20839 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); |
| 20715 } | 20840 } |
| 20716 | 20841 |
| 20717 | 20842 |
| 20718 THREADED_TEST(Regress256330) { | 20843 THREADED_TEST(Regress256330) { |
| 20719 i::FLAG_allow_natives_syntax = true; | 20844 i::FLAG_allow_natives_syntax = true; |
| 20720 LocalContext context; | 20845 LocalContext context; |
| 20721 v8::HandleScope scope(context->GetIsolate()); | 20846 v8::HandleScope scope(context->GetIsolate()); |
| 20722 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 20847 Handle<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate()); |
| 20723 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); | 20848 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 20724 context->Global()->Set(v8_str("Bug"), templ->GetFunction()); | 20849 context->Global()->Set(v8_str("Bug"), templ->GetFunction()); |
| 20725 CompileRun("\"use strict\"; var o = new Bug;" | 20850 CompileRun("\"use strict\"; var o = new Bug;" |
| 20726 "function f(o) { o.x = 10; };" | 20851 "function f(o) { o.x = 10; };" |
| 20727 "f(o); f(o); f(o);" | 20852 "f(o); f(o); f(o);" |
| 20728 "%OptimizeFunctionOnNextCall(f);" | 20853 "%OptimizeFunctionOnNextCall(f);" |
| 20729 "f(o);"); | 20854 "f(o);"); |
| 20730 ExpectBoolean("%GetOptimizationStatus(f) != 2", true); | 20855 ExpectBoolean("%GetOptimizationStatus(f) != 2", true); |
| 20731 } | 20856 } |
| 20732 | 20857 |
| 20733 | 20858 |
| 20734 THREADED_TEST(CrankshaftInterceptorSetter) { | 20859 THREADED_TEST(CrankshaftInterceptorSetter) { |
| 20735 i::FLAG_allow_natives_syntax = true; | 20860 i::FLAG_allow_natives_syntax = true; |
| 20736 v8::HandleScope scope(CcTest::isolate()); | 20861 v8::HandleScope scope(CcTest::isolate()); |
| 20737 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 20862 Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); |
| 20738 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 20863 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 20739 LocalContext env; | 20864 LocalContext env; |
| 20740 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 20865 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 20741 CompileRun("var obj = new Obj;" | 20866 CompileRun("var obj = new Obj;" |
| 20742 // Initialize fields to avoid transitions later. | 20867 // Initialize fields to avoid transitions later. |
| 20743 "obj.age = 0;" | 20868 "obj.age = 0;" |
| 20744 "obj.accessor_age = 42;" | 20869 "obj.accessor_age = 42;" |
| 20745 "function setter(i) { this.accessor_age = i; };" | 20870 "function setter(i) { this.accessor_age = i; };" |
| 20746 "function getter() { return this.accessor_age; };" | 20871 "function getter() { return this.accessor_age; };" |
| 20747 "function setAge(i) { obj.age = i; };" | 20872 "function setAge(i) { obj.age = i; };" |
| 20748 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" | 20873 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" |
| 20749 "setAge(1);" | 20874 "setAge(1);" |
| 20750 "setAge(2);" | 20875 "setAge(2);" |
| 20751 "setAge(3);" | 20876 "setAge(3);" |
| 20752 "%OptimizeFunctionOnNextCall(setAge);" | 20877 "%OptimizeFunctionOnNextCall(setAge);" |
| 20753 "setAge(4);"); | 20878 "setAge(4);"); |
| 20754 // All stores went through the interceptor. | 20879 // All stores went through the interceptor. |
| 20755 ExpectInt32("obj.interceptor_age", 4); | 20880 ExpectInt32("obj.interceptor_age", 4); |
| 20756 ExpectInt32("obj.accessor_age", 42); | 20881 ExpectInt32("obj.accessor_age", 42); |
| 20757 } | 20882 } |
| 20758 | 20883 |
| 20759 | 20884 |
| 20760 THREADED_TEST(CrankshaftInterceptorGetter) { | 20885 THREADED_TEST(CrankshaftInterceptorGetter) { |
| 20761 i::FLAG_allow_natives_syntax = true; | 20886 i::FLAG_allow_natives_syntax = true; |
| 20762 v8::HandleScope scope(CcTest::isolate()); | 20887 v8::HandleScope scope(CcTest::isolate()); |
| 20763 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 20888 Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); |
| 20764 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 20889 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 20765 LocalContext env; | 20890 LocalContext env; |
| 20766 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 20891 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 20767 CompileRun("var obj = new Obj;" | 20892 CompileRun("var obj = new Obj;" |
| 20768 // Initialize fields to avoid transitions later. | 20893 // Initialize fields to avoid transitions later. |
| 20769 "obj.age = 1;" | 20894 "obj.age = 1;" |
| 20770 "obj.accessor_age = 42;" | 20895 "obj.accessor_age = 42;" |
| 20771 "function getter() { return this.accessor_age; };" | 20896 "function getter() { return this.accessor_age; };" |
| 20772 "function getAge() { return obj.interceptor_age; };" | 20897 "function getAge() { return obj.interceptor_age; };" |
| 20773 "Object.defineProperty(obj, 'interceptor_age', { get:getter });" | 20898 "Object.defineProperty(obj, 'interceptor_age', { get:getter });" |
| 20774 "getAge();" | 20899 "getAge();" |
| 20775 "getAge();" | 20900 "getAge();" |
| 20776 "getAge();" | 20901 "getAge();" |
| 20777 "%OptimizeFunctionOnNextCall(getAge);"); | 20902 "%OptimizeFunctionOnNextCall(getAge);"); |
| 20778 // Access through interceptor. | 20903 // Access through interceptor. |
| 20779 ExpectInt32("getAge()", 1); | 20904 ExpectInt32("getAge()", 1); |
| 20780 } | 20905 } |
| 20781 | 20906 |
| 20782 | 20907 |
| 20783 THREADED_TEST(CrankshaftInterceptorFieldRead) { | 20908 THREADED_TEST(CrankshaftInterceptorFieldRead) { |
| 20784 i::FLAG_allow_natives_syntax = true; | 20909 i::FLAG_allow_natives_syntax = true; |
| 20785 v8::HandleScope scope(CcTest::isolate()); | 20910 v8::HandleScope scope(CcTest::isolate()); |
| 20786 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 20911 Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); |
| 20787 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 20912 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 20788 LocalContext env; | 20913 LocalContext env; |
| 20789 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 20914 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 20790 CompileRun("var obj = new Obj;" | 20915 CompileRun("var obj = new Obj;" |
| 20791 "obj.__proto__.interceptor_age = 42;" | 20916 "obj.__proto__.interceptor_age = 42;" |
| 20792 "obj.age = 100;" | 20917 "obj.age = 100;" |
| 20793 "function getAge() { return obj.interceptor_age; };"); | 20918 "function getAge() { return obj.interceptor_age; };"); |
| 20794 ExpectInt32("getAge();", 100); | 20919 ExpectInt32("getAge();", 100); |
| 20795 ExpectInt32("getAge();", 100); | 20920 ExpectInt32("getAge();", 100); |
| 20796 ExpectInt32("getAge();", 100); | 20921 ExpectInt32("getAge();", 100); |
| 20797 CompileRun("%OptimizeFunctionOnNextCall(getAge);"); | 20922 CompileRun("%OptimizeFunctionOnNextCall(getAge);"); |
| 20798 // Access through interceptor. | 20923 // Access through interceptor. |
| 20799 ExpectInt32("getAge();", 100); | 20924 ExpectInt32("getAge();", 100); |
| 20800 } | 20925 } |
| 20801 | 20926 |
| 20802 | 20927 |
| 20803 THREADED_TEST(CrankshaftInterceptorFieldWrite) { | 20928 THREADED_TEST(CrankshaftInterceptorFieldWrite) { |
| 20804 i::FLAG_allow_natives_syntax = true; | 20929 i::FLAG_allow_natives_syntax = true; |
| 20805 v8::HandleScope scope(CcTest::isolate()); | 20930 v8::HandleScope scope(CcTest::isolate()); |
| 20806 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 20931 Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); |
| 20807 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 20932 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 20808 LocalContext env; | 20933 LocalContext env; |
| 20809 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 20934 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 20810 CompileRun("var obj = new Obj;" | 20935 CompileRun("var obj = new Obj;" |
| 20811 "obj.age = 100000;" | 20936 "obj.age = 100000;" |
| 20812 "function setAge(i) { obj.age = i };" | 20937 "function setAge(i) { obj.age = i };" |
| 20813 "setAge(100);" | 20938 "setAge(100);" |
| 20814 "setAge(101);" | 20939 "setAge(101);" |
| 20815 "setAge(102);" | 20940 "setAge(102);" |
| 20816 "%OptimizeFunctionOnNextCall(setAge);" | 20941 "%OptimizeFunctionOnNextCall(setAge);" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20873 } | 20998 } |
| 20874 for (int i = 0; i < runs; i++) { | 20999 for (int i = 0; i < runs; i++) { |
| 20875 Local<String> expected; | 21000 Local<String> expected; |
| 20876 if (i != 0) { | 21001 if (i != 0) { |
| 20877 CHECK_EQ(v8_str("escape value"), values[i]); | 21002 CHECK_EQ(v8_str("escape value"), values[i]); |
| 20878 } else { | 21003 } else { |
| 20879 CHECK(values[i].IsEmpty()); | 21004 CHECK(values[i].IsEmpty()); |
| 20880 } | 21005 } |
| 20881 } | 21006 } |
| 20882 } | 21007 } |
| OLD | NEW |