logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

jamvm-1.6.0-opcode-guard.patch (1416B)


  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. src/interp/engine/interp-inlining.h | 11 ++++++++++-
  7. 1 file changed, 10 insertions(+), 1 deletion(-)
  8. diff --git a/src/interp/engine/interp-inlining.h b/src/interp/engine/interp-inlining.h
  9. index 3339b0e..4ee5c5a 100644
  10. --- jamvm/jamvm/src/interp/engine/interp-inlining.h
  11. +++ jamvm/jamvm/src/interp/engine/interp-inlining.h
  12. @@ -78,8 +78,17 @@
  13. 4.3, we need to insert a label, and ensure its address
  14. is taken (to stop it being optimised out). However,
  15. this reduces performance on PowerPC by approx 1 - 2%.
  16. +
  17. + With gcc 5 and newer an asm statement with a "memory"
  18. + clobber argument explicitly sets a memory barrier for the
  19. + compiler, preventing it from reordering memory accesses
  20. + in a way that breaks decaching.
  21. */
  22. -#if (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)
  23. +#if (__GNUC__ > 4)
  24. +#define DEF_GUARD_TABLE(level) /* none */
  25. +#define GUARD(opcode, level) __asm__("" ::: "memory");
  26. +#define GUARD_TBLS /* none */
  27. +#elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)
  28. #define DEF_GUARD_TABLE(level) DEF_HANDLER_TABLE(level, GUARD)
  29. #define GUARD(opcode, level) label(opcode, level, GUARD)
  30. #define GUARD_TBLS , HNDLR_TBLS(GUARD)
  31. --
  32. 2.26.2