Reviewers: Jakob,

Message:
PTAL

Description:
Remove the extensibility flag. Instead just rely on hidden_string as indication.

BUG=

Please review this at https://codereview.chromium.org/466033002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+18, -58 lines):
  M src/objects.h
  M src/objects.cc
  M src/runtime.cc


Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index d4a5d3a90e591e13967cb3bdef1708250dac588b..5399c8ed1b2862e099b24bf4569d56870fb9ffb6 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2923,8 +2923,7 @@ MaybeHandle<Object> 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> Object::AddDataProperty(LookupIterator* it,
                                             Handle<Object> 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> Object::AddDataProperty(LookupIterator* it,
         Handle<JSGlobalObject>::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<JSObject> object, Handle<Name> name,
                            Handle<Object> 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<PropertyAttributes> 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<Object> JSObject::SetOwnPropertyIgnoreAttributes(
     Handle<Name> name,
     Handle<Object> value,
     PropertyAttributes attributes,
-    ExtensibilityCheck extensibility_check,
     StoreFromKeyed store_from_keyed,
     ExecutableAccessorInfoHandling handling) {
   DCHECK(!value->IsTheHole());
@@ -4014,8 +4012,7 @@ MaybeHandle<Object> 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<ObjectHashTable> 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<ObjectHashTable> JSObject::GetOrCreateHiddenPropertiesHashtable( Handle<Object> JSObject::SetHiddenPropertiesHashTable(Handle<JSObject> object, Handle<Object> 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> name = isolate->factory()->hidden_string();
+  SetOwnPropertyIgnoreAttributes(object, name, value, DONT_ENUM);
   return object;
 }

Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index ac45a69aaf318fce916fedcee413440785bc1f71..169654411e90098716a5b8ccfb7dfcc8df2550d5 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
@@ -1511,8 +1503,7 @@ class Object {
       LookupIterator* it, Handle<Object> value);
   MUST_USE_RESULT static MaybeHandle<Object> AddDataProperty(
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
-      StrictMode strict_mode, StoreFromKeyed store_mode,
-      ExtensibilityCheck check);
+      StrictMode strict_mode, StoreFromKeyed store_mode);
   MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
       Handle<Object> object,
       Handle<Name> key);
@@ -2160,7 +2151,6 @@ class JSObject: public JSReceiver {
       Handle<Name> key,
       Handle<Object> value,
       PropertyAttributes attributes,
-      ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK,
       StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
       ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);

Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 27e10e09fa6b2eb90ece8241a85487422d2798dd..0492ac4a8a53145f73a3ad3382661770a2a60109 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<Object> Runtime::DefineObjectProperty(
                                   SLOPPY, false, DEFINE_PROPERTY);
     } else {
if (name->IsString()) name = String::Flatten(Handle<String>::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<Object> 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);
   }
 }



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to