--- old/doc/building.html 2018-12-25 16:06:21.018943057 +0100 +++ new/doc/building.html 2018-12-25 16:06:20.642933464 +0100 @@ -58,6 +58,7 @@
  • X11
  • ALSA
  • libffi
  • +
  • SoftFloat
  • Build Tools Requirements

    Use --with-libffi=<path> if configure does not properly locate your libffi files.

    +

    SoftFloat

    +

    Berkeley SoftFloat-3 can be used on ARM processors without FPU to slightly enhance the arithmetic precision of some floating point operations. It is not required, system softfp routines can be used without any problems. The precision loss is extremely small, but the JCK detects it.

    + +

    You can enable this library by specifying a library prefix via --with-sflt=<path> or by specifying path to softfloat.a via --with-sflt-lib=<path> and path to directory containing softfloat.h via --with-sflt-include=<path>. You will also need to specify path to the SoftFloat license file with --with-sflt-license=<path>. If you want to use the prefix option, ensure that <prefix>/lib/softfloat.a, <prefix>/include/softfloat.h and <prefix>/share/softfloat/softfloat.md exist. However you can override the defaults by using the options above.

    +

    If you do not enable this library, standard system libraries will be used instead.

    Build Tools Requirements

    Autoconf

    The JDK requires Autoconf on all platforms. At least version 2.69 is required.

    @@ -491,6 +499,7 @@
  • --with-x=<path> - Set the path to X11
  • --with-alsa=<path> - Set the path to ALSA
  • --with-libffi=<path> - Set the path to libffi
  • +
  • --with-sflt=<path> - Enable and set the path to SoftFloat library.
  • --with-jtreg=<path> - Set the path to JTReg. See Running Tests
  • Certain third-party libraries used by the JDK (libjpeg, giflib, libpng, lcms and zlib) are included in the JDK repository. The default behavior of the JDK build is to use this version of these libraries, but they might be replaced by an external version. To do so, specify system as the <source> option in these arguments. (The default is bundled).

    --- old/doc/building.md 2018-12-25 16:06:21.930966326 +0100 +++ new/doc/building.md 2018-12-25 16:06:21.562956937 +0100 @@ -527,6 +527,32 @@ Use `--with-libffi=` if `configure` does not properly locate your libffi files. +### SoftFloat + +[Berkeley SoftFloat-3](http://www.jhauser.us/arithmetic/SoftFloat.html) +can be used on ARM processors without FPU to slightly enhance +the arithmetic precision of some floating point operations. It is not +required, system softfp routines can be used without any problems. +The precision loss is extremely small, but [the JCK detects it]( +http://mail.openjdk.java.net/pipermail/aarch32-port-dev/2016-November/000611.html). + + * To build the library, you will have to download its source and build it + for the target platform. To do so, take a look in its + `build/Linux-ARM-VFPv2-GCC` subdirectory. + +You can enable this library by specifying a library prefix +via `--with-sflt=` or by specifying path to softfloat.a +via `--with-sflt-lib=` and path to directory +containing softfloat.h via `--with-sflt-include=`. You +will also need to specify path to the SoftFloat license file with +`--with-sflt-license=`. If you want to use the prefix option, ensure that +`/lib/softfloat.a`, `/include/softfloat.h` and +`/share/softfloat/softfloat.md` exist. However you can override +the defaults by using the options above. + +If you do not enable this library, standard system libraries +will be used instead. + ## Build Tools Requirements ### Autoconf @@ -694,6 +720,8 @@ * `--with-x=` - Set the path to [X11](#x11) * `--with-alsa=` - Set the path to [ALSA](#alsa) * `--with-libffi=` - Set the path to [libffi](#libffi) + * `--with-sflt=` - Enable and set the path to [SoftFloat](#softfloat) + library. * `--with-jtreg=` - Set the path to JTReg. See [Running Tests]( #running-tests) --- old/make/autoconf/libraries.m4 2018-12-25 16:06:22.822989085 +0100 +++ new/make/autoconf/libraries.m4 2018-12-25 16:06:22.458979798 +0100 @@ -33,6 +33,7 @@ m4_include([lib-x11.m4]) m4_include([lib-fontconfig.m4]) m4_include([lib-tests.m4]) +m4_include([lib-softfloat.m4]) ################################################################################ # Determine which libraries are needed for this configuration @@ -79,6 +80,13 @@ NEEDS_LIB_ALSA=false fi + if (test "x$OPENJDK_TARGET_CPU" == xarm && + (test "x$ARM_FLOAT_TYPE" = "xsflt" || test "x$ARM_FLOAT_TYPE" = "xvfp-sflt" )); then + USES_LIB_SOFTFLOAT=true + else + USES_LIB_SOFTFLOAT=false + fi + # Check if ffi is needed if HOTSPOT_CHECK_JVM_VARIANT(zero); then NEEDS_LIB_FFI=true @@ -98,6 +106,7 @@ LIB_SETUP_FONTCONFIG LIB_SETUP_FREETYPE LIB_SETUP_ALSA + LIB_SETUP_SOFTFLOAT LIB_SETUP_LIBFFI LIB_SETUP_BUNDLED_LIBS LIB_SETUP_MISC_LIBS --- old/make/autoconf/spec.gmk.in 2018-12-25 16:06:23.699011435 +0100 +++ new/make/autoconf/spec.gmk.in 2018-12-25 16:06:23.331002046 +0100 @@ -353,6 +353,9 @@ CUPS_CFLAGS:=@CUPS_CFLAGS@ ALSA_LIBS:=@ALSA_LIBS@ ALSA_CFLAGS:=@ALSA_CFLAGS@ +SOFTFLOAT_LIBS:=@SOFTFLOAT_LIBS@ +SOFTFLOAT_CFLAGS:=@SOFTFLOAT_CFLAGS@ +SOFTFLOAT_LICENSE:=@SOFTFLOAT_LICENSE@ LIBFFI_LIBS:=@LIBFFI_LIBS@ LIBFFI_CFLAGS:=@LIBFFI_CFLAGS@ ENABLE_LIBFFI_BUNDLING:=@ENABLE_LIBFFI_BUNDLING@ --- old/make/copy/Copy-java.base.gmk 2018-12-25 16:06:24.571033683 +0100 +++ new/make/copy/Copy-java.base.gmk 2018-12-25 16:06:24.211024498 +0100 @@ -226,6 +226,19 @@ TARGETS += $(COPY_LEGAL) ################################################################################ +# Copy softfloat license to the image + +ifneq ($(SOFTFLOAT_CFLAGS), ) + $(eval $(call SetupCopyFiles, COPY_SOFTFLOAT_LICENSE, \ + FILES := $(SOFTFLOAT_LICENSE), \ + DEST := $(LEGAL_DST_DIR), \ + )) + + TARGETS += $(COPY_SOFTFLOAT_LICENSE) +endif + + +################################################################################ # Optionally copy libffi.so.? into the the image ifeq ($(ENABLE_LIBFFI_BUNDLING), true) --- old/make/hotspot/lib/CompileJvm.gmk 2018-12-25 16:06:25.447056033 +0100 +++ new/make/hotspot/lib/CompileJvm.gmk 2018-12-25 16:06:25.087046848 +0100 @@ -49,6 +49,7 @@ JVM_LIBS += \ $(JVM_LIBS_FEATURES) \ + $(SOFTFLOAT_LIBS) \ # # These files and directories are always excluded --- old/make/hotspot/lib/JvmFlags.gmk 2018-12-25 16:06:26.307077974 +0100 +++ new/make/hotspot/lib/JvmFlags.gmk 2018-12-25 16:06:25.947068789 +0100 @@ -88,6 +88,7 @@ $(JVM_CFLAGS_TARGET_DEFINES) \ $(JVM_CFLAGS_FEATURES) \ $(JVM_CFLAGS_INCLUDES) \ + $(SOFTFLOAT_CFLAGS) \ $(EXTRA_CFLAGS) \ # --- old/src/hotspot/cpu/arm/assembler_arm_32.hpp 2018-12-25 16:06:27.183100324 +0100 +++ new/src/hotspot/cpu/arm/assembler_arm_32.hpp 2018-12-25 16:06:26.815090935 +0100 @@ -1240,12 +1240,12 @@ extern int __aeabi_dcmpge(double, double); extern int __aeabi_dcmpgt(double, double); -// Imported code from glibc soft-fp bundle for -// calculation accuracy improvement. See CR 6757269. -extern double __aeabi_fadd_glibc(float, float); -extern double __aeabi_fsub_glibc(float, float); -extern double __aeabi_dadd_glibc(double, double); -extern double __aeabi_dsub_glibc(double, double); +// Optional wrapper around SoftFloat-3e for +// calculation accuracy improvement. See CR 6757269, JDK-8215902. +extern float __aeabi_fadd_extlib(float, float); +extern float __aeabi_fsub_extlib(float, float); +extern double __aeabi_dadd_extlib(double, double); +extern double __aeabi_dsub_extlib(double, double); }; #endif // __SOFTFP__ --- old/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp 2018-12-25 16:06:28.067122877 +0100 +++ new/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp 2018-12-25 16:06:27.707113693 +0100 @@ -489,28 +489,29 @@ #ifdef __SOFTFP__ // Call function compiled with -msoft-float. - // __aeabi_XXXX_glibc: Imported code from glibc soft-fp bundle for calculation accuracy improvement. See CR 6757269. + // __aeabi_XXXX_extlib: Optional wrapper around SoftFloat-3e + // for calculation accuracy improvement. See CR 6757269, JDK-8215902. case Bytecodes::_fadd: - runtime_func = CAST_FROM_FN_PTR(address, __aeabi_fadd_glibc); + runtime_func = CAST_FROM_FN_PTR(address, __aeabi_fadd_extlib); break; case Bytecodes::_fmul: runtime_func = CAST_FROM_FN_PTR(address, __aeabi_fmul); break; case Bytecodes::_fsub: - runtime_func = CAST_FROM_FN_PTR(address, __aeabi_fsub_glibc); + runtime_func = CAST_FROM_FN_PTR(address, __aeabi_fsub_extlib); break; case Bytecodes::_fdiv: runtime_func = CAST_FROM_FN_PTR(address, __aeabi_fdiv); break; case Bytecodes::_dadd: - runtime_func = CAST_FROM_FN_PTR(address, __aeabi_dadd_glibc); + runtime_func = CAST_FROM_FN_PTR(address, __aeabi_dadd_extlib); break; case Bytecodes::_dmul: runtime_func = CAST_FROM_FN_PTR(address, __aeabi_dmul); break; case Bytecodes::_dsub: - runtime_func = CAST_FROM_FN_PTR(address, __aeabi_dsub_glibc); + runtime_func = CAST_FROM_FN_PTR(address, __aeabi_dsub_extlib); break; case Bytecodes::_ddiv: runtime_func = CAST_FROM_FN_PTR(address, __aeabi_ddiv); --- old/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp 2018-12-25 16:06:28.947145329 +0100 +++ new/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp 2018-12-25 16:06:28.583136042 +0100 @@ -804,15 +804,17 @@ #define FUNCTION_CASE(a, f) \ if ((intptr_t)a == CAST_FROM_FN_PTR(intptr_t, f)) return #f - FUNCTION_CASE(entry, __aeabi_fadd_glibc); + // __aeabi_XXXX_extlib: Optional wrapper around SoftFloat-3e + // for calculation accuracy improvement. See CR 6757269, JDK-8215902. + + FUNCTION_CASE(entry, __aeabi_fadd_extlib); FUNCTION_CASE(entry, __aeabi_fmul); - FUNCTION_CASE(entry, __aeabi_fsub_glibc); + FUNCTION_CASE(entry, __aeabi_fsub_extlib); FUNCTION_CASE(entry, __aeabi_fdiv); - // __aeabi_XXXX_glibc: Imported code from glibc soft-fp bundle for calculation accuracy improvement. See CR 6757269. - FUNCTION_CASE(entry, __aeabi_dadd_glibc); + FUNCTION_CASE(entry, __aeabi_dadd_extlib); FUNCTION_CASE(entry, __aeabi_dmul); - FUNCTION_CASE(entry, __aeabi_dsub_glibc); + FUNCTION_CASE(entry, __aeabi_dsub_extlib); FUNCTION_CASE(entry, __aeabi_ddiv); FUNCTION_CASE(entry, __aeabi_f2d); --- old/src/hotspot/cpu/arm/templateTable_arm.cpp 2018-12-25 16:06:29.827167780 +0100 +++ new/src/hotspot/cpu/arm/templateTable_arm.cpp 2018-12-25 16:06:29.463158493 +0100 @@ -1610,8 +1610,10 @@ __ mov(R1, R0_tos); __ pop_i(R0); switch (op) { - case add: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_fadd_glibc), R0, R1); break; - case sub: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_fsub_glibc), R0, R1); break; + // __aeabi_XXXX_extlib: Optional wrapper around SoftFloat-3e + // for calculation accuracy improvement. See CR 6757269, JDK-8215902. + case add: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_fadd_extlib), R0, R1); break; + case sub: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_fsub_extlib), R0, R1); break; case mul: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_fmul), R0, R1); break; case div: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_fdiv), R0, R1); break; case rem: __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::frem), R0, R1); break; @@ -1652,9 +1654,10 @@ __ mov(R3, R1_tos_hi); __ pop_l(R0, R1); switch (op) { - // __aeabi_XXXX_glibc: Imported code from glibc soft-fp bundle for calculation accuracy improvement. See CR 6757269. - case add: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_dadd_glibc), R0, R1, R2, R3); break; - case sub: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_dsub_glibc), R0, R1, R2, R3); break; + // __aeabi_XXXX_extlib: Optional wrapper around SoftFloat-3e + // for calculation accuracy improvement. See CR 6757269, JDK-8215902. + case add: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_dadd_extlib), R0, R1, R2, R3); break; + case sub: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_dsub_extlib), R0, R1, R2, R3); break; case mul: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_dmul), R0, R1, R2, R3); break; case div: __ call_VM_leaf(CAST_FROM_FN_PTR(address, __aeabi_ddiv), R0, R1, R2, R3); break; case rem: __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::drem), R0, R1, R2, R3); break; --- /dev/null 2018-12-25 09:53:35.540064662 +0100 +++ new/make/autoconf/lib-softfloat.m4 2018-12-25 16:06:30.391182169 +0100 @@ -0,0 +1,161 @@ +# +# Copyright (c) 2018, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# + +################################################################################ +# Setup softfloat library +################################################################################ +AC_DEFUN_ONCE([LIB_SETUP_SOFTFLOAT], +[ + # define options + AC_ARG_WITH(sflt, [AS_HELP_STRING([--with-sflt], + [specify prefix directory for the SoftFloat-3 prefix + (expecting PATH/lib/softfloat.a, PATH/include/softfloat.h and PATH/share/softfloat/softfloat.md)])]) + + AC_ARG_WITH(sflt-lib, [AS_HELP_STRING([--with-sflt-lib], + [specify the path to SoftFloat-3 static library])]) + + AC_ARG_WITH(sflt-include, [AS_HELP_STRING([--with-sflt-include], + [specify the path to SoftFloat-3 include directory])]) + + AC_ARG_WITH(sflt-license, [AS_HELP_STRING([--with-sflt-license], + [specify the path to SoftFloat-3 license file])]) + + # check if softfloat can be used and if the user enabled it + AC_MSG_CHECKING([if softfloat library should be used]) + if test "x$USES_LIB_SOFTFLOAT" = "xtrue"; then + SOFTFLOAT_SPECIFIED=no + + if test "x${with_sflt}" != x; then + if test "x${with_sflt}" = "xyes" || test "x${with_sflt}" = "xno"; then + AC_MSG_RESULT([error]) + AC_MSG_ERROR([--with-sflt must have a value]) + fi + SOFTFLOAT_CFLAGS="-I${with_sflt}/include -DSOFTFLOAT_EXTERNAL" + SOFTFLOAT_LIBS="${with_sflt}/lib/softfloat.a" + SOFTFLOAT_SPECIFIED=yes + fi + if test "x${with_sflt_include}" != x; then + if test "x${with_sflt_include}" = "xyes" || test "x${with_sflt_include}" = "xno"; then + AC_MSG_RESULT([error]) + AC_MSG_ERROR([--with-sflt-include must have a value]) + fi + SOFTFLOAT_CFLAGS="-I${with_sflt_include} -DSOFTFLOAT_EXTERNAL" + SOFTFLOAT_SPECIFIED=yes + fi + if test "x${with_sflt_lib}" != x; then + if test "x${with_sflt_lib}" = "xyes" || test "x${with_sflt_lib}" = "xno"; then + AC_MSG_RESULT([error]) + AC_MSG_ERROR([--with-sflt-lib must have a value]) + fi + SOFTFLOAT_LIBS="${with_sflt_lib}" + SOFTFLOAT_SPECIFIED=yes + fi + + if test "x$SOFTFLOAT_SPECIFIED" = xno; then + AC_MSG_RESULT([no, system softfp used]) + AC_MSG_NOTICE([Floating point operations may be less precise by a very small amount]) + SOFTFLOAT_LICENSE= + SOFTFLOAT_CFLAGS= + SOFTFLOAT_LIBS= + else + AC_MSG_RESULT([yes]) + + AC_MSG_CHECKING([for softfloat preprocessor flags]) + AC_MSG_RESULT([$SOFTFLOAT_CFLAGS]) + + AC_MSG_CHECKING([for softfloat linker flags]) + AC_MSG_RESULT([$SOFTFLOAT_LIBS]) + + AC_MSG_CHECKING([if softfloat works]) + AC_LANG_PUSH(C) + OLD_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $SOFTFLOAT_CFLAGS" + OLD_LIBS="$LIBS" + LIBS="$LIBS $SOFTFLOAT_LIBS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], + [ + return f32_to_i32(f32_sub(i32_to_f32(1), i32_to_f32(1)), softfloat_round_near_even, false); + ])], + [SOFTFLOAT_WORKS=yes], + [SOFTFLOAT_WORKS=no] + ) + CFLAGS="$OLD_CFLAGS" + LIBS="$OLD_LIBS" + AC_LANG_POP(C) + AC_MSG_RESULT([$SOFTFLOAT_WORKS]) + + if test "x$SOFTFLOAT_WORKS" = xno; then + HELP_MSG_MISSING_DEPENDENCY([softfloat]) + AC_MSG_ERROR([Found softfloat but could not link and compile with it. $HELP_MSG]) + fi + + SOFTFLOAT_LICENSE="" + AC_MSG_CHECKING([for softfloat license]) + + if test "x$with_sflt_license" = "xyes" || test "x$with_sflt_license" = "xno"; then + AC_MSG_RESULT([error]) + AC_MSG_ERROR([--with-sflt-license must have a value]) + elif test "x$with_sflt_license" != "x"; then + AC_MSG_RESULT([$with_sflt_license]) + SOFTFLOAT_LICENSE="$with_sflt_license" + BASIC_FIXUP_PATH(SOFTFLOAT_LICENSE) + if test ! -f "$SOFTFLOAT_LICENSE"; then + AC_MSG_ERROR([$SOFTFLOAT_LICENSE cannot be found]) + fi + else + if test "x$with_sflt" != "x" && test -f "$with_sflt/share/softfloat/softfloat.md"; then + SOFTFLOAT_LICENSE="$with_sflt/share/softfloat/softfloat.md" + AC_MSG_RESULT([$SOFTFLOAT_LICENSE]) + BASIC_FIXUP_PATH(SOFTFLOAT_LICENSE) + else + AC_MSG_RESULT([error]) + AC_MSG_ERROR([softfloat license file cannot be found]) + fi + fi + + fi + else + AC_MSG_RESULT([no, not needed]) + if test "x${with_sflt}" != x && test "x${with_sflt}" != xno; then + AC_MSG_WARN([[not building for sflt, so --with-sflt is ignored]]) + fi + if test "x${with_sflt_lib}" != x && test "x${with_sflt_lib}" != xno; then + AC_MSG_WARN([[not building for sflt, so --with-sflt-lib is ignored]]) + fi + if test "x${with_sflt_include}" != x && test "x${with_sflt_include}" != xno; then + AC_MSG_WARN([[not building for sflt, so --with-sflt-include is ignored]]) + fi + if test "x${with_sflt_license}" != x && test "x${with_sflt_license}" != xno; then + AC_MSG_WARN([[not building for sflt, so --with-sflt-license is ignored]]) + fi + SOFTFLOAT_CFLAGS= + SOFTFLOAT_LIBS= + SOFTFLOAT_LICENSE= + fi + + AC_SUBST(SOFTFLOAT_LIBS) + AC_SUBST(SOFTFLOAT_CFLAGS) + AC_SUBST(SOFTFLOAT_LICENSE) +]) --- /dev/null 2018-12-25 09:53:35.540064662 +0100 +++ new/src/hotspot/cpu/arm/softfloat_arm.cpp 2018-12-25 16:06:31.287205029 +0100 @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2018, 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. + * + */ + +#ifdef __SOFTFP__ + +// Soft float function declarations +extern "C" { + extern float __aeabi_fadd(float, float); + extern float __aeabi_fsub(float, float); + extern double __aeabi_dadd(double, double); + extern double __aeabi_dsub(double, double); + + extern float __aeabi_fadd_extlib(float, float); + extern float __aeabi_fsub_extlib(float, float); + extern double __aeabi_dadd_extlib(double, double); + extern double __aeabi_dsub_extlib(double, double); +}; + +#ifdef SOFTFLOAT_EXTERNAL + +extern "C" { +#include "softfloat.h" +} + +#include + +static float __aeabi_float_handling(float natA, float natB, bool add) { + float32_t libC; + + libC = add ? f32_add(reinterpret_cast(natA), reinterpret_cast(natB)) + : f32_sub(reinterpret_cast(natA), reinterpret_cast(natB)); + + return reinterpret_cast(libC); +} + +static double __aeabi_double_handling(double natA, double natB, bool add) { + float64_t libC; + + libC = add ? f64_add(reinterpret_cast(natA), reinterpret_cast(natB)) + : f64_sub(reinterpret_cast(natA), reinterpret_cast(natB)); + + return reinterpret_cast(libC); +} + +float __aeabi_fadd_extlib(float a, float b) { + return __aeabi_float_handling(a, b, true); +} + +float __aeabi_fsub_extlib(float a, float b) { + return __aeabi_float_handling(a, b, false); +} + +double __aeabi_dadd_extlib(double a, double b) { + return __aeabi_double_handling(a, b, true); +} + +double __aeabi_dsub_extlib(double a, double b) { + return __aeabi_double_handling(a, b, false); +} + +#else + +float __aeabi_fadd_extlib(float a, float b) { + return __aeabi_fadd(a, b); +} + +float __aeabi_fsub_extlib(float a, float b) { + return __aeabi_fsub(a, b); +} + +double __aeabi_dadd_extlib(double a, double b) { + return __aeabi_dadd(a, b); +} + +double __aeabi_dsub_extlib(double a, double b) { + return __aeabi_dsub(a, b); +} + +#endif + +#endif // __SOFTFP__ --- /dev/null 2018-12-25 09:53:35.540064662 +0100 +++ new/test/hotspot/jtreg/compiler/floatingpoint/Test8215902.java 2018-12-25 16:06:32.191228092 +0100 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018, 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.lang.Float; +import java.lang.RuntimeException; + +/* + * @test Test8215902.java + * @bug 8215902 + * @summary Check a known imprecision in Linux ARM softfp implementation. + * @run main Test8215902 + * @author jakvanek + */ +public strictfp class Test8215902 { + private static volatile Float a, b, c; + private static volatile int bC; + + private static final int bA = 0x003fffff; + private static final int bB = 0x00000001; + private static final int bC_OK = 0x00400000; + + public static void main(String... args) { + a = Float.intBitsToFloat(bA); + b = Float.intBitsToFloat(bB); + c = a + b; + bC = Float.floatToRawIntBits(c); + + if (bC == bC_OK) { + System.out.println("Passed."); + } else { + String msg = String.format("Failed.\nResult = 0x%08x|%1.60f\nExpected = 0x%08x|%1.60f", + bC, c, bC_OK, Float.intBitsToFloat(bC_OK)); + throw new RuntimeException(msg); + } + } +} +