From 4edaa94835245e5768b69a6ae57e18091829ade5 Mon Sep 17 00:00:00 2001 From: Leszek Swirski Date: Tue, 29 Mar 2022 18:30:35 +0200 Subject: [PATCH] [maglev] Fix RootConstant 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 Auto-Submit: Leszek Swirski Reviewed-by: Victor Gomes Commit-Queue: Victor Gomes Cr-Commit-Position: refs/heads/main@{#79658} --- src/maglev/maglev-graph-builder.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/maglev/maglev-graph-builder.cc b/src/maglev/maglev-graph-builder.cc index 5d0687b3c5..3496fcafc0 100644 --- a/src/maglev/maglev-graph-builder.cc +++ b/src/maglev/maglev-graph-builder.cc @@ -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({}, RootIndex::kUndefinedValue); + } + Call* call = AddNewNode(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({}, 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));