drop interalization of strings entering global constant slots
authordcarney <dcarney@chromium.org>
Thu, 30 Apr 2015 10:50:46 +0000 (03:50 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 30 Apr 2015 10:50:49 +0000 (10:50 +0000)
BUG=

Review URL: https://codereview.chromium.org/1110393003

Cr-Commit-Position: refs/heads/master@{#28155}

src/accessors.cc
src/lookup.cc
src/lookup.h
src/objects.cc
src/objects.h

index f220b82..c2518b6 100644 (file)
@@ -1028,7 +1028,7 @@ MUST_USE_RESULT static MaybeHandle<Object> ReplaceAccessorWithDataProperty(
   CHECK_EQ(LookupIterator::ACCESSOR, it.state());
   DCHECK(it.HolderIsReceiverOrHiddenPrototype());
   it.ReconfigureDataProperty(value, it.property_details().attributes());
-  value = it.WriteDataValue(value);
+  it.WriteDataValue(value);
 
   if (is_observed && !old_value->SameValue(*value)) {
     return JSObject::EnqueueChangeRecord(object, "update", name, old_value);
index a9f24ba..809fd0e 100644 (file)
@@ -332,15 +332,15 @@ Handle<Object> LookupIterator::GetDataValue() const {
 }
 
 
-Handle<Object> LookupIterator::WriteDataValue(Handle<Object> value) {
+void LookupIterator::WriteDataValue(Handle<Object> value) {
   DCHECK_EQ(DATA, state_);
   Handle<JSObject> holder = GetHolder<JSObject>();
   if (holder_map_->is_dictionary_map()) {
     Handle<NameDictionary> property_dictionary =
         handle(holder->property_dictionary());
     if (holder->IsGlobalObject()) {
-      value = PropertyCell::UpdateCell(property_dictionary, dictionary_entry(),
-                                       value, property_details_);
+      PropertyCell::UpdateCell(property_dictionary, dictionary_entry(), value,
+                               property_details_);
     } else {
       property_dictionary->ValueAtPut(dictionary_entry(), *value);
     }
@@ -349,7 +349,6 @@ Handle<Object> LookupIterator::WriteDataValue(Handle<Object> value) {
   } else {
     DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type());
   }
-  return value;
 }
 
 
index 9556ec9..a574980 100644 (file)
@@ -142,7 +142,7 @@ class LookupIterator final BASE_EMBEDDED {
   Handle<Object> GetDataValue() const;
   // Usually returns the value that was passed in, but may perform
   // non-observable modifications on it, such as internalize strings.
-  Handle<Object> WriteDataValue(Handle<Object> value);
+  void WriteDataValue(Handle<Object> value);
   void InternalizeName();
 
  private:
index feab8f4..5981c7a 100644 (file)
@@ -3374,7 +3374,7 @@ MaybeHandle<Object> Object::SetDataProperty(LookupIterator* it,
   it->PrepareForDataProperty(value);
 
   // Write the property value.
-  value = it->WriteDataValue(value);
+  it->WriteDataValue(value);
 
   // Send the change record if there are observers.
   if (is_observed && !value->SameValue(*maybe_old.ToHandleChecked())) {
@@ -3429,7 +3429,7 @@ MaybeHandle<Object> Object::AddDataProperty(LookupIterator* it,
     JSObject::AddSlowProperty(receiver, it->name(), value, attributes);
   } else {
     // Write the property value.
-    value = it->WriteDataValue(value);
+    it->WriteDataValue(value);
   }
 
   // Send the change record if there are observers.
@@ -4293,7 +4293,7 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
         }
 
         it.ReconfigureDataProperty(value, attributes);
-        value = it.WriteDataValue(value);
+        it.WriteDataValue(value);
 
         if (is_observed) {
           RETURN_ON_EXCEPTION(
@@ -4317,7 +4317,7 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
         if (is_observed) old_value = it.GetDataValue();
 
         it.ReconfigureDataProperty(value, attributes);
-        value = it.WriteDataValue(value);
+        it.WriteDataValue(value);
 
         if (is_observed) {
           if (old_value->SameValue(*value)) {
@@ -17156,9 +17156,8 @@ PropertyCellType PropertyCell::UpdatedType(Handle<PropertyCell> cell,
 }
 
 
-Handle<Object> PropertyCell::UpdateCell(Handle<NameDictionary> dictionary,
-                                        int entry, Handle<Object> value,
-                                        PropertyDetails details) {
+void PropertyCell::UpdateCell(Handle<NameDictionary> dictionary, int entry,
+                              Handle<Object> value, PropertyDetails details) {
   DCHECK(!value->IsTheHole());
   DCHECK(dictionary->ValueAt(entry)->IsPropertyCell());
   Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry)));
@@ -17179,18 +17178,6 @@ Handle<Object> PropertyCell::UpdateCell(Handle<NameDictionary> dictionary,
   DCHECK(index > 0);
   details = details.set_index(index);
 
-  // Heuristic: if a small-ish string is stored in a previously uninitialized
-  // property cell, internalize it.
-  const int kMaxLengthForInternalization = 200;
-  if ((old_type == PropertyCellType::kUninitialized ||
-       old_type == PropertyCellType::kUndefined) &&
-      value->IsString()) {
-    auto string = Handle<String>::cast(value);
-    if (string->length() <= kMaxLengthForInternalization) {
-      value = cell->GetIsolate()->factory()->InternalizeString(string);
-    }
-  }
-
   auto new_type = UpdatedType(cell, value, original_details);
   if (invalidate) cell = PropertyCell::InvalidateEntry(dictionary, entry);
 
@@ -17205,7 +17192,6 @@ Handle<Object> PropertyCell::UpdateCell(Handle<NameDictionary> dictionary,
     cell->dependent_code()->DeoptimizeDependentCodeGroup(
         isolate, DependentCode::kPropertyCellChangedGroup);
   }
-  return value;
 }
 
 
index 7244d17..12ee659 100644 (file)
@@ -9848,9 +9848,8 @@ class PropertyCell : public HeapObject {
   static PropertyCellType UpdatedType(Handle<PropertyCell> cell,
                                       Handle<Object> value,
                                       PropertyDetails details);
-  static Handle<Object> UpdateCell(Handle<NameDictionary> dictionary, int entry,
-                                   Handle<Object> value,
-                                   PropertyDetails details);
+  static void UpdateCell(Handle<NameDictionary> dictionary, int entry,
+                         Handle<Object> value, PropertyDetails details);
 
   static Handle<PropertyCell> InvalidateEntry(Handle<NameDictionary> dictionary,
                                               int entry);