From a558cd0a619a74dd69e212c79a909b8654942db2 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 25 Feb 2015 12:18:50 +0100 Subject: [PATCH] deps: revert v8 abi change Undo the ABI (but not API) change to NamedPropertyHandlerConfiguration. This avoids a NODE_MODULE_VERSION bump and forcing everyone to recompile their add-ons, at the cost of increasing the delta with upstream V8. This commit effectively backs out 4.1.0.16, the release that introduced the ABI change (and nothing else.) PR-URL: https://github.com/iojs/io.js/pull/952 Reviewed-By: Fedor Indutny Reviewed-By: Rod Vagg --- deps/v8/include/v8.h | 17 +--- deps/v8/src/api.cc | 35 ++++---- deps/v8/src/ic/ic.cc | 2 +- deps/v8/src/objects-inl.h | 1 - deps/v8/src/objects.cc | 121 +++++---------------------- deps/v8/src/objects.h | 15 +--- deps/v8/src/runtime/runtime-debug.cc | 3 +- 7 files changed, 46 insertions(+), 148 deletions(-) diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 27aa5c12d12625..d35f2fcb27fabe 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -3899,9 +3899,6 @@ class V8_EXPORT FunctionTemplate : public Template { }; -enum class PropertyHandlerFlags { kNone = 0, kAllCanRead = 1 }; - - struct NamedPropertyHandlerConfiguration { NamedPropertyHandlerConfiguration( /** Note: getter is required **/ @@ -3910,15 +3907,13 @@ struct NamedPropertyHandlerConfiguration { GenericNamedPropertyQueryCallback query = 0, GenericNamedPropertyDeleterCallback deleter = 0, GenericNamedPropertyEnumeratorCallback enumerator = 0, - Handle data = Handle(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) + Handle data = Handle()) : getter(getter), setter(setter), query(query), deleter(deleter), enumerator(enumerator), - data(data), - flags(flags) {} + data(data) {} GenericNamedPropertyGetterCallback getter; GenericNamedPropertySetterCallback setter; @@ -3926,7 +3921,6 @@ struct NamedPropertyHandlerConfiguration { GenericNamedPropertyDeleterCallback deleter; GenericNamedPropertyEnumeratorCallback enumerator; Handle data; - PropertyHandlerFlags flags; }; @@ -3938,15 +3932,13 @@ struct IndexedPropertyHandlerConfiguration { IndexedPropertyQueryCallback query = 0, IndexedPropertyDeleterCallback deleter = 0, IndexedPropertyEnumeratorCallback enumerator = 0, - Handle data = Handle(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) + Handle data = Handle()) : getter(getter), setter(setter), query(query), deleter(deleter), enumerator(enumerator), - data(data), - flags(flags) {} + data(data) {} IndexedPropertyGetterCallback getter; IndexedPropertySetterCallback setter; @@ -3954,7 +3946,6 @@ struct IndexedPropertyHandlerConfiguration { IndexedPropertyDeleterCallback deleter; IndexedPropertyEnumeratorCallback enumerator; Handle data; - PropertyHandlerFlags flags; }; diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 80afca28f343bd..88d3c889b96cab 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -1306,10 +1306,12 @@ void ObjectTemplate::SetAccessor(v8::Handle name, template -static void ObjectTemplateSetNamedPropertyHandler( - ObjectTemplate* templ, Getter getter, Setter setter, Query query, - Deleter remover, Enumerator enumerator, Handle data, - bool can_intercept_symbols, PropertyHandlerFlags flags) { +static void ObjectTemplateSetNamedPropertyHandler(ObjectTemplate* templ, + Getter getter, Setter setter, + Query query, Deleter remover, + Enumerator enumerator, + Handle data, + bool can_intercept_symbols) { i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate(); ENTER_V8(isolate); i::HandleScope scope(isolate); @@ -1317,8 +1319,10 @@ static void ObjectTemplateSetNamedPropertyHandler( i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(Utils::OpenHandle(templ)->constructor()); i::Handle cons(constructor); - auto obj = i::Handle::cast( - isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE)); + i::Handle struct_obj = + isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); + i::Handle obj = + i::Handle::cast(struct_obj); if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); @@ -1327,8 +1331,6 @@ static void ObjectTemplateSetNamedPropertyHandler( if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); obj->set_flags(0); obj->set_can_intercept_symbols(can_intercept_symbols); - obj->set_all_can_read(static_cast(flags) & - static_cast(PropertyHandlerFlags::kAllCanRead)); if (data.IsEmpty()) { data = v8::Undefined(reinterpret_cast(isolate)); @@ -1343,16 +1345,15 @@ void ObjectTemplate::SetNamedPropertyHandler( NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover, NamedPropertyEnumeratorCallback enumerator, Handle data) { ObjectTemplateSetNamedPropertyHandler(this, getter, setter, query, remover, - enumerator, data, false, - PropertyHandlerFlags::kNone); + enumerator, data, false); } void ObjectTemplate::SetHandler( const NamedPropertyHandlerConfiguration& config) { - ObjectTemplateSetNamedPropertyHandler( - this, config.getter, config.setter, config.query, config.deleter, - config.enumerator, config.data, true, config.flags); + ObjectTemplateSetNamedPropertyHandler(this, config.getter, config.setter, + config.query, config.deleter, + config.enumerator, config.data, true); } @@ -1408,8 +1409,10 @@ void ObjectTemplate::SetHandler( i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( Utils::OpenHandle(this)->constructor()); i::Handle cons(constructor); - auto obj = i::Handle::cast( - isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE)); + i::Handle struct_obj = + isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); + i::Handle obj = + i::Handle::cast(struct_obj); if (config.getter != 0) SET_FIELD_WRAPPED(obj, set_getter, config.getter); if (config.setter != 0) SET_FIELD_WRAPPED(obj, set_setter, config.setter); @@ -1419,8 +1422,6 @@ void ObjectTemplate::SetHandler( SET_FIELD_WRAPPED(obj, set_enumerator, config.enumerator); } obj->set_flags(0); - obj->set_all_can_read(static_cast(config.flags) & - static_cast(PropertyHandlerFlags::kAllCanRead)); v8::Local data = config.data; if (data.IsEmpty()) { diff --git a/deps/v8/src/ic/ic.cc b/deps/v8/src/ic/ic.cc index 0707536b84d1c7..48cef68f5ac652 100644 --- a/deps/v8/src/ic/ic.cc +++ b/deps/v8/src/ic/ic.cc @@ -2924,7 +2924,7 @@ RUNTIME_FUNCTION(LoadElementWithInterceptor) { Handle result; ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, result, - JSObject::GetElementWithInterceptor(receiver, receiver, index, true)); + JSObject::GetElementWithInterceptor(receiver, receiver, index)); return *result; } diff --git a/deps/v8/src/objects-inl.h b/deps/v8/src/objects-inl.h index fdfadb1883905b..485560f2933ebe 100644 --- a/deps/v8/src/objects-inl.h +++ b/deps/v8/src/objects-inl.h @@ -5517,7 +5517,6 @@ ACCESSORS(InterceptorInfo, data, Object, kDataOffset) SMI_ACCESSORS(InterceptorInfo, flags, kFlagsOffset) BOOL_ACCESSORS(InterceptorInfo, flags, can_intercept_symbols, kCanInterceptSymbolsBit) -BOOL_ACCESSORS(InterceptorInfo, flags, all_can_read, kAllCanReadBit) ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset) ACCESSORS(CallHandlerInfo, data, Object, kDataOffset) diff --git a/deps/v8/src/objects.cc b/deps/v8/src/objects.cc index 6b64c3fb21782d..414306f2b46555 100644 --- a/deps/v8/src/objects.cc +++ b/deps/v8/src/objects.cc @@ -572,19 +572,12 @@ MaybeHandle Object::SetPropertyWithDefinedSetter( static bool FindAllCanReadHolder(LookupIterator* it) { - // Skip current iteration, it's in state ACCESS_CHECK or INTERCEPTOR, both of - // which have already been checked. - DCHECK(it->state() == LookupIterator::ACCESS_CHECK || - it->state() == LookupIterator::INTERCEPTOR); - for (it->Next(); it->IsFound(); it->Next()) { + for (; it->IsFound(); it->Next()) { if (it->state() == LookupIterator::ACCESSOR) { - auto accessors = it->GetAccessors(); + Handle accessors = it->GetAccessors(); if (accessors->IsAccessorInfo()) { if (AccessorInfo::cast(*accessors)->all_can_read()) return true; } - } else if (it->state() == LookupIterator::INTERCEPTOR) { - auto holder = it->GetHolder(); - if (holder->GetNamedInterceptor()->all_can_read()) return true; } } return false; @@ -594,18 +587,10 @@ static bool FindAllCanReadHolder(LookupIterator* it) { MaybeHandle JSObject::GetPropertyWithFailedAccessCheck( LookupIterator* it) { Handle checked = it->GetHolder(); - while (FindAllCanReadHolder(it)) { - if (it->state() == LookupIterator::ACCESSOR) { - return GetPropertyWithAccessor(it->GetReceiver(), it->name(), - it->GetHolder(), - it->GetAccessors()); - } - DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); - auto receiver = Handle::cast(it->GetReceiver()); - auto result = GetPropertyWithInterceptor(it->GetHolder(), - receiver, it->name()); - if (it->isolate()->has_scheduled_exception()) break; - if (!result.is_null()) return result; + if (FindAllCanReadHolder(it)) { + return GetPropertyWithAccessor(it->GetReceiver(), it->name(), + it->GetHolder(), + it->GetAccessors()); } it->isolate()->ReportFailedAccessCheck(checked, v8::ACCESS_GET); RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object); @@ -616,16 +601,8 @@ MaybeHandle JSObject::GetPropertyWithFailedAccessCheck( Maybe JSObject::GetPropertyAttributesWithFailedAccessCheck( LookupIterator* it) { Handle checked = it->GetHolder(); - while (FindAllCanReadHolder(it)) { - if (it->state() == LookupIterator::ACCESSOR) { - return maybe(it->property_details().attributes()); - } - DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); - auto result = GetPropertyAttributesWithInterceptor( - it->GetHolder(), it->GetReceiver(), it->name()); - if (it->isolate()->has_scheduled_exception()) break; - if (result.has_value && result.value != ABSENT) return result; - } + if (FindAllCanReadHolder(it)) + return maybe(it->property_details().attributes()); it->isolate()->ReportFailedAccessCheck(checked, v8::ACCESS_HAS); RETURN_VALUE_IF_SCHEDULED_EXCEPTION(it->isolate(), Maybe()); @@ -759,65 +736,6 @@ Handle JSObject::DeleteNormalizedProperty(Handle object, } -static MaybeHandle FindIndexedAllCanReadHolder( - Isolate* isolate, Handle js_object, - PrototypeIterator::WhereToStart where_to_start) { - for (PrototypeIterator iter(isolate, js_object, where_to_start); - !iter.IsAtEnd(); iter.Advance()) { - auto curr = PrototypeIterator::GetCurrent(iter); - if (!curr->IsJSObject()) break; - auto obj = Handle::cast(curr); - if (!obj->HasIndexedInterceptor()) continue; - if (obj->GetIndexedInterceptor()->all_can_read()) return obj; - } - return MaybeHandle(); -} - - -MaybeHandle JSObject::GetElementWithFailedAccessCheck( - Isolate* isolate, Handle object, Handle receiver, - uint32_t index) { - Handle holder = object; - PrototypeIterator::WhereToStart where_to_start = - PrototypeIterator::START_AT_RECEIVER; - while (true) { - auto all_can_read_holder = - FindIndexedAllCanReadHolder(isolate, holder, where_to_start); - if (!all_can_read_holder.ToHandle(&holder)) break; - auto result = - JSObject::GetElementWithInterceptor(holder, receiver, index, false); - if (isolate->has_scheduled_exception()) break; - if (!result.is_null()) return result; - where_to_start = PrototypeIterator::START_AT_PROTOTYPE; - } - isolate->ReportFailedAccessCheck(object, v8::ACCESS_GET); - RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); - return isolate->factory()->undefined_value(); -} - - -Maybe JSObject::GetElementAttributesWithFailedAccessCheck( - Isolate* isolate, Handle object, Handle receiver, - uint32_t index) { - Handle holder = object; - PrototypeIterator::WhereToStart where_to_start = - PrototypeIterator::START_AT_RECEIVER; - while (true) { - auto all_can_read_holder = - FindIndexedAllCanReadHolder(isolate, holder, where_to_start); - if (!all_can_read_holder.ToHandle(&holder)) break; - auto result = - JSObject::GetElementAttributeFromInterceptor(object, receiver, index); - if (isolate->has_scheduled_exception()) break; - if (result.has_value && result.value != ABSENT) return result; - where_to_start = PrototypeIterator::START_AT_PROTOTYPE; - } - isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); - RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe()); - return maybe(ABSENT); -} - - MaybeHandle Object::GetElementWithReceiver(Isolate* isolate, Handle object, Handle receiver, @@ -850,14 +768,14 @@ MaybeHandle Object::GetElementWithReceiver(Isolate* isolate, // Check access rights if needed. if (js_object->IsAccessCheckNeeded()) { if (!isolate->MayIndexedAccess(js_object, index, v8::ACCESS_GET)) { - return JSObject::GetElementWithFailedAccessCheck(isolate, js_object, - receiver, index); + isolate->ReportFailedAccessCheck(js_object, v8::ACCESS_GET); + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); + return isolate->factory()->undefined_value(); } } if (js_object->HasIndexedInterceptor()) { - return JSObject::GetElementWithInterceptor(js_object, receiver, index, - true); + return JSObject::GetElementWithInterceptor(js_object, receiver, index); } if (js_object->elements() != isolate->heap()->empty_fixed_array()) { @@ -4266,8 +4184,9 @@ Maybe JSObject::GetElementAttributeWithReceiver( // Check access rights if needed. if (object->IsAccessCheckNeeded()) { if (!isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS)) { - return GetElementAttributesWithFailedAccessCheck(isolate, object, - receiver, index); + isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); + RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe()); + return maybe(ABSENT); } } @@ -13464,10 +13383,10 @@ MaybeHandle JSArray::ReadOnlyLengthError(Handle array) { } -MaybeHandle JSObject::GetElementWithInterceptor(Handle object, - Handle receiver, - uint32_t index, - bool check_prototype) { +MaybeHandle JSObject::GetElementWithInterceptor( + Handle object, + Handle receiver, + uint32_t index) { Isolate* isolate = object->GetIsolate(); // Make sure that the top context does not change when doing @@ -13492,8 +13411,6 @@ MaybeHandle JSObject::GetElementWithInterceptor(Handle object, } } - if (!check_prototype) return MaybeHandle(); - ElementsAccessor* handler = object->GetElementsAccessor(); Handle result; ASSIGN_RETURN_ON_EXCEPTION( diff --git a/deps/v8/src/objects.h b/deps/v8/src/objects.h index 2ae4bae8eadd65..f2f2e495b44ec2 100644 --- a/deps/v8/src/objects.h +++ b/deps/v8/src/objects.h @@ -1971,8 +1971,9 @@ class JSObject: public JSReceiver { // Returns the index'th element. // The undefined object if index is out of bounds. MUST_USE_RESULT static MaybeHandle GetElementWithInterceptor( - Handle object, Handle receiver, uint32_t index, - bool check_prototype); + Handle object, + Handle receiver, + uint32_t index); enum SetFastElementsCapacitySmiMode { kAllowSmiElements, @@ -2335,14 +2336,6 @@ class JSObject: public JSReceiver { Handle value, StrictMode strict_mode, bool check_prototype = true); - MUST_USE_RESULT static MaybeHandle GetElementWithFailedAccessCheck( - Isolate* isolate, Handle object, Handle receiver, - uint32_t index); - MUST_USE_RESULT static Maybe - GetElementAttributesWithFailedAccessCheck(Isolate* isolate, - Handle object, - Handle receiver, - uint32_t index); MUST_USE_RESULT static MaybeHandle SetPropertyWithFailedAccessCheck( LookupIterator* it, Handle value, StrictMode strict_mode); @@ -10649,7 +10642,6 @@ class InterceptorInfo: public Struct { DECL_ACCESSORS(enumerator, Object) DECL_ACCESSORS(data, Object) DECL_BOOLEAN_ACCESSORS(can_intercept_symbols) - DECL_BOOLEAN_ACCESSORS(all_can_read) inline int flags() const; inline void set_flags(int flags); @@ -10670,7 +10662,6 @@ class InterceptorInfo: public Struct { static const int kSize = kFlagsOffset + kPointerSize; static const int kCanInterceptSymbolsBit = 0; - static const int kAllCanReadBit = 1; private: DISALLOW_IMPLICIT_CONSTRUCTORS(InterceptorInfo); diff --git a/deps/v8/src/runtime/runtime-debug.cc b/deps/v8/src/runtime/runtime-debug.cc index 9b71a4f95e0117..12c5a0d84f3567 100644 --- a/deps/v8/src/runtime/runtime-debug.cc +++ b/deps/v8/src/runtime/runtime-debug.cc @@ -246,8 +246,7 @@ RUNTIME_FUNCTION(Runtime_DebugIndexedInterceptorElementValue) { CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); Handle result; ASSIGN_RETURN_FAILURE_ON_EXCEPTION( - isolate, result, - JSObject::GetElementWithInterceptor(obj, obj, index, true)); + isolate, result, JSObject::GetElementWithInterceptor(obj, obj, index)); return *result; }