From: Alexei Zavjalov Date: Wed, 30 Jul 2014 12:31:04 +0000 (+0700) Subject: ART: LoadConstWide should clobber temp reg X-Git-Tag: android-x86-7.1-r1~889^2~3445^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=54659e3a2c83d3949957a10436e55e525a430a15;p=android-x86%2Fart.git ART: LoadConstWide should clobber temp reg If we have 2+ LoadConstWide(FP) calls in one method it is possible that LoadConstWide will load the method poiner only once. In some cases, for example, if we have branches, initialization might not be done and it may lead to a segmentation fault. Change-Id: If45fc2d1109d7ce9bd272f5c56446b2a6884daac Signed-off-by: Alexei Zavjalov --- diff --git a/compiler/dex/quick/x86/utility_x86.cc b/compiler/dex/quick/x86/utility_x86.cc index ccffe5bf6..a77d79e56 100644 --- a/compiler/dex/quick/x86/utility_x86.cc +++ b/compiler/dex/quick/x86/utility_x86.cc @@ -591,6 +591,7 @@ LIR* X86Mir2Lir::LoadConstantWide(RegStorage r_dest, int64_t value) { kDouble, kNotVolatile); res->target = data_target; res->flags.fixup = kFixupLoad; + Clobber(rl_method.reg); store_method_addr_used_ = true; } else { if (val_lo == 0) { diff --git a/test/083-compiler-regressions/expected.txt b/test/083-compiler-regressions/expected.txt index 9f57dbd75..f8d92cc22 100644 --- a/test/083-compiler-regressions/expected.txt +++ b/test/083-compiler-regressions/expected.txt @@ -37,3 +37,4 @@ ManyFloatArgs passes atomicLong passes LiveFlags passes trip 3 LiveFlags passes trip 1 +minDoubleWith3ConstsTest passes diff --git a/test/083-compiler-regressions/src/Main.java b/test/083-compiler-regressions/src/Main.java index 748b0dee5..c089c527a 100644 --- a/test/083-compiler-regressions/src/Main.java +++ b/test/083-compiler-regressions/src/Main.java @@ -58,6 +58,21 @@ public class Main { ManyFloatArgs(); atomicLong(); LiveFlags.test(); + minDoubleWith3ConstsTest(); + } + + public static double minDouble(double a, double b, double c) { + return Math.min(Math.min(a, b), c); + } + + public static void minDoubleWith3ConstsTest() { + double result = minDouble(1.2, 2.5, Double.NaN); + if (Double.isNaN(result)) { + System.out.println("minDoubleWith3ConstsTest passes"); + } else { + System.out.println("minDoubleWith3ConstsTest fails: " + result + + " (expecting NaN)"); + } } public static void atomicLong() {