[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 <verwaest@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85704}
This commit is contained in:
Huáng Jùnliàng 2023-02-06 18:18:24 -05:00 committed by V8 LUCI CQ
parent 086c43455f
commit 1bae10b2cd
5 changed files with 24 additions and 47 deletions

View File

@ -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<DefineKeyedOwnPropertyInLiteralFlag>;

View File

@ -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();

View File

@ -1150,8 +1150,12 @@ void KeyedStoreGenericAssembler::KeyedStoreGeneric(
value);
} else {
DCHECK(IsDefineKeyedOwnInLiteral());
TailCallRuntime(Runtime::kDefineKeyedOwnPropertyInLiteral_Simple, context,
receiver, key, value);
TNode<Smi> flags =
SmiConstant(DefineKeyedOwnPropertyInLiteralFlag::kNoFlags);
// TODO(v8:10047): Use TaggedIndexConstant here once TurboFan supports it.
TNode<Smi> slot = SmiConstant(FeedbackSlot::Invalid().ToInt());
TailCallRuntime(Runtime::kDefineKeyedOwnPropertyInLiteral, context,
receiver, key, value, flags, UndefinedConstant(), slot);
}
}
}
@ -1238,8 +1242,12 @@ void KeyedStoreGenericAssembler::StoreProperty(TNode<Context> context,
BIND(&slow);
{
if (IsDefineKeyedOwnInLiteral()) {
CallRuntime(Runtime::kDefineKeyedOwnPropertyInLiteral_Simple, context,
receiver, unique_name, value);
TNode<Smi> flags =
SmiConstant(DefineKeyedOwnPropertyInLiteralFlag::kNoFlags);
// TODO(v8:10047): Use TaggedIndexConstant here once TurboFan supports it.
TNode<Smi> 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);

View File

@ -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<JSReceiver> object = args.at<JSReceiver>(0);
Handle<Object> key = args.at(1);
Handle<Object> value = args.at(2);
PropertyKey lookup_key(isolate, key);
LookupIterator it(isolate, object, lookup_key, LookupIterator::OWN);
Maybe<bool> 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<JSObject> object = args.at<JSObject>(0);
Handle<Name> name = args.at<Name>(1);
Handle<JSReceiver> object = args.at<JSReceiver>(0);
Handle<Object> name = args.at(1);
Handle<Object> value = args.at(2);
int flag = args.smi_value_at(3);
Handle<HeapObject> maybe_vector = args.at<HeapObject>(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<FeedbackVector> vector = Handle<FeedbackVector>::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<Name>::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<JSFunction> function = Handle<JSFunction>::cast(value);
DCHECK(!function->shared().HasSharedName());
Handle<Map> function_map(function->map(), isolate);
if (!JSFunction::SetName(function, name,
if (!JSFunction::SetName(function, Handle<Name>::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<bool> 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);

View File

@ -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) \