/
softfloat.patch
590 lines (573 loc) · 24.4 KB
/
softfloat.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
# HG changeset patch
# User Jakub Vaněk <linuxtardis@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.
+```