Commit babc4422 authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

Add empty SetProperty stub

This CL is the first step towards a SetProperty stub, by adding a
stub that redirects to the runtime and replacing every runtime
call-site with a call to this stub.

A followup CL will then add an implementation to the stub similar
to KeyedStoreGenericAssembler::KeyedStoreGeneric().

R=cbruni@chromium.org, jgruber@chromium.org

Change-Id: Iff2f913988cada6220d54817d94d011ad6de2b77
Reviewed-on: https://chromium-review.googlesource.com/1163519
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54926}
parent 1d9d1ee4
......@@ -366,8 +366,7 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) {
Goto(&done);
BIND(&slow);
CallRuntime(Runtime::kSetProperty, context(), a(), k, mapped_value,
SmiConstant(LanguageMode::kStrict));
SetPropertyStrict(context(), CAST(a()), CAST(k), CAST(mapped_value));
Goto(&done);
BIND(&detached);
......@@ -1065,8 +1064,7 @@ TF_BUILTIN(ArrayPrototypePush, CodeStubAssembler) {
Node* length = LoadJSArrayLength(array_receiver);
// TODO(danno): Use the KeyedStoreGeneric stub here when possible,
// calling into the runtime to do the elements transition is overkill.
CallRuntime(Runtime::kSetProperty, context, array_receiver, length, arg,
SmiConstant(LanguageMode::kStrict));
SetPropertyStrict(context, array_receiver, CAST(length), CAST(arg));
Increment(&arg_index);
// The runtime SetProperty call could have converted the array to dictionary
// mode, which must be detected to abort the fast-path.
......@@ -1112,8 +1110,7 @@ TF_BUILTIN(ArrayPrototypePush, CodeStubAssembler) {
Node* length = LoadJSArrayLength(array_receiver);
// TODO(danno): Use the KeyedStoreGeneric stub here when possible,
// calling into the runtime to do the elements transition is overkill.
CallRuntime(Runtime::kSetProperty, context, array_receiver, length, arg,
SmiConstant(LanguageMode::kStrict));
SetPropertyStrict(context, array_receiver, CAST(length), CAST(arg));
Increment(&arg_index);
// The runtime SetProperty call could have converted the array to dictionary
// mode, which must be detected to abort the fast-path.
......@@ -1132,8 +1129,7 @@ TF_BUILTIN(ArrayPrototypePush, CodeStubAssembler) {
args.ForEach(
[this, array_receiver, context](Node* arg) {
Node* length = LoadJSArrayLength(array_receiver);
CallRuntime(Runtime::kSetProperty, context, array_receiver, length,
arg, SmiConstant(LanguageMode::kStrict));
SetPropertyStrict(context, array_receiver, CAST(length), CAST(arg));
},
arg_index.value());
args.PopAndReturn(LoadJSArrayLength(array_receiver));
......@@ -1480,10 +1476,8 @@ TF_BUILTIN(ArrayPrototypeSlice, ArrayPrototypeSliceCodeStubAssembler) {
// 16. Let setStatus be Set(A, "length", n, true).
// 17. ReturnIfAbrupt(setStatus).
CallRuntime(Runtime::kSetProperty, context, a,
HeapConstant(isolate()->factory()->length_string()), n.value(),
SmiConstant(static_cast<int>(LanguageMode::kStrict)));
SetPropertyStrict(context, CAST(a), CodeStubAssembler::LengthStringConstant(),
CAST(n.value()));
args.PopAndReturn(a);
}
......@@ -1995,9 +1989,8 @@ class ArrayPopulatorAssembler : public CodeStubAssembler {
BIND(&runtime);
{
CallRuntime(Runtime::kSetProperty, context, static_cast<Node*>(array),
CodeStubAssembler::LengthStringConstant(), length,
SmiConstant(LanguageMode::kStrict));
SetPropertyStrict(context, array,
CodeStubAssembler::LengthStringConstant(), length);
Goto(&done);
}
......
......@@ -123,8 +123,8 @@ Node* AsyncBuiltinsAssembler::Await(
// than a meaningful catch handler
Node* const key =
HeapConstant(factory()->promise_forwarding_handler_symbol());
CallRuntime(Runtime::kSetProperty, context, on_reject, key,
TrueConstant(), SmiConstant(LanguageMode::kStrict));
SetPropertyStrict(CAST(context), CAST(on_reject), CAST(key),
TrueConstant());
GotoIf(IsFalse(is_predicted_as_caught), &common);
PromiseSetHandledHint(value);
......@@ -137,8 +137,8 @@ Node* AsyncBuiltinsAssembler::Await(
CSA_SLOW_ASSERT(this, HasInstanceType(outer_promise, JS_PROMISE_TYPE));
Node* const key = HeapConstant(factory()->promise_handled_by_symbol());
CallRuntime(Runtime::kSetProperty, context, throwaway, key, outer_promise,
SmiConstant(LanguageMode::kStrict));
SetPropertyStrict(CAST(context), CAST(throwaway), CAST(key),
CAST(outer_promise));
}
Goto(&do_perform_promise_then);
......@@ -237,8 +237,8 @@ Node* AsyncBuiltinsAssembler::AwaitOptimized(
// than a meaningful catch handler
Node* const key =
HeapConstant(factory()->promise_forwarding_handler_symbol());
CallRuntime(Runtime::kSetProperty, context, on_reject, key,
TrueConstant(), SmiConstant(LanguageMode::kStrict));
SetPropertyStrict(CAST(context), CAST(on_reject), CAST(key),
TrueConstant());
GotoIf(IsFalse(is_predicted_as_caught), &common);
PromiseSetHandledHint(value);
......@@ -251,8 +251,8 @@ Node* AsyncBuiltinsAssembler::AwaitOptimized(
CSA_SLOW_ASSERT(this, HasInstanceType(outer_promise, JS_PROMISE_TYPE));
Node* const key = HeapConstant(factory()->promise_handled_by_symbol());
CallRuntime(Runtime::kSetProperty, context, throwaway, key, outer_promise,
SmiConstant(LanguageMode::kStrict));
SetPropertyStrict(CAST(context), CAST(throwaway), CAST(key),
CAST(outer_promise));
}
Goto(&do_perform_promise_then);
......
......@@ -1312,6 +1312,7 @@ namespace internal {
ASM(CallApiGetter) \
ASM(DoubleToI) \
TFC(GetProperty, GetProperty, 1) \
TFS(SetProperty, kReceiver, kKey, kValue) \
ASM(MathPowInternal) \
\
/* Trace */ \
......
......@@ -1258,5 +1258,18 @@ TF_BUILTIN(GetProperty, CodeStubAssembler) {
Return(var_result.value());
}
// ES6 [[Set]] operation.
TF_BUILTIN(SetProperty, CodeStubAssembler) {
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
TNode<Object> key = CAST(Parameter(Descriptor::kKey));
TNode<Object> value = CAST(Parameter(Descriptor::kValue));
// TODO(szuend): Add implementation similar to KeyedStoreGeneric().
TailCallRuntime(Runtime::kSetProperty, context, receiver, key, value,
SmiConstant(LanguageMode::kStrict));
}
} // namespace internal
} // namespace v8
......@@ -709,9 +709,10 @@ void PromiseBuiltinsAssembler::SetForwardingHandlerIfTrue(
Node* context, Node* condition, const NodeGenerator& object) {
Label done(this);
GotoIfNot(condition, &done);
CallRuntime(Runtime::kSetProperty, context, object(),
HeapConstant(factory()->promise_forwarding_handler_symbol()),
TrueConstant(), SmiConstant(LanguageMode::kStrict));
SetPropertyStrict(
CAST(context), CAST(object()),
HeapConstant(factory()->promise_forwarding_handler_symbol()),
TrueConstant());
Goto(&done);
BIND(&done);
}
......@@ -723,9 +724,9 @@ void PromiseBuiltinsAssembler::SetPromiseHandledByIfTrue(
GotoIfNot(condition, &done);
GotoIf(TaggedIsSmi(promise), &done);
GotoIfNot(HasInstanceType(promise, JS_PROMISE_TYPE), &done);
CallRuntime(Runtime::kSetProperty, context, promise,
HeapConstant(factory()->promise_handled_by_symbol()),
handled_by(), SmiConstant(LanguageMode::kStrict));
SetPropertyStrict(CAST(context), CAST(promise),
HeapConstant(factory()->promise_handled_by_symbol()),
CAST(handled_by()));
Goto(&done);
BIND(&done);
}
......
......@@ -150,12 +150,8 @@ void RegExpBuiltinsAssembler::FastStoreLastIndex(Node* regexp, Node* value) {
void RegExpBuiltinsAssembler::SlowStoreLastIndex(Node* context, Node* regexp,
Node* value) {
// Store through runtime.
// TODO(ishell): Use SetPropertyStub here once available.
Node* const name = HeapConstant(isolate()->factory()->lastIndex_string());
Node* const language_mode = SmiConstant(LanguageMode::kStrict);
CallRuntime(Runtime::kSetProperty, context, regexp, name, value,
language_mode);
SetPropertyStrict(CAST(context), CAST(regexp), CAST(name), CAST(value));
}
void RegExpBuiltinsAssembler::StoreLastIndex(Node* context, Node* regexp,
......
......@@ -2255,8 +2255,13 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<Object> GetProperty(SloppyTNode<Context> context,
SloppyTNode<Object> receiver,
SloppyTNode<Object> name) {
return CallStub(Builtins::CallableFor(isolate(), Builtins::kGetProperty),
context, receiver, name);
return CallBuiltin(Builtins::kGetProperty, context, receiver, name);
}
TNode<Object> SetPropertyStrict(TNode<Context> context,
TNode<Object> receiver, TNode<Object> key,
TNode<Object> value) {
return CallBuiltin(Builtins::kSetProperty, context, receiver, key, value);
}
Node* GetMethod(Node* context, Node* object, Handle<Name> name,
......
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