[aarch64-port-dev ] Fix overflow with large page sizes
Andrew Haley
aph at redhat.com
Fri Jul 26 04:07:45 PDT 2013
With large page sizes a calculation overflows the immediate
field size. Fixed thusly.
Andrew.
# HG changeset patch
# User aph
# Date 1374835632 -3600
# Node ID cdd6408be9aa2c1617fd48ba800b8317d28cea28
# Parent d9453f3218eefad8a982bb928bbdfcbc727cb2b0
Fix overflow with large page sizes.
diff -r d9453f3218ee -r cdd6408be9aa src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
--- a/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp Thu Jul 25 18:31:25 2013 +0100
+++ b/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp Fri Jul 26 11:47:12 2013 +0100
@@ -1517,7 +1517,7 @@
}
// If a constant does not fit in an immediate field, generate some
-// number of MOV instructions and then perform the operation
+// number of MOV instructions and then perform the operation.
void MacroAssembler::wrap_add_sub_imm_insn(Register Rd, Register Rn, unsigned imm,
add_sub_imm_insn insn1,
add_sub_reg_insn insn2) {
@@ -1525,6 +1525,7 @@
(this->*insn1)(Rd, Rn, imm);
} else {
assert_different_registers(Rd, Rn);
+ assert(Rd != zr, "overflow in immediate operand");
mov(Rd, (uint64_t)imm);
(this->*insn2)(Rd, Rn, Rd, LSL, 0);
}
diff -r d9453f3218ee -r cdd6408be9aa src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp
--- a/src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp Thu Jul 25 18:31:25 2013 +0100
+++ b/src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp Fri Jul 26 11:47:12 2013 +0100
@@ -474,7 +474,12 @@
// see if the frame is greater than one page in size. If so,
// then we need to verify there is enough stack space remaining
// for the additional locals.
- __ cmp(r3, (page_size - overhead_size) / Interpreter::stackElementSize);
+ //
+ // Note that we use SUBS rather than CMP here because the immediate
+ // field of this instruction may overflow. SUBS can cope with this
+ // because it is a macro that will expand to some number of MOV
+ // instructions and a register operation.
+ __ subs(rscratch1, r3, (page_size - overhead_size) / Interpreter::stackElementSize);
__ br(Assembler::LS, after_frame_check);
// compute rsp as if this were going to be the last frame on
More information about the aarch64-port-dev
mailing list