changeset 11728:fbd5edf4d6e3

8161190: AArch64: Fix overflow in immediate cmp instruction Summary: Use subs instead of cmp to compare BlockZeroingLowLimit. Subs can check and handle immediate out of range correctly. Reviewed-by: aph Contributed-by: yang.zhang@linaro.org
author aph
date Fri, 22 Jul 2016 17:05:08 +0100
parents b029389f5ede
children 2f5e85b2a1c1
files src/cpu/aarch64/vm/macroAssembler_aarch64.cpp src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
diffstat 2 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp	Wed Jul 20 19:35:08 2016 +0300
+++ b/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp	Fri Jul 22 17:05:08 2016 +0100
@@ -4916,7 +4916,7 @@
   // alignment.
   if (!is_large || !(BlockZeroingLowLimit >= zva_length * 2)) {
     int low_limit = MAX2(zva_length * 2, (int)BlockZeroingLowLimit);
-    cmp(cnt, low_limit >> 3);
+    subs(tmp, cnt, low_limit >> 3);
     br(Assembler::LT, small);
   }
 
--- a/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Wed Jul 20 19:35:08 2016 +0300
+++ b/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Fri Jul 22 17:05:08 2016 +0100
@@ -2346,8 +2346,9 @@
     __ subw(count, count, cnt_words, Assembler::LSL, 3 - shift);
     if (UseBlockZeroing) {
       Label non_block_zeroing, rest;
+      Register tmp = rscratch1;
       // count >= BlockZeroingLowLimit && value == 0
-      __ cmp(cnt_words, BlockZeroingLowLimit >> 3);
+      __ subs(tmp, cnt_words, BlockZeroingLowLimit >> 3);
       __ ccmp(value, 0 /* comparing value */, 0 /* NZCV */, Assembler::GE);
       __ br(Assembler::NE, non_block_zeroing);
       __ mov(bz_base, to);