From f0ff2870a00a36f093fa7e2b80db466f5dad9753 Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Fri, 26 Aug 2016 18:29:46 +0000 Subject: Make the FPU hack for ARM optional. Note this hack is not necessary for VFPv3 or later, i.e., only VFPv1 and VFPv2 require this hack. https://svnweb.freebsd.org/changeset/base/288983 --- java/openjdk8/Makefile | 14 ++--- java/openjdk8/files/armv6.patch | 99 ----------------------------------- java/openjdk8/files/fpuhack.patch | 106 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 109 deletions(-) delete mode 100644 java/openjdk8/files/armv6.patch create mode 100644 java/openjdk8/files/fpuhack.patch (limited to 'java') diff --git a/java/openjdk8/Makefile b/java/openjdk8/Makefile index ba7c76cf10d5..ed1c17b745e0 100644 --- a/java/openjdk8/Makefile +++ b/java/openjdk8/Makefile @@ -234,10 +234,14 @@ CONFIGURE_SCRIPT= ../../configure CONFIGURE_WRKSRC= ${WRKSRC}/common/autoconf OPTIONS_DEFINE= POLICY TZUPDATE +OPTIONS_DEFINE_armv6= FPUHACK OPTIONS_DEFAULT= POLICY TZUPDATE +OPTIONS_DEFAULT_armv6= FPUHACK +FPUHACK_DESC= Hack denormalized numbers in flush-to-zero mode POLICY_DESC= Install the Unlimited Strength Policy Files TZUPDATE_DESC= Update the time zone data +FPUHACK_EXTRA_PATCHES= ${PATCHDIR}/fpuhack.patch POLICY_CONFIGURE_ENABLE= unlimited-crypto TZUPDATE_RUN_DEPENDS= java-zoneinfo>0:java/java-zoneinfo @@ -293,16 +297,6 @@ CONFIGURE_ARGS+= --with-boot-jdk-jvmargs="-Xmx768m" MAKE_ENV+= JAVADOC_CMD_MEM="-Xmx768m" .endif -.if ${ARCH} == "armv6" -# From NetBSD http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/lang/openjdk7/hacks.mk -# Workaround incorrect constant folding of subnormals in javac when the FPU -# does not handle subnormal arithmetic, like on ARM in Flush-to-zero mode. -# These workarounds avoid underflow conditions during the bootstrap so the -# JDK can correctly build itself. Compiling or running programs other than -# openjdk itself on such hardware may still cause unexpected behaviour. -EXTRA_PATCHES= ${PATCHDIR}/armv6.patch -.endif - .if ${ARCH} == "amd64" || ${ARCH} == "i386" JDK_BUILD_JVM= server .else diff --git a/java/openjdk8/files/armv6.patch b/java/openjdk8/files/armv6.patch deleted file mode 100644 index 45037c33a18d..000000000000 --- a/java/openjdk8/files/armv6.patch +++ /dev/null @@ -1,99 +0,0 @@ ---- jdk/src/share/classes/java/lang/Double.java.orig 2014-03-04 02:57:59 UTC -+++ jdk/src/share/classes/java/lang/Double.java -@@ -86,7 +86,7 @@ public final class Double extends Number - * - * @since 1.6 - */ -- public static final double MIN_NORMAL = 0x1.0p-1022; // 2.2250738585072014E-308 -+ public static final double MIN_NORMAL = Double.longBitsToDouble(0x10000000000000L); // 2.2250738585072014E-308 - - /** - * A constant holding the smallest positive nonzero value of type -@@ -95,7 +95,7 @@ public final class Double extends Number - * {@code 0x0.0000000000001P-1022} and also equal to - * {@code Double.longBitsToDouble(0x1L)}. - */ -- public static final double MIN_VALUE = 0x0.0000000000001P-1022; // 4.9e-324 -+ public static final double MIN_VALUE = Double.longBitsToDouble(0x1L); // 4.9e-324 - - /** - * Maximum exponent a finite {@code double} variable may have. ---- jdk/src/share/classes/java/lang/Float.java.orig 2014-03-04 02:57:59 UTC -+++ jdk/src/share/classes/java/lang/Float.java -@@ -85,7 +85,7 @@ public final class Float extends Number - * - * @since 1.6 - */ -- public static final float MIN_NORMAL = 0x1.0p-126f; // 1.17549435E-38f -+ public static final float MIN_NORMAL = Float.intBitsToFloat(0x800000); // 1.17549435E-38f - - /** - * A constant holding the smallest positive nonzero value of type -@@ -93,7 +93,7 @@ public final class Float extends Number - * hexadecimal floating-point literal {@code 0x0.000002P-126f} - * and also equal to {@code Float.intBitsToFloat(0x1)}. - */ -- public static final float MIN_VALUE = 0x0.000002P-126f; // 1.4e-45f -+ public static final float MIN_VALUE = Float.intBitsToFloat(0x1); // 1.4e-45f - - /** - * Maximum exponent a finite {@code float} variable may have. It ---- jdk/src/share/classes/sun/misc/DoubleConsts.java.orig 2014-03-04 02:58:49 UTC -+++ jdk/src/share/classes/sun/misc/DoubleConsts.java -@@ -52,7 +52,7 @@ public class DoubleConsts { - * - * @since 1.5 - */ -- public static final double MIN_NORMAL = 2.2250738585072014E-308; -+ public static final double MIN_NORMAL = Double.longBitsToDouble(0x10000000000000L); - - - /** ---- jdk/src/share/classes/sun/misc/FloatConsts.java.orig 2014-03-04 02:58:49 UTC -+++ jdk/src/share/classes/sun/misc/FloatConsts.java -@@ -49,7 +49,7 @@ public class FloatConsts { - * float, 2-126. It is equal to the value - * returned by Float.intBitsToFloat(0x00800000). - */ -- public static final float MIN_NORMAL = 1.17549435E-38f; -+ public static final float MIN_NORMAL = Float.intBitsToFloat(0x800000); - - /** - * The number of logical bits in the significand of a ---- langtools/src/share/classes/com/sun/tools/javac/jvm/Items.java.orig 2014-03-04 02:51:48 UTC -+++ langtools/src/share/classes/com/sun/tools/javac/jvm/Items.java -@@ -623,12 +623,12 @@ public class Items { - /** Return true iff float number is positive 0. - */ - private boolean isPosZero(float x) { -- return x == 0.0f && 1.0f / x > 0.0f; -+ return Float.floatToIntBits(x) == 0x0; - } - /** Return true iff double number is positive 0. - */ - private boolean isPosZero(double x) { -- return x == 0.0d && 1.0d / x > 0.0d; -+ return Double.doubleToLongBits(x) == 0x0L; - } - - CondItem mkCond() { ---- langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java.orig 2015-09-29 16:38:49 UTC -+++ langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java -@@ -703,7 +703,7 @@ public class JavacParser implements Pars - // error already reported in scanner - n = Float.NaN; - } -- if (n.floatValue() == 0.0f && !isZero(proper)) -+ if (n.floatValue() == 0.0f && !isZero(proper) && Float.floatToIntBits(n) != 0x1) - error(token.pos, "fp.number.too.small"); - else if (n.floatValue() == Float.POSITIVE_INFINITY) - error(token.pos, "fp.number.too.large"); -@@ -722,7 +722,7 @@ public class JavacParser implements Pars - // error already reported in scanner - n = Double.NaN; - } -- if (n.doubleValue() == 0.0d && !isZero(proper)) -+ if (n.doubleValue() == 0.0d && !isZero(proper) && Double.doubleToLongBits(n) != 0x1L) - error(token.pos, "fp.number.too.small"); - else if (n.doubleValue() == Double.POSITIVE_INFINITY) - error(token.pos, "fp.number.too.large"); diff --git a/java/openjdk8/files/fpuhack.patch b/java/openjdk8/files/fpuhack.patch new file mode 100644 index 000000000000..bc5ccdee138f --- /dev/null +++ b/java/openjdk8/files/fpuhack.patch @@ -0,0 +1,106 @@ +From NetBSD http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/lang/openjdk7/hacks.mk +Work around incorrect constant folding of subnormals in javac when the FPU +does not handle subnormal arithmetic, like on ARM in flush-to-zero mode. +These workarounds avoid underflow conditions during the bootstrap so the JDK +can correctly build itself. Compiling or running programs other than OpenJDK +itself on such hardware may still cause unexpected behaviour. + +--- jdk/src/share/classes/java/lang/Double.java.orig 2014-03-04 02:57:59 UTC ++++ jdk/src/share/classes/java/lang/Double.java +@@ -86,7 +86,7 @@ public final class Double extends Number + * + * @since 1.6 + */ +- public static final double MIN_NORMAL = 0x1.0p-1022; // 2.2250738585072014E-308 ++ public static final double MIN_NORMAL = Double.longBitsToDouble(0x10000000000000L); // 2.2250738585072014E-308 + + /** + * A constant holding the smallest positive nonzero value of type +@@ -95,7 +95,7 @@ public final class Double extends Number + * {@code 0x0.0000000000001P-1022} and also equal to + * {@code Double.longBitsToDouble(0x1L)}. + */ +- public static final double MIN_VALUE = 0x0.0000000000001P-1022; // 4.9e-324 ++ public static final double MIN_VALUE = Double.longBitsToDouble(0x1L); // 4.9e-324 + + /** + * Maximum exponent a finite {@code double} variable may have. +--- jdk/src/share/classes/java/lang/Float.java.orig 2014-03-04 02:57:59 UTC ++++ jdk/src/share/classes/java/lang/Float.java +@@ -85,7 +85,7 @@ public final class Float extends Number + * + * @since 1.6 + */ +- public static final float MIN_NORMAL = 0x1.0p-126f; // 1.17549435E-38f ++ public static final float MIN_NORMAL = Float.intBitsToFloat(0x800000); // 1.17549435E-38f + + /** + * A constant holding the smallest positive nonzero value of type +@@ -93,7 +93,7 @@ public final class Float extends Number + * hexadecimal floating-point literal {@code 0x0.000002P-126f} + * and also equal to {@code Float.intBitsToFloat(0x1)}. + */ +- public static final float MIN_VALUE = 0x0.000002P-126f; // 1.4e-45f ++ public static final float MIN_VALUE = Float.intBitsToFloat(0x1); // 1.4e-45f + + /** + * Maximum exponent a finite {@code float} variable may have. It +--- jdk/src/share/classes/sun/misc/DoubleConsts.java.orig 2014-03-04 02:58:49 UTC ++++ jdk/src/share/classes/sun/misc/DoubleConsts.java +@@ -52,7 +52,7 @@ public class DoubleConsts { + * + * @since 1.5 + */ +- public static final double MIN_NORMAL = 2.2250738585072014E-308; ++ public static final double MIN_NORMAL = Double.longBitsToDouble(0x10000000000000L); + + + /** +--- jdk/src/share/classes/sun/misc/FloatConsts.java.orig 2014-03-04 02:58:49 UTC ++++ jdk/src/share/classes/sun/misc/FloatConsts.java +@@ -49,7 +49,7 @@ public class FloatConsts { + * float, 2-126. It is equal to the value + * returned by Float.intBitsToFloat(0x00800000). + */ +- public static final float MIN_NORMAL = 1.17549435E-38f; ++ public static final float MIN_NORMAL = Float.intBitsToFloat(0x800000); + + /** + * The number of logical bits in the significand of a +--- langtools/src/share/classes/com/sun/tools/javac/jvm/Items.java.orig 2014-03-04 02:51:48 UTC ++++ langtools/src/share/classes/com/sun/tools/javac/jvm/Items.java +@@ -623,12 +623,12 @@ public class Items { + /** Return true iff float number is positive 0. + */ + private boolean isPosZero(float x) { +- return x == 0.0f && 1.0f / x > 0.0f; ++ return Float.floatToIntBits(x) == 0x0; + } + /** Return true iff double number is positive 0. + */ + private boolean isPosZero(double x) { +- return x == 0.0d && 1.0d / x > 0.0d; ++ return Double.doubleToLongBits(x) == 0x0L; + } + + CondItem mkCond() { +--- langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java.orig 2015-09-29 16:38:49 UTC ++++ langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +@@ -703,7 +703,7 @@ public class JavacParser implements Pars + // error already reported in scanner + n = Float.NaN; + } +- if (n.floatValue() == 0.0f && !isZero(proper)) ++ if (n.floatValue() == 0.0f && !isZero(proper) && Float.floatToIntBits(n) != 0x1) + error(token.pos, "fp.number.too.small"); + else if (n.floatValue() == Float.POSITIVE_INFINITY) + error(token.pos, "fp.number.too.large"); +@@ -722,7 +722,7 @@ public class JavacParser implements Pars + // error already reported in scanner + n = Double.NaN; + } +- if (n.doubleValue() == 0.0d && !isZero(proper)) ++ if (n.doubleValue() == 0.0d && !isZero(proper) && Double.doubleToLongBits(n) != 0x1L) + error(token.pos, "fp.number.too.small"); + else if (n.doubleValue() == Double.POSITIVE_INFINITY) + error(token.pos, "fp.number.too.large"); -- cgit v1.2.3