From 1bae10b2cd79eaf69c9541a351b0bed7d8e56710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Mon, 6 Feb 2023 18:18:24 -0500 Subject: [PATCH] [runtime]: Merge *_Simple into DefineKeyedOwnPropertyInLiteral - Merged DefineKeyedOwnPropertyInLiteral_Simple into DefineKeyedOwnPropertyInLiteral. - Removed DefineKeyedOwnPropertyInLiteralFlag::kDontEnum. The flag is not used. Change-Id: Ia92d631f0b49810e8e01d5c485dc381b639dcc1f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4193068 Commit-Queue: Toon Verwaest Reviewed-by: Toon Verwaest Cr-Commit-Position: refs/heads/main@{#85704} --- src/common/globals.h | 8 ++-- .../js-native-context-specialization.cc | 1 - src/ic/keyed-store-generic.cc | 16 +++++-- src/runtime/runtime-object.cc | 45 ++++--------------- src/runtime/runtime.h | 1 - 5 files changed, 24 insertions(+), 47 deletions(-) diff --git a/src/common/globals.h b/src/common/globals.h index 50153945a7..34d0c01cb6 100644 --- a/src/common/globals.h +++ b/src/common/globals.h @@ -1839,13 +1839,11 @@ inline std::ostream& operator<<(std::ostream& os, CollectionKind kind) { UNREACHABLE(); } -// Flags for the runtime function kDefineKeyedOwnPropertyInLiteral. A property -// can be enumerable or not, and, in case of functions, the function name can be -// set or not. +// Flags for the runtime function kDefineKeyedOwnPropertyInLiteral. +// - Whether the function name should be set or not. enum class DefineKeyedOwnPropertyInLiteralFlag { kNoFlags = 0, - kDontEnum = 1 << 0, - kSetFunctionName = 1 << 1 + kSetFunctionName = 1 << 0 }; using DefineKeyedOwnPropertyInLiteralFlags = base::Flags; diff --git a/src/compiler/js-native-context-specialization.cc b/src/compiler/js-native-context-specialization.cc index 5f25948697..5f2ea6a0ed 100644 --- a/src/compiler/js-native-context-specialization.cc +++ b/src/compiler/js-native-context-specialization.cc @@ -3069,7 +3069,6 @@ JSNativeContextSpecialization::ReduceJSDefineKeyedOwnPropertyInLiteral( NumberMatcher mflags(n.flags()); CHECK(mflags.HasResolvedValue()); DefineKeyedOwnPropertyInLiteralFlags cflags(mflags.ResolvedValue()); - DCHECK(!(cflags & DefineKeyedOwnPropertyInLiteralFlag::kDontEnum)); if (cflags & DefineKeyedOwnPropertyInLiteralFlag::kSetFunctionName) return NoChange(); diff --git a/src/ic/keyed-store-generic.cc b/src/ic/keyed-store-generic.cc index b1b9b55b3e..e3c33e1389 100644 --- a/src/ic/keyed-store-generic.cc +++ b/src/ic/keyed-store-generic.cc @@ -1150,8 +1150,12 @@ void KeyedStoreGenericAssembler::KeyedStoreGeneric( value); } else { DCHECK(IsDefineKeyedOwnInLiteral()); - TailCallRuntime(Runtime::kDefineKeyedOwnPropertyInLiteral_Simple, context, - receiver, key, value); + TNode flags = + SmiConstant(DefineKeyedOwnPropertyInLiteralFlag::kNoFlags); + // TODO(v8:10047): Use TaggedIndexConstant here once TurboFan supports it. + TNode slot = SmiConstant(FeedbackSlot::Invalid().ToInt()); + TailCallRuntime(Runtime::kDefineKeyedOwnPropertyInLiteral, context, + receiver, key, value, flags, UndefinedConstant(), slot); } } } @@ -1238,8 +1242,12 @@ void KeyedStoreGenericAssembler::StoreProperty(TNode context, BIND(&slow); { if (IsDefineKeyedOwnInLiteral()) { - CallRuntime(Runtime::kDefineKeyedOwnPropertyInLiteral_Simple, context, - receiver, unique_name, value); + TNode flags = + SmiConstant(DefineKeyedOwnPropertyInLiteralFlag::kNoFlags); + // TODO(v8:10047): Use TaggedIndexConstant here once TurboFan supports it. + TNode slot = SmiConstant(FeedbackSlot::Invalid().ToInt()); + CallRuntime(Runtime::kDefineKeyedOwnPropertyInLiteral, context, receiver, + unique_name, value, flags, p.vector(), slot); } else { CallRuntime(Runtime::kSetKeyedProperty, context, receiver, unique_name, value); diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc index dd55439d40..c0baa7935e 100644 --- a/src/runtime/runtime-object.cc +++ b/src/runtime/runtime-object.cc @@ -911,32 +911,6 @@ RUNTIME_FUNCTION(Runtime_SetNamedProperty) { StoreOrigin::kNamed)); } -// Similar to DefineKeyedOwnPropertyInLiteral, but does not update feedback, and -// and does not have a flags parameter for performing SetFunctionName(). -// -// Currently, this is used for ObjectLiteral spread properties in CloneObjectIC -// and for array literal creations in StoreInArrayLiteralIC. -// TODO(v8:12548): merge this into DefineKeyedOwnPropertyInLiteral. -RUNTIME_FUNCTION(Runtime_DefineKeyedOwnPropertyInLiteral_Simple) { - HandleScope scope(isolate); - DCHECK_EQ(3, args.length()); - - Handle object = args.at(0); - Handle key = args.at(1); - Handle value = args.at(2); - - PropertyKey lookup_key(isolate, key); - LookupIterator it(isolate, object, lookup_key, LookupIterator::OWN); - - Maybe result = JSObject::DefineOwnPropertyIgnoreAttributes( - &it, value, NONE, Just(kDontThrow)); - RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); - DCHECK(result.IsJust()); - USE(result); - - return *value; -} - namespace { // ES6 section 12.5.4. @@ -1137,20 +1111,22 @@ RUNTIME_FUNCTION(Runtime_SetFunctionName) { RUNTIME_FUNCTION(Runtime_DefineKeyedOwnPropertyInLiteral) { HandleScope scope(isolate); DCHECK_EQ(6, args.length()); - Handle object = args.at(0); - Handle name = args.at(1); + Handle object = args.at(0); + Handle name = args.at(1); Handle value = args.at(2); int flag = args.smi_value_at(3); Handle maybe_vector = args.at(4); - int index = args.tagged_index_value_at(5); if (!maybe_vector->IsUndefined()) { + int index = args.tagged_index_value_at(5); + DCHECK(name->IsName()); DCHECK(maybe_vector->IsFeedbackVector()); Handle vector = Handle::cast(maybe_vector); FeedbackNexus nexus(vector, FeedbackVector::ToSlot(index)); if (nexus.ic_state() == InlineCacheState::UNINITIALIZED) { if (name->IsUniqueName()) { - nexus.ConfigureMonomorphic(name, handle(object->map(), isolate), + nexus.ConfigureMonomorphic(Handle::cast(name), + handle(object->map(), isolate), MaybeObjectHandle()); } else { nexus.ConfigureMegamorphic(IcCheckType::kProperty); @@ -1163,17 +1139,14 @@ RUNTIME_FUNCTION(Runtime_DefineKeyedOwnPropertyInLiteral) { } DefineKeyedOwnPropertyInLiteralFlags flags(flag); - PropertyAttributes attrs = - (flags & DefineKeyedOwnPropertyInLiteralFlag::kDontEnum) - ? PropertyAttributes::DONT_ENUM - : PropertyAttributes::NONE; if (flags & DefineKeyedOwnPropertyInLiteralFlag::kSetFunctionName) { + DCHECK(name->IsName()); DCHECK(value->IsJSFunction()); Handle function = Handle::cast(value); DCHECK(!function->shared().HasSharedName()); Handle function_map(function->map(), isolate); - if (!JSFunction::SetName(function, name, + if (!JSFunction::SetName(function, Handle::cast(name), isolate->factory()->empty_string())) { return ReadOnlyRoots(isolate).exception(); } @@ -1186,7 +1159,7 @@ RUNTIME_FUNCTION(Runtime_DefineKeyedOwnPropertyInLiteral) { LookupIterator it(isolate, object, key, object, LookupIterator::OWN); Maybe result = JSObject::DefineOwnPropertyIgnoreAttributes( - &it, value, attrs, Just(kDontThrow)); + &it, value, PropertyAttributes::NONE, Just(kDontThrow)); // Cannot fail since this should only be called when // creating an object literal. RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 6ef5af2dfc..e3bbc6dd9f 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -351,7 +351,6 @@ namespace internal { F(DefineObjectOwnProperty, 3, 1) \ F(SetNamedProperty, 3, 1) \ F(SetOwnPropertyIgnoreAttributes, 4, 1) \ - F(DefineKeyedOwnPropertyInLiteral_Simple, 3, 1) \ F(ShrinkNameDictionary, 1, 1) \ F(ShrinkSwissNameDictionary, 1, 1) \ F(ToFastProperties, 1, 1) \