Commit 79ccf34a authored by verwaest's avatar verwaest Committed by Commit bot

Inline calling into the interceptor into the IC callbacks rather than going...

Inline calling into the interceptor into the IC callbacks rather than going through the LookupIterator.

This is highly performance sensitive as there is no faster path; it's
used directly by the IC.

BUG=chromium:592305
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#34660}
parent bc78ab67
......@@ -582,7 +582,9 @@ void ElementHandlerCompiler::CompileElementHandlers(
(is_js_array && elements_kind == FAST_HOLEY_ELEMENTS &&
*receiver_map == isolate()->get_initial_js_array_map(elements_kind));
if (receiver_map->has_indexed_interceptor()) {
if (receiver_map->has_indexed_interceptor() &&
!receiver_map->GetIndexedInterceptor()->getter()->IsUndefined() &&
!receiver_map->GetIndexedInterceptor()->non_masking()) {
cached_stub = LoadIndexedInterceptorStub(isolate()).GetCode();
} else if (IsSloppyArgumentsElements(elements_kind)) {
cached_stub = KeyedLoadSloppyArgumentsStub(isolate()).GetCode();
......
......@@ -2787,13 +2787,27 @@ RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptorOnly) {
Handle<JSObject> holder =
args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex);
HandleScope scope(isolate);
LookupIterator it(receiver, name, holder, LookupIterator::OWN);
bool done;
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, JSObject::GetPropertyWithInterceptor(&it, &done));
if (done) return *result;
return isolate->heap()->no_interceptor_result_sentinel();
InterceptorInfo* interceptor = holder->GetNamedInterceptor();
PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver,
*holder, Object::DONT_THROW);
v8::GenericNamedPropertyGetterCallback getter =
v8::ToCData<v8::GenericNamedPropertyGetterCallback>(
interceptor->getter());
LOG(isolate, ApiNamedPropertyAccess("interceptor-named-get", *holder, *name));
v8::Local<v8::Value> result =
arguments.Call(getter, v8::Utils::ToLocal(name));
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
Handle<Object> result_internal;
if (result.IsEmpty()) {
return isolate->heap()->no_interceptor_result_sentinel();
}
result_internal = v8::Utils::OpenHandle(*result);
result_internal->VerifyApiCallResultType();
return *result_internal;
}
......@@ -2869,10 +2883,33 @@ RUNTIME_FUNCTION(Runtime_LoadElementWithInterceptor) {
Handle<JSObject> receiver = args.at<JSObject>(0);
DCHECK(args.smi_at(1) >= 0);
uint32_t index = args.smi_at(1);
Handle<Object> result;
LookupIterator it(isolate, receiver, index, receiver);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
return *result;
InterceptorInfo* interceptor = receiver->GetIndexedInterceptor();
v8::Local<v8::Value> result;
PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver,
*receiver, Object::DONT_THROW);
v8::IndexedPropertyGetterCallback getter =
v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter());
LOG(isolate,
ApiIndexedPropertyAccess("interceptor-indexed-get", *receiver, index));
result = arguments.Call(getter, index);
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
Handle<Object> result_internal;
if (result.IsEmpty()) {
LookupIterator it(isolate, receiver, index, receiver);
DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state());
it.Next();
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result_internal,
Object::GetProperty(&it));
} else {
result_internal = v8::Utils::OpenHandle(*result);
result_internal->VerifyApiCallResultType();
}
return *result_internal;
}
......
......@@ -1883,12 +1883,27 @@ void JSObject::initialize_elements() {
InterceptorInfo* JSObject::GetIndexedInterceptor() {
DCHECK(map()->has_indexed_interceptor());
JSFunction* constructor = JSFunction::cast(map()->GetConstructor());
return map()->GetIndexedInterceptor();
}
InterceptorInfo* JSObject::GetNamedInterceptor() {
return map()->GetNamedInterceptor();
}
InterceptorInfo* Map::GetNamedInterceptor() {
DCHECK(has_named_interceptor());
JSFunction* constructor = JSFunction::cast(GetConstructor());
DCHECK(constructor->shared()->IsApiFunction());
return InterceptorInfo::cast(
constructor->shared()->get_api_func_data()->named_property_handler());
}
InterceptorInfo* Map::GetIndexedInterceptor() {
DCHECK(has_indexed_interceptor());
JSFunction* constructor = JSFunction::cast(GetConstructor());
DCHECK(constructor->shared()->IsApiFunction());
Object* result =
constructor->shared()->get_api_func_data()->indexed_property_handler();
return InterceptorInfo::cast(result);
return InterceptorInfo::cast(
constructor->shared()->get_api_func_data()->indexed_property_handler());
}
......
......@@ -16309,16 +16309,6 @@ void Dictionary<Derived, Shape, Key>::CopyValuesTo(FixedArray* elements) {
}
InterceptorInfo* JSObject::GetNamedInterceptor() {
DCHECK(map()->has_named_interceptor());
JSFunction* constructor = JSFunction::cast(map()->GetConstructor());
DCHECK(constructor->shared()->IsApiFunction());
Object* result =
constructor->shared()->get_api_func_data()->named_property_handler();
return InterceptorInfo::cast(result);
}
MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it,
bool* done) {
*done = false;
......
......@@ -2156,7 +2156,7 @@ class JSObject: public JSReceiver {
};
// Retrieve interceptors.
InterceptorInfo* GetNamedInterceptor();
inline InterceptorInfo* GetNamedInterceptor();
inline InterceptorInfo* GetIndexedInterceptor();
// Used from JSReceiver.
......@@ -5604,6 +5604,10 @@ class Map: public HeapObject {
static MaybeHandle<JSFunction> GetConstructorFunction(
Handle<Map> map, Handle<Context> native_context);
// Retrieve interceptors.
inline InterceptorInfo* GetNamedInterceptor();
inline InterceptorInfo* GetIndexedInterceptor();
// Instance type.
inline InstanceType instance_type();
inline void set_instance_type(InstanceType value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment