1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-20 18:50:21 +02:00

Add heuristic code to estimate space and resize if required jit buffer.

This commit is contained in:
pcpa 2013-01-29 16:37:43 -02:00
parent 16d18f11d3
commit 44d4fa5444
9 changed files with 111 additions and 82 deletions

View file

@ -663,7 +663,7 @@ _jit_retval_d(jit_state_t *_jit, jit_int32_t r0)
}
jit_pointer_t
_jit_emit(jit_state_t *_jit)
_emit_code(jit_state_t *_jit)
{
jit_node_t *node;
jit_node_t *temp;
@ -676,23 +676,6 @@ _jit_emit(jit_state_t *_jit)
jit_int32_t patch_offset;
} undo;
if (_jit->function)
jit_epilog();
jit_optimize();
_jit->emit = 1;
_jit->code.length = 16 * 1024 * 1024;
_jit->code.ptr = mmap(NULL, _jit->code.length,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
assert(_jit->code.ptr != MAP_FAILED);
_jit->pc.uc = _jit->code.ptr;
/* clear jit_flag_patch from label nodes if reallocating buffer
* and starting over
*/
_jit->function = NULL;
jit_reglive_setup();
@ -774,6 +757,9 @@ _jit_emit(jit_state_t *_jit)
} \
break
for (node = _jit->head; node; node = node->next) {
if (_jit->pc.uc >= _jit->code.end)
return (NULL);
value = jit_classify(node->code);
jit_regarg_set(node, value);
switch (node->code) {
@ -1249,8 +1235,6 @@ _jit_emit(jit_state_t *_jit)
#if defined(__linux__)
_flush_cache((char *)_jit->code.ptr, _jit->pc.uc - _jit->code.ptr, ICACHE);
#endif
_jit->done = 1;
jit_annotate();
return (_jit->code.ptr);
}