Commit 1dc3b908 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[maglev] Only add Call node to graph after arguments

Make sure that Call nodes are only added to the graph after their
arguments are processed. Previously we were already doing this for the
undefined constant, but forgot to also do it for tagging nodes.

Now rather than trying to add those nodes before creating the Call node,
we create the Call node without adding it to the graph, then add it only
after setting up its inputs.

Bug: v8:7700
Change-Id: Id8c4c381f42fdd3c86d19d0fa2eb57163771060b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3605248
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80159}
parent d94f8343
...@@ -738,25 +738,22 @@ void MaglevGraphBuilder::BuildCallFromRegisterList( ...@@ -738,25 +738,22 @@ void MaglevGraphBuilder::BuildCallFromRegisterList(
ValueNode* context = GetContext(); ValueNode* context = GetContext();
size_t input_count = args.register_count() + Call::kFixedInputCount; size_t input_count = args.register_count() + Call::kFixedInputCount;
RootConstant* undefined_constant;
if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) {
// The undefined constant node has to be created before the call node.
undefined_constant =
AddNewNode<RootConstant>({}, RootIndex::kUndefinedValue);
input_count++; input_count++;
} }
Call* call = AddNewNode<Call>(input_count, receiver_mode, function, context); Call* call =
CreateNewNode<Call>(input_count, receiver_mode, function, context);
int arg_index = 0; int arg_index = 0;
if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) {
call->set_arg(arg_index++, undefined_constant); call->set_arg(arg_index++,
AddNewNode<RootConstant>({}, RootIndex::kUndefinedValue));
} }
for (int i = 0; i < args.register_count(); ++i) { for (int i = 0; i < args.register_count(); ++i) {
call->set_arg(arg_index++, GetTaggedValue(args[i])); call->set_arg(arg_index++, GetTaggedValue(args[i]));
} }
SetAccumulator(call); SetAccumulator(AddNode(call));
} }
void MaglevGraphBuilder::BuildCallFromRegisters( void MaglevGraphBuilder::BuildCallFromRegisters(
...@@ -811,25 +808,20 @@ void MaglevGraphBuilder::BuildCallFromRegisters( ...@@ -811,25 +808,20 @@ void MaglevGraphBuilder::BuildCallFromRegisters(
int argc_count_with_recv = argc_count + 1; int argc_count_with_recv = argc_count + 1;
size_t input_count = argc_count_with_recv + Call::kFixedInputCount; size_t input_count = argc_count_with_recv + Call::kFixedInputCount;
// The undefined constant node has to be created before the call node.
RootConstant* undefined_constant;
if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) {
undefined_constant =
AddNewNode<RootConstant>({}, RootIndex::kUndefinedValue);
}
Call* call = AddNewNode<Call>(input_count, receiver_mode, function, context);
int arg_index = 0; int arg_index = 0;
int reg_count = argc_count_with_recv; int reg_count = argc_count_with_recv;
Call* call =
CreateNewNode<Call>(input_count, receiver_mode, function, context);
if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) {
reg_count = argc_count; reg_count = argc_count;
call->set_arg(arg_index++, undefined_constant); call->set_arg(arg_index++,
AddNewNode<RootConstant>({}, RootIndex::kUndefinedValue));
} }
for (int i = 0; i < reg_count; i++) { for (int i = 0; i < reg_count; i++) {
call->set_arg(arg_index++, LoadRegisterTagged(i + 1)); call->set_arg(arg_index++, LoadRegisterTagged(i + 1));
} }
SetAccumulator(call); SetAccumulator(AddNode(call));
} }
void MaglevGraphBuilder::VisitCallAnyReceiver() { void MaglevGraphBuilder::VisitCallAnyReceiver() {
......
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