From e36f1dde463b92c700a37cae7152b99289a40336 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Thu, 17 Jul 2014 09:06:49 +0000 Subject: [PATCH] Remove hole handling since holes cannot occur in JSObjects anymore. 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 | 5 ++--- src/lookup.cc | 9 ++------- src/objects.cc | 36 ++++++++++-------------------------- src/runtime.cc | 23 ++++++++--------------- 4 files changed, 22 insertions(+), 51 deletions(-) diff --git a/src/hydrogen.cc b/src/hydrogen.cc index a87d623..018e50f 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -5792,9 +5792,8 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedField( Handle::cast(object)->Lookup(info->name(), &lookup); Handle value(lookup.GetLazyValue(), isolate()); - if (!value->IsTheHole()) { - return New(value); - } + ASSERT(!value->IsTheHole()); + return New(value); } } diff --git a/src/lookup.cc b/src/lookup.cc index 1b46f2c..19ae1f0 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -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 LookupIterator::GetDataValue() const { ASSERT(has_property_); ASSERT_EQ(DATA, property_kind_); Handle value = FetchValue(); - if (value->IsTheHole()) { - ASSERT(property_details_.IsReadOnly()); - return factory()->undefined_value(); - } return value; } diff --git a/src/objects.cc b/src/objects.cc index d5f7f75..6c60fb3 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -472,7 +472,6 @@ MaybeHandle Object::SetPropertyWithCallback(Handle 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 JSObject::GetNormalizedProperty(Handle object, Handle value(object->property_dictionary()->ValueAt( result->GetDictionaryEntry()), isolate); if (object->IsGlobalObject()) { - value = Handle(Handle::cast(value)->value(), isolate); + value = handle(Handle::cast(value)->value(), isolate); + ASSERT(!value->IsTheHole()); } ASSERT(!value->IsPropertyCell() && !value->IsCell()); return value; @@ -2989,11 +2989,8 @@ MaybeHandle JSObject::SetPropertyWithInterceptor( isolate, interceptor->data(), *object, *object); v8::NamedPropertySetterCallback setter = v8::ToCData(interceptor->setter()); - Handle value_unhole = value->IsTheHole() - ? Handle(isolate->factory()->undefined_value()) : value; - v8::Handle result = args.Call(setter, - v8::Utils::ToLocal(name_string), - v8::Utils::ToLocal(value_unhole)); + v8::Handle 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, // 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, 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 JSObject::SetPropertyForResult( Handle 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 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 PropertyCell::UpdatedType(Handle cell, Handle value) { Isolate* isolate = cell->GetIsolate(); Handle old_type(cell->type(), isolate); - Handle new_type = value->IsTheHole() - ? HeapType::Any(isolate) - : HeapType::Constant(value, isolate); + Handle 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); diff --git a/src/runtime.cc b/src/runtime.cc index c04c834..8c3f2ac 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -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 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 DebugLookupResultValue(Isolate* isolate, UNREACHABLE(); break; } - ASSERT(!value->IsTheHole() || result->IsReadOnly()); - return value->IsTheHole() - ? Handle::cast(isolate->factory()->undefined_value()) : value; + return value; } -- 2.7.4