| 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 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 CHECK(obj->Delete(prop_name)); | 1573 CHECK(obj->Delete(prop_name)); |
| 1574 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1574 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 1575 | 1575 |
| 1576 i::Heap::CollectAllGarbage(false); | 1576 i::Heap::CollectAllGarbage(false); |
| 1577 | 1577 |
| 1578 CHECK(obj->DeleteHiddenValue(key)); | 1578 CHECK(obj->DeleteHiddenValue(key)); |
| 1579 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 1579 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
| 1580 } | 1580 } |
| 1581 | 1581 |
| 1582 | 1582 |
| 1583 static bool interceptor_for_hidden_properties_called; |
| 1583 static v8::Handle<Value> InterceptorForHiddenProperties( | 1584 static v8::Handle<Value> InterceptorForHiddenProperties( |
| 1584 Local<String> name, const AccessorInfo& info) { | 1585 Local<String> name, const AccessorInfo& info) { |
| 1585 // Make sure objects move. | 1586 interceptor_for_hidden_properties_called = true; |
| 1586 bool saved_always_compact = i::FLAG_always_compact; | |
| 1587 if (!i::FLAG_never_compact) { | |
| 1588 i::FLAG_always_compact = true; | |
| 1589 } | |
| 1590 // The whole goal of this interceptor is to cause a GC during local property | |
| 1591 // lookup. | |
| 1592 i::Heap::CollectAllGarbage(false); | |
| 1593 i::FLAG_always_compact = saved_always_compact; | |
| 1594 return v8::Handle<Value>(); | 1587 return v8::Handle<Value>(); |
| 1595 } | 1588 } |
| 1596 | 1589 |
| 1597 | 1590 |
| 1598 THREADED_TEST(HiddenPropertiesWithInterceptors) { | 1591 THREADED_TEST(HiddenPropertiesWithInterceptors) { |
| 1599 v8::HandleScope scope; | 1592 v8::HandleScope scope; |
| 1600 LocalContext context; | 1593 LocalContext context; |
| 1601 | 1594 |
| 1595 interceptor_for_hidden_properties_called = false; |
| 1596 |
| 1602 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 1597 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
| 1603 | 1598 |
| 1604 // Associate an interceptor with an object and start setting hidden values. | 1599 // Associate an interceptor with an object and start setting hidden values. |
| 1605 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 1600 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 1606 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); | 1601 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); |
| 1607 instance_templ->SetNamedPropertyHandler(InterceptorForHiddenProperties); | 1602 instance_templ->SetNamedPropertyHandler(InterceptorForHiddenProperties); |
| 1608 Local<v8::Function> function = fun_templ->GetFunction(); | 1603 Local<v8::Function> function = fun_templ->GetFunction(); |
| 1609 Local<v8::Object> obj = function->NewInstance(); | 1604 Local<v8::Object> obj = function->NewInstance(); |
| 1610 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302))); | 1605 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302))); |
| 1611 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); | 1606 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); |
| 1607 CHECK(!interceptor_for_hidden_properties_called); |
| 1612 } | 1608 } |
| 1613 | 1609 |
| 1614 | 1610 |
| 1615 THREADED_TEST(External) { | 1611 THREADED_TEST(External) { |
| 1616 v8::HandleScope scope; | 1612 v8::HandleScope scope; |
| 1617 int x = 3; | 1613 int x = 3; |
| 1618 Local<v8::External> ext = v8::External::New(&x); | 1614 Local<v8::External> ext = v8::External::New(&x); |
| 1619 LocalContext env; | 1615 LocalContext env; |
| 1620 env->Global()->Set(v8_str("ext"), ext); | 1616 env->Global()->Set(v8_str("ext"), ext); |
| 1621 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); | 1617 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); |
| (...skipping 7019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8641 " i++;" | 8637 " i++;" |
| 8642 " return s(o);" | 8638 " return s(o);" |
| 8643 " }" | 8639 " }" |
| 8644 " }" | 8640 " }" |
| 8645 "};" | 8641 "};" |
| 8646 "s(o);"); | 8642 "s(o);"); |
| 8647 CHECK(try_catch.HasCaught()); | 8643 CHECK(try_catch.HasCaught()); |
| 8648 v8::String::Utf8Value value(try_catch.Exception()); | 8644 v8::String::Utf8Value value(try_catch.Exception()); |
| 8649 CHECK_EQ(0, strcmp(*value, "Hey!")); | 8645 CHECK_EQ(0, strcmp(*value, "Hey!")); |
| 8650 } | 8646 } |
| OLD | NEW |