Date: Thu, 16 Feb 2012 11:43:20 -0800
Subject: [PATCH 14/37] 6708398: Support integer overflow
Added add/sub/multiply/toIntExact methods to j.l.Math and StrictMath classes
Reviewed-by: emcmanus
---
jdk/src/share/classes/java/lang/Math.java | 151 +++++++++-
.../share/classes/java/lang/StrictMath.java | 122 +++++++-
jdk/test/java/lang/Math/ExactArithTests.java | 266 ++++++++++++++++++
.../java/lang/StrictMath/ExactArithTests.java | 266 ++++++++++++++++++
4 files changed, 802 insertions(+), 3 deletions(-)
create mode 100644 jdk/test/java/lang/Math/ExactArithTests.java
create mode 100644 jdk/test/java/lang/StrictMath/ExactArithTests.java
diff --git a/jdk/src/share/classes/java/lang/Math.java b/jdk/src/share/classes/java/lang/Math.java
index 5453010b674..353464bada5 100644
--- a/jdk/src/share/classes/java/lang/Math.java
+++ b/jdk/src/share/classes/java/lang/Math.java
@@ -81,6 +81,22 @@ import sun.misc.DoubleConsts;
* floating-point approximation. Not all approximations that have 1
* ulp accuracy will automatically meet the monotonicity requirements.
*
+ *
+ * The platform uses signed two's complement integer arithmetic with
+ * int and long primitive types. The developer should choose
+ * the primitive type to ensure that arithmetic operations consistently
+ * produce correct results, which in some cases means the operations
+ * will not overflow the range of values of the computation.
+ * The best practice is to choose the primitive type and algorithm to avoid
+ * overflow. In cases where the size is {@code int} or {@code long} and
+ * overflow errors need to be detected, the methods {@code addExact},
+ * {@code subtractExact}, {@code multiplyExact}, and {@code toIntExact}
+ * throw an {@code ArithmeticException} when the results overflow.
+ * For other arithmetic operations such as divide, absolute value,
+ * increment, decrement, and negation overflow occurs only with
+ * a specific minimum or maximum value and should be checked against
+ * the minimum or maximum as appropriate.
+ *
* @author unascribed
* @author Joseph D. Darcy
* @since JDK1.0
@@ -718,6 +734,137 @@ public final class Math {
return rnd.nextDouble();
}
+ /**
+ * Returns the sum of its arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ */
+ public static int addExact(int x, int y) {
+ int r = x + y;
+ // HD 2-12 Overflow iff both arguments have the opposite sign of the result
+ if (((x ^ r) & (y ^ r)) < 0) {
+ throw new ArithmeticException("integer overflow");
+ }
+ return r;
+ }
+
+ /**
+ * Returns the sum of its arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ */
+ public static long addExact(long x, long y) {
+ long r = x + y;
+ // HD 2-12 Overflow iff both arguments have the opposite sign of the result
+ if (((x ^ r) & (y ^ r)) < 0) {
+ throw new ArithmeticException("long overflow");
+ }
+ return r;
+ }
+
+ /**
+ * Returns the difference of the arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value to subtract from the first
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ */
+ public static int subtractExact(int x, int y) {
+ int r = x - y;
+ // HD 2-12 Overflow iff the arguments have different signs and
+ // the sign of the result is different than the sign of x
+ if (((x ^ y) & (x ^ r)) < 0) {
+ throw new ArithmeticException("integer overflow");
+ }
+ return r;
+ }
+
+ /**
+ * Returns the difference of the arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value to subtract from the first
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ */
+ public static long subtractExact(long x, long y) {
+ long r = x - y;
+ // HD 2-12 Overflow iff the arguments have different signs and
+ // the sign of the result is different than the sign of x
+ if (((x ^ y) & (x ^ r)) < 0) {
+ throw new ArithmeticException("long overflow");
+ }
+ return r;
+ }
+
+ /**
+ * Returns the product of the arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ */
+ public static int multiplyExact(int x, int y) {
+ long r = (long)x * (long)y;
+ if ((int)r != r) {
+ throw new ArithmeticException("long overflow");
+ }
+ return (int)r;
+ }
+
+ /**
+ * Returns the product of the arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ */
+ public static long multiplyExact(long x, long y) {
+ long r = x * y;
+ long ax = Math.abs(x);
+ long ay = Math.abs(y);
+ if (((ax | ay) >>> 31 != 0)) {
+ // Some bits greater than 2^31 that might cause overflow
+ // Check the result using the divide operator
+ // and check for the special case of Long.MIN_VALUE * -1
+ if (((y != 0) && (r / y != x)) ||
+ (x == Long.MIN_VALUE && y == -1)) {
+ throw new ArithmeticException("long overflow");
+ }
+ }
+ return r;
+ }
+
+ /**
+ * Returns the value of the {@code long} argument;
+ * throwing an exception if the value overflows an {@code int}.
+ *
+ * @param value the long value
+ * @return the argument as an int
+ * @throws ArithmeticException if the {@code argument} overflows an int
+ */
+ public static int toIntExact(long value) {
+ if ((int)value != value) {
+ throw new ArithmeticException("integer overflow");
+ }
+ return (int)value;
+ }
+
/**
* Returns the absolute value of an {@code int} value.
* If the argument is not negative, the argument is returned.
@@ -1737,7 +1884,7 @@ public final class Math {
}
/**
- * Return {@code d} ×
+ * Returns {@code d} ×
* 2{@code scaleFactor} rounded as if performed
* by a single correctly rounded floating-point multiply to a
* member of the double value set. See the Java
@@ -1844,7 +1991,7 @@ public final class Math {
}
/**
- * Return {@code f} ×
+ * Returns {@code f} ×
* 2{@code scaleFactor} rounded as if performed
* by a single correctly rounded floating-point multiply to a
* member of the float value set. See the Java
diff --git a/jdk/src/share/classes/java/lang/StrictMath.java b/jdk/src/share/classes/java/lang/StrictMath.java
index e1c489551f1..1a06f761571 100644
--- a/jdk/src/share/classes/java/lang/StrictMath.java
+++ b/jdk/src/share/classes/java/lang/StrictMath.java
@@ -56,6 +56,22 @@ import sun.misc.DoubleConsts;
* {@code sinh}, {@code cosh}, {@code tanh},
* {@code hypot}, {@code expm1}, and {@code log1p}.
*
+ *
+ * The platform uses signed two's complement integer arithmetic with
+ * int and long primitive types. The developer should choose
+ * the primitive type to ensure that arithmetic operations consistently
+ * produce correct results, which in some cases means the operations
+ * will not overflow the range of values of the computation.
+ * The best practice is to choose the primitive type and algorithm to avoid
+ * overflow. In cases where the size is {@code int} or {@code long} and
+ * overflow errors need to be detected, the methods {@code addExact},
+ * {@code subtractExact}, {@code multiplyExact}, and {@code toIntExact}
+ * throw an {@code ArithmeticException} when the results overflow.
+ * For other arithmetic operations such as divide, absolute value,
+ * increment, decrement, and negation overflow occurs only with
+ * a specific minimum or maximum value and should be checked against
+ * the minimum or maximum as appropriate.
+ *
* @author unascribed
* @author Joseph D. Darcy
* @since 1.3
@@ -699,7 +715,111 @@ public final class StrictMath {
}
/**
- * Returns the absolute value of an {@code int} value..
+ * Returns the sum of its arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ * @see Math#addExact(int,int)
+ * @since 1.8
+ */
+ public static int addExact(int x, int y) {
+ return Math.addExact(x, y);
+ }
+
+ /**
+ * Returns the sum of its arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ * @see Math#addExact(long,long)
+ * @since 1.8
+ */
+ public static long addExact(long x, long y) {
+ return Math.addExact(x, y);
+ }
+
+ /**
+ * Return the difference of the arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value to subtract from the first
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ * @see Math#subtractExact(int,int)
+ * @since 1.8
+ */
+ public static int subtractExact(int x, int y) {
+ return Math.subtractExact(x, y);
+ }
+
+ /**
+ * Return the difference of the arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value to subtract from the first
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ * @see Math#subtractExact(long,long)
+ * @since 1.8
+ */
+ public static long subtractExact(long x, long y) {
+ return Math.subtractExact(x, y);
+ }
+
+ /**
+ * Return the product of the arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ * @see Math#multiplyExact(int,int)
+ * @since 1.8
+ */
+ public static int multiplyExact(int x, int y) {
+ return Math.multiplyExact(x, y);
+ }
+
+ /**
+ * Return the product of the arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ * @see Math#multiplyExact(long,long)
+ * @since 1.8
+ */
+ public static long multiplyExact(long x, long y) {
+ return Math.multiplyExact(x, y);
+ }
+
+ /**
+ * Return the value of the {@code long} argument;
+ * throwing an exception if the value overflows an {@code int}.
+ *
+ * @param value the long value
+ * @return the argument as an int
+ * @throws ArithmeticException if the {@code argument} overflows an int
+ * @see Math#toIntExact(int)
+ * @since 1.8
+ */
+ public static int toIntExact(long value) {
+ return Math.toIntExact(value);
+ }
+
+ /**
+ * Returns the absolute value of an {@code int} value.
* If the argument is not negative, the argument is returned.
* If the argument is negative, the negation of the argument is returned.
*
diff --git a/jdk/test/java/lang/Math/ExactArithTests.java b/jdk/test/java/lang/Math/ExactArithTests.java
new file mode 100644
index 00000000000..86d7da3e8f1
--- /dev/null
+++ b/jdk/test/java/lang/Math/ExactArithTests.java
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. 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.
+ */
+
+import java.math.BigInteger;
+
+/**
+ * @test Test for Math.*Exact integer and long methods.
+ * @bug 6708398
+ * @summary Basic tests for Math exact arithmetic operations.
+ *
+ * @author Roger Riggs
+ */
+public class ExactArithTests {
+
+ /**
+ * The count of test errors.
+ */
+ private static int errors = 0;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ testIntegerExact();
+ testLongExact();
+
+ if (errors > 0) {
+ throw new RuntimeException(errors + " errors found in ExactArithTests.");
+ }
+ }
+
+ static void fail(String message) {
+ errors++;
+ System.err.println(message);
+ }
+
+ /**
+ * Test Math.addExact, multiplyExact, subtractExact, toIntValue methods
+ * with {@code int} arguments.
+ */
+ static void testIntegerExact() {
+ testIntegerExact(0, 0);
+ testIntegerExact(1, 1);
+ testIntegerExact(1, -1);
+ testIntegerExact(-1, 1);
+ testIntegerExact(1000, 2000);
+
+ testIntegerExact(Integer.MIN_VALUE, Integer.MIN_VALUE);
+ testIntegerExact(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ testIntegerExact(Integer.MIN_VALUE, 1);
+ testIntegerExact(Integer.MAX_VALUE, 1);
+ testIntegerExact(Integer.MIN_VALUE, 2);
+ testIntegerExact(Integer.MAX_VALUE, 2);
+ testIntegerExact(Integer.MIN_VALUE, -1);
+ testIntegerExact(Integer.MAX_VALUE, -1);
+ testIntegerExact(Integer.MIN_VALUE, -2);
+ testIntegerExact(Integer.MAX_VALUE, -2);
+
+ }
+
+ /**
+ * Test exact arithmetic by comparing with the same operations using long
+ * and checking that the result is the same as the integer truncation.
+ * Errors are reported with {@link fail}.
+ *
+ * @param x first parameter
+ * @param y second parameter
+ */
+ static void testIntegerExact(int x, int y) {
+ try {
+ // Test addExact
+ int sum = Math.addExact(x, y);
+ long sum2 = (long) x + (long) y;
+ if ((int) sum2 != sum2) {
+ fail("FAIL: int Math.addExact(" + x + " + " + y + ") = " + sum + "; expected Arithmetic exception");
+ } else if (sum != sum2) {
+ fail("FAIL: long Math.addExact(" + x + " + " + y + ") = " + sum + "; expected: " + sum2);
+ }
+ } catch (ArithmeticException ex) {
+ long sum2 = (long) x + (long) y;
+ if ((int) sum2 == sum2) {
+ fail("FAIL: int Math.addExact(" + x + " + " + y + ")" + "; Unexpected exception: " + ex);
+
+ }
+ }
+
+ try {
+ // Test subtractExact
+ int diff = Math.subtractExact(x, y);
+ long diff2 = (long) x - (long) y;
+ if ((int) diff2 != diff2) {
+ fail("FAIL: int Math.subtractExact(" + x + " - " + y + ") = " + diff + "; expected: " + diff2);
+ }
+
+ } catch (ArithmeticException ex) {
+ long diff2 = (long) x - (long) y;
+ if ((int) diff2 == diff2) {
+ fail("FAIL: int Math.subtractExact(" + x + " - " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test multiplyExact
+ int product = Math.multiplyExact(x, y);
+ long m2 = (long) x * (long) y;
+ if ((int) m2 != m2) {
+ fail("FAIL: int Math.multiplyExact(" + x + " * " + y + ") = " + product + "; expected: " + m2);
+ }
+ } catch (ArithmeticException ex) {
+ long m2 = (long) x * (long) y;
+ if ((int) m2 == m2) {
+ fail("FAIL: int Math.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ }
+
+ /**
+ * Test Math.addExact, multiplyExact, subtractExact, toIntExact methods
+ * with {@code long} arguments.
+ */
+ static void testLongExact() {
+ testLongExactTwice(0, 0);
+ testLongExactTwice(1, 1);
+ testLongExactTwice(1, -1);
+ testLongExactTwice(1000, 2000);
+
+ testLongExactTwice(Long.MIN_VALUE, Long.MIN_VALUE);
+ testLongExactTwice(Long.MAX_VALUE, Long.MAX_VALUE);
+ testLongExactTwice(Long.MIN_VALUE, 1);
+ testLongExactTwice(Long.MAX_VALUE, 1);
+ testLongExactTwice(Long.MIN_VALUE, 2);
+ testLongExactTwice(Long.MAX_VALUE, 2);
+ testLongExactTwice(Long.MIN_VALUE, -1);
+ testLongExactTwice(Long.MAX_VALUE, -1);
+ testLongExactTwice(Long.MIN_VALUE, -2);
+ testLongExactTwice(Long.MAX_VALUE, -2);
+ testLongExactTwice(Long.MIN_VALUE/2, 2);
+ testLongExactTwice(Long.MAX_VALUE, 2);
+ testLongExactTwice(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ testLongExactTwice(Integer.MAX_VALUE, -Integer.MAX_VALUE);
+ testLongExactTwice(Integer.MAX_VALUE+1, Integer.MAX_VALUE+1);
+ testLongExactTwice(Integer.MAX_VALUE+1, -Integer.MAX_VALUE+1);
+ testLongExactTwice(Integer.MIN_VALUE-1, Integer.MIN_VALUE-1);
+ testLongExactTwice(Integer.MIN_VALUE-1, -Integer.MIN_VALUE-1);
+ testLongExactTwice(Integer.MIN_VALUE/2, 2);
+
+ }
+
+ /**
+ * Test each of the exact operations with the arguments and
+ * with the arguments reversed.
+ * @param x
+ * @param y
+ */
+ static void testLongExactTwice(long x, long y) {
+ testLongExact(x, y);
+ testLongExact(y, x);
+ }
+
+
+ /**
+ * Test long exact arithmetic by comparing with the same operations using BigInteger
+ * and checking that the result is the same as the long truncation.
+ * Errors are reported with {@link fail}.
+ *
+ * @param x first parameter
+ * @param y second parameter
+ */
+ static void testLongExact(long x, long y) {
+ BigInteger resultBig = null;
+ final BigInteger xBig = BigInteger.valueOf(x);
+ final BigInteger yBig = BigInteger.valueOf(y);
+ try {
+ // Test addExact
+ resultBig = xBig.add(yBig);
+ long sum = Math.addExact(x, y);
+ checkResult("long Math.addExact", x, y, sum, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long Math.addExact(" + x + " + " + y + "); Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test subtractExact
+ resultBig = xBig.subtract(yBig);
+ long diff = Math.subtractExact(x, y);
+ checkResult("long Math.subtractExact", x, y, diff, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long Math.subtractExact(" + x + " - " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test multiplyExact
+ resultBig = xBig.multiply(yBig);
+ long product = Math.multiplyExact(x, y);
+ checkResult("long Math.multiplyExact", x, y, product, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long Math.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test toIntExact
+ int value = Math.toIntExact(x);
+ if ((long)value != x) {
+ fail("FAIL: " + "long Math.toIntExact" + "(" + x + ") = " + value + "; expected an arithmetic exception: ");
+ }
+ } catch (ArithmeticException ex) {
+ if (resultBig.bitLength() <= 32) {
+ fail("FAIL: long Math.toIntExact(" + x + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ }
+
+ /**
+ * Compare the expected and actual results.
+ * @param message message for the error
+ * @param x first argument
+ * @param y second argument
+ * @param result actual result value
+ * @param expected expected result value
+ */
+ static void checkResult(String message, long x, long y, long result, BigInteger expected) {
+ BigInteger resultBig = BigInteger.valueOf(result);
+ if (!inLongRange(expected)) {
+ fail("FAIL: " + message + "(" + x + ", " + y + ") = " + result + "; expected an arithmetic exception: ");
+ } else if (!resultBig.equals(expected)) {
+ fail("FAIL: " + message + "(" + x + ", " + y + ") = " + result + "; expected " + expected);
+ }
+ }
+
+ /**
+ * Check if the value fits in 64 bits (a long).
+ * @param value
+ * @return true if the value fits in 64 bits (including the sign).
+ */
+ static boolean inLongRange(BigInteger value) {
+ return value.bitLength() <= 63;
+ }
+}
diff --git a/jdk/test/java/lang/StrictMath/ExactArithTests.java b/jdk/test/java/lang/StrictMath/ExactArithTests.java
new file mode 100644
index 00000000000..4ceedf2cb17
--- /dev/null
+++ b/jdk/test/java/lang/StrictMath/ExactArithTests.java
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. 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.
+ */
+
+import java.math.BigInteger;
+
+/**
+ * @test Test for StrictMath.*Exact integer and long methods.
+ * @bug 6708398
+ * @summary Basic tests for StrictMath exact arithmetic operations.
+ *
+ * @author Roger Riggs
+ */
+public class ExactArithTests {
+
+ /**
+ * The count of test errors.
+ */
+ private static int errors = 0;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ testIntegerExact();
+ testLongExact();
+
+ if (errors > 0) {
+ throw new RuntimeException(errors + " errors found in ExactArithTests.");
+ }
+ }
+
+ static void fail(String message) {
+ errors++;
+ System.err.println(message);
+ }
+
+ /**
+ * Test StrictMath.addExact, multiplyExact, subtractExact, toIntValue methods
+ * with {@code int} arguments.
+ */
+ static void testIntegerExact() {
+ testIntegerExact(0, 0);
+ testIntegerExact(1, 1);
+ testIntegerExact(1, -1);
+ testIntegerExact(-1, 1);
+ testIntegerExact(1000, 2000);
+
+ testIntegerExact(Integer.MIN_VALUE, Integer.MIN_VALUE);
+ testIntegerExact(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ testIntegerExact(Integer.MIN_VALUE, 1);
+ testIntegerExact(Integer.MAX_VALUE, 1);
+ testIntegerExact(Integer.MIN_VALUE, 2);
+ testIntegerExact(Integer.MAX_VALUE, 2);
+ testIntegerExact(Integer.MIN_VALUE, -1);
+ testIntegerExact(Integer.MAX_VALUE, -1);
+ testIntegerExact(Integer.MIN_VALUE, -2);
+ testIntegerExact(Integer.MAX_VALUE, -2);
+
+ }
+
+ /**
+ * Test exact arithmetic by comparing with the same operations using long
+ * and checking that the result is the same as the integer truncation.
+ * Errors are reported with {@link fail}.
+ *
+ * @param x first parameter
+ * @param y second parameter
+ */
+ static void testIntegerExact(int x, int y) {
+ try {
+ // Test addExact
+ int sum = StrictMath.addExact(x, y);
+ long sum2 = (long) x + (long) y;
+ if ((int) sum2 != sum2) {
+ fail("FAIL: int StrictMath.addExact(" + x + " + " + y + ") = " + sum + "; expected Arithmetic exception");
+ } else if (sum != sum2) {
+ fail("FAIL: long StrictMath.addExact(" + x + " + " + y + ") = " + sum + "; expected: " + sum2);
+ }
+ } catch (ArithmeticException ex) {
+ long sum2 = (long) x + (long) y;
+ if ((int) sum2 == sum2) {
+ fail("FAIL: int StrictMath.addExact(" + x + " + " + y + ")" + "; Unexpected exception: " + ex);
+
+ }
+ }
+
+ try {
+ // Test subtractExact
+ int diff = StrictMath.subtractExact(x, y);
+ long diff2 = (long) x - (long) y;
+ if ((int) diff2 != diff2) {
+ fail("FAIL: int StrictMath.subtractExact(" + x + " - " + y + ") = " + diff + "; expected: " + diff2);
+ }
+
+ } catch (ArithmeticException ex) {
+ long diff2 = (long) x - (long) y;
+ if ((int) diff2 == diff2) {
+ fail("FAIL: int StrictMath.subtractExact(" + x + " - " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test multiplyExact
+ int product = StrictMath.multiplyExact(x, y);
+ long m2 = (long) x * (long) y;
+ if ((int) m2 != m2) {
+ fail("FAIL: int StrictMath.multiplyExact(" + x + " * " + y + ") = " + product + "; expected: " + m2);
+ }
+ } catch (ArithmeticException ex) {
+ long m2 = (long) x * (long) y;
+ if ((int) m2 == m2) {
+ fail("FAIL: int StrictMath.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ }
+
+ /**
+ * Test StrictMath.addExact, multiplyExact, subtractExact, toIntExact methods
+ * with {@code long} arguments.
+ */
+ static void testLongExact() {
+ testLongExactTwice(0, 0);
+ testLongExactTwice(1, 1);
+ testLongExactTwice(1, -1);
+ testLongExactTwice(1000, 2000);
+
+ testLongExactTwice(Long.MIN_VALUE, Long.MIN_VALUE);
+ testLongExactTwice(Long.MAX_VALUE, Long.MAX_VALUE);
+ testLongExactTwice(Long.MIN_VALUE, 1);
+ testLongExactTwice(Long.MAX_VALUE, 1);
+ testLongExactTwice(Long.MIN_VALUE, 2);
+ testLongExactTwice(Long.MAX_VALUE, 2);
+ testLongExactTwice(Long.MIN_VALUE, -1);
+ testLongExactTwice(Long.MAX_VALUE, -1);
+ testLongExactTwice(Long.MIN_VALUE, -2);
+ testLongExactTwice(Long.MAX_VALUE, -2);
+ testLongExactTwice(Long.MIN_VALUE/2, 2);
+ testLongExactTwice(Long.MAX_VALUE, 2);
+ testLongExactTwice(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ testLongExactTwice(Integer.MAX_VALUE, -Integer.MAX_VALUE);
+ testLongExactTwice(Integer.MAX_VALUE+1, Integer.MAX_VALUE+1);
+ testLongExactTwice(Integer.MAX_VALUE+1, -Integer.MAX_VALUE+1);
+ testLongExactTwice(Integer.MIN_VALUE-1, Integer.MIN_VALUE-1);
+ testLongExactTwice(Integer.MIN_VALUE-1, -Integer.MIN_VALUE-1);
+ testLongExactTwice(Integer.MIN_VALUE/2, 2);
+
+ }
+
+ /**
+ * Test each of the exact operations with the arguments and
+ * with the arguments reversed.
+ * @param x
+ * @param y
+ */
+ static void testLongExactTwice(long x, long y) {
+ testLongExact(x, y);
+ testLongExact(y, x);
+ }
+
+
+ /**
+ * Test long exact arithmetic by comparing with the same operations using BigInteger
+ * and checking that the result is the same as the long truncation.
+ * Errors are reported with {@link fail}.
+ *
+ * @param x first parameter
+ * @param y second parameter
+ */
+ static void testLongExact(long x, long y) {
+ BigInteger resultBig = null;
+ final BigInteger xBig = BigInteger.valueOf(x);
+ final BigInteger yBig = BigInteger.valueOf(y);
+ try {
+ // Test addExact
+ resultBig = xBig.add(yBig);
+ long sum = StrictMath.addExact(x, y);
+ checkResult("long StrictMath.addExact", x, y, sum, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long StrictMath.addExact(" + x + " + " + y + "); Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test subtractExact
+ resultBig = xBig.subtract(yBig);
+ long diff = StrictMath.subtractExact(x, y);
+ checkResult("long StrictMath.subtractExact", x, y, diff, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long StrictMath.subtractExact(" + x + " - " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test multiplyExact
+ resultBig = xBig.multiply(yBig);
+ long product = StrictMath.multiplyExact(x, y);
+ checkResult("long StrictMath.multiplyExact", x, y, product, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long StrictMath.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test toIntExact
+ int value = StrictMath.toIntExact(x);
+ if ((long)value != x) {
+ fail("FAIL: " + "long StrictMath.toIntExact" + "(" + x + ") = " + value + "; expected an arithmetic exception: ");
+ }
+ } catch (ArithmeticException ex) {
+ if (resultBig.bitLength() <= 32) {
+ fail("FAIL: long StrictMath.toIntExact(" + x + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ }
+
+ /**
+ * Compare the expected and actual results.
+ * @param message message for the error
+ * @param x first argument
+ * @param y second argument
+ * @param result actual result value
+ * @param expected expected result value
+ */
+ static void checkResult(String message, long x, long y, long result, BigInteger expected) {
+ BigInteger resultBig = BigInteger.valueOf(result);
+ if (!inLongRange(expected)) {
+ fail("FAIL: " + message + "(" + x + ", " + y + ") = " + result + "; expected an arithmetic exception: ");
+ } else if (!resultBig.equals(expected)) {
+ fail("FAIL: " + message + "(" + x + ", " + y + ") = " + result + "; expected " + expected);
+ }
+ }
+
+ /**
+ * Check if the value fits in 64 bits (a long).
+ * @param value
+ * @return true if the value fits in 64 bits (including the sign).
+ */
+ static boolean inLongRange(BigInteger value) {
+ return value.bitLength() <= 63;
+ }
+}
From 1b32c44aa3cdf3229ad257635e61db0fa9d05240 Mon Sep 17 00:00:00 2001
From: Xueming Shen
Date: Thu, 16 Feb 2012 22:13:10 -0800
Subject: [PATCH 15/37] 4153167: separate between ANSI and OEM code pages on
Windows
To use OEM code page for System.out&err when not redirected
Reviewed-by: alanb
---
jdk/src/share/classes/java/lang/System.java | 18 ++++++++++--
jdk/src/share/native/java/lang/System.c | 7 +++++
jdk/src/share/native/java/lang/java_props.h | 2 ++
.../windows/native/java/lang/java_props_md.c | 29 +++++++++++++++++++
4 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/jdk/src/share/classes/java/lang/System.java b/jdk/src/share/classes/java/lang/System.java
index e2b010e086b..67ec909f6fb 100644
--- a/jdk/src/share/classes/java/lang/System.java
+++ b/jdk/src/share/classes/java/lang/System.java
@@ -1099,6 +1099,19 @@ public final class System {
*/
public static native String mapLibraryName(String libname);
+ /**
+ * Create PrintStream for stdout/err based on encoding.
+ */
+ private static PrintStream newPrintStream(FileOutputStream fos, String enc) {
+ if (enc != null) {
+ try {
+ return new PrintStream(new BufferedOutputStream(fos, 128), true, enc);
+ } catch (UnsupportedEncodingException uee) {}
+ }
+ return new PrintStream(new BufferedOutputStream(fos, 128), true);
+ }
+
+
/**
* Initialize the system class. Called after thread initialization.
*/
@@ -1139,8 +1152,9 @@ public final class System {
FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err);
setIn0(new BufferedInputStream(fdIn));
- setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128), true));
- setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128), true));
+ setOut0(newPrintStream(fdOut, props.getProperty("sun.stdout.encoding")));
+ setErr0(newPrintStream(fdErr, props.getProperty("sun.stderr.encoding")));
+
// Load the zip library now in order to keep java.util.zip.ZipFile
// from trying to use itself to load this library later.
loadLibrary("zip");
diff --git a/jdk/src/share/native/java/lang/System.c b/jdk/src/share/native/java/lang/System.c
index 86ad8f6ce2f..6b06cbd6a85 100644
--- a/jdk/src/share/native/java/lang/System.c
+++ b/jdk/src/share/native/java/lang/System.c
@@ -235,7 +235,14 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
}
PUTPROP(props, "file.encoding", sprops->encoding);
PUTPROP(props, "sun.jnu.encoding", sprops->sun_jnu_encoding);
+ if (sprops->sun_stdout_encoding != NULL) {
+ PUTPROP(props, "sun.stdout.encoding", sprops->sun_stdout_encoding);
+ }
+ if (sprops->sun_stderr_encoding != NULL) {
+ PUTPROP(props, "sun.stderr.encoding", sprops->sun_stderr_encoding);
+ }
PUTPROP(props, "file.encoding.pkg", "sun.io");
+
/* unicode_encoding specifies the default endianness */
PUTPROP(props, "sun.io.unicode.encoding", sprops->unicode_encoding);
PUTPROP(props, "sun.cpu.isalist",
diff --git a/jdk/src/share/native/java/lang/java_props.h b/jdk/src/share/native/java/lang/java_props.h
index 89f7671c7e6..18a1b345134 100644
--- a/jdk/src/share/native/java/lang/java_props.h
+++ b/jdk/src/share/native/java/lang/java_props.h
@@ -66,6 +66,8 @@ typedef struct {
char *display_variant;
char *encoding;
char *sun_jnu_encoding;
+ char *sun_stdout_encoding;
+ char *sun_stderr_encoding;
char *timezone;
char *printerJob;
diff --git a/jdk/src/windows/native/java/lang/java_props_md.c b/jdk/src/windows/native/java/lang/java_props_md.c
index e27d1ea0b5b..bfa3711b947 100644
--- a/jdk/src/windows/native/java/lang/java_props_md.c
+++ b/jdk/src/windows/native/java/lang/java_props_md.c
@@ -31,6 +31,9 @@
#include
#include
+#include
+#include
+
#include "locale_str.h"
#include "java_props.h"
@@ -123,6 +126,17 @@ getEncodingInternal(LCID lcid)
return ret;
}
+static char* getConsoleEncoding()
+{
+ char* buf = malloc(16);
+ int cp = GetConsoleCP();
+ if (cp >= 874 && cp <= 950)
+ sprintf(buf, "ms%d", cp);
+ else
+ sprintf(buf, "cp%d", cp);
+ return buf;
+}
+
// Exported entries for AWT
DllExport const char *
getEncodingFromLangID(LANGID langID)
@@ -562,6 +576,7 @@ GetJavaProperties(JNIEnv* env)
{
char * display_encoding;
+ HANDLE hStdOutErr;
// Windows UI Language selection list only cares "language"
// information of the UI Language. For example, the list
@@ -606,6 +621,20 @@ GetJavaProperties(JNIEnv* env)
sprops.encoding = "MS950_HKSCS";
sprops.sun_jnu_encoding = "MS950_HKSCS";
}
+
+ hStdOutErr = GetStdHandle(STD_OUTPUT_HANDLE);
+ if (hStdOutErr != INVALID_HANDLE_VALUE &&
+ GetFileType(hStdOutErr) == FILE_TYPE_CHAR) {
+ sprops.sun_stdout_encoding = getConsoleEncoding();
+ }
+ hStdOutErr = GetStdHandle(STD_ERROR_HANDLE);
+ if (hStdOutErr != INVALID_HANDLE_VALUE &&
+ GetFileType(hStdOutErr) == FILE_TYPE_CHAR) {
+ if (sprops.sun_stdout_encoding != NULL)
+ sprops.sun_stderr_encoding = sprops.sun_stdout_encoding;
+ else
+ sprops.sun_stderr_encoding = getConsoleEncoding();
+ }
}
}
From a908ea8cb5e5252dd04934fef3f080426587e9a0 Mon Sep 17 00:00:00 2001
From: Alejandro Murillo
Date: Fri, 17 Feb 2012 15:11:32 -0800
Subject: [PATCH 16/37] 7146700: new hotspot build - hs24-b01
Reviewed-by: jcoomes
---
hotspot/make/hotspot_version | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version
index f92de62e153..f67badd6da0 100644
--- a/hotspot/make/hotspot_version
+++ b/hotspot/make/hotspot_version
@@ -33,9 +33,9 @@
# Don't put quotes (fail windows build).
HOTSPOT_VM_COPYRIGHT=Copyright 2011
-HS_MAJOR_VER=23
+HS_MAJOR_VER=24
HS_MINOR_VER=0
-HS_BUILD_NUMBER=16
+HS_BUILD_NUMBER=01
JDK_MAJOR_VER=1
JDK_MINOR_VER=8
From b0b5725863ca48ef6fea669e930dd9d60990a26f Mon Sep 17 00:00:00 2001
From: "Daniel D. Daugherty"
Date: Fri, 17 Feb 2012 15:55:27 -0800
Subject: [PATCH 17/37] 7145798: System.loadLibrary does not search current
working directory
Append "." to java.library.path on MacOS X to ease migration from Apple's Java6 to OpenJDK7.
Reviewed-by: phh, jmelvin, coleenp
---
hotspot/src/os/bsd/vm/os_bsd.cpp | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp
index 2611e9c1401..d059a2d13d2 100644
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp
@@ -568,6 +568,25 @@ void os::init_system_properties_values() {
sprintf(ld_library_path, "%s:%s", v, t);
free(t);
}
+
+#ifdef __APPLE__
+ // Apple's Java6 has "." at the beginning of java.library.path.
+ // OpenJDK on Windows has "." at the end of java.library.path.
+ // OpenJDK on Linux and Solaris don't have "." in java.library.path
+ // at all. To ease the transition from Apple's Java6 to OpenJDK7,
+ // "." is appended to the end of java.library.path. Yes, this
+ // could cause a change in behavior, but Apple's Java6 behavior
+ // can be achieved by putting "." at the beginning of the
+ // JAVA_LIBRARY_PATH environment variable.
+ {
+ char *t = ld_library_path;
+ // that's +3 for appending ":." and the trailing '\0'
+ ld_library_path = (char *) malloc(strlen(t) + 3);
+ sprintf(ld_library_path, "%s:%s", t, ".");
+ free(t);
+ }
+#endif
+
Arguments::set_library_path(ld_library_path);
}
From d856a7745c0549291de2f3ddfcd283543fe7dd28 Mon Sep 17 00:00:00 2001
From: Staffan Larsen
Date: Sun, 19 Feb 2012 13:11:39 +0100
Subject: [PATCH 18/37] 7132070: Use a mach_port_t as the OSThread thread_id
rather than pthread_t on BSD/OSX
Change OSThread to use mach thread_t
Reviewed-by: phh, dcubed
---
hotspot/src/cpu/x86/vm/vm_version_x86.cpp | 10 ++++----
hotspot/src/os/bsd/vm/osThread_bsd.cpp | 6 ++++-
hotspot/src/os/bsd/vm/osThread_bsd.hpp | 25 ++++++++++++++++---
hotspot/src/os/bsd/vm/os_bsd.cpp | 21 +++++++++++++---
.../os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp | 12 ++++++---
.../vm/utilities/globalDefinitions_gcc.hpp | 11 ++------
6 files changed, 61 insertions(+), 24 deletions(-)
diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
index 2155d767980..121be7a2ba7 100644
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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
@@ -65,8 +65,8 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
address generate_getPsrInfo() {
// Flags to test CPU type.
- const uint32_t EFL_AC = 0x40000;
- const uint32_t EFL_ID = 0x200000;
+ const uint32_t HS_EFL_AC = 0x40000;
+ const uint32_t HS_EFL_ID = 0x200000;
// Values for when we don't have a CPUID instruction.
const int CPU_FAMILY_SHIFT = 8;
const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT);
@@ -100,7 +100,7 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
//
// if we are unable to change the AC flag, we have a 386
//
- __ xorl(rax, EFL_AC);
+ __ xorl(rax, HS_EFL_AC);
__ push(rax);
__ popf();
__ pushf();
@@ -118,7 +118,7 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
//
__ bind(detect_486);
__ mov(rax, rcx);
- __ xorl(rax, EFL_ID);
+ __ xorl(rax, HS_EFL_ID);
__ push(rax);
__ popf();
__ pushf();
diff --git a/hotspot/src/os/bsd/vm/osThread_bsd.cpp b/hotspot/src/os/bsd/vm/osThread_bsd.cpp
index efac8037698..98a3f2f6340 100644
--- a/hotspot/src/os/bsd/vm/osThread_bsd.cpp
+++ b/hotspot/src/os/bsd/vm/osThread_bsd.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. 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
@@ -49,7 +49,11 @@
void OSThread::pd_initialize() {
assert(this != NULL, "check");
+#ifdef __APPLE__
+ _thread_id = 0;
+#else
_thread_id = NULL;
+#endif
_pthread_id = NULL;
_siginfo = NULL;
_ucontext = NULL;
diff --git a/hotspot/src/os/bsd/vm/osThread_bsd.hpp b/hotspot/src/os/bsd/vm/osThread_bsd.hpp
index 82dd34fcbe8..0e60cc3eefd 100644
--- a/hotspot/src/os/bsd/vm/osThread_bsd.hpp
+++ b/hotspot/src/os/bsd/vm/osThread_bsd.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. 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
@@ -40,10 +40,17 @@
private:
#ifdef _ALLBSD_SOURCE
- // _thread_id and _pthread_id are the same on BSD
- // keep both to minimize code divergence in os_bsd.cpp
+
+#ifdef __APPLE__
+ thread_t _thread_id;
+#else
pthread_t _thread_id;
+#endif
+
+ // _pthread_id is the pthread id, which is used by library calls
+ // (e.g. pthread_kill).
pthread_t _pthread_id;
+
#else
// _thread_id is kernel thread id (similar to LWP id on Solaris). Each
// thread has a unique thread_id (BsdThreads or NPTL). It can be used
@@ -64,9 +71,15 @@
void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+ thread_t thread_id() const {
+ return _thread_id;
+ }
+#else
pthread_t thread_id() const {
return _thread_id;
}
+#endif
#else
pid_t thread_id() const {
return _thread_id;
@@ -84,9 +97,15 @@
}
#endif // ASSERT
#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+ void set_thread_id(thread_t id) {
+ _thread_id = id;
+ }
+#else
void set_thread_id(pthread_t id) {
_thread_id = id;
}
+#endif
#else
void set_thread_id(pid_t id) {
_thread_id = id;
diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp
index d059a2d13d2..5643798bc30 100644
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp
@@ -998,8 +998,13 @@ static void *java_start(Thread *thread) {
}
#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+ // thread_id is mach thread on macos
+ osthread->set_thread_id(::mach_thread_self());
+#else
// thread_id is pthread_id on BSD
osthread->set_thread_id(::pthread_self());
+#endif
#else
// thread_id is kernel thread id (similar to Solaris LWP id)
osthread->set_thread_id(os::Bsd::gettid());
@@ -1190,7 +1195,11 @@ bool os::create_attached_thread(JavaThread* thread) {
// Store pthread info into the OSThread
#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+ osthread->set_thread_id(::mach_thread_self());
+#else
osthread->set_thread_id(::pthread_self());
+#endif
#else
osthread->set_thread_id(os::Bsd::gettid());
#endif
@@ -1807,7 +1816,13 @@ size_t os::lasterror(char *buf, size_t len) {
return n;
}
-intx os::current_thread_id() { return (intx)pthread_self(); }
+intx os::current_thread_id() {
+#ifdef __APPLE__
+ return (intx)::mach_thread_self();
+#else
+ return (intx)::pthread_self();
+#endif
+}
int os::current_process_id() {
// Under the old bsd thread library, bsd gives each thread
@@ -5152,9 +5167,9 @@ jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
struct thread_basic_info tinfo;
mach_msg_type_number_t tcount = THREAD_INFO_MAX;
kern_return_t kr;
- mach_port_t mach_thread;
+ thread_t mach_thread;
- mach_thread = pthread_mach_thread_np(thread->osthread()->thread_id());
+ mach_thread = thread->osthread()->thread_id();
kr = thread_info(mach_thread, THREAD_BASIC_INFO, (thread_info_t)&tinfo, &tcount);
if (kr != KERN_SUCCESS)
return -1;
diff --git a/hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp b/hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp
index 210d5d97b81..4ccf8074424 100644
--- a/hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp
+++ b/hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. 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
@@ -29,12 +29,18 @@
// constants required by the Serviceability Agent. This file is
// referenced by vmStructs.cpp.
+#ifdef __APPLE__
+#define OS_THREAD_ID_TYPE thread_t
+#else
+#define OS_THREAD_ID_TYPE pthread_t
+#endif
+
#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field, last_entry) \
\
/******************************/ \
/* Threads (NOTE: incomplete) */ \
/******************************/ \
- nonstatic_field(OSThread, _thread_id, pthread_t) \
+ nonstatic_field(OSThread, _thread_id, OS_THREAD_ID_TYPE) \
nonstatic_field(OSThread, _pthread_id, pthread_t) \
/* This must be the last entry, and must be present */ \
last_entry()
@@ -46,7 +52,7 @@
/* Posix Thread IDs */ \
/**********************/ \
\
- declare_integer_type(pid_t) \
+ declare_unsigned_integer_type(thread_t) \
declare_unsigned_integer_type(pthread_t) \
\
/* This must be the last entry, and must be present */ \
diff --git a/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp b/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp
index 45b5e8fff6c..e103816de93 100644
--- a/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp
+++ b/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. 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
@@ -87,14 +87,7 @@
#endif
#ifdef __APPLE__
#include
- #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
- // Mac OS X 10.4 defines EFL_AC and EFL_ID,
- // which conflict with hotspot variable names.
- //
- // This has been fixed in Mac OS X 10.5.
- #undef EFL_AC
- #undef EFL_ID
- #endif
+ #include
#endif
#include
#endif // LINUX || _ALLBSD_SOURCE
From d2449123bee91536f5e50d4d78d21a71eaa3abee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Forax?=
Date: Sun, 19 Feb 2012 16:51:35 +0000
Subject: [PATCH 19/37] 7146152: File.path should be final
Reviewed-by: alanb, dholmes, mduigou
---
jdk/src/share/classes/java/io/File.java | 28 ++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/jdk/src/share/classes/java/io/File.java b/jdk/src/share/classes/java/io/File.java
index fba80c2f461..0dbb307c78f 100644
--- a/jdk/src/share/classes/java/io/File.java
+++ b/jdk/src/share/classes/java/io/File.java
@@ -153,7 +153,7 @@ public class File
/**
* The FileSystem object representing the platform's local file system.
*/
- static private FileSystem fs = FileSystem.getFileSystem();
+ private static final FileSystem fs = FileSystem.getFileSystem();
/**
* This abstract pathname's normalized pathname string. A normalized
@@ -162,13 +162,13 @@ public class File
*
* @serial
*/
- private String path;
+ private final String path;
/**
* The length of this abstract pathname's prefix, or zero if it has no
* prefix.
*/
- private transient int prefixLength;
+ private final transient int prefixLength;
/**
* Returns the length of this abstract pathname's prefix.
@@ -2023,10 +2023,28 @@ public class File
char sep = s.readChar(); // read the previous separator char
if (sep != separatorChar)
pathField = pathField.replace(sep, separatorChar);
- this.path = fs.normalize(pathField);
- this.prefixLength = fs.prefixLength(this.path);
+ String path = fs.normalize(pathField);
+ UNSAFE.putObject(this, PATH_OFFSET, path);
+ UNSAFE.putIntVolatile(this, PREFIX_LENGTH_OFFSET, fs.prefixLength(path));
}
+ private static final long PATH_OFFSET;
+ private static final long PREFIX_LENGTH_OFFSET;
+ private static final sun.misc.Unsafe UNSAFE;
+ static {
+ try {
+ sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe();
+ PATH_OFFSET = unsafe.objectFieldOffset(
+ File.class.getDeclaredField("path"));
+ PREFIX_LENGTH_OFFSET = unsafe.objectFieldOffset(
+ File.class.getDeclaredField("prefixLength"));
+ UNSAFE = unsafe;
+ } catch (ReflectiveOperationException e) {
+ throw new Error(e);
+ }
+ }
+
+
/** use serialVersionUID from JDK 1.0.2 for interoperability */
private static final long serialVersionUID = 301077366599181567L;
From 2995eff3e367ce944a83f1bc51fb3c7f5fe0925d Mon Sep 17 00:00:00 2001
From: Charles Lee
Date: Mon, 20 Feb 2012 11:24:06 +0800
Subject: [PATCH 20/37] 7146506: (fc) Add EACCES check to the return of fcntl
native method
Add EACCES check according to the spec of fcntl
Reviewed-by: alanb
---
jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c b/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
index 6468ee9a39f..f7310bab157 100644
--- a/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
+++ b/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
@@ -191,7 +191,7 @@ Java_sun_nio_ch_FileDispatcherImpl_lock0(JNIEnv *env, jobject this, jobject fdo,
}
lockResult = fcntl(fd, cmd, &fl);
if (lockResult < 0) {
- if ((cmd == F_SETLK64) && (errno == EAGAIN))
+ if ((cmd == F_SETLK64) && (errno == EAGAIN || errno == EACCES))
return sun_nio_ch_FileDispatcherImpl_NO_LOCK;
if (errno == EINTR)
return sun_nio_ch_FileDispatcherImpl_INTERRUPTED;
From 86410b610b6514bc3ff80f1314037c0bc0b56d9d Mon Sep 17 00:00:00 2001
From: Alan Bateman
Date: Mon, 20 Feb 2012 18:55:10 +0000
Subject: [PATCH 21/37] 6346658: (se) Selector briefly spins when
asynchronously closing a registered channel [win]
Reviewed-by: chegar, coffeys
---
.../classes/sun/nio/ch/NativeThreadSet.java | 10 +++----
.../classes/sun/nio/ch/NativeThread.java | 6 +++-
.../classes/sun/nio/ch/SocketDispatcher.java | 7 +++--
.../native/sun/nio/ch/SocketDispatcher.c | 28 ++++++++++---------
4 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/jdk/src/share/classes/sun/nio/ch/NativeThreadSet.java b/jdk/src/share/classes/sun/nio/ch/NativeThreadSet.java
index 51eabbcaf23..8c976ce0667 100644
--- a/jdk/src/share/classes/sun/nio/ch/NativeThreadSet.java
+++ b/jdk/src/share/classes/sun/nio/ch/NativeThreadSet.java
@@ -44,8 +44,9 @@ class NativeThreadSet {
//
int add() {
long th = NativeThread.current();
- if (th == -1)
- return -1;
+ // 0 and -1 are treated as placeholders, not real thread handles
+ if (th == 0)
+ th = -1;
synchronized (this) {
int start = 0;
if (used >= elts.length) {
@@ -71,8 +72,6 @@ class NativeThreadSet {
// Removes the thread at the given index.
//
void remove(int i) {
- if (i < 0)
- return;
synchronized (this) {
elts[i] = 0;
used--;
@@ -91,7 +90,8 @@ class NativeThreadSet {
long th = elts[i];
if (th == 0)
continue;
- NativeThread.signal(th);
+ if (th != -1)
+ NativeThread.signal(th);
if (--u == 0)
break;
}
diff --git a/jdk/src/windows/classes/sun/nio/ch/NativeThread.java b/jdk/src/windows/classes/sun/nio/ch/NativeThread.java
index 2138ad5239c..39a9fc6b902 100644
--- a/jdk/src/windows/classes/sun/nio/ch/NativeThread.java
+++ b/jdk/src/windows/classes/sun/nio/ch/NativeThread.java
@@ -31,7 +31,11 @@ package sun.nio.ch;
class NativeThread {
- static long current() { return -1; }
+ static long current() {
+ // return 0 to ensure that async close of blocking sockets will close
+ // the underlying socket.
+ return 0;
+ }
static void signal(long nt) { }
diff --git a/jdk/src/windows/classes/sun/nio/ch/SocketDispatcher.java b/jdk/src/windows/classes/sun/nio/ch/SocketDispatcher.java
index acbab4cfb3c..faf99215cdc 100644
--- a/jdk/src/windows/classes/sun/nio/ch/SocketDispatcher.java
+++ b/jdk/src/windows/classes/sun/nio/ch/SocketDispatcher.java
@@ -55,10 +55,11 @@ class SocketDispatcher extends NativeDispatcher
return writev0(fd, address, len);
}
- void close(FileDescriptor fd) throws IOException {
+ void preClose(FileDescriptor fd) throws IOException {
+ preClose0(fd);
}
- void preClose(FileDescriptor fd) throws IOException {
+ void close(FileDescriptor fd) throws IOException {
close0(fd);
}
@@ -75,5 +76,7 @@ class SocketDispatcher extends NativeDispatcher
static native long writev0(FileDescriptor fd, long address, int len)
throws IOException;
+ static native void preClose0(FileDescriptor fd) throws IOException;
+
static native void close0(FileDescriptor fd) throws IOException;
}
diff --git a/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c b/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c
index 2a0ba288e15..4dc8259dfc4 100644
--- a/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c
+++ b/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c
@@ -238,23 +238,25 @@ Java_sun_nio_ch_SocketDispatcher_writev0(JNIEnv *env, jclass clazz,
}
JNIEXPORT void JNICALL
-Java_sun_nio_ch_SocketDispatcher_close0(JNIEnv *env, jclass clazz,
- jobject fdo)
+Java_sun_nio_ch_SocketDispatcher_preClose0(JNIEnv *env, jclass clazz,
+ jobject fdo)
{
jint fd = fdval(env, fdo);
struct linger l;
int len = sizeof(l);
-
- if (fd != -1) {
- int result = 0;
- if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (char *)&l, &len) == 0) {
- if (l.l_onoff == 0) {
- WSASendDisconnect(fd, NULL);
- }
- }
- result = closesocket(fd);
- if (result == SOCKET_ERROR) {
- JNU_ThrowIOExceptionWithLastError(env, "Socket close failed");
+ if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (char *)&l, &len) == 0) {
+ if (l.l_onoff == 0) {
+ WSASendDisconnect(fd, NULL);
}
}
}
+
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_SocketDispatcher_close0(JNIEnv *env, jclass clazz,
+ jobject fdo)
+{
+ jint fd = fdval(env, fdo);
+ if (closesocket(fd) == SOCKET_ERROR) {
+ JNU_ThrowIOExceptionWithLastError(env, "Socket close failed");
+ }
+}
From 697f1518969f3dba392e86bc5c3689c01a8d2c12 Mon Sep 17 00:00:00 2001
From: Alan Bateman
Date: Mon, 20 Feb 2012 19:33:32 +0000
Subject: [PATCH 22/37] 7147087: Remove AWT/Swing/client tests from ProblemList
Reviewed-by: ohair
---
jdk/test/Makefile | 4 +-
jdk/test/ProblemList.txt | 167 +++++----------------------------------
2 files changed, 20 insertions(+), 151 deletions(-)
diff --git a/jdk/test/Makefile b/jdk/test/Makefile
index 9f443817469..268d6a5b071 100644
--- a/jdk/test/Makefile
+++ b/jdk/test/Makefile
@@ -432,14 +432,14 @@ jdk_awt: $(call TestDirs, com/sun/awt java/awt sun/awt \
javax/imageio javax/print sun/pisces)
$(call RunOthervmBatch)
-# Stable agentvm testruns (minus items from PROBLEM_LIST)
+# Stable othervm testruns (minus items from PROBLEM_LIST)
JDK_ALL_TARGETS += jdk_beans1
JDK_DEFAULT_TARGETS += jdk_beans1
jdk_beans1: $(call TestDirs, \
java/beans/beancontext java/beans/PropertyChangeSupport \
java/beans/Introspector java/beans/Performance \
java/beans/VetoableChangeSupport java/beans/Statement)
- $(call RunAgentvmBatch)
+ $(call RunOthervmBatch)
# Stable othervm testruns (minus items from PROBLEM_LIST)
# Using agentvm has serious problems with these tests
diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt
index 7397a9a840d..b75084eb97e 100644
--- a/jdk/test/ProblemList.txt
+++ b/jdk/test/ProblemList.txt
@@ -114,83 +114,10 @@
# jdk_awt
-# None of the awt tests are using samevm, might not be worth the effort due
-# to the vm overhead not being enough to make a difference.
-# In general, the awt tests are problematic with or without samevm, and there
-# are issues with using a Xvfb display.
-
-# Fails on solaris sparc, timedout? in othervm mode
-java/awt/event/MouseEvent/AcceptExtraButton/AcceptExtraButton.java generic-all
-
-# Causes hang in samevm mode??? Solaris 11 i586
-java/awt/FullScreen/SetFSWindow/FSFrame.java generic-all
-
-# Fails on solaris 11 i586, -client, in othervm mode not sure why
-java/awt/Component/PrintAllXcheckJNI/PrintAllXcheckJNI.java generic-all
-java/awt/Focus/CloseDialogActivateOwnerTest/CloseDialogActivateOwnerTest.java generic-all
-java/awt/FontClass/FontAccess.java generic-all
-java/awt/Mixing/HWDisappear.java generic-all
-java/awt/Mixing/MixingInHwPanel.java generic-all
-java/awt/Mouse/MaximizedFrameTest/MaximizedFrameTest.html generic-all
-java/awt/Robot/AcceptExtraMouseButtons/AcceptExtraMouseButtons.java generic-all
-java/awt/Toolkit/SecurityTest/SecurityTest2.java generic-all
-java/awt/image/mlib/MlibOpsTest.java generic-all
-
-# Fails on windows, othervm mode, various errors
-java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java generic-all
-java/awt/Focus/OwnedWindowFocusIMECrashTest/OwnedWindowFocusIMECrashTest.java generic-all
-java/awt/FullScreen/NoResizeEventOnDMChangeTest/NoResizeEventOnDMChangeTest.java generic-all
-java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Standard.java generic-all
-java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html generic-all
-java/awt/font/Threads/FontThread.java generic-all
-java/awt/print/PrinterJob/PrtException.java generic-all
-
-# Fails with windows X64, othervm, -server
-com/sun/awt/Translucency/WindowOpacity.java generic-all
-java/awt/EventDispatchThread/HandleExceptionOnEDT/HandleExceptionOnEDT.java generic-all
-java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html generic-all
-java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html generic-all
-java/awt/Focus/FocusEmbeddedFrameTest/FocusEmbeddedFrameTest.java generic-all
-java/awt/Frame/LayoutOnMaximizeTest/LayoutOnMaximizeTest.java generic-all
-java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java generic-all
-java/awt/Mixing/MixingOnShrinkingHWButton.java generic-all
-java/awt/Mouse/MouseModifiersUnitTest/ExtraButtonDrag.java generic-all
-
############################################################################
# jdk_beans
-# A large set of the beans tests set the security manager, which would seem
-# to indicate that a large number of them should be "othervm", yet are all
-# very small tests and could greatly benefit from a samevm test run.
-# So a large batch of beans tests are currently run with othervm mode.
-
-# Filed 6986807
-java/beans/Introspector/TestTypeResolver.java generic-all
-
-# Filed 6986813
-java/beans/Introspector/memory/Test4508780.java generic-all
-
-# Linux, some kind of problems with X11 display
-java/beans/PropertyChangeSupport/Test4682386.java generic-all
-java/beans/PropertyChangeSupport/TestSynchronization.java generic-all
-java/beans/Statement/Test4653179.java generic-all
-
-# Runs REALLY slow on Solaris sparc for some reason, both -client and -server
-java/beans/XMLEncoder/Test4625418.java solaris-sparc
-
-# Problems with samevm and setting security manager (speculation partially)
-java/beans/Introspector/4168475/Test4168475.java generic-all
-java/beans/Introspector/4520754/Test4520754.java generic-all
-java/beans/Introspector/6380849/TestBeanInfo.java generic-all
-java/beans/Introspector/Test4144543.java generic-all
-
-# Failed to call method solaris-sparc???
-java/beans/EventHandler/Test6788531.java generic-all
-
-# Jar or class not found???
-java/beans/XMLEncoder/6329581/Test6329581.java generic-all
-
############################################################################
# jdk_lang
@@ -211,6 +138,12 @@ java/lang/management/MemoryMXBean/CollectionUsageThreshold.java generic-all
# jdk_management
+# 6959636
+javax/management/loading/LibraryLoader/LibraryLoaderTest.java windows-all
+
+# 7144846
+javax/management/remote/mandatory/connection/ReconnectTest.java generic-all
+
# 7073626
sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh windows-all
sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh windows-all
@@ -229,72 +162,6 @@ demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java generic-all
# Need to be marked othervm, or changed to be samevm safe
com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java generic-all
-# Need to be marked othervm, or changed to be samevm safe
-com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java generic-all
-
-# Solaris sparc and others, exception in initializer
-javax/imageio/CachePremissionsTest/CachePermissionsTest.java generic-all
-
-# Leaves file rgba_* open, fails with windows samevm
-javax/imageio/plugins/png/PngOutputTypeTest.java generic-all
-
-# Suspect test.png file is left open, windows samevm problems
-javax/imageio/plugins/png/ITXtTest.java generic-all
-
-# Solaris sparc and others, failed to compile testcase
-javax/imageio/metadata/DOML3Node.java generic-all
-
-# One of these tests is leaving file IMGP1001.JPG open, windows samevm
-javax/imageio/plugins/jpeg/ConcurrentReadingTest.java generic-all
-javax/imageio/plugins/jpeg/ReadingInterruptionTest.java generic-all
-
-# One of these files is missing a close on writer_* files, windows samevm
-javax/imageio/plugins/jpeg/ConcurrentWritingTest.java generic-all
-javax/imageio/plugins/jpeg/WritingInterruptionTest.java generic-all
-
-# Leaving file test.jpg open, windows samevm
-javax/imageio/plugins/jpeg/ReadAsGrayTest.java generic-all
-
-# Missing close on file wbmp*, windows samevm
-javax/imageio/plugins/wbmp/CanDecodeTest.java generic-all
-
-# Failures on OpenSolaris, cannot read input files? samevm issues?
-javax/imageio/metadata/BooleanAttributes.java generic-all
-javax/imageio/plugins/bmp/BMPSubsamplingTest.java generic-all
-javax/imageio/plugins/bmp/TopDownTest.java generic-all
-javax/imageio/plugins/gif/EncodeSubImageTest.java generic-all
-javax/imageio/plugins/gif/GifTransparencyTest.java generic-all
-javax/imageio/plugins/png/GrayPngTest.java generic-all
-javax/imageio/plugins/png/ItxtUtf8Test.java generic-all
-javax/imageio/plugins/png/MergeStdCommentTest.java generic-all
-javax/imageio/plugins/png/ShortHistogramTest.java generic-all
-javax/imageio/plugins/shared/BitDepth.java generic-all
-
-# Exclude all javax/print tests, even if they passed, they may need samevm work
-
-# Times out on solaris-sparc, sparcv9, x64 -server, some on i586 -client
-javax/print/attribute/autosense/PrintAutoSenseData.java generic-all
-javax/print/attribute/Chroma.java generic-all
-javax/print/attribute/CollateAttr.java generic-all
-javax/print/attribute/PSCopiesFlavorTest.java generic-all
-javax/print/LookupServices.java generic-all
-javax/print/TestRaceCond.java generic-all
-
-# These tests really require a printer (might all be windows only tests?)
-javax/print/CheckDupFlavor.java generic-all
-javax/print/PrintSE/PrintSE.sh generic-all
-javax/print/attribute/ChromaticityValues.java generic-all
-javax/print/attribute/GetCopiesSupported.java generic-all
-javax/print/attribute/SidesPageRangesTest.java generic-all
-javax/print/attribute/SupportedPrintableAreas.java generic-all
-javax/print/attribute/AttributeTest.java generic-all
-
-# Only print test left, excluding just because all print tests have been
-javax/print/attribute/MediaMappingsTest.java generic-all
-
-# Filed 7058852
-javax/sound/sampled/FileWriter/AlawEncoderSync.java generic-all
-
############################################################################
# jdk_net
@@ -317,6 +184,7 @@ java/net/InetAddress/CheckJNI.java linux-all
# failing on vista 32/64 on nightly
# 7102702
java/net/PortUnreachableException/OneExceptionOnly.java windows-all
+
############################################################################
# jdk_io
@@ -354,6 +222,12 @@ java/rmi/registry/readTest/readTest.sh windows-all
# jdk_security
+# 7145024
+sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/main.java solaris-all
+
+# 7147060
+com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java generic-all
+
# Failing on Solaris i586, 3/9/2010, not a -samevm issue (jdk_security3)
sun/security/pkcs11/Secmod/AddPrivateKey.java solaris-i586
sun/security/pkcs11/ec/ReadCertificates.java solaris-i586
@@ -409,21 +283,16 @@ sun/security/tools/keytool/standard.sh solaris-all
############################################################################
-# jdk_swing (not using samevm)
+# jdk_sound
-# Fails on solaris 11 i586, with othervm
-javax/swing/JFileChooser/6570445/bug6570445.java generic-all
-javax/swing/JFileChooser/6738668/bug6738668.java generic-all
-javax/swing/JPopupMenu/6675802/bug6675802.java generic-all
-javax/swing/system/6799345/TestShutdown.java generic-all
+############################################################################
+
+# jdk_swing
############################################################################
# jdk_text
-# Linux x64 occasional errors, no details
-java/text/Bidi/Bug6665028.java linux-x64
-
############################################################################
# jdk_tools
@@ -452,7 +321,7 @@ sun/tools/jconsole/ResourceCheckTest.sh generic-all
# 7132203
sun/jvmstat/monitor/MonitoredVm/CR6672135.java generic-all
-# Tests take too long
+# Tests take too long, see 7143279
tools/pack200/CommandLineTests.java generic-all
tools/pack200/Pack200Test.java generic-all
From d21a6ce41f6a23775c15d14790151494ecfe4aab Mon Sep 17 00:00:00 2001
From: Weijun Wang
Date: Tue, 21 Feb 2012 08:51:26 +0800
Subject: [PATCH 23/37] 7144530: KeyTab.getInstance(String) no longer handles
keyTabNames with "file:" prefix
Reviewed-by: valeriep
---
.../security/krb5/internal/ktab/KeyTab.java | 2 +-
.../sun/security/krb5/ktab/FileKeyTab.java | 58 +++++++++++++++++++
2 files changed, 59 insertions(+), 1 deletion(-)
create mode 100644 jdk/test/sun/security/krb5/ktab/FileKeyTab.java
diff --git a/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java b/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java
index 3ae4afc89a8..b7b1db2d97e 100644
--- a/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java
+++ b/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java
@@ -141,7 +141,7 @@ public class KeyTab implements KeyTabConstants {
if (s == null) {
return getInstance();
} else {
- return getInstance0(s);
+ return getInstance0(parse(s));
}
}
diff --git a/jdk/test/sun/security/krb5/ktab/FileKeyTab.java b/jdk/test/sun/security/krb5/ktab/FileKeyTab.java
new file mode 100644
index 00000000000..ab6fb64da91
--- /dev/null
+++ b/jdk/test/sun/security/krb5/ktab/FileKeyTab.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. 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 7144530
+ * @summary KeyTab.getInstance(String) no longer handles keyTabNames with "file:" prefix
+ */
+import java.io.File;
+import sun.security.krb5.PrincipalName;
+import sun.security.krb5.internal.ktab.KeyTab;
+
+public class FileKeyTab {
+ public static void main(String[] args) throws Exception {
+ String name = "ktab";
+ KeyTab kt = KeyTab.create(name);
+ kt.addEntry(new PrincipalName("a@A"), "x".toCharArray(), 1, true);
+ kt.save();
+ check(name);
+ check("FILE:" + name);
+
+ name = new File(name).getAbsolutePath().toString();
+
+ check(name);
+ check("FILE:" + name);
+
+ // The bug reporter uses this style, should only work for
+ // absolute path
+ check("FILE:/" + name);
+ }
+
+ static void check(String file) throws Exception {
+ System.out.println("Checking for " + file + "...");
+ KeyTab kt2 = KeyTab.getInstance(file);
+ if (kt2.isMissing()) {
+ throw new Exception("FILE:ktab cannot be loaded");
+ }
+ }
+}
From 41f7f6302b322bcaecb4a549207269442ee8c454 Mon Sep 17 00:00:00 2001
From: Krystal Mok
Date: Mon, 20 Feb 2012 21:27:56 -0800
Subject: [PATCH 24/37] 7145358: SA throws ClassCastException for partially
loaded ConstantPool
In printValueOn() in ConstantPool.java check if the poolHolder is a valid Klass and only then print it.
Reviewed-by: sla, sspitsyn
---
.../share/classes/sun/jvm/hotspot/oops/ConstantPool.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java
index 5752eaed39a..874512fdc77 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java
@@ -648,7 +648,12 @@ public class ConstantPool extends Oop implements ClassConstants {
}
public void printValueOn(PrintStream tty) {
- tty.print("ConstantPool for " + getPoolHolder().getName().asString());
+ Oop holder = poolHolder.getValue(this);
+ if (holder instanceof Klass) {
+ tty.print("ConstantPool for " + ((Klass)holder).getName().asString());
+ } else {
+ tty.print("ConstantPool for partially loaded class");
+ }
}
public long getObjectSize() {
From ace6464105e7bfe2faf01e53e04704ad1de74fad Mon Sep 17 00:00:00 2001
From: Weijun Wang
Date: Tue, 21 Feb 2012 15:11:27 +0800
Subject: [PATCH 25/37] 7147336: clarification on warning of keytool -printcrl
Reviewed-by: xuelei
---
jdk/src/share/classes/sun/security/tools/KeyTool.java | 11 ++++++++---
.../share/classes/sun/security/util/Resources.java | 4 ++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/jdk/src/share/classes/sun/security/tools/KeyTool.java b/jdk/src/share/classes/sun/security/tools/KeyTool.java
index 3125f6f54c7..44fb40d5d5b 100644
--- a/jdk/src/share/classes/sun/security/tools/KeyTool.java
+++ b/jdk/src/share/classes/sun/security/tools/KeyTool.java
@@ -2117,19 +2117,24 @@ public final class KeyTool {
if (caks != null) {
issuer = verifyCRL(caks, crl);
if (issuer != null) {
- System.out.println("Verified by " + issuer + " in cacerts");
+ out.printf(rb.getString(
+ "verified.by.s.in.s"), issuer, "cacerts");
+ out.println();
}
}
if (issuer == null && keyStore != null) {
issuer = verifyCRL(keyStore, crl);
if (issuer != null) {
- System.out.println("Verified by " + issuer + " in keystore");
+ out.printf(rb.getString(
+ "verified.by.s.in.s"), issuer, "keystore");
+ out.println();
}
}
if (issuer == null) {
out.println(rb.getString
("STAR"));
- out.println("WARNING: not verified. Make sure -keystore and -alias are correct.");
+ out.println(rb.getString
+ ("warning.not.verified.make.sure.keystore.is.correct"));
out.println(rb.getString
("STARNN"));
}
diff --git a/jdk/src/share/classes/sun/security/util/Resources.java b/jdk/src/share/classes/sun/security/util/Resources.java
index 299facc668a..a7ba9e2e36d 100644
--- a/jdk/src/share/classes/sun/security/util/Resources.java
+++ b/jdk/src/share/classes/sun/security/util/Resources.java
@@ -409,6 +409,10 @@ public class Resources extends java.util.ListResourceBundle {
{"Please.provide.keysize.for.secret.key.generation",
"Please provide -keysize for secret key generation"},
+ {"verified.by.s.in.s", "Verified by %s in %s"},
+ {"warning.not.verified.make.sure.keystore.is.correct",
+ "WARNING: not verified. Make sure -keystore is correct."},
+
{"Extensions.", "Extensions: "},
{".Empty.value.", "(Empty value)"},
{"Extension.Request.", "Extension Request:"},
From e9695997501db7e5250fc25ef4e81fb77e9c1f08 Mon Sep 17 00:00:00 2001
From: Xue-Lei Andrew Fan
Date: Tue, 21 Feb 2012 05:44:29 -0800
Subject: [PATCH 26/37] 7147407: remove never used debug code in DnsClient.java
Reviewed-by: vinnie
---
jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java b/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java
index 65db51e13b6..33d69ec36b0 100644
--- a/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java
+++ b/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. 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
@@ -622,11 +622,7 @@ public class DnsClient {
//-------------------------------------------------------------------------
- private static boolean debug = false;
-
- public static void setDebug(boolean flag) {
- debug = flag;
- }
+ private static final boolean debug = false;
private static void dprint(String mess) {
if (debug) {
From 3e904497b1e31a87875c65216c07833e3d17d03b Mon Sep 17 00:00:00 2001
From: Jiangli Zhou
Date: Tue, 21 Feb 2012 13:14:55 -0500
Subject: [PATCH 27/37] 7120481: storeStore barrier in constructor with final
field
Issue storestore barrier before constructor return if the constructor write final field.
Reviewed-by: dholmes, jrose, roland, coleenp
---
.../cpu/sparc/vm/c1_LIRAssembler_sparc.cpp | 20 +++++++++++++++++++
.../src/cpu/x86/vm/c1_LIRAssembler_x86.cpp | 19 ++++++++++++++++++
hotspot/src/share/vm/c1/c1_Canonicalizer.cpp | 1 +
hotspot/src/share/vm/c1/c1_Canonicalizer.hpp | 1 +
hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 18 ++++++++++++++++-
hotspot/src/share/vm/c1/c1_IR.cpp | 1 +
hotspot/src/share/vm/c1/c1_IR.hpp | 3 +++
hotspot/src/share/vm/c1/c1_Instruction.hpp | 19 ++++++++++++++++++
.../src/share/vm/c1/c1_InstructionPrinter.cpp | 16 +++++++++++++++
.../src/share/vm/c1/c1_InstructionPrinter.hpp | 1 +
hotspot/src/share/vm/c1/c1_LIR.cpp | 8 ++++++++
hotspot/src/share/vm/c1/c1_LIR.hpp | 8 ++++++++
hotspot/src/share/vm/c1/c1_LIRAssembler.cpp | 16 +++++++++++++++
hotspot/src/share/vm/c1/c1_LIRAssembler.hpp | 4 ++++
hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 17 ++++++++++++++++
hotspot/src/share/vm/c1/c1_LIRGenerator.hpp | 1 +
hotspot/src/share/vm/c1/c1_Optimizer.cpp | 2 ++
hotspot/src/share/vm/c1/c1_ValueMap.hpp | 1 +
18 files changed, 155 insertions(+), 1 deletion(-)
diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp
index 565fdee6565..904489e3a2b 100644
--- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp
@@ -3231,6 +3231,26 @@ void LIR_Assembler::membar_release() {
// no-op on TSO
}
+void LIR_Assembler::membar_loadload() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::loadload));
+}
+
+void LIR_Assembler::membar_storestore() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::storestore));
+}
+
+void LIR_Assembler::membar_loadstore() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::loadstore));
+}
+
+void LIR_Assembler::membar_storeload() {
+ __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
+}
+
+
// Pack two sequential registers containing 32 bit values
// into a single 64 bit register.
// src and src->successor() are packed into dst
diff --git a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
index c745ade299f..b0062406da1 100644
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
@@ -3713,6 +3713,25 @@ void LIR_Assembler::membar_release() {
// __ store_fence();
}
+void LIR_Assembler::membar_loadload() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::loadload));
+}
+
+void LIR_Assembler::membar_storestore() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::storestore));
+}
+
+void LIR_Assembler::membar_loadstore() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::loadstore));
+}
+
+void LIR_Assembler::membar_storeload() {
+ __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
+}
+
void LIR_Assembler::get_thread(LIR_Opr result_reg) {
assert(result_reg->is_register(), "check");
#ifdef _LP64
diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
index 5cee812f04a..c7a5198da33 100644
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
@@ -908,3 +908,4 @@ void Canonicalizer::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {}
void Canonicalizer::do_ProfileCall(ProfileCall* x) {}
void Canonicalizer::do_ProfileInvoke(ProfileInvoke* x) {}
void Canonicalizer::do_RuntimeCall(RuntimeCall* x) {}
+void Canonicalizer::do_MemBar(MemBar* x) {}
diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp
index 571e707888b..8ae3a218319 100644
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp
@@ -104,6 +104,7 @@ class Canonicalizer: InstructionVisitor {
virtual void do_ProfileCall (ProfileCall* x);
virtual void do_ProfileInvoke (ProfileInvoke* x);
virtual void do_RuntimeCall (RuntimeCall* x);
+ virtual void do_MemBar (MemBar* x);
};
#endif // SHARE_VM_C1_C1_CANONICALIZER_HPP
diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
index ac0cea7080b..a59ae10dde4 100644
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
@@ -1418,6 +1418,12 @@ void GraphBuilder::method_return(Value x) {
call_register_finalizer();
}
+ bool need_mem_bar = false;
+ if (method()->name() == ciSymbol::object_initializer_name() &&
+ scope()->wrote_final()) {
+ need_mem_bar = true;
+ }
+
// Check to see whether we are inlining. If so, Return
// instructions become Gotos to the continuation point.
if (continuation() != NULL) {
@@ -1437,6 +1443,10 @@ void GraphBuilder::method_return(Value x) {
monitorexit(state()->lock_at(0), SynchronizationEntryBCI);
}
+ if (need_mem_bar) {
+ append(new MemBar(lir_membar_storestore));
+ }
+
// State at end of inlined method is the state of the caller
// without the method parameters on stack, including the
// return value, if any, of the inlined method on operand stack.
@@ -1456,7 +1466,6 @@ void GraphBuilder::method_return(Value x) {
// the continuation point.
append_with_bci(goto_callee, scope_data()->continuation()->bci());
incr_num_returns();
-
return;
}
@@ -1472,6 +1481,10 @@ void GraphBuilder::method_return(Value x) {
append_split(new MonitorExit(receiver, state()->unlock()));
}
+ if (need_mem_bar) {
+ append(new MemBar(lir_membar_storestore));
+ }
+
append(new Return(x));
}
@@ -1504,6 +1517,9 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
}
}
+ if (field->is_final() && (code == Bytecodes::_putfield)) {
+ scope()->set_wrote_final();
+ }
const int offset = !needs_patching ? field->offset() : -1;
switch (code) {
diff --git a/hotspot/src/share/vm/c1/c1_IR.cpp b/hotspot/src/share/vm/c1/c1_IR.cpp
index 917fc5bd5db..bdff56008bd 100644
--- a/hotspot/src/share/vm/c1/c1_IR.cpp
+++ b/hotspot/src/share/vm/c1/c1_IR.cpp
@@ -141,6 +141,7 @@ IRScope::IRScope(Compilation* compilation, IRScope* caller, int caller_bci, ciMe
_xhandlers = new XHandlers(method);
_number_of_locks = 0;
_monitor_pairing_ok = method->has_balanced_monitors();
+ _wrote_final = false;
_start = NULL;
if (osr_bci == -1) {
diff --git a/hotspot/src/share/vm/c1/c1_IR.hpp b/hotspot/src/share/vm/c1/c1_IR.hpp
index 217774f575f..83c25d633e0 100644
--- a/hotspot/src/share/vm/c1/c1_IR.hpp
+++ b/hotspot/src/share/vm/c1/c1_IR.hpp
@@ -149,6 +149,7 @@ class IRScope: public CompilationResourceObj {
XHandlers* _xhandlers; // the exception handlers
int _number_of_locks; // the number of monitor lock slots needed
bool _monitor_pairing_ok; // the monitor pairing info
+ bool _wrote_final; // has written final field
BlockBegin* _start; // the start block, successsors are method entries
BitMap _requires_phi_function; // bit is set if phi functions at loop headers are necessary for a local variable
@@ -181,6 +182,8 @@ class IRScope: public CompilationResourceObj {
void set_min_number_of_locks(int n) { if (n > _number_of_locks) _number_of_locks = n; }
bool monitor_pairing_ok() const { return _monitor_pairing_ok; }
BlockBegin* start() const { return _start; }
+ void set_wrote_final() { _wrote_final = true; }
+ bool wrote_final () const { return _wrote_final; }
};
diff --git a/hotspot/src/share/vm/c1/c1_Instruction.hpp b/hotspot/src/share/vm/c1/c1_Instruction.hpp
index 9f9de6a14e3..9cdef87b9f3 100644
--- a/hotspot/src/share/vm/c1/c1_Instruction.hpp
+++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp
@@ -107,6 +107,7 @@ class UnsafePrefetchWrite;
class ProfileCall;
class ProfileInvoke;
class RuntimeCall;
+class MemBar;
// A Value is a reference to the instruction creating the value
typedef Instruction* Value;
@@ -204,6 +205,7 @@ class InstructionVisitor: public StackObj {
virtual void do_ProfileCall (ProfileCall* x) = 0;
virtual void do_ProfileInvoke (ProfileInvoke* x) = 0;
virtual void do_RuntimeCall (RuntimeCall* x) = 0;
+ virtual void do_MemBar (MemBar* x) = 0;
};
@@ -2351,6 +2353,23 @@ LEAF(ProfileInvoke, Instruction)
virtual void state_values_do(ValueVisitor*);
};
+LEAF(MemBar, Instruction)
+ private:
+ LIR_Code _code;
+
+ public:
+ MemBar(LIR_Code code)
+ : Instruction(voidType)
+ , _code(code)
+ {
+ pin();
+ }
+
+ LIR_Code code() { return _code; }
+
+ virtual void input_values_do(ValueVisitor*) {}
+};
+
class BlockPair: public CompilationResourceObj {
private:
BlockBegin* _from;
diff --git a/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp b/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp
index 1db5a4dd1b7..88b0b3c7739 100644
--- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp
+++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp
@@ -855,4 +855,20 @@ void InstructionPrinter::do_RuntimeCall(RuntimeCall* x) {
output()->put(')');
}
+void InstructionPrinter::do_MemBar(MemBar* x) {
+ if (os::is_MP()) {
+ LIR_Code code = x->code();
+ switch (code) {
+ case lir_membar_acquire : output()->print("membar_acquire"); break;
+ case lir_membar_release : output()->print("membar_release"); break;
+ case lir_membar : output()->print("membar"); break;
+ case lir_membar_loadload : output()->print("membar_loadload"); break;
+ case lir_membar_storestore: output()->print("membar_storestore"); break;
+ case lir_membar_loadstore : output()->print("membar_loadstore"); break;
+ case lir_membar_storeload : output()->print("membar_storeload"); break;
+ default : ShouldNotReachHere(); break;
+ }
+ }
+}
+
#endif // PRODUCT
diff --git a/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp b/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp
index 94479704240..de6bff4ffee 100644
--- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp
+++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp
@@ -132,6 +132,7 @@ class InstructionPrinter: public InstructionVisitor {
virtual void do_ProfileCall (ProfileCall* x);
virtual void do_ProfileInvoke (ProfileInvoke* x);
virtual void do_RuntimeCall (RuntimeCall* x);
+ virtual void do_MemBar (MemBar* x);
};
#endif // PRODUCT
diff --git a/hotspot/src/share/vm/c1/c1_LIR.cpp b/hotspot/src/share/vm/c1/c1_LIR.cpp
index 629d849bc60..776a6a3df2d 100644
--- a/hotspot/src/share/vm/c1/c1_LIR.cpp
+++ b/hotspot/src/share/vm/c1/c1_LIR.cpp
@@ -464,6 +464,10 @@ void LIR_OpVisitState::visit(LIR_Op* op) {
case lir_membar: // result and info always invalid
case lir_membar_acquire: // result and info always invalid
case lir_membar_release: // result and info always invalid
+ case lir_membar_loadload: // result and info always invalid
+ case lir_membar_storestore: // result and info always invalid
+ case lir_membar_loadstore: // result and info always invalid
+ case lir_membar_storeload: // result and info always invalid
{
assert(op->as_Op0() != NULL, "must be");
assert(op->_info == NULL, "info not used by this instruction");
@@ -1607,6 +1611,10 @@ const char * LIR_Op::name() const {
case lir_membar: s = "membar"; break;
case lir_membar_acquire: s = "membar_acquire"; break;
case lir_membar_release: s = "membar_release"; break;
+ case lir_membar_loadload: s = "membar_loadload"; break;
+ case lir_membar_storestore: s = "membar_storestore"; break;
+ case lir_membar_loadstore: s = "membar_loadstore"; break;
+ case lir_membar_storeload: s = "membar_storeload"; break;
case lir_word_align: s = "word_align"; break;
case lir_label: s = "label"; break;
case lir_nop: s = "nop"; break;
diff --git a/hotspot/src/share/vm/c1/c1_LIR.hpp b/hotspot/src/share/vm/c1/c1_LIR.hpp
index 7220c335d09..f8589c36964 100644
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp
@@ -866,6 +866,10 @@ enum LIR_Code {
, lir_membar
, lir_membar_acquire
, lir_membar_release
+ , lir_membar_loadload
+ , lir_membar_storestore
+ , lir_membar_loadstore
+ , lir_membar_storeload
, lir_get_thread
, end_op0
, begin_op1
@@ -1918,6 +1922,10 @@ class LIR_List: public CompilationResourceObj {
void membar() { append(new LIR_Op0(lir_membar)); }
void membar_acquire() { append(new LIR_Op0(lir_membar_acquire)); }
void membar_release() { append(new LIR_Op0(lir_membar_release)); }
+ void membar_loadload() { append(new LIR_Op0(lir_membar_loadload)); }
+ void membar_storestore() { append(new LIR_Op0(lir_membar_storestore)); }
+ void membar_loadstore() { append(new LIR_Op0(lir_membar_loadstore)); }
+ void membar_storeload() { append(new LIR_Op0(lir_membar_storeload)); }
void nop() { append(new LIR_Op0(lir_nop)); }
void build_frame() { append(new LIR_Op0(lir_build_frame)); }
diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp
index 258fde28308..528f21e841c 100644
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp
@@ -664,6 +664,22 @@ void LIR_Assembler::emit_op0(LIR_Op0* op) {
membar_release();
break;
+ case lir_membar_loadload:
+ membar_loadload();
+ break;
+
+ case lir_membar_storestore:
+ membar_storestore();
+ break;
+
+ case lir_membar_loadstore:
+ membar_loadstore();
+ break;
+
+ case lir_membar_storeload:
+ membar_storeload();
+ break;
+
case lir_get_thread:
get_thread(op->result_opr());
break;
diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp
index 14b62985833..58adf591978 100644
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp
@@ -241,6 +241,10 @@ class LIR_Assembler: public CompilationResourceObj {
void membar();
void membar_acquire();
void membar_release();
+ void membar_loadload();
+ void membar_storestore();
+ void membar_loadstore();
+ void membar_storeload();
void get_thread(LIR_Opr result);
void verify_oop_map(CodeEmitInfo* info);
diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
index d92d919865c..3c7f305222a 100644
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
@@ -3165,3 +3165,20 @@ LIR_Opr LIRGenerator::call_runtime(BasicTypeArray* signature, LIRItemList* args,
}
return result;
}
+
+void LIRGenerator::do_MemBar(MemBar* x) {
+ if (os::is_MP()) {
+ LIR_Code code = x->code();
+ switch(code) {
+ case lir_membar_acquire : __ membar_acquire(); break;
+ case lir_membar_release : __ membar_release(); break;
+ case lir_membar : __ membar(); break;
+ case lir_membar_loadload : __ membar_loadload(); break;
+ case lir_membar_storestore: __ membar_storestore(); break;
+ case lir_membar_loadstore : __ membar_loadstore(); break;
+ case lir_membar_storeload : __ membar_storeload(); break;
+ default : ShouldNotReachHere(); break;
+ }
+ }
+}
+
diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp
index 2b8fc23e65b..56b28e4eb8e 100644
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp
@@ -525,6 +525,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure {
virtual void do_ProfileCall (ProfileCall* x);
virtual void do_ProfileInvoke (ProfileInvoke* x);
virtual void do_RuntimeCall (RuntimeCall* x);
+ virtual void do_MemBar (MemBar* x);
};
diff --git a/hotspot/src/share/vm/c1/c1_Optimizer.cpp b/hotspot/src/share/vm/c1/c1_Optimizer.cpp
index e1a0ef7bfdd..ff05781ce67 100644
--- a/hotspot/src/share/vm/c1/c1_Optimizer.cpp
+++ b/hotspot/src/share/vm/c1/c1_Optimizer.cpp
@@ -509,6 +509,7 @@ public:
void do_ProfileCall (ProfileCall* x);
void do_ProfileInvoke (ProfileInvoke* x);
void do_RuntimeCall (RuntimeCall* x);
+ void do_MemBar (MemBar* x);
};
@@ -678,6 +679,7 @@ void NullCheckVisitor::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {}
void NullCheckVisitor::do_ProfileCall (ProfileCall* x) { nce()->clear_last_explicit_null_check(); }
void NullCheckVisitor::do_ProfileInvoke (ProfileInvoke* x) {}
void NullCheckVisitor::do_RuntimeCall (RuntimeCall* x) {}
+void NullCheckVisitor::do_MemBar (MemBar* x) {}
void NullCheckEliminator::visit(Value* p) {
diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.hpp b/hotspot/src/share/vm/c1/c1_ValueMap.hpp
index 248d174964d..4278b11d39a 100644
--- a/hotspot/src/share/vm/c1/c1_ValueMap.hpp
+++ b/hotspot/src/share/vm/c1/c1_ValueMap.hpp
@@ -200,6 +200,7 @@ class ValueNumberingVisitor: public InstructionVisitor {
void do_ProfileCall (ProfileCall* x) { /* nothing to do */ }
void do_ProfileInvoke (ProfileInvoke* x) { /* nothing to do */ };
void do_RuntimeCall (RuntimeCall* x) { /* nothing to do */ };
+ void do_MemBar (MemBar* x) { /* nothing to do */ };
};
From aebf95f6f227917b3df7e946007687252dbb75a4 Mon Sep 17 00:00:00 2001
From: David Katleman
Date: Thu, 23 Feb 2012 12:03:01 -0800
Subject: [PATCH 28/37] Added tag jdk8-b27 for changeset 9f0948ea25eb
---
.hgtags-top-repo | 1 +
1 file changed, 1 insertion(+)
diff --git a/.hgtags-top-repo b/.hgtags-top-repo
index 4ed846ec0c6..650464aa130 100644
--- a/.hgtags-top-repo
+++ b/.hgtags-top-repo
@@ -148,3 +148,4 @@ cc771d92284f71765eca14d6d08703c4af254c04 jdk8-b21
1a5f1d6b98d6827cdb529a4abe6e52a886d944f4 jdk8-b24
221a378e06a326f45e5d89e2123cd6323e0181d1 jdk8-b25
2accafff224ae39caf5f532c305251ba624bf2c0 jdk8-b26
+1533dfab9903e4edcfead3b0192643f38c418b9b jdk8-b27
From 663327f408875e15e4f4617615ff654d55ee25e2 Mon Sep 17 00:00:00 2001
From: David Katleman
Date: Thu, 23 Feb 2012 12:03:03 -0800
Subject: [PATCH 29/37] Added tag jdk8-b27 for changeset 96028882c1dc
---
corba/.hgtags | 1 +
1 file changed, 1 insertion(+)
diff --git a/corba/.hgtags b/corba/.hgtags
index 900118fb343..528e8770d13 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -148,3 +148,4 @@ a11d0062c445d5f36651c78650ab88aa594bcbff jdk8-b22
b98f0e6dddf987df565029a1f58417fc1844c3f3 jdk8-b24
e45d6b406d5f91ff5256a5c82456ab1e7eb8becd jdk8-b25
79f709a099f40c08f76567fa6d813f9009a69826 jdk8-b26
+4fffe75e4edd39a2517f10b743941bf94edb143d jdk8-b27
From 158427237ebab75edd68d132a188e9d0695a099c Mon Sep 17 00:00:00 2001
From: David Katleman
Date: Thu, 23 Feb 2012 12:03:08 -0800
Subject: [PATCH 30/37] Added tag jdk8-b27 for changeset 30cf3316d124
---
hotspot/.hgtags | 1 +
1 file changed, 1 insertion(+)
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index 9d4934f3938..22f0a554e4c 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -224,3 +224,4 @@ fd3060701216a11c0df6dcd053c6fd7c2b17a42c jdk8-b26
f92a171cf0071ca6c3fa8231d7d570377f8b2f4d hs23-b16
f92a171cf0071ca6c3fa8231d7d570377f8b2f4d hs23-b16
931e5f39e365a0d550d79148ff87a7f9e864d2e1 hs23-b16
+3b24e7e01d20ca590d0f86b1222bb7c3f1a2aa2d jdk8-b27
From 076a67b1bf3a56d8aeb267f95726893b8154f6b1 Mon Sep 17 00:00:00 2001
From: David Katleman
Date: Thu, 23 Feb 2012 12:03:16 -0800
Subject: [PATCH 31/37] Added tag jdk8-b27 for changeset 4506e41cb329
---
jaxp/.hgtags | 1 +
1 file changed, 1 insertion(+)
diff --git a/jaxp/.hgtags b/jaxp/.hgtags
index c45e6fc5aa1..4fbc5eb0f97 100644
--- a/jaxp/.hgtags
+++ b/jaxp/.hgtags
@@ -148,3 +148,4 @@ cf9d6ec44f891236ad18451021d6dcd57dc82f7b jdk8-b22
7836655e2495646c462f13de73dcc3ada197b64f jdk8-b24
bb694c151fc7b5c8f9edc8af6a80738530feacaf jdk8-b25
dbb7283c197b27da1fc12ae8a83785c851b68c12 jdk8-b26
+80c47eb83d24fdd64bbb48f288bd6d4f03e0ec88 jdk8-b27
From 5e6beee12cb4aa3774c10042b90fc751e71e1192 Mon Sep 17 00:00:00 2001
From: David Katleman
Date: Thu, 23 Feb 2012 12:03:17 -0800
Subject: [PATCH 32/37] Added tag jdk8-b27 for changeset 0b1b48f6f78d
---
jaxws/.hgtags | 1 +
1 file changed, 1 insertion(+)
diff --git a/jaxws/.hgtags b/jaxws/.hgtags
index 792c0b730b7..f38ab8b17ec 100644
--- a/jaxws/.hgtags
+++ b/jaxws/.hgtags
@@ -148,3 +148,4 @@ c266cab0e3fff05f2048c23046c14d60f7102175 jdk8-b21
e0d90803439b174fe0b0033e09d50444ba12498f jdk8-b24
b376d901e006cd9e0c59733c84e190aace23eec6 jdk8-b25
3518639eab6ce5c7b482bdb0a60342c392ab97a8 jdk8-b26
+38c037af4127289de12efc67f45d19bb67abff69 jdk8-b27
From 7835898d92ffcd3a9cf2ea31dc4ab00a1da3f417 Mon Sep 17 00:00:00 2001
From: David Katleman
Date: Thu, 23 Feb 2012 12:03:21 -0800
Subject: [PATCH 33/37] Added tag jdk8-b27 for changeset 020ee18d16db
---
jdk/.hgtags | 1 +
1 file changed, 1 insertion(+)
diff --git a/jdk/.hgtags b/jdk/.hgtags
index cf44fdc38c7..432a28363ed 100644
--- a/jdk/.hgtags
+++ b/jdk/.hgtags
@@ -148,3 +148,4 @@ dda27c73d8db4a9c7a23872b6f0c5106edcb2021 jdk8-b22
34029a0c69bba882264a29fc822f8283fd15f104 jdk8-b24
ec17fbe5b8fbc52da070eec43b4711d9354b2ab8 jdk8-b25
5aca406e87cb9144a9405be312dadd728a9c6fe2 jdk8-b26
+c68342532e2e7deb3a25fc04ed3e4c142278f747 jdk8-b27
From 9d978102bc81a07d5470134fa7b228265f491c97 Mon Sep 17 00:00:00 2001
From: David Katleman
Date: Thu, 23 Feb 2012 12:03:30 -0800
Subject: [PATCH 34/37] Added tag jdk8-b27 for changeset bc664cc5f2a0
---
langtools/.hgtags | 1 +
1 file changed, 1 insertion(+)
diff --git a/langtools/.hgtags b/langtools/.hgtags
index 9807c2ea95d..d6bb59fb794 100644
--- a/langtools/.hgtags
+++ b/langtools/.hgtags
@@ -148,3 +148,4 @@ bcb21abf1c4177baf4574f99709513dcd4474727 jdk8-b21
6c9d21ca92c41ff5fcfa76c5b7fafe0f042f4aef jdk8-b24
520c30f85bb529a3daf5d7623764c2464f00fd19 jdk8-b25
b556aa8a99c358469861770aebdce884e06fa178 jdk8-b26
+be456f9c64e818161c789252145d4ddc292ae863 jdk8-b27
From c3da3a5048775daf3abdc624586da2e354c6fca6 Mon Sep 17 00:00:00 2001
From: Abhijit Saha
Date: Fri, 24 Feb 2012 17:31:59 -0800
Subject: [PATCH 35/37] 7148758: Resolve merge issue which caused testcase
failure
Reviewed-by: alanb, chegar
---
jdk/src/share/classes/sun/net/httpserver/ServerConfig.java | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java b/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java
index 5e898c75a99..a6b7427822d 100644
--- a/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java
+++ b/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java
@@ -81,6 +81,10 @@ class ServerConfig {
drainAmount = Long.getLong("sun.net.httpserver.drainAmount",
DEFAULT_DRAIN_AMOUNT);
+ maxReqHeaders = Integer.getInteger(
+ "sun.net.httpserver.maxReqHeaders",
+ DEFAULT_MAX_REQ_HEADERS);
+
maxReqTime = Long.getLong("sun.net.httpserver.maxReqTime",
DEFAULT_MAX_REQ_TIME);
From 7f5093d00dbb1e134734d835813a17e3f94a10d4 Mon Sep 17 00:00:00 2001
From: Alejandro Murillo
Date: Fri, 24 Feb 2012 18:08:59 -0800
Subject: [PATCH 36/37] Added tag hs24-b01 for changeset b357c6ebe63e
---
hotspot/.hgtags | 1 +
1 file changed, 1 insertion(+)
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index 22f0a554e4c..7166d465099 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -225,3 +225,4 @@ f92a171cf0071ca6c3fa8231d7d570377f8b2f4d hs23-b16
f92a171cf0071ca6c3fa8231d7d570377f8b2f4d hs23-b16
931e5f39e365a0d550d79148ff87a7f9e864d2e1 hs23-b16
3b24e7e01d20ca590d0f86b1222bb7c3f1a2aa2d jdk8-b27
+975c4105f1e2ef1190a75b77124033f1fd4290b5 hs24-b01
From 111563dc52020b259017a0412be09e83409044bf Mon Sep 17 00:00:00 2001
From: "J. Duke"
Date: Wed, 5 Jul 2017 18:03:21 +0200
Subject: [PATCH 37/37] Added tag jdk8-b27 for changeset c51754cddc03
---
.hgtags | 1 +
1 file changed, 1 insertion(+)
diff --git a/.hgtags b/.hgtags
index 7fb44cb4378..7a7bbeb39e4 100644
--- a/.hgtags
+++ b/.hgtags
@@ -148,3 +148,4 @@ e8f03541af27e38aafb619b96863e17f65ffe53b jdk8-b22
7d3720d8c595d1519c31e9ff7366203fc2c61350 jdk8-b24
0071a6d64113a35ba345bb1580c256de5ce17d3e jdk8-b25
6c805d8ed4e5449ea5e4d158c7bdbd7b0b70efd1 jdk8-b26
+c51754cddc037b9609e202b9ed38363d8683e7a8 jdk8-b27