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