Commit cf5ce194 authored by Joyee Cheung's avatar Joyee Cheung Committed by V8 LUCI CQ

[ic] name Set/Define/Store property operations more consistently pt.2

As a follow-up of
https://chromium-review.googlesource.com/c/v8/v8/+/3481475,
this renames a few more operations related to property stores to keep
them consistent and adds comments to explain about what they do.

Summary of the renamed identifiers:

- SetPropertyInLiteral -> CreateDataProperty: this implements
  [[CreateDataProperty]] in the spec which does [[DefineOwnProperty]]
  instead of [[Set]], so rename for clarity.
- IsStoreIC(), IsStoreICKind() -> IsSetNamedIC(), IsSetNamedICKind():
  these only check whether the feedback kind is kSetNamedSloppy or
  kSetNamedStrict, so the scope can be narrowed.
- StoreMode::kOrdinary -> StoreMode::kSet: this implements [[Set]]
  in the spec and is used by both KeyedStoreIC and
  StoreIC to set the properties when there is no feedback.
- StoreMode::kInLiteral -> StoreMode::kDefineKeyedOwnInLiteral:
  this implements [[CreateDataProperty]] while expecting the receiver
  to be a JSObject created by us (the `InLiteral` part). Prepend
  `DefineKeyedOwn` to it so that it's more aligned with other
  StoreModes - it should be possible to just merge this into the
  more generic StoreMode::kDefineKeyedOwn later.
- KeyedStoreGenericAssembler::SetProperty ->
  KeyedStoreGenericAssembler::StoreProperty: these helpers are used by
  both define and set operations, distinguished with the StoreMode,
  so rename it to the more generic StoreProperty.

Bug: v8:12548
Change-Id: Iccef673c1dc707bbdbf010f02f7db1e9ec32b3e4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3557690Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Joyee Cheung <joyee@igalia.com>
Cr-Commit-Position: refs/heads/main@{#79694}
parent 8ba70dfe
......@@ -672,7 +672,7 @@ extern transitioning builtin SetProperty(implicit context: Context)(
JSAny, JSAny, JSAny): JSAny;
extern transitioning builtin SetPropertyIgnoreAttributes(
implicit context: Context)(JSObject, String, JSAny, Smi): JSAny;
extern transitioning builtin SetPropertyInLiteral(implicit context: Context)(
extern transitioning builtin CreateDataProperty(implicit context: Context)(
JSAny, JSAny, JSAny): JSAny;
extern transitioning builtin DeleteProperty(implicit context: Context)(
JSAny, JSAny | PrivateSymbol, LanguageModeSmi): Boolean;
......
......@@ -1062,7 +1062,7 @@ namespace internal {
TFC(GetProperty, GetProperty) \
TFS(GetPropertyWithReceiver, kObject, kKey, kReceiver, kOnNonExistent) \
TFS(SetProperty, kReceiver, kKey, kValue) \
TFS(SetPropertyInLiteral, kReceiver, kKey, kValue) \
TFS(CreateDataProperty, kReceiver, kKey, kValue) \
ASM(MemCopyUint8Uint8, CCall) \
ASM(MemMove, CCall) \
\
......
......@@ -839,7 +839,7 @@ class SetOrCopyDataPropertiesAssembler : public CodeStubAssembler {
1, IndexAdvanceMode::kPost);
}
CallBuiltin(Builtin::kSetPropertyInLiteral, context, target, key,
CallBuiltin(Builtin::kCreateDataProperty, context, target, key,
value);
Goto(&skip);
Bind(&skip);
......@@ -1362,14 +1362,14 @@ TF_BUILTIN(SetProperty, CodeStubAssembler) {
// being initialized, and have not yet been made accessible to the user. Thus,
// any operation here should be unobservable until after the object has been
// returned.
TF_BUILTIN(SetPropertyInLiteral, CodeStubAssembler) {
TF_BUILTIN(CreateDataProperty, CodeStubAssembler) {
auto context = Parameter<Context>(Descriptor::kContext);
auto receiver = Parameter<JSObject>(Descriptor::kReceiver);
auto key = Parameter<Object>(Descriptor::kKey);
auto value = Parameter<Object>(Descriptor::kValue);
KeyedStoreGenericGenerator::SetPropertyInLiteral(state(), context, receiver,
key, value);
KeyedStoreGenericGenerator::CreateDataProperty(state(), context, receiver,
key, value);
}
TF_BUILTIN(InstantiateAsmJs, CodeStubAssembler) {
......
......@@ -18,20 +18,20 @@ transitioning macro ObjectFromEntriesFastCase(implicit context: Context)(
const pair: KeyValuePair =
collections::LoadKeyValuePairNoSideEffects(value)
otherwise IfSlow;
// StorePropertyInLiteral only handles Names and Numbers. Bail out if
// CreateDataProperty only handles Names and Numbers. Bail out if
// the key is not one of those types. Note that JSReceivers should
// always bail to the slow path, as calling Symbol.toPrimitive,
// toString, or valueOf could invalidate assumptions about the
// iterable.
typeswitch (pair.key) {
case (Name): {
SetPropertyInLiteral(result, pair.key, pair.value);
CreateDataProperty(result, pair.key, pair.value);
}
case (Number): {
SetPropertyInLiteral(result, pair.key, pair.value);
CreateDataProperty(result, pair.key, pair.value);
}
case (oddball: Oddball): {
SetPropertyInLiteral(result, oddball.to_string, pair.value);
CreateDataProperty(result, oddball.to_string, pair.value);
}
case (JSAny): {
goto IfSlow;
......
......@@ -3229,10 +3229,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
return CallBuiltin(Builtin::kSetProperty, context, receiver, key, value);
}
TNode<Object> SetPropertyInLiteral(TNode<Context> context,
TNode<JSObject> receiver,
TNode<Object> key, TNode<Object> value) {
return CallBuiltin(Builtin::kSetPropertyInLiteral, context, receiver, key,
TNode<Object> CreateDataProperty(TNode<Context> context,
TNode<JSObject> receiver, TNode<Object> key,
TNode<Object> value) {
return CallBuiltin(Builtin::kCreateDataProperty, context, receiver, key,
value);
}
......
......@@ -429,7 +429,7 @@ NamedAccessFeedback::NamedAccessFeedback(NameRef const& name,
ZoneVector<MapRef> const& maps,
FeedbackSlotKind slot_kind)
: ProcessedFeedback(kNamedAccess, slot_kind), name_(name), maps_(maps) {
DCHECK(IsLoadICKind(slot_kind) || IsStoreICKind(slot_kind) ||
DCHECK(IsLoadICKind(slot_kind) || IsSetNamedICKind(slot_kind) ||
IsDefineNamedOwnICKind(slot_kind) || IsKeyedLoadICKind(slot_kind) ||
IsKeyedHasICKind(slot_kind) || IsKeyedStoreICKind(slot_kind) ||
IsStoreInArrayLiteralICKind(slot_kind) ||
......
......@@ -4134,7 +4134,7 @@ void AccessorAssembler::StoreInArrayLiteralIC(const StoreICParameters* p) {
BIND(&no_feedback);
{
Comment("StoreInArrayLiteralIC_NoFeedback");
TailCallBuiltin(Builtin::kSetPropertyInLiteral, p->context(), p->receiver(),
TailCallBuiltin(Builtin::kCreateDataProperty, p->context(), p->receiver(),
p->name(), p->value());
}
......@@ -4782,7 +4782,7 @@ void AccessorAssembler::GenerateCloneObjectIC_Slow() {
ForEachEnumerableOwnProperty(
context, source_map, CAST(source), kPropertyAdditionOrder,
[=](TNode<Name> key, TNode<Object> value) {
SetPropertyInLiteral(context, result, key, value);
CreateDataProperty(context, result, key, value);
},
&call_runtime);
Goto(&done);
......
......@@ -2859,7 +2859,7 @@ RUNTIME_FUNCTION(Runtime_StoreIC_Miss) {
kind = vector->GetKind(vector_slot);
}
DCHECK(IsStoreICKind(kind) || IsDefineNamedOwnICKind(kind));
DCHECK(IsSetNamedICKind(kind) || IsDefineNamedOwnICKind(kind));
StoreIC ic(isolate, vector, vector_slot, kind);
ic.UpdateState(receiver, key);
RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value));
......@@ -3151,7 +3151,7 @@ RUNTIME_FUNCTION(Runtime_ElementsTransitionAndStoreIC_Miss) {
StoreOwnElement(isolate, Handle<JSArray>::cast(object), key, value);
return *value;
} else {
DCHECK(IsKeyedStoreICKind(kind) || IsStoreICKind(kind) ||
DCHECK(IsKeyedStoreICKind(kind) || IsSetNamedICKind(kind) ||
IsDefineKeyedOwnICKind(kind));
RETURN_RESULT_OR_FAILURE(
isolate,
......
......@@ -53,7 +53,7 @@ class IC {
return IsLoadIC() || IsLoadGlobalIC() || IsKeyedLoadIC();
}
bool IsAnyStore() const {
return IsStoreIC() || IsDefineNamedOwnIC() || IsStoreGlobalIC() ||
return IsSetNamedIC() || IsDefineNamedOwnIC() || IsStoreGlobalIC() ||
IsKeyedStoreIC() || IsStoreInArrayLiteralICKind(kind()) ||
IsDefineKeyedOwnIC();
}
......@@ -121,7 +121,7 @@ class IC {
bool IsLoadGlobalIC() const { return IsLoadGlobalICKind(kind_); }
bool IsKeyedLoadIC() const { return IsKeyedLoadICKind(kind_); }
bool IsStoreGlobalIC() const { return IsStoreGlobalICKind(kind_); }
bool IsStoreIC() const { return IsStoreICKind(kind_); }
bool IsSetNamedIC() const { return IsSetNamedICKind(kind_); }
bool IsDefineNamedOwnIC() const { return IsDefineNamedOwnICKind(kind_); }
bool IsStoreInArrayLiteralIC() const {
return IsStoreInArrayLiteralICKind(kind_);
......
This diff is collapsed.
......@@ -28,10 +28,10 @@ class KeyedStoreGenericGenerator {
TNode<Object> key, TNode<Object> value,
LanguageMode language_mode);
static void SetPropertyInLiteral(compiler::CodeAssemblerState* state,
TNode<Context> context,
TNode<JSObject> receiver, TNode<Object> key,
TNode<Object> value);
static void CreateDataProperty(compiler::CodeAssemblerState* state,
TNode<Context> context,
TNode<JSObject> receiver, TNode<Object> key,
TNode<Object> value);
};
class DefineKeyedOwnGenericGenerator {
......
......@@ -1427,7 +1427,7 @@ void FeedbackNexus::ResetTypeProfile() {
FeedbackIterator::FeedbackIterator(const FeedbackNexus* nexus)
: done_(false), index_(-1), state_(kOther) {
DCHECK(
IsLoadICKind(nexus->kind()) || IsStoreICKind(nexus->kind()) ||
IsLoadICKind(nexus->kind()) || IsSetNamedICKind(nexus->kind()) ||
IsKeyedLoadICKind(nexus->kind()) || IsKeyedStoreICKind(nexus->kind()) ||
IsDefineNamedOwnICKind(nexus->kind()) ||
IsDefineKeyedOwnPropertyInLiteralKind(nexus->kind()) ||
......
......@@ -94,7 +94,7 @@ inline bool IsStoreGlobalICKind(FeedbackSlotKind kind) {
kind == FeedbackSlotKind::kStoreGlobalStrict;
}
inline bool IsStoreICKind(FeedbackSlotKind kind) {
inline bool IsSetNamedICKind(FeedbackSlotKind kind) {
return kind == FeedbackSlotKind::kSetNamedSloppy ||
kind == FeedbackSlotKind::kSetNamedStrict;
}
......@@ -140,7 +140,7 @@ inline TypeofMode GetTypeofModeFromSlotKind(FeedbackSlotKind kind) {
}
inline LanguageMode GetLanguageModeFromSlotKind(FeedbackSlotKind kind) {
DCHECK(IsStoreICKind(kind) || IsDefineNamedOwnICKind(kind) ||
DCHECK(IsSetNamedICKind(kind) || IsDefineNamedOwnICKind(kind) ||
IsStoreGlobalICKind(kind) || IsKeyedStoreICKind(kind) ||
IsDefineKeyedOwnICKind(kind));
STATIC_ASSERT(FeedbackSlotKind::kStoreGlobalSloppy <=
......@@ -290,7 +290,7 @@ class FeedbackVector
DEFINE_SLOT_KIND_PREDICATE(IsLoadIC)
DEFINE_SLOT_KIND_PREDICATE(IsLoadGlobalIC)
DEFINE_SLOT_KIND_PREDICATE(IsKeyedLoadIC)
DEFINE_SLOT_KIND_PREDICATE(IsStoreIC)
DEFINE_SLOT_KIND_PREDICATE(IsSetNamedIC)
DEFINE_SLOT_KIND_PREDICATE(IsDefineNamedOwnIC)
DEFINE_SLOT_KIND_PREDICATE(IsStoreGlobalIC)
DEFINE_SLOT_KIND_PREDICATE(IsKeyedStoreIC)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment