[aarch64-port-dev ] Fix to addmw

Edward Nevill ed at camswl.com
Fri Dec 27 03:18:51 PST 2013


Hi,

addmw immediate currently does

void addmw(Address a, int imm, Register scratch) {
    lea(scratch, a);
    ldrw(scratch, Address(scratch));
     if (imm > 0)
       addw(scratch, scratch, (unsigned)imm);
     else
       subw(scratch, scratch, (unsigned)-imm);
    lea(scratch, a);
    strw(scratch, Address(scratch));  /// <<<< Write address into itself
}

Unfortunately this does not have the desired effect, but instead writes the address of the memory word into itself.

I have fixed this by changing it to

void addmw(Address a, int imm, Register scratch) {
    ldrw(scratch, a);
     if (imm > 0)
       addw(scratch, scratch, (unsigned)imm);
     else
       subw(scratch, scratch, (unsigned)-imm);
    strw(scratch, a);
}

and changing the one occurrence where the lea was necessary from

    addmw(ExternalAddress((address)BiasedLocking::fast_path_entry_count_addr()),
         1, rscratch1);

to

    lea(rscratch2, ExternalAddress((address)BiasedLocking::fast_path_entry_count_addr()));
    addmw(Address(rscratch2, 0), 1, rscratch1);

Ed.

--- CUT HERE ---
# HG changeset patch
# User Edward Nevill edward.nevill at linaro.org
# Date 1388142252 0
#      Fri Dec 27 11:04:12 2013 +0000
# Node ID 2c66dde8d44bec38098017a8c910d8ffac477131
# Parent  02c45d47419fd90ba13c74595218d50917b4fa40
Fix addmw

diff -r 02c45d47419f -r 2c66dde8d44b src/cpu/aarch64/vm/c1_MacroAssembler_aarch64.cpp
--- a/src/cpu/aarch64/vm/c1_MacroAssembler_aarch64.cpp  Mon Dec 23 12:59:40 2013 +0000
+++ b/src/cpu/aarch64/vm/c1_MacroAssembler_aarch64.cpp  Fri Dec 27 11:04:12 2013 +0000
@@ -122,8 +122,8 @@
   // done
   bind(done);
   if (PrintBiasedLockingStatistics) {
-    addmw(ExternalAddress((address)BiasedLocking::fast_path_entry_count_addr()),
-         1, rscratch1);
+    lea(rscratch2, ExternalAddress((address)BiasedLocking::fast_path_entry_count_addr()));
+    addmw(Address(rscratch2, 0), 1, rscratch1);
   }
   return null_check_offset;
 }
diff -r 02c45d47419f -r 2c66dde8d44b src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
--- a/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp     Mon Dec 23 12:59:40 2013 +0000
+++ b/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp     Fri Dec 27 11:04:12 2013 +0000
@@ -143,14 +143,12 @@
 
   // Add constant to memory word
   void addmw(Address a, int imm, Register scratch) {
-    lea(scratch, a);
-    ldrw(scratch, Address(scratch));
+    ldrw(scratch, a);
     if (imm > 0)
       addw(scratch, scratch, (unsigned)imm);
     else
       subw(scratch, scratch, (unsigned)-imm);
-    lea(scratch, a);
-    strw(scratch, Address(scratch));
+    strw(scratch, a);
   }
 
   virtual void _call_Unimplemented(address call_site) {
--- CUT HERE ---




More information about the aarch64-port-dev mailing list