[aarch64-port-dev ] Fix out-of-range operand in tableswitch

Andrew Haley aph at redhat.com
Mon Jul 22 07:18:17 PDT 2013


There are occasional days when I really don't like this architecture.  This
is one of them.

Andrew.


changeset:   4758:53c82d8e3b68
tag:         tip
user:        aph
date:        Mon Jul 22 15:16:58 2013 +0100
summary:     Fix out-of-range operand in tableswitch

diff -r 3234a13a8273 -r 53c82d8e3b68 src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
--- a/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp	Mon Jul 22 12:38:52 2013 +0100
+++ b/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp	Mon Jul 22 15:16:58 2013 +0100
@@ -1218,11 +1218,22 @@
   void repne_scanw(Register addr, Register value, Register count,
 		   Register scratch);

+  // SUBSW with an arbitrary integer operand
+  void adjsw(Register Rd, Register Rn, jint imm) {
+    if (operand_valid_for_add_sub_immediate(imm)) {
+      subsw(Rd, Rn, imm);
+    } else {
+      assert_different_registers(Rd, Rn);
+      movw(Rd, imm);
+      subsw(Rd, Rn, Rd);
+    }
+  }
+
   void tableswitch(Register index, jint lowbound, jint highbound,
 		   Label &jumptable, Label &jumptable_end) {
     adr(rscratch1, jumptable);
-    subw(rscratch2, index, lowbound);
-    cmpw(rscratch2, highbound - lowbound);
+    adjsw(rscratch2, index, lowbound);
+    adjsw(zr, rscratch2, highbound - lowbound);
     br(Assembler::HS, jumptable_end);
     add(rscratch1, rscratch1, rscratch2, ext::sxtw, 2);
     br(rscratch1);




More information about the aarch64-port-dev mailing list