Skip to content

Commit

Permalink
deps: revert v8 abi change
Browse files Browse the repository at this point in the history
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: nodejs#952
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
  • Loading branch information
bnoordhuis committed Feb 25, 2015
1 parent 54532a9 commit a558cd0
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 148 deletions.
17 changes: 4 additions & 13 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -3899,9 +3899,6 @@ class V8_EXPORT FunctionTemplate : public Template {
};


enum class PropertyHandlerFlags { kNone = 0, kAllCanRead = 1 };


struct NamedPropertyHandlerConfiguration {
NamedPropertyHandlerConfiguration(
/** Note: getter is required **/
Expand All @@ -3910,23 +3907,20 @@ struct NamedPropertyHandlerConfiguration {
GenericNamedPropertyQueryCallback query = 0,
GenericNamedPropertyDeleterCallback deleter = 0,
GenericNamedPropertyEnumeratorCallback enumerator = 0,
Handle<Value> data = Handle<Value>(),
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
Handle<Value> data = Handle<Value>())
: getter(getter),
setter(setter),
query(query),
deleter(deleter),
enumerator(enumerator),
data(data),
flags(flags) {}
data(data) {}

GenericNamedPropertyGetterCallback getter;
GenericNamedPropertySetterCallback setter;
GenericNamedPropertyQueryCallback query;
GenericNamedPropertyDeleterCallback deleter;
GenericNamedPropertyEnumeratorCallback enumerator;
Handle<Value> data;
PropertyHandlerFlags flags;
};


Expand All @@ -3938,23 +3932,20 @@ struct IndexedPropertyHandlerConfiguration {
IndexedPropertyQueryCallback query = 0,
IndexedPropertyDeleterCallback deleter = 0,
IndexedPropertyEnumeratorCallback enumerator = 0,
Handle<Value> data = Handle<Value>(),
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
Handle<Value> data = Handle<Value>())
: getter(getter),
setter(setter),
query(query),
deleter(deleter),
enumerator(enumerator),
data(data),
flags(flags) {}
data(data) {}

IndexedPropertyGetterCallback getter;
IndexedPropertySetterCallback setter;
IndexedPropertyQueryCallback query;
IndexedPropertyDeleterCallback deleter;
IndexedPropertyEnumeratorCallback enumerator;
Handle<Value> data;
PropertyHandlerFlags flags;
};


Expand Down
35 changes: 18 additions & 17 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1306,19 +1306,23 @@ void ObjectTemplate::SetAccessor(v8::Handle<Name> name,

template <typename Getter, typename Setter, typename Query, typename Deleter,
typename Enumerator>
static void ObjectTemplateSetNamedPropertyHandler(
ObjectTemplate* templ, Getter getter, Setter setter, Query query,
Deleter remover, Enumerator enumerator, Handle<Value> data,
bool can_intercept_symbols, PropertyHandlerFlags flags) {
static void ObjectTemplateSetNamedPropertyHandler(ObjectTemplate* templ,
Getter getter, Setter setter,
Query query, Deleter remover,
Enumerator enumerator,
Handle<Value> data,
bool can_intercept_symbols) {
i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
EnsureConstructor(isolate, templ);
i::FunctionTemplateInfo* constructor =
i::FunctionTemplateInfo::cast(Utils::OpenHandle(templ)->constructor());
i::Handle<i::FunctionTemplateInfo> cons(constructor);
auto obj = i::Handle<i::InterceptorInfo>::cast(
isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE));
i::Handle<i::Struct> struct_obj =
isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE);
i::Handle<i::InterceptorInfo> obj =
i::Handle<i::InterceptorInfo>::cast(struct_obj);

if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
Expand All @@ -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<int>(flags) &
static_cast<int>(PropertyHandlerFlags::kAllCanRead));

if (data.IsEmpty()) {
data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
Expand All @@ -1343,16 +1345,15 @@ void ObjectTemplate::SetNamedPropertyHandler(
NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover,
NamedPropertyEnumeratorCallback enumerator, Handle<Value> 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);
}


Expand Down Expand Up @@ -1408,8 +1409,10 @@ void ObjectTemplate::SetHandler(
i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
Utils::OpenHandle(this)->constructor());
i::Handle<i::FunctionTemplateInfo> cons(constructor);
auto obj = i::Handle<i::InterceptorInfo>::cast(
isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE));
i::Handle<i::Struct> struct_obj =
isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE);
i::Handle<i::InterceptorInfo> obj =
i::Handle<i::InterceptorInfo>::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);
Expand All @@ -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<int>(config.flags) &
static_cast<int>(PropertyHandlerFlags::kAllCanRead));

v8::Local<v8::Value> data = config.data;
if (data.IsEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/ic/ic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2924,7 +2924,7 @@ RUNTIME_FUNCTION(LoadElementWithInterceptor) {
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
JSObject::GetElementWithInterceptor(receiver, receiver, index, true));
JSObject::GetElementWithInterceptor(receiver, receiver, index));
return *result;
}

Expand Down
1 change: 0 additions & 1 deletion deps/v8/src/objects-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
121 changes: 19 additions & 102 deletions deps/v8/src/objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -572,19 +572,12 @@ MaybeHandle<Object> 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<Object> 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<JSObject>();
if (holder->GetNamedInterceptor()->all_can_read()) return true;
}
}
return false;
Expand All @@ -594,18 +587,10 @@ static bool FindAllCanReadHolder(LookupIterator* it) {
MaybeHandle<Object> JSObject::GetPropertyWithFailedAccessCheck(
LookupIterator* it) {
Handle<JSObject> checked = it->GetHolder<JSObject>();
while (FindAllCanReadHolder(it)) {
if (it->state() == LookupIterator::ACCESSOR) {
return GetPropertyWithAccessor(it->GetReceiver(), it->name(),
it->GetHolder<JSObject>(),
it->GetAccessors());
}
DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
auto receiver = Handle<JSObject>::cast(it->GetReceiver());
auto result = GetPropertyWithInterceptor(it->GetHolder<JSObject>(),
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<JSObject>(),
it->GetAccessors());
}
it->isolate()->ReportFailedAccessCheck(checked, v8::ACCESS_GET);
RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object);
Expand All @@ -616,16 +601,8 @@ MaybeHandle<Object> JSObject::GetPropertyWithFailedAccessCheck(
Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithFailedAccessCheck(
LookupIterator* it) {
Handle<JSObject> checked = it->GetHolder<JSObject>();
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<JSObject>(), 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<PropertyAttributes>());
Expand Down Expand Up @@ -759,65 +736,6 @@ Handle<Object> JSObject::DeleteNormalizedProperty(Handle<JSObject> object,
}


static MaybeHandle<JSObject> FindIndexedAllCanReadHolder(
Isolate* isolate, Handle<JSObject> 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<JSObject>::cast(curr);
if (!obj->HasIndexedInterceptor()) continue;
if (obj->GetIndexedInterceptor()->all_can_read()) return obj;
}
return MaybeHandle<JSObject>();
}


MaybeHandle<Object> JSObject::GetElementWithFailedAccessCheck(
Isolate* isolate, Handle<JSObject> object, Handle<Object> receiver,
uint32_t index) {
Handle<JSObject> 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<PropertyAttributes> JSObject::GetElementAttributesWithFailedAccessCheck(
Isolate* isolate, Handle<JSObject> object, Handle<Object> receiver,
uint32_t index) {
Handle<JSObject> 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<PropertyAttributes>());
return maybe(ABSENT);
}


MaybeHandle<Object> Object::GetElementWithReceiver(Isolate* isolate,
Handle<Object> object,
Handle<Object> receiver,
Expand Down Expand Up @@ -850,14 +768,14 @@ MaybeHandle<Object> 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()) {
Expand Down Expand Up @@ -4266,8 +4184,9 @@ Maybe<PropertyAttributes> 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<PropertyAttributes>());
return maybe(ABSENT);
}
}

Expand Down Expand Up @@ -13464,10 +13383,10 @@ MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) {
}


MaybeHandle<Object> JSObject::GetElementWithInterceptor(Handle<JSObject> object,
Handle<Object> receiver,
uint32_t index,
bool check_prototype) {
MaybeHandle<Object> JSObject::GetElementWithInterceptor(
Handle<JSObject> object,
Handle<Object> receiver,
uint32_t index) {
Isolate* isolate = object->GetIsolate();

// Make sure that the top context does not change when doing
Expand All @@ -13492,8 +13411,6 @@ MaybeHandle<Object> JSObject::GetElementWithInterceptor(Handle<JSObject> object,
}
}

if (!check_prototype) return MaybeHandle<Object>();

ElementsAccessor* handler = object->GetElementsAccessor();
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
Expand Down
15 changes: 3 additions & 12 deletions deps/v8/src/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object> GetElementWithInterceptor(
Handle<JSObject> object, Handle<Object> receiver, uint32_t index,
bool check_prototype);
Handle<JSObject> object,
Handle<Object> receiver,
uint32_t index);

enum SetFastElementsCapacitySmiMode {
kAllowSmiElements,
Expand Down Expand Up @@ -2335,14 +2336,6 @@ class JSObject: public JSReceiver {
Handle<Object> value,
StrictMode strict_mode,
bool check_prototype = true);
MUST_USE_RESULT static MaybeHandle<Object> GetElementWithFailedAccessCheck(
Isolate* isolate, Handle<JSObject> object, Handle<Object> receiver,
uint32_t index);
MUST_USE_RESULT static Maybe<PropertyAttributes>
GetElementAttributesWithFailedAccessCheck(Isolate* isolate,
Handle<JSObject> object,
Handle<Object> receiver,
uint32_t index);

MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithFailedAccessCheck(
LookupIterator* it, Handle<Object> value, StrictMode strict_mode);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions deps/v8/src/runtime/runtime-debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ RUNTIME_FUNCTION(Runtime_DebugIndexedInterceptorElementValue) {
CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]);
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
JSObject::GetElementWithInterceptor(obj, obj, index, true));
isolate, result, JSObject::GetElementWithInterceptor(obj, obj, index));
return *result;
}

Expand Down

0 comments on commit a558cd0

Please sign in to comment.