Remove hole handling since holes cannot occur in JSObjects anymore.
authorverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 17 Jul 2014 09:06:49 +0000 (09:06 +0000)
committerverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 17 Jul 2014 09:06:49 +0000 (09:06 +0000)
The only case in which the hole can still occur, is in a pre-allocated PropertyCell in a GlobalObject. In that case it indicates that the property is absent.

BUG=
R=ishell@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22441 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/hydrogen.cc
src/lookup.cc
src/objects.cc
src/runtime.cc

index a87d623..018e50f 100644 (file)
@@ -5792,9 +5792,8 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedField(
       Handle<JSObject>::cast(object)->Lookup(info->name(), &lookup);
       Handle<Object> value(lookup.GetLazyValue(), isolate());
 
-      if (!value->IsTheHole()) {
-        return New<HConstant>(value);
-      }
+      ASSERT(!value->IsTheHole());
+      return New<HConstant>(value);
     }
   }
 
index 1b46f2c..19ae1f0 100644 (file)
@@ -114,10 +114,9 @@ bool LookupIterator::HasProperty() {
     if (number_ == NameDictionary::kNotFound) return false;
 
     property_details_ = GetHolder()->property_dictionary()->DetailsAt(number_);
-    // Holes in dictionary cells are absent values unless marked as read-only.
+    // Holes in dictionary cells are absent values.
     if (holder->IsGlobalObject() &&
-        (property_details_.IsDeleted() ||
-         (!property_details_.IsReadOnly() && FetchValue()->IsTheHole()))) {
+        (property_details_.IsDeleted() || FetchValue()->IsTheHole())) {
       return false;
     }
   } else {
@@ -178,10 +177,6 @@ Handle<Object> LookupIterator::GetDataValue() const {
   ASSERT(has_property_);
   ASSERT_EQ(DATA, property_kind_);
   Handle<Object> value = FetchValue();
-  if (value->IsTheHole()) {
-    ASSERT(property_details_.IsReadOnly());
-    return factory()->undefined_value();
-  }
   return value;
 }
 
index d5f7f75..6c60fb3 100644 (file)
@@ -472,7 +472,6 @@ MaybeHandle<Object> Object::SetPropertyWithCallback(Handle<Object> receiver,
 
   // We should never get here to initialize a const with the hole
   // value since a const declaration would conflict with the setter.
-  ASSERT(!value->IsTheHole());
   ASSERT(!structure->IsForeign());
   if (structure->IsExecutableAccessorInfo()) {
     // api style callbacks
@@ -670,7 +669,8 @@ Handle<Object> JSObject::GetNormalizedProperty(Handle<JSObject> object,
   Handle<Object> value(object->property_dictionary()->ValueAt(
       result->GetDictionaryEntry()), isolate);
   if (object->IsGlobalObject()) {
-    value = Handle<Object>(Handle<PropertyCell>::cast(value)->value(), isolate);
+    value = handle(Handle<PropertyCell>::cast(value)->value(), isolate);
+    ASSERT(!value->IsTheHole());
   }
   ASSERT(!value->IsPropertyCell() && !value->IsCell());
   return value;
@@ -2989,11 +2989,8 @@ MaybeHandle<Object> JSObject::SetPropertyWithInterceptor(
         isolate, interceptor->data(), *object, *object);
     v8::NamedPropertySetterCallback setter =
         v8::ToCData<v8::NamedPropertySetterCallback>(interceptor->setter());
-    Handle<Object> value_unhole = value->IsTheHole()
-        ? Handle<Object>(isolate->factory()->undefined_value()) : value;
-    v8::Handle<v8::Value> result = args.Call(setter,
-                                             v8::Utils::ToLocal(name_string),
-                                             v8::Utils::ToLocal(value_unhole));
+    v8::Handle<v8::Value> result = args.Call(
+        setter, v8::Utils::ToLocal(name_string), v8::Utils::ToLocal(value));
     RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
     if (!result.IsEmpty()) return value;
   }
@@ -3462,13 +3459,6 @@ void JSObject::LookupOwnRealNamedProperty(Handle<Name> name,
     // properties where map transitions are handled.
     ASSERT(!result->IsFound() ||
            (result->holder() == this && result->IsFastPropertyType()));
-    // Disallow caching for uninitialized constants. These can only
-    // occur as fields.
-    if (result->IsField() &&
-        result->IsReadOnly() &&
-        RawFastPropertyAt(result->GetFieldIndex())->IsTheHole()) {
-      result->DisallowCaching();
-    }
     return;
   }
 
@@ -3477,15 +3467,12 @@ void JSObject::LookupOwnRealNamedProperty(Handle<Name> name,
     Object* value = property_dictionary()->ValueAt(entry);
     if (IsGlobalObject()) {
       PropertyDetails d = property_dictionary()->DetailsAt(entry);
-      if (d.IsDeleted()) {
+      if (d.IsDeleted() || PropertyCell::cast(value)->value()->IsTheHole()) {
         result->NotFound();
         return;
       }
       value = PropertyCell::cast(value)->value();
     }
-    // Make sure to disallow caching for uninitialized constants
-    // found in the dictionary-mode objects.
-    if (value->IsTheHole()) result->DisallowCaching();
     result->DictionaryResult(this, entry);
     return;
   }
@@ -4053,6 +4040,7 @@ MaybeHandle<Object> JSObject::SetPropertyForResult(
     Handle<Object> value,
     StrictMode strict_mode,
     StoreFromKeyed store_mode) {
+  ASSERT(!value->IsTheHole());
   Isolate* isolate = object->GetIsolate();
 
   // Make sure that the top context does not change when doing callbacks or
@@ -4209,6 +4197,7 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
     ExtensibilityCheck extensibility_check,
     StoreFromKeyed store_from_keyed,
     ExecutableAccessorInfoHandling handling) {
+  ASSERT(!value->IsTheHole());
   Isolate* isolate = object->GetIsolate();
 
   // Make sure that the top context does not change when doing callbacks or
@@ -5154,8 +5143,7 @@ Object* JSObject::GetHiddenPropertiesHashTable() {
     if (result.IsFound()) {
       ASSERT(result.IsNormal());
       ASSERT(result.holder() == this);
-      Object* value = GetNormalizedProperty(&result);
-      if (!value->IsTheHole()) return value;
+      return GetNormalizedProperty(&result);
     }
     return GetHeap()->undefined_value();
   }
@@ -16868,13 +16856,9 @@ Handle<HeapType> PropertyCell::UpdatedType(Handle<PropertyCell> cell,
                                            Handle<Object> value) {
   Isolate* isolate = cell->GetIsolate();
   Handle<HeapType> old_type(cell->type(), isolate);
-  Handle<HeapType> new_type = value->IsTheHole()
-                                  ? HeapType::Any(isolate)
-                                  : HeapType::Constant(value, isolate);
+  Handle<HeapType> new_type = HeapType::Constant(value, isolate);
 
-  if (new_type->Is(old_type)) {
-    return old_type;
-  }
+  if (new_type->Is(old_type)) return old_type;
 
   cell->dependent_code()->DeoptimizeDependentCodeGroup(
       isolate, DependentCode::kPropertyCellChangedGroup);
index c04c834..8c3f2ac 100644 (file)
@@ -4805,11 +4805,8 @@ RUNTIME_FUNCTION(Runtime_KeyedGetProperty) {
         int index = keyed_lookup_cache->Lookup(receiver_map, key);
         if (index != -1) {
           // Doubles are not cached, so raw read the value.
-          Object* value = receiver->RawFastPropertyAt(
+          return receiver->RawFastPropertyAt(
               FieldIndex::ForKeyedLookupCacheIndex(*receiver_map, index));
-          return value->IsTheHole()
-              ? isolate->heap()->undefined_value()
-              : value;
         }
         // Lookup cache miss.  Perform lookup and update the cache if
         // appropriate.
@@ -4837,7 +4834,7 @@ RUNTIME_FUNCTION(Runtime_KeyedGetProperty) {
           if (!receiver->IsGlobalObject()) return value;
           value = PropertyCell::cast(value)->value();
           if (!value->IsTheHole()) return value;
-          // If value is the hole do the general lookup.
+          // If value is the hole (meaning, absent) do the general lookup.
         }
       }
     } else if (FLAG_smi_only_arrays && key_obj->IsSmi()) {
@@ -10640,14 +10637,12 @@ static Handle<Object> DebugLookupResultValue(Isolate* isolate,
   if  (!result->IsFound()) return value;
   switch (result->type()) {
     case NORMAL:
-      value = JSObject::GetNormalizedProperty(
-          handle(result->holder(), isolate), result);
-      break;
+      return JSObject::GetNormalizedProperty(handle(result->holder(), isolate),
+                                             result);
     case FIELD:
-      value = JSObject::FastPropertyAt(handle(result->holder(), isolate),
-                                       result->representation(),
-                                       result->GetFieldIndex());
-      break;
+      return JSObject::FastPropertyAt(handle(result->holder(), isolate),
+                                      result->representation(),
+                                      result->GetFieldIndex());
     case CONSTANT:
       return handle(result->GetConstant(), isolate);
     case CALLBACKS: {
@@ -10672,9 +10667,7 @@ static Handle<Object> DebugLookupResultValue(Isolate* isolate,
       UNREACHABLE();
       break;
   }
-  ASSERT(!value->IsTheHole() || result->IsReadOnly());
-  return value->IsTheHole()
-      ? Handle<Object>::cast(isolate->factory()->undefined_value()) : value;
+  return value;
 }