Skip to content

Commit 93e73bf

Browse files
mralephCommit Queue
authored and
Commit Queue
committed
[vm/compiler] Rename PushArgument to MoveArgument
This is follow up to 65f4a73, which switched optimized code to use fixed frame for outgoing arguments. Change Kernel to IL translation to handle null-checks in invocations differently: this code used to duplicate receiver on the stack to accomodate for PushArgument in unoptimized code, but PushArgument has not been inserted since f4e61ea, which means duplication of the receiver is no longer necessary. TEST=ci Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try Change-Id: I6c1f1e8c354f9ea92424b6602b83b9e9ebce8b69 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284184 Commit-Queue: Slava Egorov <[email protected]> Reviewed-by: Martin Kustermann <[email protected]>
1 parent 354e806 commit 93e73bf

35 files changed

+238
-338
lines changed

runtime/tests/vm/dart/records_allocation_sinking_il_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ void matchIL$test(FlowGraph graph) {
3535
'bar' << match.Parameter(index: 3),
3636
'baz' << match.Parameter(index: 4),
3737
match.CheckStackOverflow(),
38-
match.PushArgument('x'),
38+
match.MoveArgument('x'),
3939
match.StaticCall(),
40-
match.PushArgument('y'),
40+
match.MoveArgument('y'),
4141
match.StaticCall(),
4242
'baz_boxed' << match.BoxInt64('baz'),
43-
match.PushArgument('foo'),
43+
match.MoveArgument('foo'),
4444
match.StaticCall(),
45-
match.PushArgument('baz_boxed'),
45+
match.MoveArgument('baz_boxed'),
4646
match.StaticCall(),
4747
match.Return(),
4848
]),

runtime/tests/vm/dart/records_return_value_unboxing_il_test.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,42 +103,42 @@ void matchIL$test(FlowGraph graph) {
103103
'obj2' << match.Parameter(index: 5),
104104
match.CheckStackOverflow(),
105105

106-
match.PushArgument('x'),
107-
match.PushArgument('z'),
106+
match.MoveArgument('x'),
107+
match.MoveArgument('z'),
108108
'r1' << match.StaticCall(),
109109
'r1_0' << match.ExtractNthOutput('r1', index: 0),
110110
'r1_1' << match.ExtractNthOutput('r1', index: 1),
111-
match.PushArgument('r1_0'),
111+
match.MoveArgument('r1_0'),
112112
match.StaticCall(),
113-
match.PushArgument('r1_1'),
113+
match.MoveArgument('r1_1'),
114114
match.StaticCall(),
115115

116-
match.PushArgument('foo'),
117-
match.PushArgument('bar'),
116+
match.MoveArgument('foo'),
117+
match.MoveArgument('bar'),
118118
'r2' << match.StaticCall(),
119119
'r2_bar' << match.ExtractNthOutput('r2', index: 0),
120120
'r2_foo' << match.ExtractNthOutput('r2', index: 1),
121-
match.PushArgument('r2_foo'),
121+
match.MoveArgument('r2_foo'),
122122
match.StaticCall(),
123-
match.PushArgument('r2_bar'),
123+
match.MoveArgument('r2_bar'),
124124
match.StaticCall(),
125125

126-
match.PushArgument('obj1'),
126+
match.MoveArgument('obj1'),
127127
'r3' << match.StaticCall(),
128128
'r3_0' << match.ExtractNthOutput('r3', index: 0),
129129
'r3_y' << match.ExtractNthOutput('r3', index: 1),
130-
match.PushArgument('r3_0'),
130+
match.MoveArgument('r3_0'),
131131
match.StaticCall(),
132-
match.PushArgument('r3_y'),
132+
match.MoveArgument('r3_y'),
133133
match.StaticCall(),
134134

135135
'obj2_cid' << match.LoadClassId('obj2'),
136-
match.PushArgument('obj2'),
136+
match.MoveArgument('obj2'),
137137
'r4' << match.DispatchTableCall('obj2_cid'),
138138
'r4_0' << match.ExtractNthOutput('r4', index: 0),
139139
'r4_y' << match.ExtractNthOutput('r4', index: 1),
140140
'r4_boxed' << match.AllocateSmallRecord('r4_0', 'r4_y'),
141-
match.PushArgument('r4_boxed'),
141+
match.MoveArgument('r4_boxed'),
142142
match.StaticCall(),
143143

144144
match.Return(),

runtime/vm/compiler/backend/constant_propagator.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ void ConstantPropagator::VisitNativeParameter(NativeParameterInstr* instr) {
432432
SetValue(instr, non_constant_);
433433
}
434434

435-
void ConstantPropagator::VisitPushArgument(PushArgumentInstr* instr) {
436-
UNREACHABLE();
435+
void ConstantPropagator::VisitMoveArgument(MoveArgumentInstr* instr) {
436+
UNREACHABLE(); // Inserted right before register allocation.
437437
}
438438

439439
void ConstantPropagator::VisitAssertAssignable(AssertAssignableInstr* instr) {
@@ -1753,7 +1753,6 @@ bool ConstantPropagator::TransformDefinition(Definition* defn) {
17531753
// Replace constant-valued instructions without observable side
17541754
// effects. Do this for smis and old objects only to avoid having to
17551755
// copy other objects into the heap's old generation.
1756-
ASSERT((defn == nullptr) || !defn->IsPushArgument());
17571756
if ((defn != nullptr) && IsConstant(defn->constant_value()) &&
17581757
(defn->constant_value().IsSmi() || defn->constant_value().IsOld()) &&
17591758
!defn->IsConstant() && !defn->IsStoreIndexed() && !defn->IsStoreField() &&
@@ -1770,7 +1769,7 @@ bool ConstantPropagator::TransformDefinition(Definition* defn) {
17701769
ASSERT(!constant_value_.IsNull());
17711770
}
17721771
if (auto call = defn->AsStaticCall()) {
1773-
ASSERT(!call->HasPushArguments());
1772+
ASSERT(!call->HasMoveArguments());
17741773
}
17751774
Definition* replacement =
17761775
graph_->TryCreateConstantReplacementFor(defn, constant_value_);

runtime/vm/compiler/backend/flow_graph.cc

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void FlowGraph::ReplaceCurrentInstruction(ForwardInstructionIterator* iterator,
158158
}
159159
}
160160
if (current->ArgumentCount() != 0) {
161-
ASSERT(!current->HasPushArguments());
161+
ASSERT(!current->HasMoveArguments());
162162
}
163163
iterator->RemoveCurrentFromGraph();
164164
}
@@ -1558,7 +1558,7 @@ void FlowGraph::RenameRecursive(
15581558
break;
15591559
}
15601560

1561-
case Instruction::kPushArgument:
1561+
case Instruction::kMoveArgument:
15621562
UNREACHABLE();
15631563
break;
15641564

@@ -1628,7 +1628,7 @@ void FlowGraph::RenameRecursive(
16281628
// Rename input operand.
16291629
Definition* input = (*env)[i];
16301630
ASSERT(input != nullptr);
1631-
ASSERT(!input->IsPushArgument());
1631+
ASSERT(!input->IsMoveArgument());
16321632
Value* use = new (zone()) Value(input);
16331633
phi->SetInputAt(pred_index, use);
16341634
}
@@ -2414,7 +2414,7 @@ void FlowGraph::WidenSmiToInt32() {
24142414
if (use_defn == NULL) {
24152415
// We assume that tagging before returning or pushing argument costs
24162416
// very little compared to the cost of the return/call itself.
2417-
ASSERT(!instr->IsPushArgument());
2417+
ASSERT(!instr->IsMoveArgument());
24182418
if (!instr->IsReturn() &&
24192419
(use->use_index() >= instr->ArgumentCount())) {
24202420
gain--;
@@ -2998,7 +2998,7 @@ PhiInstr* FlowGraph::AddPhi(JoinEntryInstr* join,
29982998
return phi;
29992999
}
30003000

3001-
void FlowGraph::InsertPushArguments() {
3001+
void FlowGraph::InsertMoveArguments() {
30023002
intptr_t max_argument_slot_count = 0;
30033003
for (BlockIterator block_it = reverse_postorder_iterator(); !block_it.Done();
30043004
block_it.Advance()) {
@@ -3010,37 +3010,37 @@ void FlowGraph::InsertPushArguments() {
30103010
if (arg_count == 0) {
30113011
continue;
30123012
}
3013-
PushArgumentsArray* arguments =
3014-
new (Z) PushArgumentsArray(zone(), arg_count);
3013+
MoveArgumentsArray* arguments =
3014+
new (Z) MoveArgumentsArray(zone(), arg_count);
30153015
arguments->EnsureLength(arg_count, nullptr);
30163016

3017-
intptr_t top_of_stack_relative_index = 0;
3017+
intptr_t sp_relative_index = 0;
30183018
for (intptr_t i = arg_count - 1; i >= 0; --i) {
30193019
Value* arg = instruction->ArgumentValueAt(i);
30203020
const auto rep = instruction->RequiredInputRepresentation(i);
3021-
(*arguments)[i] = new (Z) PushArgumentInstr(
3022-
arg->CopyWithType(Z), rep, top_of_stack_relative_index);
3021+
(*arguments)[i] = new (Z)
3022+
MoveArgumentInstr(arg->CopyWithType(Z), rep, sp_relative_index);
30233023

30243024
static_assert(compiler::target::kIntSpillFactor ==
30253025
compiler::target::kDoubleSpillFactor,
30263026
"double and int are expected to be of the same size");
30273027
RELEASE_ASSERT(rep == kTagged || rep == kUnboxedDouble ||
30283028
rep == kUnboxedInt64);
3029-
top_of_stack_relative_index +=
3029+
sp_relative_index +=
30303030
(rep == kTagged) ? 1 : compiler::target::kIntSpillFactor;
30313031
}
30323032
max_argument_slot_count =
3033-
Utils::Maximum(max_argument_slot_count, top_of_stack_relative_index);
3033+
Utils::Maximum(max_argument_slot_count, sp_relative_index);
30343034

3035-
for (auto push_arg : *arguments) {
3036-
// Insert all PushArgument instructions immediately before call.
3037-
// PushArgumentInstr::EmitNativeCode may generate more efficient
3038-
// code for subsequent PushArgument instructions (ARM, ARM64).
3039-
InsertBefore(instruction, push_arg, /*env=*/nullptr, kEffect);
3035+
for (auto move_arg : *arguments) {
3036+
// Insert all MoveArgument instructions immediately before call.
3037+
// MoveArgumentInstr::EmitNativeCode may generate more efficient
3038+
// code for subsequent MoveArgument instructions (ARM, ARM64).
3039+
InsertBefore(instruction, move_arg, /*env=*/nullptr, kEffect);
30403040
}
3041-
instruction->ReplaceInputsWithPushArguments(arguments);
3041+
instruction->ReplaceInputsWithMoveArguments(arguments);
30423042
if (instruction->env() != nullptr) {
3043-
instruction->RepairPushArgsInEnvironment();
3043+
instruction->RepairArgumentUsesInEnvironment();
30443044
}
30453045
}
30463046
}

runtime/vm/compiler/backend/flow_graph.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,11 @@ class FlowGraph : public ZoneAllocated {
382382
// Remove the redefinition instructions inserted to inhibit code motion.
383383
void RemoveRedefinitions(bool keep_checks = false);
384384

385-
// Insert PushArgument instructions and remove explicit def-use
385+
// Insert MoveArgument instructions and remove explicit def-use
386386
// relations between calls and their arguments.
387387
//
388388
// Compute the maximum number of arguments.
389-
void InsertPushArguments();
389+
void InsertMoveArguments();
390390

391391
// Copy deoptimization target from one instruction to another if we still
392392
// have to keep deoptimization environment at gotos for LICM purposes.

runtime/vm/compiler/backend/flow_graph_checker.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ static void AssertArgumentsInEnv(FlowGraph* flow_graph, Definition* call) {
140140
ASSERT1((arg_count + after_args_input_count) <= env_count, call);
141141
const intptr_t env_base = env_count - arg_count - after_args_input_count;
142142
for (intptr_t i = 0; i < arg_count; i++) {
143-
if (call->HasPushArguments()) {
143+
if (call->HasMoveArguments()) {
144144
ASSERT1(call->ArgumentAt(i) == env->ValueAt(env_base + i)
145145
->definition()
146-
->AsPushArgument()
146+
->AsMoveArgument()
147147
->value()
148148
->definition(),
149149
call);

runtime/vm/compiler/backend/flow_graph_compiler.cc

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,16 @@ compiler::LRState ComputeInnerLRState(const FlowGraph& flow_graph) {
9595
}
9696
#endif
9797

98-
// Assign locations to incoming arguments, i.e., values pushed above spill slots
99-
// with PushArgument. Recursively allocates from outermost to innermost
100-
// environment.
101-
void CompilerDeoptInfo::AllocateIncomingParametersRecursive(Environment* env) {
98+
// Assign locations to outgoing arguments. Note that MoveArgument
99+
// can only occur in the innermost environment because we insert
100+
// them immediately before the call instruction and right before
101+
// register allocation.
102+
void CompilerDeoptInfo::AllocateOutgoingArguments(Environment* env) {
102103
if (env == NULL) return;
103-
AllocateIncomingParametersRecursive(env->outer());
104104
for (Environment::ShallowIterator it(env); !it.Done(); it.Advance()) {
105105
if (it.CurrentLocation().IsInvalid()) {
106-
if (auto push_arg = it.CurrentValue()->definition()->AsPushArgument()) {
107-
it.SetCurrentLocation(push_arg->locs()->out(0));
106+
if (auto move_arg = it.CurrentValue()->definition()->AsMoveArgument()) {
107+
it.SetCurrentLocation(move_arg->locs()->out(0));
108108
}
109109
}
110110
}
@@ -592,8 +592,7 @@ static bool IsPusher(Instruction* instr) {
592592
static bool IsPopper(Instruction* instr) {
593593
// TODO(ajcbik): even allow deopt targets by making environment aware?
594594
if (!instr->CanBecomeDeoptimizationTarget()) {
595-
return !instr->IsPushArgument() && instr->ArgumentCount() == 0 &&
596-
instr->InputCount() > 0;
595+
return instr->ArgumentCount() == 0 && instr->InputCount() > 0;
597596
}
598597
return false;
599598
}
@@ -1040,21 +1039,21 @@ void FlowGraphCompiler::RecordSafepoint(LocationSummary* locs,
10401039
RELEASE_ASSERT(args_count == 0 || is_optimizing());
10411040

10421041
for (intptr_t i = 0; i < args_count; i++) {
1043-
const auto push_arg =
1044-
instr->ArgumentValueAt(i)->instruction()->AsPushArgument();
1045-
const auto rep = push_arg->representation();
1042+
const auto move_arg =
1043+
instr->ArgumentValueAt(i)->instruction()->AsMoveArgument();
1044+
const auto rep = move_arg->representation();
10461045

10471046
ASSERT(rep == kTagged || rep == kUnboxedInt64 || rep == kUnboxedDouble);
10481047
static_assert(compiler::target::kIntSpillFactor ==
10491048
compiler::target::kDoubleSpillFactor,
10501049
"int and double are of the same size");
1051-
const bool is_tagged = push_arg->representation() == kTagged;
1050+
const bool is_tagged = move_arg->representation() == kTagged;
10521051
const intptr_t num_bits =
10531052
is_tagged ? 1 : compiler::target::kIntSpillFactor;
10541053

10551054
// Note: bits are reversed so higher bit corresponds to lower word.
10561055
const intptr_t last_arg_bit =
1057-
(spill_area_size - 1) - push_arg->top_of_stack_relative_index();
1056+
(spill_area_size - 1) - move_arg->sp_relative_index();
10581057
bitmap.SetRange(last_arg_bit - (num_bits - 1), last_arg_bit, is_tagged);
10591058
}
10601059
ASSERT(slow_path_argument_count == 0 || !using_shared_stub);
@@ -1731,7 +1730,7 @@ void FlowGraphCompiler::AllocateRegistersLocally(Instruction* instr) {
17311730
}
17321731

17331732
// Allocate all unallocated input locations.
1734-
RELEASE_ASSERT(!instr->IsPushArgument());
1733+
ASSERT(!instr->IsMoveArgument());
17351734
Register fpu_unboxing_temp = kNoRegister;
17361735
for (intptr_t i = locs->input_count() - 1; i >= 0; i--) {
17371736
Location loc = locs->in(i);
@@ -3292,10 +3291,6 @@ void FlowGraphCompiler::FrameStateUpdateWith(Instruction* instr) {
32923291
ASSERT(!is_optimizing());
32933292

32943293
switch (instr->tag()) {
3295-
case Instruction::kPushArgument:
3296-
// Do nothing.
3297-
break;
3298-
32993294
case Instruction::kDropTemps:
33003295
FrameStatePop(instr->locs()->input_count() +
33013296
instr->AsDropTemps()->num_temps());

runtime/vm/compiler/backend/flow_graph_compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class CompilerDeoptInfo : public ZoneAllocated {
199199
private:
200200
void EmitMaterializations(Environment* env, DeoptInfoBuilder* builder);
201201

202-
void AllocateIncomingParametersRecursive(Environment* env);
202+
void AllocateOutgoingArguments(Environment* env);
203203

204204
intptr_t pc_offset_;
205205
const intptr_t deopt_id_;

runtime/vm/compiler/backend/flow_graph_compiler_arm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ TypedDataPtr CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler,
9898
return TypedData::null();
9999
}
100100

101-
AllocateIncomingParametersRecursive(deopt_env_);
101+
AllocateOutgoingArguments(deopt_env_);
102102

103103
intptr_t slot_ix = 0;
104104
Environment* current = deopt_env_;

runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ TypedDataPtr CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler,
9292
return TypedData::null();
9393
}
9494

95-
AllocateIncomingParametersRecursive(deopt_env_);
95+
AllocateOutgoingArguments(deopt_env_);
9696

9797
intptr_t slot_ix = 0;
9898
Environment* current = deopt_env_;

runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ TypedDataPtr CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler,
7070
return TypedData::null();
7171
}
7272

73-
AllocateIncomingParametersRecursive(deopt_env_);
73+
AllocateOutgoingArguments(deopt_env_);
7474

7575
intptr_t slot_ix = 0;
7676
Environment* current = deopt_env_;

runtime/vm/compiler/backend/flow_graph_compiler_riscv.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ TypedDataPtr CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler,
7979
return TypedData::null();
8080
}
8181

82-
AllocateIncomingParametersRecursive(deopt_env_);
82+
AllocateOutgoingArguments(deopt_env_);
8383

8484
intptr_t slot_ix = 0;
8585
Environment* current = deopt_env_;

runtime/vm/compiler/backend/flow_graph_compiler_x64.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ TypedDataPtr CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler,
9393
return TypedData::null();
9494
}
9595

96-
AllocateIncomingParametersRecursive(deopt_env_);
96+
AllocateOutgoingArguments(deopt_env_);
9797

9898
intptr_t slot_ix = 0;
9999
Environment* current = deopt_env_;

runtime/vm/compiler/backend/il.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,18 +1475,18 @@ void Instruction::UnuseAllInputs() {
14751475
}
14761476
}
14771477

1478-
void Instruction::RepairPushArgsInEnvironment() const {
1478+
void Instruction::RepairArgumentUsesInEnvironment() const {
14791479
// Some calls (e.g. closure calls) have more inputs than actual arguments.
14801480
// Those extra inputs will be consumed from the stack before the call.
14811481
const intptr_t after_args_input_count = env()->LazyDeoptPruneCount();
1482-
PushArgumentsArray* push_arguments = GetPushArguments();
1483-
ASSERT(push_arguments != nullptr);
1482+
MoveArgumentsArray* move_arguments = GetMoveArguments();
1483+
ASSERT(move_arguments != nullptr);
14841484
const intptr_t arg_count = ArgumentCount();
14851485
ASSERT((arg_count + after_args_input_count) <= env()->Length());
14861486
const intptr_t env_base =
14871487
env()->Length() - arg_count - after_args_input_count;
14881488
for (intptr_t i = 0; i < arg_count; ++i) {
1489-
env()->ValueAt(env_base + i)->BindToEnvironment(push_arguments->At(i));
1489+
env()->ValueAt(env_base + i)->BindToEnvironment(move_arguments->At(i));
14901490
}
14911491
}
14921492

0 commit comments

Comments
 (0)