Hi Magnus, Thanks for your review!
Jakub On 2018-12-10 at 15:16 +0100, Magnus Ihse Bursie wrote: > > On 2018-12-08 14:34, Jakub Vaněk wrote: > > Hi, > > > > I'm sending an updated patch. Changes: > > > > * I have changed NEEDS_LIB_SOFTFLOAT to USES_LIB_SOFTFLOAT. > > * I have added a --enable-softfloat option for enabling/disabling > > the > > library. I have also added a --with-softfloat option for linking > > from a > > prefix. > > * I have updated the documentation. I prefer using --with- > > softfloat- > > include and --with-softfloat-lib here, because SoftFloat itself has > > no > > install rules and the library is built into the build/???/ > > directory. > > * I have added a test to check if the library works. > > * I have added a SoftFloat license + exclusion code, because it is > > linked statically. > > > > I have sent a jdk author request to Mark Reinhold, but I haven't > > got a > > reply yet. > > > > However the patch can be found also here: > > https://github.com/ev3dev-lang-java/openjdk-ev3/blob/9eab3db7c865d763bf518fe0110bc81c14fd42e6/upstream/softfloat.patch > > The build changes all look good to me. I can't comment on the > Hotspot > ARM code. > > /Magnus > > > > The patch was successfully built here: > > https://ci.adoptopenjdk.net/view/ev3dev/job/openjdk12_build_ev3_linux/56/ > > > > Thanks, > > > > Jakub > > > > # HG changeset patch > > # User Jakub Vaněk <linuxtar...@gmail.com> > > # Date 1544273385 -3600 > > # Sat Dec 08 13:49:45 2018 +0100 > > # Node ID 2dda78cf712d402b53df779325e8b8f23b487be2 > > # Parent 583fd71c47d60dea883b1f03d9f1b2c267c0a891 > > Add support for compiling with SoftFloat-3e on arm sflt builds > > > > diff --git a/doc/building.html b/doc/building.html > > --- a/doc/building.html > > +++ b/doc/building.html > > @@ -53,6 +53,7 @@ > > <li><a href="#x11">X11</a></li> > > <li><a href="#alsa">ALSA</a></li> > > <li><a href="#libffi">libffi</a></li> > > +<li><a href="#softfloat">SoftFloat</a></li> > > </ul></li> > > <li><a href="#build-tools-requirements">Build Tools > > Requirements</a><ul> > > <li><a href="#autoconf">Autoconf</a></li> > > @@ -415,6 +416,14 @@ > > <li>To install on an rpm-based Linux, try running <code>sudo yum > > install libffi-devel</code>.</li> > > </ul> > > <p>Use <code>--with-libffi=<path></code> if > > <code>configure</code> does not properly locate your libffi > > files.</p> > > + > > +<h3 id="softfloat">SoftFloat</h3> > > +<p><a href=" > > http://www.jhauser.us/arithmetic/SoftFloat.html">Berkeley > > SoftFloat-3</a> 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 <a > > href="http://mail.openjdk.java.net/pipermail/aarch32-port-dev/2016- > > November/000611.html">the JCK detects it</a>.</p> > > +<ul> > > +<li>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 > > <code>build/Linux-ARM-VFPv2-GCC</code> subdirectory.</li> > > +</ul> > > +<p>Use <code>--enable-softfloat</code> to enable the use of this > > library. You can then use <code>--with-softfloat- > > lib=<path></code> and <code>--with-softfloat- > > include=<path></code> to specify the path to the > > <code>softfloat.a</code> archive and the > > <code>source/include</code> directory. Alternatively, if you > > install the library and its headers to a prefix, you can pass its > > path to <code>--with-softfloat=<path></code>.</p> > > +<p>If you do not enable this library, standard system libraries > > will be used instead.</p> > > <h2 id="build-tools-requirements">Build Tools Requirements</h2> > > <h3 id="autoconf">Autoconf</h3> > > <p>The JDK requires <a href=" > > http://www.gnu.org/software/autoconf">Autoconf</a>;; on all > > platforms. At least version 2.69 is required.</p> > > @@ -486,6 +495,8 @@ > > <li><code>--with-x=<path></code> - Set the path to <a > > href="#x11">X11</a></li> > > <li><code>--with-alsa=<path></code> - Set the path to <a > > href="#alsa">ALSA</a></li> > > <li><code>--with-libffi=<path></code> - Set the path to <a > > href="#libffi">libffi</a></li> > > +<li><code>--enable-softfloat</code> - Enable the use of external > > <a href="#softfloat">SoftFloat</a> library on sflt builds.</li> > > +<li><code>--with-softfloat=<path></code> or <code>--with- > > softfloat-lib=<path></code>, <code>--with-softfloat- > > include=<path></code> - Set the path to <a > > href="#softfloat">SoftFloat</a> library and include directory.</li> > > <li><code>--with-jtreg=<path></code> - Set the path to > > JTReg. See <a href="#running-tests">Running Tests</a></li> > > </ul> > > <p>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 <code>system</code> as the > > <code><source></code> option in these arguments. (The default > > is <code>bundled</code>).</p> > > diff --git a/doc/building.md b/doc/building.md > > --- a/doc/building.md > > +++ b/doc/building.md > > @@ -527,6 +527,28 @@ > > Use `--with-libffi=<path>` 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. > > + > > +Use `--enable-softfloat` to enable the use of this library. You > > can then > > +use `--with-softfloat-lib=<path>` and `--with-softfloat- > > include=<path>` > > +to specify the path to the `softfloat.a` archive and the > > `source/include` > > +directory. Alternatively, if you install the library and its > > headers to > > +a prefix, you can pass its path to `--with-softfloat=<path>`. > > + > > +If you do not enable this library, standard system libraries > > +will be used instead. > > + > > ## Build Tools Requirements > > > > ### Autoconf > > @@ -694,6 +716,10 @@ > > * `--with-x=<path>` - Set the path to [X11](#x11) > > * `--with-alsa=<path>` - Set the path to [ALSA](#alsa) > > * `--with-libffi=<path>` - Set the path to [libffi](#libffi) > > + * `--enable-softfloat` - Enable the use of external > > [SoftFloat](#softfloat) > > + library on sflt builds. > > + * `--with-softfloat=<path>` or `--with-softfloat-lib=<path>`, `- > > -with-softfloat-include=<path>` - > > + Set the path to [SoftFloat](#softfloat) library and include > > directory. > > * `--with-jtreg=<path>` - Set the path to JTReg. See [Running > > Tests]( > > #running-tests) > > > > diff --git a/make/autoconf/lib-softfloat.m4 b/make/autoconf/lib- > > softfloat.m4 > > new file mode 100644 > > --- /dev/null > > +++ b/make/autoconf/lib-softfloat.m4 > > @@ -0,0 +1,149 @@ > > +# > > +# 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_ENABLE(softfloat, [AS_HELP_STRING([--enable-softfloat], > > + [enable use of SoftFloat-3 on softfp builds])]) > > + > > + AC_ARG_WITH(softfloat, [AS_HELP_STRING([--with-softfloat], > > + [specify prefix directory for the softfloat package > > + (expecting softfloat.a under PATH/lib and softfloat.h under > > PATH/include)])]) > > + > > + AC_ARG_WITH(softfloat-lib, [AS_HELP_STRING([--with-softfloat- > > lib], > > + [specify the path to SoftFloat-3 static library])]) > > + > > + AC_ARG_WITH(softfloat-include, [AS_HELP_STRING([--with- > > softfloat-include], > > + [specify the path to SoftFloat-3 include directory])]) > > + > > + # 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 > > + > > + if test "x$enable_softfloat" = "x" || test > > "x$enable_softfloat" = "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_ENABLED=no > > + > > + elif test "x$enable_softfloat" = "xyes"; then > > + AC_MSG_RESULT([yes]) > > + SOFTFLOAT_ENABLED=yes > > + else > > + AC_MSG_ERROR([Invalid value for --enable-softfloat]) > > + fi > > + > > + else > > + AC_MSG_RESULT([no, not needed]) > > + if test "x${enable_softfloat}" != x && test > > "x${enable_softfloat}" != xno; then > > + AC_MSG_WARN([[not building for sflt, so --enable-softfloat > > is ignored]]) > > + fi > > + if test "x${with_softfloat}" != x && test "x${with_softfloat}" > > != xno; then > > + AC_MSG_WARN([[not building for sflt, so --with-softfloat is > > ignored]]) > > + fi > > + if test "x${with_softfloat_lib}" != x && test > > "x${with_softfloat_lib}" != xno; then > > + AC_MSG_WARN([[not building for sflt, so --with-softfloat-lib > > is ignored]]) > > + fi > > + if test "x${with_softfloat_include}" != x && test > > "x${with_softfloat_include}" != xno; then > > + AC_MSG_WARN([[not building for sflt, so --with-softfloat- > > include is ignored]]) > > + fi > > + SOFTFLOAT_ENABLED=no > > + fi > > + > > + # if the library can be used and the user wants it, find it and > > test it > > + if test "x$SOFTFLOAT_ENABLED" = "xyes"; then > > + SOFTFLOAT_FOUND=no > > + > > + if test "x${with_softfloat}" = xno || test > > "x${with_softfloat_lib}" = xno || test "x${with_softfloat_include}" > > = xno; then > > + AC_MSG_ERROR([Please do not combine --enable-softfloat and > > --without-softfloat* options.]) > > + fi > > + > > + if test "x${with_softfloat}" != x; then > > + SOFTFLOAT_CFLAGS="-I${with_softfloat}/include > > -DSOFTFLOAT_EXTERNAL" > > + SOFTFLOAT_LIBS="${with_softfloat}/lib/softfloat.a" > > + SOFTFLOAT_FOUND=yes > > + fi > > + if test "x${with_softfloat_include}" != x; then > > + SOFTFLOAT_CFLAGS="-I${with_softfloat_include} > > -DSOFTFLOAT_EXTERNAL" > > + SOFTFLOAT_FOUND=yes > > + fi > > + if test "x${with_softfloat_lib}" != x; then > > + SOFTFLOAT_LIBS="${with_softfloat_lib}" > > + SOFTFLOAT_FOUND=yes > > + fi > > + if test "x$SOFTFLOAT_FOUND" = xno; then > > + AC_CHECK_HEADERS([softfloat.h], > > + [ > > + SOFTFLOAT_FOUND=yes > > + SOFTFLOAT_CFLAGS="-DSOFTFLOAT_EXTERNAL" > > + SOFTFLOAT_LIBS="-l:softfloat.a" > > + ], > > + [SOFTFLOAT_FOUND=no] > > + ) > > + fi > > + if test "x$SOFTFLOAT_FOUND" = xno; then > > + HELP_MSG_MISSING_DEPENDENCY([softfloat]) > > + AC_MSG_ERROR([Could not find softfloat! $HELP_MSG]) > > + else > > + AC_MSG_CHECKING([for softfloat library]) > > + AC_MSG_RESULT([$SOFTFLOAT_LIBS]) > > + > > + AC_MSG_CHECKING([for softfloat compiler flags]) > > + AC_MSG_RESULT([$SOFTFLOAT_CFLAGS]) > > + fi > > + > > + 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 <softfloat.h>], > > + [ > > + 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 > > + else > > + SOFTFLOAT_CFLAGS= > > + SOFTFLOAT_LIBS= > > + fi > > + > > + AC_SUBST(SOFTFLOAT_LIBS) > > + AC_SUBST(SOFTFLOAT_CFLAGS) > > +]) > > diff --git a/make/autoconf/libraries.m4 > > b/make/autoconf/libraries.m4 > > --- a/make/autoconf/libraries.m4 > > +++ b/make/autoconf/libraries.m4 > > @@ -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 > > diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in > > --- a/make/autoconf/spec.gmk.in > > +++ b/make/autoconf/spec.gmk.in > > @@ -353,6 +353,8 @@ > > CUPS_CFLAGS:=@CUPS_CFLAGS@ > > ALSA_LIBS:=@ALSA_LIBS@ > > ALSA_CFLAGS:=@ALSA_CFLAGS@ > > +SOFTFLOAT_LIBS:=@SOFTFLOAT_LIBS@ > > +SOFTFLOAT_CFLAGS:=@SOFTFLOAT_CFLAGS@ > > LIBFFI_LIBS:=@LIBFFI_LIBS@ > > LIBFFI_CFLAGS:=@LIBFFI_CFLAGS@ > > ENABLE_LIBFFI_BUNDLING:=@ENABLE_LIBFFI_BUNDLING@ > > diff --git a/make/copy/Copy-java.base.gmk b/make/copy/Copy- > > java.base.gmk > > --- a/make/copy/Copy-java.base.gmk > > +++ b/make/copy/Copy-java.base.gmk > > @@ -219,6 +219,10 @@ > > LEGAL_EXCLUDES += zlib.md > > endif > > > > +ifeq ($(SOFTFLOAT_LIBS), ) > > + LEGAL_EXCLUDES += softfloat.md > > +endif > > + > > $(eval $(call SetupCopyLegalFiles, COPY_LEGAL, \ > > EXCLUDES := $(LEGAL_EXCLUDES), \ > > )) > > diff --git a/make/hotspot/lib/CompileJvm.gmk > > b/make/hotspot/lib/CompileJvm.gmk > > --- a/make/hotspot/lib/CompileJvm.gmk > > +++ b/make/hotspot/lib/CompileJvm.gmk > > @@ -49,6 +49,7 @@ > > > > JVM_LIBS += \ > > $(JVM_LIBS_FEATURES) \ > > + $(SOFTFLOAT_LIBS) \ > > # > > > > # These files and directories are always excluded > > diff --git a/make/hotspot/lib/JvmFlags.gmk > > b/make/hotspot/lib/JvmFlags.gmk > > --- a/make/hotspot/lib/JvmFlags.gmk > > +++ b/make/hotspot/lib/JvmFlags.gmk > > @@ -88,6 +88,7 @@ > > $(JVM_CFLAGS_TARGET_DEFINES) \ > > $(JVM_CFLAGS_FEATURES) \ > > $(JVM_CFLAGS_INCLUDES) \ > > + $(SOFTFLOAT_CFLAGS) \ > > $(EXTRA_CFLAGS) \ > > # > > > > diff --git a/src/hotspot/cpu/arm/assembler_arm_32.hpp > > b/src/hotspot/cpu/arm/assembler_arm_32.hpp > > --- a/src/hotspot/cpu/arm/assembler_arm_32.hpp > > +++ b/src/hotspot/cpu/arm/assembler_arm_32.hpp > > @@ -1242,10 +1242,10 @@ > > > > // 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); > > +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__ > > > > diff --git a/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp > > b/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp > > --- a/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp > > +++ b/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp > > @@ -490,27 +490,28 @@ > > // Call function compiled with -msoft-float. > > > > // __aeabi_XXXX_glibc: Imported code from glibc soft-fp > > bundle for calculation accuracy improvement. See CR 6757269. > > + // > > http://mail.openjdk.java.net/pipermail/aarch32-port-dev/2016-November/000611.html > > > > 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); > > diff --git a/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp > > b/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp > > --- a/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp > > +++ b/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp > > @@ -804,15 +804,16 @@ > > #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_glibc: Imported code from glibc soft-fp bundle > > for calculation accuracy improvement. See CR 6757269. > > + // > > http://mail.openjdk.java.net/pipermail/aarch32-port-dev/2016-November/000611.html > > + 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); > > diff --git a/src/hotspot/cpu/arm/softfloat_arm.cpp > > b/src/hotspot/cpu/arm/softfloat_arm.cpp > > new file mode 100644 > > --- /dev/null > > +++ b/src/hotspot/cpu/arm/softfloat_arm.cpp > > @@ -0,0 +1,112 @@ > > +/* > > + * 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 <cstring> > > + > > +static float __aeabi_float_handling(float natA, float natB, bool > > add) { > > + float32_t libA; > > + float32_t libB; > > + float32_t libC; > > + float natC; > > + > > + memcpy(&libA, &natA, sizeof(libA)); > > + memcpy(&libB, &natB, sizeof(libB)); > > + libC = add ? f32_add(libA, libB) : f32_sub(libA, libB); > > + memcpy(&natC, &libC, sizeof(libC)); > > + > > + return natC; > > +} > > + > > +static double __aeabi_double_handling(double natA, double natB, > > bool add) { > > + float64_t libA; > > + float64_t libB; > > + float64_t libC; > > + double natC; > > + > > + memcpy(&libA, &natA, sizeof(libA)); > > + memcpy(&libB, &natB, sizeof(libB)); > > + libC = add ? f64_add(libA, libB) : f64_sub(libA, libB); > > + memcpy(&natC, &libC, sizeof(libC)); > > + > > + return natC; > > +} > > + > > +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__ > > diff --git a/src/hotspot/cpu/arm/templateTable_arm.cpp > > b/src/hotspot/cpu/arm/templateTable_arm.cpp > > --- a/src/hotspot/cpu/arm/templateTable_arm.cpp > > +++ b/src/hotspot/cpu/arm/templateTable_arm.cpp > > @@ -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_glibc: Imported code from glibc soft-fp bundle > > for calculation accuracy improvement. See CR 6757269. > > + // > > http://mail.openjdk.java.net/pipermail/aarch32-port-dev/2016-November/000611.html > > + 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; > > @@ -1653,8 +1655,9 @@ > > __ 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; > > + // > > http://mail.openjdk.java.net/pipermail/aarch32-port-dev/2016-November/000611.html > > + 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; > > diff --git a/src/java.base/share/legal/softfloat.md > > b/src/java.base/share/legal/softfloat.md > > new file mode 100644 > > --- /dev/null > > +++ b/src/java.base/share/legal/softfloat.md > > @@ -0,0 +1,40 @@ > > +## SoftFloat-3e > > + > > +### SoftFloat license > > +``` > > +License for Berkeley SoftFloat Release 3e > > + > > +John R. Hauser > > +2018 January 20 > > + > > +The following applies to the whole of SoftFloat Release 3e as well > > as to > > +each source file individually. > > + > > +Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The > > Regents of the > > +University of California. All rights reserved. > > + > > +Redistribution and use in source and binary forms, with or without > > +modification, are permitted provided that the following conditions > > are met: > > + > > + 1. Redistributions of source code must retain the above copyright > > notice, > > + this list of conditions, and the following disclaimer. > > + > > + 2. Redistributions in binary form must reproduce the above > > copyright > > + notice, this list of conditions, and the following disclaimer > > in the > > + documentation and/or other materials provided with the > > distribution. > > + > > + 3. Neither the name of the University nor the names of its > > contributors > > + may be used to endorse or promote products derived from this > > software > > + without specific prior written permission. > > + > > +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", > > AND ANY > > +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > > IMPLIED > > +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR > > PURPOSE, ARE > > +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE > > LIABLE FOR ANY > > +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > > DAMAGES > > +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > > SERVICES; > > +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER > > CAUSED AND > > +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, > > OR TORT > > +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE > > USE OF > > +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > > +``` > > > >