[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:
parent
086c43455f
commit
1bae10b2cd
@ -1839,13 +1839,11 @@ inline std::ostream& operator<<(std::ostream& os, CollectionKind kind) {
|
|||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flags for the runtime function kDefineKeyedOwnPropertyInLiteral. A property
|
// Flags for the runtime function kDefineKeyedOwnPropertyInLiteral.
|
||||||
// can be enumerable or not, and, in case of functions, the function name can be
|
// - Whether the function name should be set or not.
|
||||||
// set or not.
|
|
||||||
enum class DefineKeyedOwnPropertyInLiteralFlag {
|
enum class DefineKeyedOwnPropertyInLiteralFlag {
|
||||||
kNoFlags = 0,
|
kNoFlags = 0,
|
||||||
kDontEnum = 1 << 0,
|
kSetFunctionName = 1 << 0
|
||||||
kSetFunctionName = 1 << 1
|
|
||||||
};
|
};
|
||||||
using DefineKeyedOwnPropertyInLiteralFlags =
|
using DefineKeyedOwnPropertyInLiteralFlags =
|
||||||
base::Flags<DefineKeyedOwnPropertyInLiteralFlag>;
|
base::Flags<DefineKeyedOwnPropertyInLiteralFlag>;
|
||||||
|
@ -3069,7 +3069,6 @@ JSNativeContextSpecialization::ReduceJSDefineKeyedOwnPropertyInLiteral(
|
|||||||
NumberMatcher mflags(n.flags());
|
NumberMatcher mflags(n.flags());
|
||||||
CHECK(mflags.HasResolvedValue());
|
CHECK(mflags.HasResolvedValue());
|
||||||
DefineKeyedOwnPropertyInLiteralFlags cflags(mflags.ResolvedValue());
|
DefineKeyedOwnPropertyInLiteralFlags cflags(mflags.ResolvedValue());
|
||||||
DCHECK(!(cflags & DefineKeyedOwnPropertyInLiteralFlag::kDontEnum));
|
|
||||||
if (cflags & DefineKeyedOwnPropertyInLiteralFlag::kSetFunctionName)
|
if (cflags & DefineKeyedOwnPropertyInLiteralFlag::kSetFunctionName)
|
||||||
return NoChange();
|
return NoChange();
|
||||||
|
|
||||||
|
@ -1150,8 +1150,12 @@ void KeyedStoreGenericAssembler::KeyedStoreGeneric(
|
|||||||
value);
|
value);
|
||||||
} else {
|
} else {
|
||||||
DCHECK(IsDefineKeyedOwnInLiteral());
|
DCHECK(IsDefineKeyedOwnInLiteral());
|
||||||
TailCallRuntime(Runtime::kDefineKeyedOwnPropertyInLiteral_Simple, context,
|
TNode<Smi> flags =
|
||||||
receiver, key, value);
|
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);
|
BIND(&slow);
|
||||||
{
|
{
|
||||||
if (IsDefineKeyedOwnInLiteral()) {
|
if (IsDefineKeyedOwnInLiteral()) {
|
||||||
CallRuntime(Runtime::kDefineKeyedOwnPropertyInLiteral_Simple, context,
|
TNode<Smi> flags =
|
||||||
receiver, unique_name, value);
|
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 {
|
} else {
|
||||||
CallRuntime(Runtime::kSetKeyedProperty, context, receiver, unique_name,
|
CallRuntime(Runtime::kSetKeyedProperty, context, receiver, unique_name,
|
||||||
value);
|
value);
|
||||||
|
@ -911,32 +911,6 @@ RUNTIME_FUNCTION(Runtime_SetNamedProperty) {
|
|||||||
StoreOrigin::kNamed));
|
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 {
|
namespace {
|
||||||
|
|
||||||
// ES6 section 12.5.4.
|
// ES6 section 12.5.4.
|
||||||
@ -1137,20 +1111,22 @@ RUNTIME_FUNCTION(Runtime_SetFunctionName) {
|
|||||||
RUNTIME_FUNCTION(Runtime_DefineKeyedOwnPropertyInLiteral) {
|
RUNTIME_FUNCTION(Runtime_DefineKeyedOwnPropertyInLiteral) {
|
||||||
HandleScope scope(isolate);
|
HandleScope scope(isolate);
|
||||||
DCHECK_EQ(6, args.length());
|
DCHECK_EQ(6, args.length());
|
||||||
Handle<JSObject> object = args.at<JSObject>(0);
|
Handle<JSReceiver> object = args.at<JSReceiver>(0);
|
||||||
Handle<Name> name = args.at<Name>(1);
|
Handle<Object> name = args.at(1);
|
||||||
Handle<Object> value = args.at(2);
|
Handle<Object> value = args.at(2);
|
||||||
int flag = args.smi_value_at(3);
|
int flag = args.smi_value_at(3);
|
||||||
Handle<HeapObject> maybe_vector = args.at<HeapObject>(4);
|
Handle<HeapObject> maybe_vector = args.at<HeapObject>(4);
|
||||||
int index = args.tagged_index_value_at(5);
|
|
||||||
|
|
||||||
if (!maybe_vector->IsUndefined()) {
|
if (!maybe_vector->IsUndefined()) {
|
||||||
|
int index = args.tagged_index_value_at(5);
|
||||||
|
DCHECK(name->IsName());
|
||||||
DCHECK(maybe_vector->IsFeedbackVector());
|
DCHECK(maybe_vector->IsFeedbackVector());
|
||||||
Handle<FeedbackVector> vector = Handle<FeedbackVector>::cast(maybe_vector);
|
Handle<FeedbackVector> vector = Handle<FeedbackVector>::cast(maybe_vector);
|
||||||
FeedbackNexus nexus(vector, FeedbackVector::ToSlot(index));
|
FeedbackNexus nexus(vector, FeedbackVector::ToSlot(index));
|
||||||
if (nexus.ic_state() == InlineCacheState::UNINITIALIZED) {
|
if (nexus.ic_state() == InlineCacheState::UNINITIALIZED) {
|
||||||
if (name->IsUniqueName()) {
|
if (name->IsUniqueName()) {
|
||||||
nexus.ConfigureMonomorphic(name, handle(object->map(), isolate),
|
nexus.ConfigureMonomorphic(Handle<Name>::cast(name),
|
||||||
|
handle(object->map(), isolate),
|
||||||
MaybeObjectHandle());
|
MaybeObjectHandle());
|
||||||
} else {
|
} else {
|
||||||
nexus.ConfigureMegamorphic(IcCheckType::kProperty);
|
nexus.ConfigureMegamorphic(IcCheckType::kProperty);
|
||||||
@ -1163,17 +1139,14 @@ RUNTIME_FUNCTION(Runtime_DefineKeyedOwnPropertyInLiteral) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DefineKeyedOwnPropertyInLiteralFlags flags(flag);
|
DefineKeyedOwnPropertyInLiteralFlags flags(flag);
|
||||||
PropertyAttributes attrs =
|
|
||||||
(flags & DefineKeyedOwnPropertyInLiteralFlag::kDontEnum)
|
|
||||||
? PropertyAttributes::DONT_ENUM
|
|
||||||
: PropertyAttributes::NONE;
|
|
||||||
|
|
||||||
if (flags & DefineKeyedOwnPropertyInLiteralFlag::kSetFunctionName) {
|
if (flags & DefineKeyedOwnPropertyInLiteralFlag::kSetFunctionName) {
|
||||||
|
DCHECK(name->IsName());
|
||||||
DCHECK(value->IsJSFunction());
|
DCHECK(value->IsJSFunction());
|
||||||
Handle<JSFunction> function = Handle<JSFunction>::cast(value);
|
Handle<JSFunction> function = Handle<JSFunction>::cast(value);
|
||||||
DCHECK(!function->shared().HasSharedName());
|
DCHECK(!function->shared().HasSharedName());
|
||||||
Handle<Map> function_map(function->map(), isolate);
|
Handle<Map> function_map(function->map(), isolate);
|
||||||
if (!JSFunction::SetName(function, name,
|
if (!JSFunction::SetName(function, Handle<Name>::cast(name),
|
||||||
isolate->factory()->empty_string())) {
|
isolate->factory()->empty_string())) {
|
||||||
return ReadOnlyRoots(isolate).exception();
|
return ReadOnlyRoots(isolate).exception();
|
||||||
}
|
}
|
||||||
@ -1186,7 +1159,7 @@ RUNTIME_FUNCTION(Runtime_DefineKeyedOwnPropertyInLiteral) {
|
|||||||
LookupIterator it(isolate, object, key, object, LookupIterator::OWN);
|
LookupIterator it(isolate, object, key, object, LookupIterator::OWN);
|
||||||
|
|
||||||
Maybe<bool> result = JSObject::DefineOwnPropertyIgnoreAttributes(
|
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
|
// Cannot fail since this should only be called when
|
||||||
// creating an object literal.
|
// creating an object literal.
|
||||||
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
|
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
|
||||||
|
@ -351,7 +351,6 @@ namespace internal {
|
|||||||
F(DefineObjectOwnProperty, 3, 1) \
|
F(DefineObjectOwnProperty, 3, 1) \
|
||||||
F(SetNamedProperty, 3, 1) \
|
F(SetNamedProperty, 3, 1) \
|
||||||
F(SetOwnPropertyIgnoreAttributes, 4, 1) \
|
F(SetOwnPropertyIgnoreAttributes, 4, 1) \
|
||||||
F(DefineKeyedOwnPropertyInLiteral_Simple, 3, 1) \
|
|
||||||
F(ShrinkNameDictionary, 1, 1) \
|
F(ShrinkNameDictionary, 1, 1) \
|
||||||
F(ShrinkSwissNameDictionary, 1, 1) \
|
F(ShrinkSwissNameDictionary, 1, 1) \
|
||||||
F(ToFastProperties, 1, 1) \
|
F(ToFastProperties, 1, 1) \
|
||||||
|
Loading…
Reference in New Issue
Block a user