Commit bd5b19e4 authored by pan.deng's avatar pan.deng Committed by Commit bot

Inline functions to speedup GetElement.

BUG=None
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#32354}
parent a594545a
...@@ -92,10 +92,8 @@ void LookupIterator::RestartInternal(InterceptorState interceptor_state) { ...@@ -92,10 +92,8 @@ void LookupIterator::RestartInternal(InterceptorState interceptor_state) {
// static // static
Handle<JSReceiver> LookupIterator::GetRoot(Isolate* isolate, Handle<JSReceiver> LookupIterator::GetRootForNonJSReceiver(
Handle<Object> receiver, Isolate* isolate, Handle<Object> receiver, uint32_t index) {
uint32_t index) {
if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
// Strings are the only objects with properties (only elements) directly on // Strings are the only objects with properties (only elements) directly on
// the wrapper. Hence we can skip generating the wrapper for all other cases. // the wrapper. Hence we can skip generating the wrapper for all other cases.
if (index != kMaxUInt32 && receiver->IsString() && if (index != kMaxUInt32 && receiver->IsString() &&
...@@ -530,8 +528,6 @@ void LookupIterator::WriteDataValue(Handle<Object> value) { ...@@ -530,8 +528,6 @@ void LookupIterator::WriteDataValue(Handle<Object> value) {
bool LookupIterator::IsIntegerIndexedExotic(JSReceiver* holder) { bool LookupIterator::IsIntegerIndexedExotic(JSReceiver* holder) {
DCHECK(exotic_index_state_ != ExoticIndexState::kNotExotic); DCHECK(exotic_index_state_ != ExoticIndexState::kNotExotic);
// Currently typed arrays are the only such objects.
if (!holder->IsJSTypedArray()) return false;
if (exotic_index_state_ == ExoticIndexState::kExotic) return true; if (exotic_index_state_ == ExoticIndexState::kExotic) return true;
if (!InternalHolderIsReceiverOrHiddenPrototype()) { if (!InternalHolderIsReceiverOrHiddenPrototype()) {
exotic_index_state_ = ExoticIndexState::kNotExotic; exotic_index_state_ = ExoticIndexState::kNotExotic;
...@@ -566,18 +562,6 @@ bool LookupIterator::HasInterceptor(Map* map) const { ...@@ -566,18 +562,6 @@ bool LookupIterator::HasInterceptor(Map* map) const {
} }
Handle<InterceptorInfo> LookupIterator::GetInterceptor() const {
DCHECK_EQ(INTERCEPTOR, state_);
return handle(GetInterceptor(JSObject::cast(*holder_)), isolate_);
}
InterceptorInfo* LookupIterator::GetInterceptor(JSObject* holder) const {
if (IsElement()) return holder->GetIndexedInterceptor();
return holder->GetNamedInterceptor();
}
bool LookupIterator::SkipInterceptor(JSObject* holder) { bool LookupIterator::SkipInterceptor(JSObject* holder) {
auto info = GetInterceptor(holder); auto info = GetInterceptor(holder);
// TODO(dcarney): check for symbol/can_intercept_symbols here as well. // TODO(dcarney): check for symbol/can_intercept_symbols here as well.
...@@ -633,7 +617,7 @@ LookupIterator::State LookupIterator::LookupInHolder(Map* const map, ...@@ -633,7 +617,7 @@ LookupIterator::State LookupIterator::LookupInHolder(Map* const map,
// Fall through. // Fall through.
case ACCESS_CHECK: case ACCESS_CHECK:
if (exotic_index_state_ != ExoticIndexState::kNotExotic && if (exotic_index_state_ != ExoticIndexState::kNotExotic &&
IsIntegerIndexedExotic(holder)) { holder->IsJSTypedArray() && IsIntegerIndexedExotic(holder)) {
return INTEGER_INDEXED_EXOTIC; return INTEGER_INDEXED_EXOTIC;
} }
if (check_interceptor() && HasInterceptor(map) && if (check_interceptor() && HasInterceptor(map) &&
......
...@@ -203,8 +203,7 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -203,8 +203,7 @@ class LookupIterator final BASE_EMBEDDED {
DCHECK(IsFound()); DCHECK(IsFound());
return Handle<T>::cast(holder_); return Handle<T>::cast(holder_);
} }
static Handle<JSReceiver> GetRoot(Isolate* isolate, Handle<Object> receiver,
uint32_t index = kMaxUInt32);
bool HolderIsReceiverOrHiddenPrototype() const; bool HolderIsReceiverOrHiddenPrototype() const;
/* ACCESS_CHECK */ /* ACCESS_CHECK */
...@@ -245,7 +244,10 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -245,7 +244,10 @@ class LookupIterator final BASE_EMBEDDED {
int GetConstantIndex() const; int GetConstantIndex() const;
Handle<PropertyCell> GetPropertyCell() const; Handle<PropertyCell> GetPropertyCell() const;
Handle<Object> GetAccessors() const; Handle<Object> GetAccessors() const;
Handle<InterceptorInfo> GetInterceptor() const; inline Handle<InterceptorInfo> GetInterceptor() const {
DCHECK_EQ(INTERCEPTOR, state_);
return handle(GetInterceptor(JSObject::cast(*holder_)), isolate_);
}
Handle<Object> GetDataValue() const; Handle<Object> GetDataValue() const;
void WriteDataValue(Handle<Object> value); void WriteDataValue(Handle<Object> value);
void InternalizeName(); void InternalizeName();
...@@ -269,10 +271,13 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -269,10 +271,13 @@ class LookupIterator final BASE_EMBEDDED {
State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder); State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder);
Handle<Object> FetchValue() const; Handle<Object> FetchValue() const;
void ReloadPropertyInformation(); void ReloadPropertyInformation();
bool SkipInterceptor(JSObject* holder); inline bool SkipInterceptor(JSObject* holder);
bool HasInterceptor(Map* map) const; bool HasInterceptor(Map* map) const;
bool InternalHolderIsReceiverOrHiddenPrototype() const; bool InternalHolderIsReceiverOrHiddenPrototype() const;
InterceptorInfo* GetInterceptor(JSObject* holder) const; inline InterceptorInfo* GetInterceptor(JSObject* holder) const {
if (IsElement()) return holder->GetIndexedInterceptor();
return holder->GetNamedInterceptor();
}
bool check_hidden() const { return (configuration_ & kHidden) != 0; } bool check_hidden() const { return (configuration_ & kHidden) != 0; }
bool check_interceptor() const { bool check_interceptor() const {
...@@ -302,8 +307,17 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -302,8 +307,17 @@ class LookupIterator final BASE_EMBEDDED {
} }
} }
static Handle<JSReceiver> GetRootForNonJSReceiver(
Isolate* isolate, Handle<Object> receiver, uint32_t index = kMaxUInt32);
inline static Handle<JSReceiver> GetRoot(Isolate* isolate,
Handle<Object> receiver,
uint32_t index = kMaxUInt32) {
if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
return GetRootForNonJSReceiver(isolate, receiver, index);
}
enum class ExoticIndexState { kUninitialized, kNotExotic, kExotic }; enum class ExoticIndexState { kUninitialized, kNotExotic, kExotic };
bool IsIntegerIndexedExotic(JSReceiver* holder); inline bool IsIntegerIndexedExotic(JSReceiver* holder);
// If configuration_ becomes mutable, update // If configuration_ becomes mutable, update
// HolderIsReceiverOrHiddenPrototype. // HolderIsReceiverOrHiddenPrototype.
......
...@@ -1995,6 +1995,16 @@ void JSObject::initialize_elements() { ...@@ -1995,6 +1995,16 @@ void JSObject::initialize_elements() {
} }
InterceptorInfo* JSObject::GetIndexedInterceptor() {
DCHECK(map()->has_indexed_interceptor());
JSFunction* constructor = JSFunction::cast(map()->GetConstructor());
DCHECK(constructor->shared()->IsApiFunction());
Object* result =
constructor->shared()->get_api_func_data()->indexed_property_handler();
return InterceptorInfo::cast(result);
}
ACCESSORS(Oddball, to_string, String, kToStringOffset) ACCESSORS(Oddball, to_string, String, kToStringOffset)
ACCESSORS(Oddball, to_number, Object, kToNumberOffset) ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
ACCESSORS(Oddball, type_of, String, kTypeOfOffset) ACCESSORS(Oddball, type_of, String, kTypeOfOffset)
......
...@@ -15089,16 +15089,6 @@ InterceptorInfo* JSObject::GetNamedInterceptor() { ...@@ -15089,16 +15089,6 @@ InterceptorInfo* JSObject::GetNamedInterceptor() {
} }
InterceptorInfo* JSObject::GetIndexedInterceptor() {
DCHECK(map()->has_indexed_interceptor());
JSFunction* constructor = JSFunction::cast(map()->GetConstructor());
DCHECK(constructor->shared()->IsApiFunction());
Object* result =
constructor->shared()->get_api_func_data()->indexed_property_handler();
return InterceptorInfo::cast(result);
}
MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it, MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it,
bool* done) { bool* done) {
*done = false; *done = false;
......
...@@ -2119,7 +2119,7 @@ class JSObject: public JSReceiver { ...@@ -2119,7 +2119,7 @@ class JSObject: public JSReceiver {
// Retrieve interceptors. // Retrieve interceptors.
InterceptorInfo* GetNamedInterceptor(); InterceptorInfo* GetNamedInterceptor();
InterceptorInfo* GetIndexedInterceptor(); inline InterceptorInfo* GetIndexedInterceptor();
// Used from JSReceiver. // Used from JSReceiver.
MUST_USE_RESULT static Maybe<PropertyAttributes> MUST_USE_RESULT static Maybe<PropertyAttributes>
......
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