8214189: test/hotspot/jtreg/compiler/intrinsics/mathexact/MulExactLConstantTest.java fails on Windows x64 when run with -XX:-TieredCompilation
authorroland
Mon, 26 Nov 2018 17:35:35 +0100
changeset 52693 0037ea3c7322
parent 52692 bffef37beacb
child 52694 93afbb11063b
8214189: test/hotspot/jtreg/compiler/intrinsics/mathexact/MulExactLConstantTest.java fails on Windows x64 when run with -XX:-TieredCompilation Reviewed-by: kvn
src/hotspot/share/opto/mulnode.cpp
src/hotspot/share/utilities/globalDefinitions.hpp
test/hotspot/jtreg/ProblemList.txt
test/hotspot/jtreg/compiler/integerArithmetic/MultiplyByConstantLongMax.java
--- a/src/hotspot/share/opto/mulnode.cpp	Mon Nov 26 22:49:57 2018 -0800
+++ b/src/hotspot/share/opto/mulnode.cpp	Mon Nov 26 17:35:35 2018 +0100
@@ -286,20 +286,20 @@
 
   // Check for negative constant; if so negate the final result
   bool sign_flip = false;
-  unsigned long abs_con = uabs(con);
-  if (abs_con != (unsigned long)con) {
+  julong abs_con = uabs(con);
+  if (abs_con != (julong)con) {
     sign_flip = true;
   }
 
   // Get low bit; check for being the only bit
   Node *res = NULL;
-  unsigned long bit1 = abs_con & (0-abs_con);      // Extract low bit
+  julong bit1 = abs_con & (0-abs_con);      // Extract low bit
   if (bit1 == abs_con) {           // Found a power of 2?
     res = new LShiftLNode(in(1), phase->intcon(log2_long(bit1)));
   } else {
 
     // Check for constant with 2 bits set
-    unsigned long bit2 = abs_con-bit1;
+    julong bit2 = abs_con-bit1;
     bit2 = bit2 & (0-bit2);          // Extract 2nd bit
     if (bit2 + bit1 == abs_con) {    // Found all bits in con?
       Node *n1 = phase->transform(new LShiftLNode(in(1), phase->intcon(log2_long(bit1))));
@@ -308,7 +308,7 @@
 
     } else if (is_power_of_2_long(abs_con+1)) {
       // Sleezy: power-of-2 -1.  Next time be generic.
-      unsigned long temp = abs_con + 1;
+      julong temp = abs_con + 1;
       Node *n1 = phase->transform( new LShiftLNode(in(1), phase->intcon(log2_long(temp))));
       res = new SubLNode(n1, in(1));
     } else {
--- a/src/hotspot/share/utilities/globalDefinitions.hpp	Mon Nov 26 22:49:57 2018 -0800
+++ b/src/hotspot/share/utilities/globalDefinitions.hpp	Mon Nov 26 17:35:35 2018 +0100
@@ -1110,16 +1110,16 @@
   if (value < 0) result = 0-result;
   return result;
 }
-static inline unsigned long uabs(unsigned long n) {
+static inline julong uabs(julong n) {
   union {
-    unsigned long result;
-    long value;
+    julong result;
+    jlong value;
   };
   result = n;
   if (value < 0) result = 0-result;
   return result;
 }
-static inline unsigned long uabs(jlong n) { return uabs((unsigned long)n); }
+static inline julong uabs(jlong n) { return uabs((julong)n); }
 static inline unsigned int uabs(int n) { return uabs((unsigned int)n); }
 
 // "to" should be greater than "from."
--- a/test/hotspot/jtreg/ProblemList.txt	Mon Nov 26 22:49:57 2018 -0800
+++ b/test/hotspot/jtreg/ProblemList.txt	Mon Nov 26 17:35:35 2018 +0100
@@ -61,8 +61,6 @@
 
 compiler/runtime/Test8168712.java 8211769,8211771 generic-ppc64,generic-ppc64le,linux-s390x
 
-compiler/intrinsics/mathexact/MulExactLConstantTest.java 8214189 windows-all
-
 #############################################################################
 
 # :hotspot_gc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/integerArithmetic/MultiplyByConstantLongMax.java	Mon Nov 26 17:35:35 2018 +0100
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8214189
+ * @summary test/hotspot/jtreg/compiler/intrinsics/mathexact/MulExactLConstantTest.java fails on Windows x64 when run with -XX:-TieredCompilation
+ *
+ * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement MultiplyByConstantLongMax
+ *
+ */
+
+public class MultiplyByConstantLongMax {
+    public static void main(String[] args) {
+        for (int i = 0; i < 20_000; i++) {
+            if (test(1) != Long.MAX_VALUE) {
+                throw new RuntimeException("incorrect result");
+            }
+        }
+    }
+
+    private static long test(long v) {
+        return v * Long.MAX_VALUE;
+    }
+}