From d69ead663c6ec5aa989ef45012d86b04129e8dfb Mon Sep 17 00:00:00 2001 From: verwaest Date: Wed, 17 Jun 2015 09:05:22 -0700 Subject: [PATCH] Make sure to flatten names before lookup. Lookup using cons strings is really slow. Restores SortNumbers perf degrade BUG=chromium:495949, v8:4137 LOG=n Review URL: https://codereview.chromium.org/1177043009 Cr-Commit-Position: refs/heads/master@{#29095} --- src/api.cc | 3 --- src/lookup.h | 7 +++++-- src/objects-inl.h | 6 ++++++ src/objects.h | 5 +++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/api.cc b/src/api.cc index 8e6c554f1d..560dc34b30 100644 --- a/src/api.cc +++ b/src/api.cc @@ -3658,9 +3658,6 @@ i::MaybeHandle DeleteObjectProperty( name = i::Handle::cast(converted); } - if (name->IsString()) { - name = i::String::Flatten(i::Handle::cast(name)); - } return i::JSReceiver::DeleteProperty(receiver, name, language_mode); } diff --git a/src/lookup.h b/src/lookup.h index c2b98070c0..d0ee6cb54d 100644 --- a/src/lookup.h +++ b/src/lookup.h @@ -52,7 +52,7 @@ class LookupIterator final BASE_EMBEDDED { interceptor_state_(InterceptorState::kUninitialized), property_details_(PropertyDetails::Empty()), isolate_(name->GetIsolate()), - name_(name), + name_(Name::Flatten(name)), // kMaxUInt32 isn't a valid index. index_(kMaxUInt32), receiver_(receiver), @@ -76,7 +76,7 @@ class LookupIterator final BASE_EMBEDDED { interceptor_state_(InterceptorState::kUninitialized), property_details_(PropertyDetails::Empty()), isolate_(name->GetIsolate()), - name_(name), + name_(Name::Flatten(name)), // kMaxUInt32 isn't a valid index. index_(kMaxUInt32), receiver_(receiver), @@ -135,6 +135,7 @@ class LookupIterator final BASE_EMBEDDED { static LookupIterator PropertyOrElement( Isolate* isolate, Handle receiver, Handle name, Configuration configuration = DEFAULT) { + name = Name::Flatten(name); uint32_t index; LookupIterator it = name->AsArrayIndex(&index) @@ -147,6 +148,7 @@ class LookupIterator final BASE_EMBEDDED { static LookupIterator PropertyOrElement( Isolate* isolate, Handle receiver, Handle name, Handle holder, Configuration configuration = DEFAULT) { + name = Name::Flatten(name); uint32_t index; LookupIterator it = name->AsArrayIndex(&index) @@ -155,6 +157,7 @@ class LookupIterator final BASE_EMBEDDED { it.name_ = name; return it; } + Isolate* isolate() const { return isolate_; } State state() const { return state_; } diff --git a/src/objects-inl.h b/src/objects-inl.h index 2a74bf2d85..c3ee543b7c 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -3226,6 +3226,12 @@ Handle String::Flatten(Handle string, PretenureFlag pretenure) { } +Handle Name::Flatten(Handle name, PretenureFlag pretenure) { + if (name->IsSymbol()) return name; + return String::Flatten(Handle::cast(name)); +} + + uint16_t String::Get(int index) { DCHECK(index >= 0 && index < length()); switch (StringShape(this).full_representation_tag()) { diff --git a/src/objects.h b/src/objects.h index 4a683405bd..f5ce1d6c42 100644 --- a/src/objects.h +++ b/src/objects.h @@ -8592,6 +8592,11 @@ class Name: public HeapObject { // If the name is private, it can only name own properties. inline bool IsPrivate(); + // If the name is a non-flat string, this method returns a flat version of the + // string. Otherwise it'll just return the input. + static inline Handle Flatten(Handle name, + PretenureFlag pretenure = NOT_TENURED); + DECLARE_CAST(Name) DECLARE_PRINTER(Name)