Commit 93e744a7 authored by verwaest's avatar verwaest Committed by Commit bot

Speed up indexed interceptor handling in the LookupIterator

BUG=chromium:592305
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#34552}
parent 4fdf5644
......@@ -2871,8 +2871,8 @@ RUNTIME_FUNCTION(Runtime_LoadElementWithInterceptor) {
DCHECK(args.smi_at(1) >= 0);
uint32_t index = args.smi_at(1);
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, Object::GetElement(isolate, receiver, index));
LookupIterator it(isolate, receiver, index, receiver);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
return *result;
}
......
......@@ -51,7 +51,6 @@ void LookupIterator::Start() {
has_property_ = false;
state_ = NOT_FOUND;
number_ = DescriptorArray::kNotFound;
holder_ = initial_holder_;
JSReceiver* holder = *holder_;
......@@ -110,6 +109,7 @@ template <bool is_element>
void LookupIterator::RestartInternal(InterceptorState interceptor_state) {
interceptor_state_ = interceptor_state;
property_details_ = PropertyDetails::Empty();
number_ = DescriptorArray::kNotFound;
Start<is_element>();
}
......@@ -617,9 +617,9 @@ void LookupIterator::WriteDataValue(Handle<Object> value) {
}
}
template <bool is_element>
bool LookupIterator::SkipInterceptor(JSObject* holder) {
auto info = GetInterceptor(holder);
auto info = GetInterceptor<is_element>(holder);
// TODO(dcarney): check for symbol/can_intercept_symbols here as well.
if (info->non_masking()) {
switch (interceptor_state_) {
......@@ -689,7 +689,7 @@ LookupIterator::State LookupIterator::LookupInSpecialHolder(
// Fall through.
case ACCESS_CHECK:
if (check_interceptor() && HasInterceptor<is_element>(map) &&
!SkipInterceptor(JSObject::cast(holder))) {
!SkipInterceptor<is_element>(JSObject::cast(holder))) {
if (is_element || !name_->IsPrivate()) return INTERCEPTOR;
}
// Fall through.
......
......@@ -51,10 +51,11 @@ class LookupIterator final BASE_EMBEDDED {
property_details_(PropertyDetails::Empty()),
isolate_(name->GetIsolate()),
name_(isolate_->factory()->InternalizeName(name)),
receiver_(receiver),
initial_holder_(GetRoot(isolate_, receiver)),
// kMaxUInt32 isn't a valid index.
index_(kMaxUInt32),
receiver_(receiver),
initial_holder_(GetRoot(isolate_, receiver)) {
number_(DescriptorArray::kNotFound) {
#ifdef DEBUG
uint32_t index; // Assert that the name is not an array index.
DCHECK(!name->AsArrayIndex(&index));
......@@ -70,10 +71,11 @@ class LookupIterator final BASE_EMBEDDED {
property_details_(PropertyDetails::Empty()),
isolate_(name->GetIsolate()),
name_(isolate_->factory()->InternalizeName(name)),
receiver_(receiver),
initial_holder_(holder),
// kMaxUInt32 isn't a valid index.
index_(kMaxUInt32),
receiver_(receiver),
initial_holder_(holder) {
number_(DescriptorArray::kNotFound) {
#ifdef DEBUG
uint32_t index; // Assert that the name is not an array index.
DCHECK(!name->AsArrayIndex(&index));
......@@ -87,10 +89,10 @@ class LookupIterator final BASE_EMBEDDED {
interceptor_state_(InterceptorState::kUninitialized),
property_details_(PropertyDetails::Empty()),
isolate_(isolate),
name_(),
index_(index),
receiver_(receiver),
initial_holder_(GetRoot(isolate, receiver, index)) {
initial_holder_(GetRoot(isolate, receiver, index)),
index_(index),
number_(DescriptorArray::kNotFound) {
// kMaxUInt32 isn't a valid index.
DCHECK_NE(kMaxUInt32, index_);
Start<true>();
......@@ -103,10 +105,10 @@ class LookupIterator final BASE_EMBEDDED {
interceptor_state_(InterceptorState::kUninitialized),
property_details_(PropertyDetails::Empty()),
isolate_(isolate),
name_(),
index_(index),
receiver_(receiver),
initial_holder_(holder) {
initial_holder_(holder),
index_(index),
number_(DescriptorArray::kNotFound) {
// kMaxUInt32 isn't a valid index.
DCHECK_NE(kMaxUInt32, index_);
Start<true>();
......@@ -253,7 +255,10 @@ class LookupIterator final BASE_EMBEDDED {
Handle<Object> GetAccessors() const;
inline Handle<InterceptorInfo> GetInterceptor() const {
DCHECK_EQ(INTERCEPTOR, state_);
return handle(GetInterceptor(JSObject::cast(*holder_)), isolate_);
InterceptorInfo* result =
IsElement() ? GetInterceptor<true>(JSObject::cast(*holder_))
: GetInterceptor<false>(JSObject::cast(*holder_));
return handle(result, isolate_);
}
Handle<Object> GetDataValue() const;
void WriteDataValue(Handle<Object> value);
......@@ -302,10 +307,12 @@ class LookupIterator final BASE_EMBEDDED {
template <bool is_element>
void ReloadPropertyInformation();
inline bool SkipInterceptor(JSObject* holder);
template <bool is_element>
bool SkipInterceptor(JSObject* holder);
template <bool is_element>
inline InterceptorInfo* GetInterceptor(JSObject* holder) const {
if (IsElement()) return holder->GetIndexedInterceptor();
return holder->GetNamedInterceptor();
return is_element ? holder->GetIndexedInterceptor()
: holder->GetNamedInterceptor();
}
bool check_hidden() const { return (configuration_ & kHidden) != 0; }
......@@ -357,11 +364,11 @@ class LookupIterator final BASE_EMBEDDED {
PropertyDetails property_details_;
Isolate* const isolate_;
Handle<Name> name_;
uint32_t index_;
Handle<Object> transition_;
const Handle<Object> receiver_;
Handle<JSReceiver> holder_;
const Handle<JSReceiver> initial_holder_;
uint32_t index_;
uint32_t number_;
};
......
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