Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / patches / jamvm-2.0.0-opcode-guard.patch
1 From ca11b53896365c948426974cb90e8f71c70d123b Mon Sep 17 00:00:00 2001
2 From: Simon South <simon@simonsouth.net>
3 Date: Sun, 31 May 2020 20:36:43 -0400
4 Subject: [PATCH] Guard floating-point opcodes with explicit memory barrier
5
6 ---
7 src/interp/engine/interp-inlining.h | 11 ++++++++++-
8 1 file changed, 10 insertions(+), 1 deletion(-)
9
10 diff --git a/src/interp/engine/interp-inlining.h b/src/interp/engine/interp-inlining.h
11 index 3339b0e..4ee5c5a 100644
12 --- a/src/interp/engine/interp-inlining.h
13 +++ b/src/interp/engine/interp-inlining.h
14 @@ -78,8 +78,17 @@
15 4.3, we need to insert a label, and ensure its address
16 is taken (to stop it being optimised out). However,
17 this reduces performance on PowerPC by approx 1 - 2%.
18 +
19 + With gcc 5 and newer an asm statement with a "memory"
20 + clobber argument explicitly sets a memory barrier for the
21 + compiler, preventing it from reordering memory accesses
22 + in a way that breaks decaching.
23 */
24 -#if (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)
25 +#if (__GNUC__ > 4)
26 +#define DEF_GUARD_TABLE(level) /* none */
27 +#define GUARD(opcode, level) __asm__("" ::: "memory");
28 +#define GUARD_TBLS /* none */
29 +#elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)
30 #define DEF_GUARD_TABLE(level) DEF_HANDLER_TABLE(level, GUARD)
31 #define GUARD(opcode, level) label(opcode, level, GUARD)
32 #define GUARD_TBLS , HNDLR_TBLS(GUARD)
33 --
34 2.26.2
35