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}
This commit is contained in:
parent
b62a7a833b
commit
d69ead663c
@ -3658,9 +3658,6 @@ i::MaybeHandle<i::Object> DeleteObjectProperty(
|
||||
name = i::Handle<i::String>::cast(converted);
|
||||
}
|
||||
|
||||
if (name->IsString()) {
|
||||
name = i::String::Flatten(i::Handle<i::String>::cast(name));
|
||||
}
|
||||
return i::JSReceiver::DeleteProperty(receiver, name, language_mode);
|
||||
}
|
||||
|
||||
|
@ -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<Object> receiver, Handle<Name> 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<Object> receiver, Handle<Name> name,
|
||||
Handle<JSReceiver> 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_; }
|
||||
|
||||
|
@ -3226,6 +3226,12 @@ Handle<String> String::Flatten(Handle<String> string, PretenureFlag pretenure) {
|
||||
}
|
||||
|
||||
|
||||
Handle<Name> Name::Flatten(Handle<Name> name, PretenureFlag pretenure) {
|
||||
if (name->IsSymbol()) return name;
|
||||
return String::Flatten(Handle<String>::cast(name));
|
||||
}
|
||||
|
||||
|
||||
uint16_t String::Get(int index) {
|
||||
DCHECK(index >= 0 && index < length());
|
||||
switch (StringShape(this).full_representation_tag()) {
|
||||
|
@ -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<Name> Flatten(Handle<Name> name,
|
||||
PretenureFlag pretenure = NOT_TENURED);
|
||||
|
||||
DECLARE_CAST(Name)
|
||||
|
||||
DECLARE_PRINTER(Name)
|
||||
|
Loading…
Reference in New Issue
Block a user