Commit 60d165d8 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[cleanup] Add base::Optional to new_target in CallOrConstruct*

It was using nullptr to signal that it was empty.

Bug: v8:10155
Change-Id: I0844d6a2bfacb1fd35ba83c24307de86f77f4e40
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2056470Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66271}
parent 6a95fb6b
......@@ -65,14 +65,14 @@ void Builtins::Generate_CallFunctionForwardVarargs(MacroAssembler* masm) {
}
void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
TNode<Object> target, SloppyTNode<Object> new_target,
TNode<Object> target, base::Optional<TNode<Object>> new_target,
TNode<Object> arguments_list, TNode<Context> context) {
Label if_done(this), if_arguments(this), if_array(this),
if_holey_array(this, Label::kDeferred),
if_runtime(this, Label::kDeferred);
// Perform appropriate checks on {target} (and {new_target} first).
if (new_target == nullptr) {
if (!new_target) {
// Check that {target} is Callable.
Label if_target_callable(this),
if_target_not_callable(this, Label::kDeferred);
......@@ -102,12 +102,12 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
// Check that {new_target} is a Constructor.
Label if_new_target_constructor(this),
if_new_target_not_constructor(this, Label::kDeferred);
GotoIf(TaggedIsSmi(new_target), &if_new_target_not_constructor);
Branch(IsConstructor(CAST(new_target)), &if_new_target_constructor,
GotoIf(TaggedIsSmi(*new_target), &if_new_target_not_constructor);
Branch(IsConstructor(CAST(*new_target)), &if_new_target_constructor,
&if_new_target_not_constructor);
BIND(&if_new_target_not_constructor);
{
CallRuntime(Runtime::kThrowNotConstructor, context, new_target);
CallRuntime(Runtime::kThrowNotConstructor, context, *new_target);
Unreachable();
}
BIND(&if_new_target_constructor);
......@@ -215,12 +215,12 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
BIND(&if_not_double);
{
if (new_target == nullptr) {
if (!new_target) {
Callable callable = CodeFactory::CallVarargs(isolate());
TailCallStub(callable, context, target, args_count, length, elements);
} else {
Callable callable = CodeFactory::ConstructVarargs(isolate());
TailCallStub(callable, context, target, new_target, args_count, length,
TailCallStub(callable, context, target, *new_target, args_count, length,
elements);
}
}
......@@ -240,7 +240,7 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
// boxed as HeapNumbers, then tail calls CallVarargs/ConstructVarargs depending
// on whether {new_target} was passed.
void CallOrConstructBuiltinsAssembler::CallOrConstructDoubleVarargs(
TNode<Object> target, SloppyTNode<Object> new_target,
TNode<Object> target, base::Optional<TNode<Object>> new_target,
TNode<FixedDoubleArray> elements, TNode<Int32T> length,
TNode<Int32T> args_count, TNode<Context> context, TNode<Int32T> kind) {
const ElementsKind new_kind = PACKED_ELEMENTS;
......@@ -258,19 +258,19 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructDoubleVarargs(
CopyFixedArrayElements(PACKED_DOUBLE_ELEMENTS, elements, new_kind,
new_elements, intptr_length, intptr_length,
barrier_mode);
if (new_target == nullptr) {
if (!new_target) {
Callable callable = CodeFactory::CallVarargs(isolate());
TailCallStub(callable, context, target, args_count, length, new_elements);
} else {
Callable callable = CodeFactory::ConstructVarargs(isolate());
TailCallStub(callable, context, target, new_target, args_count, length,
TailCallStub(callable, context, target, *new_target, args_count, length,
new_elements);
}
}
void CallOrConstructBuiltinsAssembler::CallOrConstructWithSpread(
TNode<Object> target, TNode<Object> new_target, TNode<Object> spread,
TNode<Int32T> args_count, TNode<Context> context) {
TNode<Object> target, base::Optional<TNode<Object>> new_target,
TNode<Object> spread, TNode<Int32T> args_count, TNode<Context> context) {
Label if_smiorobject(this), if_double(this),
if_generic(this, Label::kDeferred);
......@@ -350,12 +350,12 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithSpread(
CSA_ASSERT(this, Int32LessThanOrEqual(
length, Int32Constant(FixedArray::kMaxLength)));
if (new_target == nullptr) {
if (!new_target) {
Callable callable = CodeFactory::CallVarargs(isolate());
TailCallStub(callable, context, target, args_count, length, elements);
} else {
Callable callable = CodeFactory::ConstructVarargs(isolate());
TailCallStub(callable, context, target, new_target, args_count, length,
TailCallStub(callable, context, target, *new_target, args_count, length,
elements);
}
}
......@@ -371,7 +371,7 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithSpread(
TF_BUILTIN(CallWithArrayLike, CallOrConstructBuiltinsAssembler) {
TNode<Object> target = CAST(Parameter(Descriptor::kTarget));
SloppyTNode<Object> new_target = nullptr;
base::Optional<TNode<Object>> new_target = base::nullopt;
TNode<Object> arguments_list = CAST(Parameter(Descriptor::kArgumentsList));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
CallOrConstructWithArrayLike(target, new_target, arguments_list, context);
......@@ -379,7 +379,7 @@ TF_BUILTIN(CallWithArrayLike, CallOrConstructBuiltinsAssembler) {
TF_BUILTIN(CallWithSpread, CallOrConstructBuiltinsAssembler) {
TNode<Object> target = CAST(Parameter(Descriptor::kTarget));
SloppyTNode<Object> new_target = nullptr;
base::Optional<TNode<Object>> new_target = base::nullopt;
TNode<Object> spread = CAST(Parameter(Descriptor::kSpread));
TNode<Int32T> args_count =
UncheckedCast<Int32T>(Parameter(Descriptor::kArgumentsCount));
......
......@@ -16,16 +16,17 @@ class CallOrConstructBuiltinsAssembler : public CodeStubAssembler {
: CodeStubAssembler(state) {}
void CallOrConstructWithArrayLike(TNode<Object> target,
SloppyTNode<Object> new_target,
base::Optional<TNode<Object>> new_target,
TNode<Object> arguments_list,
TNode<Context> context);
void CallOrConstructDoubleVarargs(TNode<Object> target,
SloppyTNode<Object> new_target,
base::Optional<TNode<Object>> new_target,
TNode<FixedDoubleArray> elements,
TNode<Int32T> length,
TNode<Int32T> args_count,
TNode<Context> context, TNode<Int32T> kind);
void CallOrConstructWithSpread(TNode<Object> target, TNode<Object> new_target,
void CallOrConstructWithSpread(TNode<Object> target,
base::Optional<TNode<Object>> new_target,
TNode<Object> spread, TNode<Int32T> args_count,
TNode<Context> context);
......
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