diff --git a/src/builtins/builtins-forin-gen.cc b/src/builtins/builtins-forin-gen.cc index ad3f4d6e17..0f428b68c0 100644 --- a/src/builtins/builtins-forin-gen.cc +++ b/src/builtins/builtins-forin-gen.cc @@ -21,28 +21,18 @@ typedef compiler::Node Node; Node* ForInBuiltinsAssembler::ForInFilter(Node* key, Node* object, Node* context) { - Label return_undefined(this, Label::kDeferred), return_to_name(this), - end(this); + CSA_ASSERT(this, IsName(key)); - Variable var_result(this, MachineRepresentation::kTagged); + Variable var_result(this, MachineRepresentation::kTagged, key); Node* has_property = HasProperty(object, key, context, Runtime::kForInHasProperty); - Branch(WordEqual(has_property, BooleanConstant(true)), &return_to_name, - &return_undefined); + Label end(this); + GotoIf(WordEqual(has_property, BooleanConstant(true)), &end); - Bind(&return_to_name); - { - var_result.Bind(ToName(context, key)); - Goto(&end); - } - - Bind(&return_undefined); - { - var_result.Bind(UndefinedConstant()); - Goto(&end); - } + var_result.Bind(UndefinedConstant()); + Goto(&end); Bind(&end); return var_result.value(); diff --git a/src/factory.h b/src/factory.h index 2038bf2d10..ced247df4e 100644 --- a/src/factory.h +++ b/src/factory.h @@ -671,7 +671,14 @@ class V8_EXPORT_PRIVATE Factory final { bool check_number_string_cache = true); Handle Uint32ToString(uint32_t value) { - return NumberToString(NewNumberFromUint(value)); + Handle result = NumberToString(NewNumberFromUint(value)); + + if (result->length() <= String::kMaxArrayIndexSize) { + uint32_t field = + StringHasher::MakeArrayIndexHash(value, result->length()); + result->set_hash_field(field); + } + return result; } Handle InstallMembers(Handle function); diff --git a/src/objects.cc b/src/objects.cc index 942bbb5ce1..ba5f6f61b0 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -18549,8 +18549,13 @@ Handle OrderedHashSet::ConvertToKeysArray( for (int i = 0; i < length; i++) { int index = kHashTableStartIndex + nof_buckets + (i * kEntrySize); Object* key = table->get(index); - if (convert == GetKeysConversion::kConvertToString && key->IsNumber()) { - key = *isolate->factory()->NumberToString(handle(key, isolate)); + if (convert == GetKeysConversion::kConvertToString) { + uint32_t index_value; + if (key->ToArrayIndex(&index_value)) { + key = *isolate->factory()->Uint32ToString(index_value); + } else { + CHECK(key->IsName()); + } } result->set(i, key); } diff --git a/src/runtime/runtime-forin.cc b/src/runtime/runtime-forin.cc index 9a7c539865..08f6d86819 100644 --- a/src/runtime/runtime-forin.cc +++ b/src/runtime/runtime-forin.cc @@ -31,7 +31,7 @@ MaybeHandle Enumerate(Handle receiver) { if (!accumulator.is_receiver_simple_enum()) { Handle keys; ASSIGN_RETURN_ON_EXCEPTION( - isolate, keys, accumulator.GetKeys(GetKeysConversion::kKeepNumbers), + isolate, keys, accumulator.GetKeys(GetKeysConversion::kConvertToString), HeapObject); // Test again, since cache may have been built by GetKeys() calls above. if (!accumulator.is_receiver_simple_enum()) return keys;