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) {
// static
Handle<JSReceiver> LookupIterator::GetRoot(Isolate* isolate,
Handle<Object> receiver,
uint32_t index) {
if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
Handle<JSReceiver> LookupIterator::GetRootForNonJSReceiver(
Isolate* isolate, Handle<Object> receiver, uint32_t index) {
// Strings are the only objects with properties (only elements) directly on
// the wrapper. Hence we can skip generating the wrapper for all other cases.
if (index != kMaxUInt32 && receiver->IsString() &&
......@@ -530,8 +528,6 @@ void LookupIterator::WriteDataValue(Handle<Object> value) {
bool LookupIterator::IsIntegerIndexedExotic(JSReceiver* holder) {
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 (!InternalHolderIsReceiverOrHiddenPrototype()) {
exotic_index_state_ = ExoticIndexState::kNotExotic;
......@@ -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) {
auto info = GetInterceptor(holder);
// TODO(dcarney): check for symbol/can_intercept_symbols here as well.
......@@ -633,7 +617,7 @@ LookupIterator::State LookupIterator::LookupInHolder(Map* const map,
// Fall through.
case ACCESS_CHECK:
if (exotic_index_state_ != ExoticIndexState::kNotExotic &&
IsIntegerIndexedExotic(holder)) {
holder->IsJSTypedArray() && IsIntegerIndexedExotic(holder)) {
return INTEGER_INDEXED_EXOTIC;
}
if (check_interceptor() && HasInterceptor(map) &&
......
......@@ -203,8 +203,7 @@ class LookupIterator final BASE_EMBEDDED {
DCHECK(IsFound());
return Handle<T>::cast(holder_);
}
static Handle<JSReceiver> GetRoot(Isolate* isolate, Handle<Object> receiver,
uint32_t index = kMaxUInt32);
bool HolderIsReceiverOrHiddenPrototype() const;
/* ACCESS_CHECK */
......@@ -245,7 +244,10 @@ class LookupIterator final BASE_EMBEDDED {
int GetConstantIndex() const;
Handle<PropertyCell> GetPropertyCell() 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;
void WriteDataValue(Handle<Object> value);
void InternalizeName();
......@@ -269,10 +271,13 @@ class LookupIterator final BASE_EMBEDDED {
State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder);
Handle<Object> FetchValue() const;
void ReloadPropertyInformation();
bool SkipInterceptor(JSObject* holder);
inline bool SkipInterceptor(JSObject* holder);
bool HasInterceptor(Map* map) 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_interceptor() const {
......@@ -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 };
bool IsIntegerIndexedExotic(JSReceiver* holder);
inline bool IsIntegerIndexedExotic(JSReceiver* holder);
// If configuration_ becomes mutable, update
// HolderIsReceiverOrHiddenPrototype.
......
......@@ -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_number, Object, kToNumberOffset)
ACCESSORS(Oddball, type_of, String, kTypeOfOffset)
......
......@@ -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,
bool* done) {
*done = false;
......
......@@ -2119,7 +2119,7 @@ class JSObject: public JSReceiver {
// Retrieve interceptors.
InterceptorInfo* GetNamedInterceptor();
InterceptorInfo* GetIndexedInterceptor();
inline InterceptorInfo* GetIndexedInterceptor();
// Used from JSReceiver.
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