| OLD | NEW |
| 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 CHECK(obj->Delete(prop_name)); | 1337 CHECK(obj->Delete(prop_name)); |
| 1338 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1338 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 1339 | 1339 |
| 1340 i::Heap::CollectAllGarbage(false); | 1340 i::Heap::CollectAllGarbage(false); |
| 1341 | 1341 |
| 1342 CHECK(obj->DeleteHiddenValue(key)); | 1342 CHECK(obj->DeleteHiddenValue(key)); |
| 1343 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 1343 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
| 1344 } | 1344 } |
| 1345 | 1345 |
| 1346 | 1346 |
| 1347 static bool interceptor_for_hidden_properties_called; |
| 1347 static v8::Handle<Value> InterceptorForHiddenProperties( | 1348 static v8::Handle<Value> InterceptorForHiddenProperties( |
| 1348 Local<String> name, const AccessorInfo& info) { | 1349 Local<String> name, const AccessorInfo& info) { |
| 1349 // Make sure objects move. | 1350 interceptor_for_hidden_properties_called = true; |
| 1350 bool saved_always_compact = i::FLAG_always_compact; | |
| 1351 if (!i::FLAG_never_compact) { | |
| 1352 i::FLAG_always_compact = true; | |
| 1353 } | |
| 1354 // The whole goal of this interceptor is to cause a GC during local property | |
| 1355 // lookup. | |
| 1356 i::Heap::CollectAllGarbage(false); | |
| 1357 i::FLAG_always_compact = saved_always_compact; | |
| 1358 return v8::Handle<Value>(); | 1351 return v8::Handle<Value>(); |
| 1359 } | 1352 } |
| 1360 | 1353 |
| 1361 | 1354 |
| 1362 THREADED_TEST(HiddenPropertiesWithInterceptors) { | 1355 THREADED_TEST(HiddenPropertiesWithInterceptors) { |
| 1363 v8::HandleScope scope; | 1356 v8::HandleScope scope; |
| 1364 LocalContext context; | 1357 LocalContext context; |
| 1365 | 1358 |
| 1359 interceptor_for_hidden_properties_called = false; |
| 1360 |
| 1366 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 1361 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
| 1367 | 1362 |
| 1368 // Associate an interceptor with an object and start setting hidden values. | 1363 // Associate an interceptor with an object and start setting hidden values. |
| 1369 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 1364 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 1370 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); | 1365 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); |
| 1371 instance_templ->SetNamedPropertyHandler(InterceptorForHiddenProperties); | 1366 instance_templ->SetNamedPropertyHandler(InterceptorForHiddenProperties); |
| 1372 Local<v8::Function> function = fun_templ->GetFunction(); | 1367 Local<v8::Function> function = fun_templ->GetFunction(); |
| 1373 Local<v8::Object> obj = function->NewInstance(); | 1368 Local<v8::Object> obj = function->NewInstance(); |
| 1374 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302))); | 1369 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302))); |
| 1375 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); | 1370 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); |
| 1371 CHECK(!interceptor_for_hidden_properties_called); |
| 1376 } | 1372 } |
| 1377 | 1373 |
| 1378 | 1374 |
| 1379 THREADED_TEST(External) { | 1375 THREADED_TEST(External) { |
| 1380 v8::HandleScope scope; | 1376 v8::HandleScope scope; |
| 1381 int x = 3; | 1377 int x = 3; |
| 1382 Local<v8::External> ext = v8::External::New(&x); | 1378 Local<v8::External> ext = v8::External::New(&x); |
| 1383 LocalContext env; | 1379 LocalContext env; |
| 1384 env->Global()->Set(v8_str("ext"), ext); | 1380 env->Global()->Set(v8_str("ext"), ext); |
| 1385 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); | 1381 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); |
| (...skipping 6986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8372 " i++;" | 8368 " i++;" |
| 8373 " return s(o);" | 8369 " return s(o);" |
| 8374 " }" | 8370 " }" |
| 8375 " }" | 8371 " }" |
| 8376 "};" | 8372 "};" |
| 8377 "s(o);"); | 8373 "s(o);"); |
| 8378 CHECK(try_catch.HasCaught()); | 8374 CHECK(try_catch.HasCaught()); |
| 8379 v8::String::Utf8Value value(try_catch.Exception()); | 8375 v8::String::Utf8Value value(try_catch.Exception()); |
| 8380 CHECK_EQ(0, strcmp(*value, "Hey!")); | 8376 CHECK_EQ(0, strcmp(*value, "Hey!")); |
| 8381 } | 8377 } |
| OLD | NEW |