Commit 6eb483f8 authored by verwaest's avatar verwaest Committed by Commit bot

Specialize helper methods in the LookupIterator by is_element.

This speeds up lookup.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#34430}
parent 2608ecc7
This diff is collapsed.
...@@ -59,7 +59,7 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -59,7 +59,7 @@ class LookupIterator final BASE_EMBEDDED {
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));
#endif // DEBUG #endif // DEBUG
Start(); Start<false>();
} }
LookupIterator(Handle<Object> receiver, Handle<Name> name, LookupIterator(Handle<Object> receiver, Handle<Name> name,
...@@ -78,7 +78,7 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -78,7 +78,7 @@ class LookupIterator final BASE_EMBEDDED {
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));
#endif // DEBUG #endif // DEBUG
Start(); Start<false>();
} }
LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index,
...@@ -93,7 +93,7 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -93,7 +93,7 @@ class LookupIterator final BASE_EMBEDDED {
initial_holder_(GetRoot(isolate, receiver, index)) { initial_holder_(GetRoot(isolate, receiver, index)) {
// kMaxUInt32 isn't a valid index. // kMaxUInt32 isn't a valid index.
DCHECK_NE(kMaxUInt32, index_); DCHECK_NE(kMaxUInt32, index_);
Start(); Start<true>();
} }
LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index,
...@@ -109,7 +109,7 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -109,7 +109,7 @@ class LookupIterator final BASE_EMBEDDED {
initial_holder_(holder) { initial_holder_(holder) {
// kMaxUInt32 isn't a valid index. // kMaxUInt32 isn't a valid index.
DCHECK_NE(kMaxUInt32, index_); DCHECK_NE(kMaxUInt32, index_);
Start(); Start<true>();
} }
static LookupIterator PropertyOrElement( static LookupIterator PropertyOrElement(
...@@ -142,7 +142,10 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -142,7 +142,10 @@ class LookupIterator final BASE_EMBEDDED {
Isolate* isolate, Handle<Object> receiver, Handle<Object> key, Isolate* isolate, Handle<Object> receiver, Handle<Object> key,
bool* success, Configuration configuration = DEFAULT); bool* success, Configuration configuration = DEFAULT);
void Restart() { RestartInternal(InterceptorState::kUninitialized); } void Restart() {
InterceptorState state = InterceptorState::kUninitialized;
IsElement() ? RestartInternal<true>(state) : RestartInternal<false>(state);
}
Isolate* isolate() const { return isolate_; } Isolate* isolate() const { return isolate_; }
State state() const { return state_; } State state() const { return state_; }
...@@ -257,9 +260,6 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -257,9 +260,6 @@ class LookupIterator final BASE_EMBEDDED {
void UpdateProtector(); void UpdateProtector();
private: private:
void Start();
void NextInternal(Map* map, JSReceiver* holder);
enum class InterceptorState { enum class InterceptorState {
kUninitialized, kUninitialized,
kSkipNonMasking, kSkipNonMasking,
...@@ -269,21 +269,32 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -269,21 +269,32 @@ class LookupIterator final BASE_EMBEDDED {
Handle<Map> GetReceiverMap() const; Handle<Map> GetReceiverMap() const;
MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map); MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map);
template <bool is_element>
void Start();
template <bool is_element>
void NextInternal(Map* map, JSReceiver* holder);
template <bool is_element>
inline State LookupInHolder(Map* map, JSReceiver* holder) { inline State LookupInHolder(Map* map, JSReceiver* holder) {
return map->instance_type() <= LAST_SPECIAL_RECEIVER_TYPE return map->instance_type() <= LAST_SPECIAL_RECEIVER_TYPE
? LookupInSpecialHolder(map, holder) ? LookupInSpecialHolder<is_element>(map, holder)
: LookupInRegularHolder(map, holder); : LookupInRegularHolder<is_element>(map, holder);
} }
template <bool is_element>
State LookupInRegularHolder(Map* map, JSReceiver* holder); State LookupInRegularHolder(Map* map, JSReceiver* holder);
template <bool is_element>
State LookupInSpecialHolder(Map* map, JSReceiver* holder); State LookupInSpecialHolder(Map* map, JSReceiver* holder);
template <bool is_element>
void RestartLookupForNonMaskingInterceptors() { void RestartLookupForNonMaskingInterceptors() {
RestartInternal(InterceptorState::kProcessNonMasking); RestartInternal<is_element>(InterceptorState::kProcessNonMasking);
} }
template <bool is_element>
void RestartInternal(InterceptorState interceptor_state); void RestartInternal(InterceptorState interceptor_state);
Handle<Object> FetchValue() const; Handle<Object> FetchValue() const;
template <bool is_element>
void ReloadPropertyInformation(); void ReloadPropertyInformation();
inline bool SkipInterceptor(JSObject* holder); inline bool SkipInterceptor(JSObject* holder);
bool HasInterceptor(Map* map) const;
inline InterceptorInfo* GetInterceptor(JSObject* holder) const { inline InterceptorInfo* GetInterceptor(JSObject* holder) const {
if (IsElement()) return holder->GetIndexedInterceptor(); if (IsElement()) return holder->GetIndexedInterceptor();
return holder->GetNamedInterceptor(); return holder->GetNamedInterceptor();
......
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