Commit 3f82a2d5 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by V8 LUCI CQ

[runtime] Rename DefineClassField -> DefineObjectOwnProperty

This runtime function is now also used for setting properties in object
literals.

Bug: v8:9888
Change-Id: I869a3feff6237a13bb777278b1d0a0062ac1825c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3244316
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJoyee Cheung <joyee@igalia.com>
Cr-Commit-Position: refs/heads/main@{#77580}
parent 3f27ca4f
......@@ -2351,8 +2351,8 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result,
IsDefineOwnIC()
? Runtime::DefineClassField(isolate(), object, key, value,
StoreOrigin::kMaybeKeyed)
? Runtime::DefineObjectOwnProperty(isolate(), object, key, value,
StoreOrigin::kMaybeKeyed)
: Runtime::SetObjectProperty(isolate(), object, key, value,
StoreOrigin::kMaybeKeyed),
Object);
......@@ -2419,8 +2419,8 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), store_handle,
IsDefineOwnIC()
? Runtime::DefineClassField(isolate(), object, key, value,
StoreOrigin::kMaybeKeyed)
? Runtime::DefineObjectOwnProperty(isolate(), object, key, value,
StoreOrigin::kMaybeKeyed)
: Runtime::SetObjectProperty(isolate(), object, key, value,
StoreOrigin::kMaybeKeyed),
Object);
......
......@@ -1075,9 +1075,7 @@ void KeyedStoreGenericAssembler::KeyedStoreGeneric(
TailCallRuntime(Runtime::kSetKeyedProperty, context, receiver, key,
value);
} else if (IsKeyedDefineOwn()) {
// Currently, KeyedDefineOwn ICs are only used for class instance
// fields, hence %DefineClassField.
TailCallRuntime(Runtime::kDefineClassField, context, receiver, key,
TailCallRuntime(Runtime::kDefineObjectOwnProperty, context, receiver, key,
value);
} else {
DCHECK(IsStoreInLiteral());
......
......@@ -552,12 +552,10 @@ MaybeHandle<Object> Runtime::SetObjectProperty(
return value;
}
MaybeHandle<Object> Runtime::DefineClassField(Isolate* isolate,
Handle<Object> object,
Handle<Object> key,
Handle<Object> value,
StoreOrigin store_origin,
Maybe<ShouldThrow> should_throw) {
MaybeHandle<Object> Runtime::DefineObjectOwnProperty(
Isolate* isolate, Handle<Object> object, Handle<Object> key,
Handle<Object> value, StoreOrigin store_origin,
Maybe<ShouldThrow> should_throw) {
if (object->IsNullOrUndefined(isolate)) {
THROW_NEW_ERROR(
isolate,
......@@ -857,7 +855,7 @@ RUNTIME_FUNCTION(Runtime_SetKeyedProperty) {
StoreOrigin::kMaybeKeyed));
}
RUNTIME_FUNCTION(Runtime_DefineClassField) {
RUNTIME_FUNCTION(Runtime_DefineObjectOwnProperty) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
......@@ -866,8 +864,8 @@ RUNTIME_FUNCTION(Runtime_DefineClassField) {
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
RETURN_RESULT_OR_FAILURE(
isolate, Runtime::DefineClassField(isolate, object, key, value,
StoreOrigin::kMaybeKeyed));
isolate, Runtime::DefineObjectOwnProperty(isolate, object, key, value,
StoreOrigin::kMaybeKeyed));
}
RUNTIME_FUNCTION(Runtime_SetNamedProperty) {
......
......@@ -333,7 +333,7 @@ namespace internal {
F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
F(SetDataProperties, 2, 1) \
F(SetKeyedProperty, 3, 1) \
F(DefineClassField, 3, 1) \
F(DefineObjectOwnProperty, 3, 1) \
F(SetNamedProperty, 3, 1) \
F(SetOwnPropertyIgnoreAttributes, 4, 1) \
F(StoreDataPropertyInLiteral, 3, 1) \
......@@ -794,15 +794,22 @@ class Runtime : public AllStatic {
DeleteObjectProperty(Isolate* isolate, Handle<JSReceiver> receiver,
Handle<Object> key, LanguageMode language_mode);
// Perform a property store on object. If the key is a private name (i.e. this
// is a private field assignment), this method throws if the private field
// does not exist on object.
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
SetObjectProperty(Isolate* isolate, Handle<Object> object, Handle<Object> key,
Handle<Object> value, StoreOrigin store_origin,
Maybe<ShouldThrow> should_throw = Nothing<ShouldThrow>());
// Defines a property on object. If the key is a private name (i.e. this is a
// private field definition), this method throws if the field already exists
// on object.
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
DefineClassField(Isolate* isolate, Handle<Object> object, Handle<Object> key,
Handle<Object> value, StoreOrigin store_origin,
Maybe<ShouldThrow> should_throw = Nothing<ShouldThrow>());
DefineObjectOwnProperty(
Isolate* isolate, Handle<Object> object, Handle<Object> key,
Handle<Object> value, StoreOrigin store_origin,
Maybe<ShouldThrow> should_throw = Nothing<ShouldThrow>());
// When "receiver" is not passed, it defaults to "lookup_start_object".
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
......
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