From e1575f8369b324884e9e5d39edc1ff4f70c4c8b8 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Mon, 18 Aug 2014 14:27:24 +0000 Subject: [PATCH] Remove the extensibility flag. Instead just rely on hidden_string as indication. BUG= R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/466033002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23164 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/objects.cc | 52 ++++++++++++---------------------------------------- src/objects.h | 12 +----------- src/runtime.cc | 12 +++++------- 3 files changed, 18 insertions(+), 58 deletions(-) diff --git a/src/objects.cc b/src/objects.cc index d55dc66..eab3e2c 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -2923,8 +2923,7 @@ MaybeHandle Object::SetProperty(LookupIterator* it, if (done) break; } - return AddDataProperty(it, value, NONE, strict_mode, store_mode, - PERFORM_EXTENSIBILITY_CHECK); + return AddDataProperty(it, value, NONE, strict_mode, store_mode); } @@ -2979,8 +2978,7 @@ MaybeHandle Object::AddDataProperty(LookupIterator* it, Handle value, PropertyAttributes attributes, StrictMode strict_mode, - StoreFromKeyed store_mode, - ExtensibilityCheck check) { + StoreFromKeyed store_mode) { DCHECK(!it->GetReceiver()->IsJSProxy()); if (!it->GetReceiver()->IsJSObject()) { // TODO(verwaest): Throw a TypeError with a more specific message. @@ -2998,7 +2996,7 @@ MaybeHandle Object::AddDataProperty(LookupIterator* it, Handle::cast(PrototypeIterator::GetCurrent(iter)); } - if (check == PERFORM_EXTENSIBILITY_CHECK && + if (!it->name().is_identical_to(it->isolate()->factory()->hidden_string()) && !receiver->map()->is_extensible()) { if (strict_mode == SLOPPY) return value; @@ -3873,18 +3871,19 @@ void JSObject::WriteToField(int descriptor, Object* value) { void JSObject::AddProperty(Handle object, Handle name, Handle value, PropertyAttributes attributes) { + LookupIterator it(object, name, LookupIterator::CHECK_OWN_REAL); #ifdef DEBUG uint32_t index; DCHECK(!object->IsJSProxy()); DCHECK(!name->AsArrayIndex(&index)); - LookupIterator it(object, name, LookupIterator::CHECK_OWN_REAL); Maybe maybe = GetPropertyAttributes(&it); DCHECK(maybe.has_value); DCHECK(!it.IsFound()); - DCHECK(object->map()->is_extensible()); + DCHECK(object->map()->is_extensible() || + name.is_identical_to(it.isolate()->factory()->hidden_string())); #endif - SetOwnPropertyIgnoreAttributes(object, name, value, attributes, - OMIT_EXTENSIBILITY_CHECK).Check(); + AddDataProperty(&it, value, attributes, STRICT, + CERTAINLY_NOT_STORE_FROM_KEYED).Check(); } @@ -3895,7 +3894,6 @@ MaybeHandle JSObject::SetOwnPropertyIgnoreAttributes( Handle name, Handle value, PropertyAttributes attributes, - ExtensibilityCheck extensibility_check, StoreFromKeyed store_from_keyed, ExecutableAccessorInfoHandling handling) { DCHECK(!value->IsTheHole()); @@ -4014,8 +4012,7 @@ MaybeHandle JSObject::SetOwnPropertyIgnoreAttributes( } } - return AddDataProperty(&it, value, attributes, STRICT, store_from_keyed, - extensibility_check); + return AddDataProperty(&it, value, attributes, STRICT, store_from_keyed); } @@ -4843,10 +4840,7 @@ Handle JSObject::GetOrCreateHiddenPropertiesHashtable( inline_value); } - JSObject::SetOwnPropertyIgnoreAttributes( - object, isolate->factory()->hidden_string(), - hashtable, DONT_ENUM).Assert(); - + SetHiddenPropertiesHashTable(object, hashtable); return hashtable; } @@ -4854,31 +4848,9 @@ Handle JSObject::GetOrCreateHiddenPropertiesHashtable( Handle JSObject::SetHiddenPropertiesHashTable(Handle object, Handle value) { DCHECK(!object->IsJSGlobalProxy()); - Isolate* isolate = object->GetIsolate(); - - // We can store the identity hash inline iff there is no backing store - // for hidden properties yet. - DCHECK(JSObject::HasHiddenProperties(object) != value->IsSmi()); - if (object->HasFastProperties()) { - // If the object has fast properties, check whether the first slot - // in the descriptor array matches the hidden string. Since the - // hidden strings hash code is zero (and no other name has hash - // code zero) it will always occupy the first entry if present. - DescriptorArray* descriptors = object->map()->instance_descriptors(); - if (descriptors->number_of_descriptors() > 0) { - int sorted_index = descriptors->GetSortedKeyIndex(0); - if (descriptors->GetKey(sorted_index) == isolate->heap()->hidden_string() - && sorted_index < object->map()->NumberOfOwnDescriptors()) { - object->WriteToField(sorted_index, *value); - return object; - } - } - } - - SetOwnPropertyIgnoreAttributes(object, isolate->factory()->hidden_string(), - value, DONT_ENUM, - OMIT_EXTENSIBILITY_CHECK).Assert(); + Handle name = isolate->factory()->hidden_string(); + SetOwnPropertyIgnoreAttributes(object, name, value, DONT_ENUM).Assert(); return object; } diff --git a/src/objects.h b/src/objects.h index b4d19e1..3659e44 100644 --- a/src/objects.h +++ b/src/objects.h @@ -247,14 +247,6 @@ enum PropertyNormalizationMode { }; -// Internal properties (e.g. the hidden properties dictionary) might -// be added even though the receiver is non-extensible. -enum ExtensibilityCheck { - PERFORM_EXTENSIBILITY_CHECK, - OMIT_EXTENSIBILITY_CHECK -}; - - // Indicates how aggressively the prototype should be optimized. FAST_PROTOTYPE // will give the fastest result by tailoring the map to the prototype, but that // will cause polymorphism with other objects. REGULAR_PROTOTYPE is to be used @@ -1500,8 +1492,7 @@ class Object { LookupIterator* it, Handle value); MUST_USE_RESULT static MaybeHandle AddDataProperty( LookupIterator* it, Handle value, PropertyAttributes attributes, - StrictMode strict_mode, StoreFromKeyed store_mode, - ExtensibilityCheck check); + StrictMode strict_mode, StoreFromKeyed store_mode); MUST_USE_RESULT static inline MaybeHandle GetPropertyOrElement( Handle object, Handle key); @@ -2149,7 +2140,6 @@ class JSObject: public JSReceiver { Handle key, Handle value, PropertyAttributes attributes, - ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); diff --git a/src/runtime.cc b/src/runtime.cc index 2b9c20c..6dacbac 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -5041,7 +5041,7 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyUnchecked) { ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, result, JSObject::SetOwnPropertyIgnoreAttributes( - js_object, name, obj_value, attr, PERFORM_EXTENSIBILITY_CHECK, + js_object, name, obj_value, attr, JSReceiver::MAY_BE_STORE_FROM_KEYED, JSObject::DONT_FORCE_FIELD)); return *result; } @@ -5195,9 +5195,8 @@ MaybeHandle Runtime::DefineObjectProperty( SLOPPY, false, DEFINE_PROPERTY); } else { if (name->IsString()) name = String::Flatten(Handle::cast(name)); - return JSObject::SetOwnPropertyIgnoreAttributes( - js_object, name, value, attr, PERFORM_EXTENSIBILITY_CHECK, - store_from_keyed); + return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value, + attr, store_from_keyed); } } @@ -5211,9 +5210,8 @@ MaybeHandle Runtime::DefineObjectProperty( return JSObject::SetElement(js_object, index, value, attr, SLOPPY, false, DEFINE_PROPERTY); } else { - return JSObject::SetOwnPropertyIgnoreAttributes( - js_object, name, value, attr, PERFORM_EXTENSIBILITY_CHECK, - store_from_keyed); + return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value, + attr, store_from_keyed); } } -- 2.7.4