Skip to content

Commit

Permalink
ARM: Don't generate memory instructions with writeback where the data…
Browse files Browse the repository at this point in the history
… and address registers are the same.

BUG=http://dartbug.com/24855
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1434323003 .
  • Loading branch information
rmacnak-google committed Nov 13, 2015
1 parent 974b461 commit c315da5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions runtime/vm/assembler_arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ void Assembler::EmitMemOp(Condition cond,
Address ad) {
ASSERT(rd != kNoRegister);
ASSERT(cond != kNoCondition);
ASSERT(!ad.has_writeback() || (ad.rn() != rd)); // Unpredictable.

int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) |
B26 | (ad.kind() == Address::Immediate ? 0 : B25) |
(load ? L : 0) |
Expand Down
5 changes: 5 additions & 0 deletions runtime/vm/assembler_arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ class Address : public ValueObject {

Mode mode() const { return static_cast<Mode>(encoding() & kModeMask); }

bool has_writeback() const {
return (mode() == PreIndex) || (mode() == PostIndex) ||
(mode() == NegPreIndex) || (mode() == NegPostIndex);
}

uint32_t encoding() const { return encoding_; }

// Encoding for addressing mode 3.
Expand Down
3 changes: 3 additions & 0 deletions runtime/vm/simulator_arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1996,6 +1996,7 @@ void Simulator::DecodeType01(Instr* instr) {
HandleIllegalAccess(addr, instr);
} else {
if (write_back) {
ASSERT(rd != rn); // Unpredictable.
set_register(rn, rn_val);
}
if (!instr->HasSign()) {
Expand Down Expand Up @@ -2312,6 +2313,7 @@ void Simulator::DecodeType2(Instr* instr) {
HandleIllegalAccess(addr, instr);
} else {
if (write_back) {
ASSERT(rd != rn); // Unpredictable.
set_register(rn, rn_val);
}
if (instr->HasB()) {
Expand Down Expand Up @@ -2424,6 +2426,7 @@ void Simulator::DecodeType3(Instr* instr) {
HandleIllegalAccess(addr, instr);
} else {
if (write_back) {
ASSERT(rd != rn); // Unpredictable.
set_register(rn, rn_val);
}
if (instr->HasB()) {
Expand Down
8 changes: 7 additions & 1 deletion runtime/vm/stub_code_arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ static void GenerateDeoptimizationSequence(Assembler* assembler,
__ eor(IP, IP, Operand(LR));

// Set up the frame manually with return address now stored in IP.
COMPILE_ASSERT(PP < CODE_REG);
COMPILE_ASSERT(CODE_REG < FP);
COMPILE_ASSERT(FP < IP);
__ EnterFrame((1 << PP) | (1 << CODE_REG) | (1 << FP) | (1 << IP), 0);
__ LoadPoolPointer();

Expand All @@ -434,9 +437,12 @@ static void GenerateDeoptimizationSequence(Assembler* assembler,
if (i == CODE_REG) {
// Save the original value of CODE_REG pushed before invoking this stub
// instead of the value used to call this stub.
COMPILE_ASSERT(IP > CODE_REG); // Assert IP is pushed first.
__ ldr(IP, Address(FP, kCallerSpSlotFromFp * kWordSize));
__ Push(IP);
} else if (i == SP) {
// Push(SP) has unpredictable behavior.
__ mov(IP, Operand(SP));
__ Push(IP);
} else {
__ Push(static_cast<Register>(i));
}
Expand Down

0 comments on commit c315da5

Please sign in to comment.