mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 09:02:50 -06:00
added assertion in the JIT compiler which checks that we are not going outside of the compilation window
This commit is contained in:
@@ -14,6 +14,7 @@ struct PgfJitState {
|
|||||||
GuPool* pool;
|
GuPool* pool;
|
||||||
jit_state jit;
|
jit_state jit;
|
||||||
jit_insn *buf;
|
jit_insn *buf;
|
||||||
|
char *save_ip_ptr;
|
||||||
GuBuf* patches;
|
GuBuf* patches;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,10 +72,10 @@ pgf_jit_init(GuPool* tmp_pool, GuPool* pool)
|
|||||||
PgfJitState* state = gu_new(PgfJitState, tmp_pool);
|
PgfJitState* state = gu_new(PgfJitState, tmp_pool);
|
||||||
state->tmp_pool = tmp_pool;
|
state->tmp_pool = tmp_pool;
|
||||||
state->pool = pool;
|
state->pool = pool;
|
||||||
state->buf = NULL;
|
|
||||||
state->patches = gu_new_buf(PgfCallPatch, tmp_pool);
|
state->patches = gu_new_buf(PgfCallPatch, tmp_pool);
|
||||||
|
|
||||||
pgf_jit_alloc_page(state);
|
pgf_jit_alloc_page(state);
|
||||||
|
state->save_ip_ptr = jit_get_ip().ptr;
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@@ -82,11 +83,15 @@ pgf_jit_init(GuPool* tmp_pool, GuPool* pool)
|
|||||||
static void
|
static void
|
||||||
pgf_jit_make_space(PgfJitState* state)
|
pgf_jit_make_space(PgfJitState* state)
|
||||||
{
|
{
|
||||||
|
assert (state->save_ip_ptr + JIT_CODE_WINDOW > jit_get_ip().ptr);
|
||||||
|
|
||||||
size_t page_size = getpagesize();
|
size_t page_size = getpagesize();
|
||||||
if (jit_get_ip().ptr + JIT_CODE_WINDOW > ((char*) state->buf) + page_size) {
|
if (jit_get_ip().ptr + JIT_CODE_WINDOW > ((char*) state->buf) + page_size) {
|
||||||
jit_flush_code(state->buf, jit_get_ip().ptr);
|
jit_flush_code(state->buf, jit_get_ip().ptr);
|
||||||
pgf_jit_alloc_page(state);
|
pgf_jit_alloc_page(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state->save_ip_ptr = jit_get_ip().ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user