8202705: ARM32 build crashes on long JavaThread offsets
authordsamersoff
Sun, 10 Jun 2018 12:58:38 +0300
changeset 50499 65e65d5905bc
parent 50498 6c12c0bf0962
child 50500 ade54c345982
child 56719 a846e7bbcdfa
child 56721 01b558efd286
child 56723 d927981eeb64
child 56726 3a9b7a1f9197
8202705: ARM32 build crashes on long JavaThread offsets Summary: Account extra bytes at the beginning of JavaThread Reviewed-by: shade, roland, dsamersoff Contributed-by: boris.ulasevich@bell-sw.com
src/hotspot/cpu/arm/macroAssembler_arm.cpp
--- a/src/hotspot/cpu/arm/macroAssembler_arm.cpp	Sat Jun 09 20:57:43 2018 -0700
+++ b/src/hotspot/cpu/arm/macroAssembler_arm.cpp	Sun Jun 10 12:58:38 2018 +0300
@@ -1367,9 +1367,12 @@
   // Bump total bytes allocated by this thread
   Label done;
 
-  ldr(tmp, Address(Rthread, in_bytes(JavaThread::allocated_bytes_offset())));
+  // Borrow the Rthread for alloc counter
+  Register Ralloc = Rthread;
+  add(Ralloc, Ralloc, in_bytes(JavaThread::allocated_bytes_offset()));
+  ldr(tmp, Address(Ralloc));
   adds(tmp, tmp, size_in_bytes);
-  str(tmp, Address(Rthread, in_bytes(JavaThread::allocated_bytes_offset())), cc);
+  str(tmp, Address(Ralloc), cc);
   b(done, cc);
 
   // Increment the high word and store single-copy atomically (that is an unlikely scenario on typical embedded systems as it means >4GB has been allocated)
@@ -1387,14 +1390,17 @@
   }
   push(RegisterSet(low, high));
 
-  ldrd(low, Address(Rthread, in_bytes(JavaThread::allocated_bytes_offset())));
+  ldrd(low, Address(Ralloc));
   adds(low, low, size_in_bytes);
   adc(high, high, 0);
-  strd(low, Address(Rthread, in_bytes(JavaThread::allocated_bytes_offset())));
+  strd(low, Address(Ralloc));
 
   pop(RegisterSet(low, high));
 
   bind(done);
+
+  // Unborrow the Rthread
+  sub(Rthread, Ralloc, in_bytes(JavaThread::allocated_bytes_offset()));
 #endif // AARCH64
 }