changeset 10919:c4390912be8a

8248336: AArch64: C2: offset overflow in BoxLockNode::emit Reviewed-by: adinn
author aph
date Thu, 25 Jun 2020 12:24:50 -0400
parents 631ce052d827
children a435c913c8ce
files src/cpu/aarch64/vm/aarch64.ad
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/aarch64/vm/aarch64.ad	Mon Mar 16 10:51:01 2020 +0800
+++ b/src/cpu/aarch64/vm/aarch64.ad	Thu Jun 25 12:24:50 2020 -0400
@@ -1824,16 +1824,20 @@
   int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
   int reg    = ra_->get_encode(this);
 
-  if (Assembler::operand_valid_for_add_sub_immediate(offset)) {
-    __ add(as_Register(reg), sp, offset);
-  } else {
-    ShouldNotReachHere();
-  }
+  // This add will handle any 24-bit signed offset. 24 bits allows an
+  // 8 megabyte stack frame.
+  __ add(as_Register(reg), sp, offset);
 }
 
 uint BoxLockNode::size(PhaseRegAlloc *ra_) const {
   // BoxLockNode is not a MachNode, so we can't just call MachNode::size(ra_).
-  return 4;
+  int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
+
+  if (Assembler::operand_valid_for_add_sub_immediate(offset)) {
+    return NativeInstruction::instruction_size;
+  } else {
+    return 2 * NativeInstruction::instruction_size;
+  }
 }
 
 //=============================================================================