[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 201/437: Do not start over jit generation if can safely
From: |
Andy Wingo |
Subject: |
[Guile-commits] 201/437: Do not start over jit generation if can safely grow buffer size. |
Date: |
Mon, 2 Jul 2018 05:14:18 -0400 (EDT) |
wingo pushed a commit to branch lightning
in repository guile.
commit 51c96f9e196d3d3d4d946083b469d7fa1ab9b77c
Author: pcpa <address@hidden>
Date: Fri Mar 29 12:53:40 2013 -0300
Do not start over jit generation if can safely grow buffer size.
* include/lightning/jit_private.h, lib/jit_arm.c, lib/jit_memory.c,
lib/jit_mips.c, lib/jit_ppc.c, lib/jit_sparc.c, lib/jit_x86.c,
lib/lightning.c: Do not start over jit generation if can grow
the code buffer with mremap without moving the base pointer.
---
ChangeLog | 7 +++++++
include/lightning/jit_private.h | 9 +++++++++
lib/jit_arm.c | 2 +-
lib/jit_memory.c | 24 ++++++++++++++++++++++++
lib/jit_mips.c | 2 +-
lib/jit_ppc.c | 2 +-
lib/jit_sparc.c | 2 +-
lib/jit_x86.c | 2 +-
lib/lightning.c | 9 ++++-----
9 files changed, 49 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9d46844..a174e64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2013-03-29 Paulo Andrade <address@hidden>
+ * include/lightning/jit_private.h, lib/jit_arm.c, lib/jit_memory.c,
+ lib/jit_mips.c, lib/jit_ppc.c, lib/jit_sparc.c, lib/jit_x86.c,
+ lib/lightning.c: Do not start over jit generation if can grow
+ the code buffer with mremap without moving the base pointer.
+
+2013-03-29 Paulo Andrade <address@hidden>
+
* lib/jit_memory.c: Implement a simple memory allocation wrapper
to allow overriding calls to malloc/calloc/realloc/free, as well
as ensuring all memory containing pointers is zero or points to
diff --git a/include/lightning/jit_private.h b/include/lightning/jit_private.h
index 02847ea..133937b 100644
--- a/include/lightning/jit_private.h
+++ b/include/lightning/jit_private.h
@@ -360,6 +360,8 @@ struct jit_compiler {
} prolog;
jit_bool_t jump;
#endif
+ /* global flag for code buffer heuristic size computation */
+ jit_word_t mult;
};
#define _jitc _jit->comp
@@ -485,6 +487,13 @@ extern void jit_alloc(jit_pointer_t*, jit_word_t);
extern void jit_realloc(jit_pointer_t*, jit_word_t, jit_word_t);
void jit_free(jit_pointer_t*);
+#if HAVE_MREMAP
+# define jit_remap() _jit_remap(_jit)
+extern jit_bool_t _jit_remap(jit_state_t*);
+#else
+# define jit_remap() 0
+#endif
+
/*
* Externs
*/
diff --git a/lib/jit_arm.c b/lib/jit_arm.c
index 103307f..c4fe59e 100644
--- a/lib/jit_arm.c
+++ b/lib/jit_arm.c
@@ -1034,7 +1034,7 @@ _emit_code(jit_state_t *_jit)
} \
break
for (node = _jitc->head; node; node = node->next) {
- if (_jit->pc.uc >= _jitc->code.end)
+ if (_jit->pc.uc >= _jitc->code.end && !jit_remap())
return (NULL);
value = jit_classify(node->code);
diff --git a/lib/jit_memory.c b/lib/jit_memory.c
index ef2624f..7aa5afc 100644
--- a/lib/jit_memory.c
+++ b/lib/jit_memory.c
@@ -17,6 +17,7 @@
#include <lightning.h>
#include <lightning/jit_private.h>
+#include <sys/mman.h>
/*
* Prototypes
@@ -83,6 +84,29 @@ jit_free(jit_pointer_t *ptr)
*ptr = NULL;
}
+#if HAVE_MREMAP
+jit_bool_t
+_jit_remap(jit_state_t *_jit)
+{
+ jit_uint8_t *code;
+ jit_word_t length;
+
+ length = _jitc->pool.length * 1024 * (_jitc->mult + 1);
+
+ code = mremap(_jit->code.ptr, _jit->code.length, length, 0, NULL);
+ if (code != MAP_FAILED) {
+ assert(code == _jit->code.ptr);
+ ++_jitc->mult;
+ _jit->code.length = length;
+ _jitc->code.end = _jit->code.ptr + _jit->code.length - 64;
+
+ return (1);
+ }
+
+ return (0);
+}
+#endif
+
static void *
jit_default_alloc_func(size_t size)
{
diff --git a/lib/jit_mips.c b/lib/jit_mips.c
index 0d92756..29e0871 100644
--- a/lib/jit_mips.c
+++ b/lib/jit_mips.c
@@ -775,7 +775,7 @@ _emit_code(jit_state_t *_jit)
} \
break
for (node = _jitc->head; node; node = node->next) {
- if (_jit->pc.uc >= _jitc->code.end)
+ if (_jit->pc.uc >= _jitc->code.end && !jit_remap())
return (NULL);
value = jit_classify(node->code);
diff --git a/lib/jit_ppc.c b/lib/jit_ppc.c
index ec51882..a09b24f 100644
--- a/lib/jit_ppc.c
+++ b/lib/jit_ppc.c
@@ -866,7 +866,7 @@ _emit_code(jit_state_t *_jit)
} \
break
for (node = _jitc->head; node; node = node->next) {
- if (_jit->pc.uc >= _jitc->code.end)
+ if (_jit->pc.uc >= _jitc->code.end && !jit_remap())
return (NULL);
value = jit_classify(node->code);
diff --git a/lib/jit_sparc.c b/lib/jit_sparc.c
index 43072a2..a9eab39 100644
--- a/lib/jit_sparc.c
+++ b/lib/jit_sparc.c
@@ -692,7 +692,7 @@ _emit_code(jit_state_t *_jit)
} \
break
for (node = _jitc->head; node; node = node->next) {
- if (_jit->pc.uc >= _jitc->code.end)
+ if (_jit->pc.uc >= _jitc->code.end && !jit_remap())
return (NULL);
value = jit_classify(node->code);
diff --git a/lib/jit_x86.c b/lib/jit_x86.c
index daf826f..345dad7 100644
--- a/lib/jit_x86.c
+++ b/lib/jit_x86.c
@@ -1125,7 +1125,7 @@ _emit_code(jit_state_t *_jit)
} \
break
for (node = _jitc->head; node; node = node->next) {
- if (_jit->pc.uc >= _jitc->code.end)
+ if (_jit->pc.uc >= _jitc->code.end && !jit_remap())
return (NULL);
value = jit_classify(node->code);
diff --git a/lib/lightning.c b/lib/lightning.c
index 7c2dcad..58b1a55 100644
--- a/lib/lightning.c
+++ b/lib/lightning.c
@@ -1455,7 +1455,6 @@ _jit_emit(jit_state_t *_jit)
{
jit_pointer_t code;
jit_node_t *node;
- jit_int32_t mult;
size_t length;
int result;
@@ -1464,11 +1463,11 @@ _jit_emit(jit_state_t *_jit)
jit_optimize();
/* Heuristic to guess code buffer size */
- mult = 4;
+ _jitc->mult = 4;
_jitc->emit = 1;
- _jit->code.length = _jitc->pool.length * 1024 * mult;
+ _jit->code.length = _jitc->pool.length * 1024 * _jitc->mult;
_jit->code.ptr = mmap(NULL, _jit->code.length,
PROT_EXEC | PROT_READ | PROT_WRITE,
@@ -1485,8 +1484,8 @@ _jit_emit(jit_state_t *_jit)
node->code == jit_code_epilog))
node->flag &= ~jit_flag_patch;
}
- ++mult;
- length = _jitc->pool.length * 1024 * mult;
+ ++_jitc->mult;
+ length = _jitc->pool.length * 1024 * _jitc->mult;
#if !HAVE_MREMAP
munmap(_jit->code.ptr, _jit->code.length);
- [Guile-commits] 146/437: Add several arithmetic and branch tests cases., (continued)
- [Guile-commits] 146/437: Add several arithmetic and branch tests cases., Andy Wingo, 2018/07/02
- [Guile-commits] 191/437: Add updated sparc example from lightning 1.2c documentation., Andy Wingo, 2018/07/02
- [Guile-commits] 151/437: Add new varargs test and correct related test case failures in all ports., Andy Wingo, 2018/07/02
- [Guile-commits] 198/437: Remove non optional gmp dependency., Andy Wingo, 2018/07/02
- [Guile-commits] 202/437: Ensure the end argument of __clear_cache is page aligned., Andy Wingo, 2018/07/02
- [Guile-commits] 197/437: Adapt PowerPC port to work in Darwin 32 bit and Linux 64 bit., Andy Wingo, 2018/07/02
- [Guile-commits] 184/437: Implement the "live" code to explicitly tell a register is live., Andy Wingo, 2018/07/02
- [Guile-commits] 149/437: Make all current test cases pass in Darwin PowerPC., Andy Wingo, 2018/07/02
- [Guile-commits] 113/437: Change JIT_REXTMP, JIT_R, JIT_V to use 64-bit registers, Andy Wingo, 2018/07/02
- [Guile-commits] 173/437: Add filename and line number annotation abstraction., Andy Wingo, 2018/07/02
- [Guile-commits] 201/437: Do not start over jit generation if can safely grow buffer size.,
Andy Wingo <=
- [Guile-commits] 152/437: Remove most type casts and compile test tool silently with -Wall, Andy Wingo, 2018/07/02
- [Guile-commits] 208/437: Implement fpr register arguments and minor extra fixes., Andy Wingo, 2018/07/02
- [Guile-commits] 211/437: Correct the cvt.tst test case on Itanium., Andy Wingo, 2018/07/02
- [Guile-commits] 187/437: Correct regression with float arguments in arm hardp, Andy Wingo, 2018/07/02
- [Guile-commits] 200/437: Add a simple memory management wrapper., Andy Wingo, 2018/07/02
- [Guile-commits] 196/437: Add missing __ppc__ definition., Andy Wingo, 2018/07/02
- [Guile-commits] 159/437: Correct stack.tst test case on ppc. Now all tests pass in all backends., Andy Wingo, 2018/07/02
- [Guile-commits] 172/437: Rework {get, push}arg{, i, r}_{f, d} to a more descriptive name and usage., Andy Wingo, 2018/07/02
- [Guile-commits] 221/437: Correct build and pass all tests on Solaris Sparc., Andy Wingo, 2018/07/02
- [Guile-commits] 228/437: Properly check tests output., Andy Wingo, 2018/07/02