Skip to content

Commit 78d9a28

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
[vm, arm] Globally block LR for register allocation.
Flutter Gallery release: Instructions(CodeSize): 5668368 -> 5670880 (+0.044%) Fixes #34411 Bug: #34411 Change-Id: I5281ac9609ec5953cdaa881226f7034a5697d0ce Reviewed-on: https://dart-review.googlesource.com/74923 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
1 parent 078be2c commit 78d9a28

File tree

6 files changed

+10
-56
lines changed

6 files changed

+10
-56
lines changed

runtime/vm/compiler/assembler/assembler_arm.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,7 +3068,7 @@ void Assembler::ReserveAlignedFrameSpace(intptr_t frame_space) {
30683068
void Assembler::EnterCallRuntimeFrame(intptr_t frame_space) {
30693069
Comment("EnterCallRuntimeFrame");
30703070
// Preserve volatile CPU registers and PP.
3071-
EnterFrame(kDartVolatileCpuRegs | (1 << PP) | (1 << FP), 0);
3071+
EnterFrame(kDartVolatileCpuRegs | (1 << PP) | (1 << FP) | (1 << LR), 0);
30723072
COMPILE_ASSERT((kDartVolatileCpuRegs & (1 << PP)) == 0);
30733073

30743074
// Preserve all volatile FPU registers.
@@ -3120,7 +3120,7 @@ void Assembler::LeaveCallRuntimeFrame() {
31203120
}
31213121

31223122
// Restore volatile CPU registers.
3123-
LeaveFrame(kDartVolatileCpuRegs | (1 << PP) | (1 << FP));
3123+
LeaveFrame(kDartVolatileCpuRegs | (1 << PP) | (1 << FP) | (1 << LR));
31243124
}
31253125

31263126
void Assembler::CallRuntime(const RuntimeEntry& entry,

runtime/vm/compiler/backend/flow_graph_compiler_arm.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,8 @@ void CompilerDeoptInfoWithStub::GenerateCode(FlowGraphCompiler* compiler,
169169

170170
ASSERT(deopt_env() != NULL);
171171

172-
// LR may be live. It will be clobbered by BranchLink, so cache it in IP.
173-
// It will be restored at the top of the deoptimization stub, specifically in
174-
// GenerateDeoptimizationSequence in stub_code_arm.cc.
175172
__ Push(CODE_REG);
176-
__ mov(IP, Operand(LR));
173+
ASSERT(kReservedCpuRegisters & (1 << LR));
177174
__ BranchLink(*StubCode::Deoptimize_entry());
178175
set_pc_offset(assembler->CodeSize());
179176
#undef __

runtime/vm/compiler/backend/il_arm.cc

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,9 +1492,6 @@ LocationSummary* StoreIndexedInstr::MakeLocationSummary(Zone* zone,
14921492

14931493
bool needs_base = false;
14941494
intptr_t kNumTemps = 0;
1495-
if (ShouldEmitStoreBarrier()) {
1496-
kNumTemps += 1; // Block LR for the store barrier.
1497-
}
14981495
if (CanBeImmediateIndex(index(), class_id(), IsExternal(),
14991496
false, // Store.
15001497
&needs_base)) {
@@ -1562,10 +1559,6 @@ LocationSummary* StoreIndexedInstr::MakeLocationSummary(Zone* zone,
15621559
return NULL;
15631560
}
15641561

1565-
if (ShouldEmitStoreBarrier()) {
1566-
locs->set_temp(kNumTemps - 1, Location::RegisterLocation(LR));
1567-
}
1568-
15691562
return locs;
15701563
}
15711564

@@ -2196,8 +2189,7 @@ LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Zone* zone,
21962189
bool opt) const {
21972190
const intptr_t kNumInputs = 2;
21982191
const intptr_t kNumTemps =
2199-
((IsUnboxedStore() && opt) ? 2 : ((IsPotentialUnboxedStore()) ? 3 : 0)) +
2200-
(ShouldEmitStoreBarrier() ? 1 : 0); // Block LR for the store barrier.
2192+
((IsUnboxedStore() && opt) ? 2 : ((IsPotentialUnboxedStore()) ? 3 : 0));
22012193
LocationSummary* summary = new (zone)
22022194
LocationSummary(zone, kNumInputs, kNumTemps,
22032195
((IsUnboxedStore() && opt && is_initialization()) ||
@@ -2228,9 +2220,6 @@ LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Zone* zone,
22282220
: Location::RegisterOrConstant(value()));
22292221
#endif
22302222
}
2231-
if (ShouldEmitStoreBarrier()) {
2232-
summary->set_temp(kNumTemps - 1, Location::RegisterLocation(LR));
2233-
}
22342223
return summary;
22352224
}
22362225

@@ -2433,8 +2422,7 @@ void LoadStaticFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
24332422
LocationSummary* StoreStaticFieldInstr::MakeLocationSummary(Zone* zone,
24342423
bool opt) const {
24352424
const intptr_t kNumInputs = 1;
2436-
const intptr_t kNumTemps =
2437-
value()->NeedsWriteBarrier() ? 2 : 1; // Block LR for the store barrier.
2425+
const intptr_t kNumTemps = 1;
24382426
LocationSummary* locs = new (zone)
24392427
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kNoCall);
24402428
#if defined(CONCURRENT_MARKING)
@@ -2444,9 +2432,6 @@ LocationSummary* StoreStaticFieldInstr::MakeLocationSummary(Zone* zone,
24442432
: Location::RequiresRegister());
24452433
#endif
24462434
locs->set_temp(0, Location::RequiresRegister());
2447-
if (value()->NeedsWriteBarrier()) {
2448-
locs->set_temp(kNumTemps - 1, Location::RegisterLocation(LR));
2449-
}
24502435
return locs;
24512436
}
24522437

@@ -3063,8 +3048,7 @@ class CheckStackOverflowSlowPath
30633048
? Thread::stack_overflow_shared_with_fpu_regs_entry_point_offset()
30643049
: Thread::
30653050
stack_overflow_shared_without_fpu_regs_entry_point_offset();
3066-
ASSERT(instruction()->locs()->temp(1).IsRegister() &&
3067-
instruction()->locs()->temp(1).reg() == LR);
3051+
ASSERT(kReservedCpuRegisters & (1 << LR));
30683052
__ ldr(LR, Address(THR, entry_point_offset));
30693053
__ blx(LR);
30703054
compiler->RecordSafepoint(instruction()->locs(), kNumSlowPathArgs);

runtime/vm/compiler/backend/locations.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ LocationSummary::LocationSummary(Zone* zone,
2828
intptr_t temp_count,
2929
LocationSummary::ContainsCall contains_call)
3030
: num_inputs_(input_count),
31-
#if defined(TARGET_ARCH_ARM)
32-
num_temps_(temp_count + (contains_call == kCallOnSharedSlowPath ? 1 : 0)),
33-
#else
3431
num_temps_(temp_count),
35-
#endif
3632
stack_bitmap_(NULL),
3733
contains_call_(contains_call),
3834
live_registers_() {
@@ -41,14 +37,6 @@ LocationSummary::LocationSummary(Zone* zone,
4137
#endif
4238
input_locations_ = zone->Alloc<Location>(num_inputs_);
4339
temp_locations_ = zone->Alloc<Location>(num_temps_);
44-
45-
#if defined(TARGET_ARCH_ARM)
46-
if (contains_call == kCallOnSharedSlowPath) {
47-
// TODO(sjindel): Mitigate the negative effect on the fast-path of blocking
48-
// LR.
49-
set_temp(temp_count, Location::RegisterLocation(LR));
50-
}
51-
#endif
5240
}
5341

5442
LocationSummary* LocationSummary::Make(

runtime/vm/constants_arm.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,12 @@ const QRegister kAbiLastPreservedFpuReg = Q7;
306306
const int kAbiPreservedFpuRegCount = 4;
307307

308308
const RegList kReservedCpuRegisters = (1 << SPREG) | (1 << FPREG) | (1 << TMP) |
309-
(1 << PP) | (1 << THR) | (1 << PC);
309+
(1 << PP) | (1 << THR) | (1 << LR) |
310+
(1 << PC);
310311
// CPU registers available to Dart allocator.
311312
constexpr RegList kDartAvailableCpuRegs =
312313
kAllCpuRegistersList & ~kReservedCpuRegisters;
313-
constexpr int kNumberOfDartAvailableCpuRegs = kNumberOfCpuRegisters - 6;
314+
constexpr int kNumberOfDartAvailableCpuRegs = kNumberOfCpuRegisters - 7;
314315
const intptr_t kStoreBufferWrapperSize = 24;
315316
// Registers available to Dart that are not preserved by runtime calls.
316317
const RegList kDartVolatileCpuRegs =

runtime/vm/stub_code_arm.cc

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ void StubCode::GenerateSharedStub(Assembler* assembler,
121121

122122
// We want the saved registers to appear like part of the caller's frame, so
123123
// we push them before calling EnterStubFrame.
124-
//
125-
// TODO(sjindel): We could skip saving LR (and thus remove one bit from the
126-
// stackmap of the callsite), but this would add ARM-specific complexity to
127-
// FlowGraphCompiler::RecordSafepoint and
128-
// FlowGraphCompiler::SlowPathEnvironmentFor.
129124
RegisterSet all_registers;
130125
all_registers.AddAllNonReservedRegisters(save_fpu_registers);
131126
__ PushRegisters(all_registers);
@@ -506,18 +501,7 @@ static void GenerateDeoptimizationSequence(Assembler* assembler,
506501
DeoptStubKind kind) {
507502
// DeoptimizeCopyFrame expects a Dart frame, i.e. EnterDartFrame(0), but there
508503
// is no need to set the correct PC marker or load PP, since they get patched.
509-
510-
// IP has the potentially live LR value. LR was clobbered by the call with
511-
// the return address, so move it into IP to set up the Dart frame.
512-
__ eor(IP, IP, Operand(LR));
513-
__ eor(LR, IP, Operand(LR));
514-
__ eor(IP, IP, Operand(LR));
515-
516-
// Set up the frame manually with return address now stored in IP.
517-
COMPILE_ASSERT(PP < CODE_REG);
518-
COMPILE_ASSERT(CODE_REG < FP);
519-
COMPILE_ASSERT(FP < IP);
520-
__ EnterFrame((1 << PP) | (1 << CODE_REG) | (1 << FP) | (1 << IP), 0);
504+
__ EnterDartFrame(0);
521505
__ LoadPoolPointer();
522506

523507
// The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry

0 commit comments

Comments
 (0)