[maglev] Fix RootConstant<Undefined> and Call order

The "undefined" node has to be in the CFG graph before the "Call" node.

Bug: v8:7700
Change-Id: I137cde1d884e87e72fd4d6a22d5105168c8fb6cb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3557331
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79658}
This commit is contained in:
Leszek Swirski 2022-03-29 18:30:35 +02:00 committed by V8 LUCI CQ
parent f859193aed
commit 4edaa94835

View File

@ -8,6 +8,7 @@
#include "src/compiler/heap-refs.h"
#include "src/handles/maybe-handles-inl.h"
#include "src/ic/handler-configuration.h"
#include "src/maglev/maglev-ir.h"
#include "src/objects/feedback-vector.h"
#include "src/objects/name-inl.h"
#include "src/objects/slots-inl.h"
@ -395,13 +396,19 @@ void MaglevGraphBuilder::BuildCallFromRegisters(
int argc_count_with_recv = argc_count + 1;
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 reg_count = argc_count_with_recv;
if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) {
reg_count = argc_count;
call->set_arg(arg_index++,
AddNewNode<RootConstant>({}, RootIndex::kUndefinedValue));
call->set_arg(arg_index++, undefined_constant);
}
for (int i = 0; i < reg_count; i++) {
call->set_arg(arg_index++, LoadRegister(i + 1));