mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 13:00:26 +02:00
Rework to better describe what is used only during jit generation.
* include/lightning/jit_private.h, lib/jit_arm-cpu.c, lib/jit_arm.c, lib/jit_disasm.c, lib/jit_mips-cpu.c, lib/jit_mips.c, lib/jit_note.c, lib/jit_ppc-cpu.c, lib/jit_ppc.c, lib/jit_print.c, lib/jit_sparc-cpu.c, lib/jit_sparc.c, lib/jit_x86-cpu.c, lib/jit_x86.c, lib/lightning.c: Add an extra structure for data storage during jit generation, and release it after generating jit, to reduce a bit memory usage, and also to make it easier to understand what data is available during jit runtime.
This commit is contained in:
parent
f39eee6694
commit
9afca85921
16 changed files with 1328 additions and 1299 deletions
314
lib/jit_ppc.c
314
lib/jit_ppc.c
|
@ -114,7 +114,7 @@ jit_get_cpu(void)
|
|||
void
|
||||
_jit_init(jit_state_t *_jit)
|
||||
{
|
||||
_jit->reglen = jit_size(_rvs) - 1;
|
||||
_jitc->reglen = jit_size(_rvs) - 1;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -122,53 +122,53 @@ _jit_prolog(jit_state_t *_jit)
|
|||
{
|
||||
jit_int32_t offset;
|
||||
|
||||
if (_jit->function)
|
||||
if (_jitc->function)
|
||||
jit_epilog();
|
||||
assert(jit_regset_cmp_ui(_jit->regarg, 0) == 0);
|
||||
jit_regset_set_ui(_jit->regsav, 0);
|
||||
offset = _jit->functions.offset;
|
||||
if (offset >= _jit->functions.length) {
|
||||
_jit->functions.ptr = realloc(_jit->functions.ptr,
|
||||
(_jit->functions.length + 16) *
|
||||
assert(jit_regset_cmp_ui(_jitc->regarg, 0) == 0);
|
||||
jit_regset_set_ui(_jitc->regsav, 0);
|
||||
offset = _jitc->functions.offset;
|
||||
if (offset >= _jitc->functions.length) {
|
||||
_jitc->functions.ptr = realloc(_jitc->functions.ptr,
|
||||
(_jitc->functions.length + 16) *
|
||||
sizeof(jit_function_t));
|
||||
memset(_jit->functions.ptr + _jit->functions.length, 0,
|
||||
memset(_jitc->functions.ptr + _jitc->functions.length, 0,
|
||||
16 * sizeof(jit_function_t));
|
||||
_jit->functions.length += 16;
|
||||
_jitc->functions.length += 16;
|
||||
}
|
||||
_jit->function = _jit->functions.ptr + _jit->functions.offset++;
|
||||
_jit->function->self.size = params_offset;
|
||||
_jit->function->self.argi = _jit->function->self.argf =
|
||||
_jit->function->self.alen = 0;
|
||||
_jitc->function = _jitc->functions.ptr + _jitc->functions.offset++;
|
||||
_jitc->function->self.size = params_offset;
|
||||
_jitc->function->self.argi = _jitc->function->self.argf =
|
||||
_jitc->function->self.alen = 0;
|
||||
/* float conversion */
|
||||
_jit->function->self.aoff = alloca_offset - 8;
|
||||
_jit->function->self.call = jit_call_default;
|
||||
_jit->function->regoff = calloc(_jit->reglen, sizeof(jit_int32_t));
|
||||
_jitc->function->self.aoff = alloca_offset - 8;
|
||||
_jitc->function->self.call = jit_call_default;
|
||||
_jitc->function->regoff = calloc(_jitc->reglen, sizeof(jit_int32_t));
|
||||
|
||||
_jit->function->prolog = jit_new_node_no_link(jit_code_prolog);
|
||||
jit_link(_jit->function->prolog);
|
||||
_jit->function->prolog->w.w = offset;
|
||||
_jit->function->epilog = jit_new_node_no_link(jit_code_epilog);
|
||||
_jitc->function->prolog = jit_new_node_no_link(jit_code_prolog);
|
||||
jit_link(_jitc->function->prolog);
|
||||
_jitc->function->prolog->w.w = offset;
|
||||
_jitc->function->epilog = jit_new_node_no_link(jit_code_epilog);
|
||||
/* u: label value
|
||||
* v: offset in blocks vector
|
||||
* w: offset in functions vector
|
||||
*/
|
||||
_jit->function->epilog->w.w = offset;
|
||||
_jitc->function->epilog->w.w = offset;
|
||||
|
||||
jit_regset_new(_jit->function->regset);
|
||||
jit_regset_new(_jitc->function->regset);
|
||||
}
|
||||
|
||||
jit_int32_t
|
||||
_jit_allocai(jit_state_t *_jit, jit_int32_t length)
|
||||
{
|
||||
assert(_jit->function);
|
||||
assert(_jitc->function);
|
||||
switch (length) {
|
||||
case 0: case 1: break;
|
||||
case 2: _jit->function->self.aoff &= -2; break;
|
||||
case 3: case 4: _jit->function->self.aoff &= -4; break;
|
||||
default: _jit->function->self.aoff &= -8; break;
|
||||
case 2: _jitc->function->self.aoff &= -2; break;
|
||||
case 3: case 4: _jitc->function->self.aoff &= -4; break;
|
||||
default: _jitc->function->self.aoff &= -8; break;
|
||||
}
|
||||
_jit->function->self.aoff -= length;
|
||||
return (_jit->function->self.aoff);
|
||||
_jitc->function->self.aoff -= length;
|
||||
return (_jitc->function->self.aoff);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -176,11 +176,11 @@ _jit_ret(jit_state_t *_jit)
|
|||
{
|
||||
jit_node_t *instr;
|
||||
|
||||
assert(_jit->function);
|
||||
assert(_jitc->function);
|
||||
|
||||
/* jump to epilog */
|
||||
instr = jit_jmpi();
|
||||
jit_patch_at(instr, _jit->function->epilog);
|
||||
jit_patch_at(instr, _jitc->function->epilog);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -238,22 +238,22 @@ _jit_reti_d(jit_state_t *_jit, jit_float64_t u)
|
|||
void
|
||||
_jit_epilog(jit_state_t *_jit)
|
||||
{
|
||||
assert(_jit->function);
|
||||
assert(_jit->function->epilog->next == NULL);
|
||||
jit_link(_jit->function->epilog);
|
||||
_jit->function = NULL;
|
||||
assert(_jitc->function);
|
||||
assert(_jitc->function->epilog->next == NULL);
|
||||
jit_link(_jitc->function->epilog);
|
||||
_jitc->function = NULL;
|
||||
}
|
||||
|
||||
jit_node_t *
|
||||
_jit_arg(jit_state_t *_jit)
|
||||
{
|
||||
jit_int32_t offset;
|
||||
assert(_jit->function);
|
||||
if (_jit->function->self.argi < 8)
|
||||
offset = _jit->function->self.argi++;
|
||||
assert(_jitc->function);
|
||||
if (_jitc->function->self.argi < 8)
|
||||
offset = _jitc->function->self.argi++;
|
||||
else
|
||||
offset = _jit->function->self.size;
|
||||
_jit->function->self.size += sizeof(jit_word_t);
|
||||
offset = _jitc->function->self.size;
|
||||
_jitc->function->self.size += sizeof(jit_word_t);
|
||||
return (jit_new_node_w(jit_code_arg, offset));
|
||||
}
|
||||
|
||||
|
@ -267,12 +267,12 @@ jit_node_t *
|
|||
_jit_arg_f(jit_state_t *_jit)
|
||||
{
|
||||
jit_int32_t offset;
|
||||
assert(_jit->function);
|
||||
if (_jit->function->self.argf < 13)
|
||||
offset = _jit->function->self.argf++;
|
||||
assert(_jitc->function);
|
||||
if (_jitc->function->self.argf < 13)
|
||||
offset = _jitc->function->self.argf++;
|
||||
else
|
||||
offset = _jit->function->self.size;
|
||||
_jit->function->self.size += sizeof(jit_float32_t);
|
||||
offset = _jitc->function->self.size;
|
||||
_jitc->function->self.size += sizeof(jit_float32_t);
|
||||
return (jit_new_node_w(jit_code_arg_f, offset));
|
||||
}
|
||||
|
||||
|
@ -286,12 +286,12 @@ jit_node_t *
|
|||
_jit_arg_d(jit_state_t *_jit)
|
||||
{
|
||||
jit_int32_t offset;
|
||||
assert(_jit->function);
|
||||
if (_jit->function->self.argf < 13)
|
||||
offset = _jit->function->self.argf++;
|
||||
assert(_jitc->function);
|
||||
if (_jitc->function->self.argf < 13)
|
||||
offset = _jitc->function->self.argf++;
|
||||
else
|
||||
offset = _jit->function->self.size;
|
||||
_jit->function->self.size += sizeof(jit_float64_t);
|
||||
offset = _jitc->function->self.size;
|
||||
_jitc->function->self.size += sizeof(jit_float64_t);
|
||||
return (jit_new_node_w(jit_code_arg_d, offset));
|
||||
}
|
||||
|
||||
|
@ -423,62 +423,62 @@ _jit_getarg_d(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
|||
void
|
||||
_jit_pushargr(jit_state_t *_jit, jit_int32_t u)
|
||||
{
|
||||
assert(_jit->function);
|
||||
if (_jit->function->call.argi < 8) {
|
||||
jit_movr(JIT_RA0 - _jit->function->call.argi, u);
|
||||
++_jit->function->call.argi;
|
||||
assert(_jitc->function);
|
||||
if (_jitc->function->call.argi < 8) {
|
||||
jit_movr(JIT_RA0 - _jitc->function->call.argi, u);
|
||||
++_jitc->function->call.argi;
|
||||
}
|
||||
else
|
||||
jit_stxi(_jit->function->call.size + params_offset, JIT_SP, u);
|
||||
_jit->function->call.size += sizeof(jit_word_t);
|
||||
jit_stxi(_jitc->function->call.size + params_offset, JIT_SP, u);
|
||||
_jitc->function->call.size += sizeof(jit_word_t);
|
||||
}
|
||||
|
||||
void
|
||||
_jit_pushargi(jit_state_t *_jit, jit_word_t u)
|
||||
{
|
||||
jit_int32_t regno;
|
||||
assert(_jit->function);
|
||||
if (_jit->function->call.argi < 8) {
|
||||
jit_movi(JIT_RA0 - _jit->function->call.argi, u);
|
||||
++_jit->function->call.argi;
|
||||
assert(_jitc->function);
|
||||
if (_jitc->function->call.argi < 8) {
|
||||
jit_movi(JIT_RA0 - _jitc->function->call.argi, u);
|
||||
++_jitc->function->call.argi;
|
||||
}
|
||||
else {
|
||||
regno = jit_get_reg(jit_class_gpr);
|
||||
jit_movi(regno, u);
|
||||
jit_stxi(_jit->function->call.size + params_offset, JIT_SP, regno);
|
||||
jit_stxi(_jitc->function->call.size + params_offset, JIT_SP, regno);
|
||||
jit_unget_reg(regno);
|
||||
}
|
||||
_jit->function->call.size += sizeof(jit_word_t);
|
||||
_jitc->function->call.size += sizeof(jit_word_t);
|
||||
}
|
||||
|
||||
void
|
||||
_jit_pushargr_f(jit_state_t *_jit, jit_int32_t u)
|
||||
{
|
||||
assert(_jit->function);
|
||||
if (_jit->function->call.argf < 13) {
|
||||
jit_movr_d(JIT_FA0 - _jit->function->call.argf, u);
|
||||
++_jit->function->call.argf;
|
||||
if (!(_jit->function->call.call & jit_call_varargs)) {
|
||||
assert(_jitc->function);
|
||||
if (_jitc->function->call.argf < 13) {
|
||||
jit_movr_d(JIT_FA0 - _jitc->function->call.argf, u);
|
||||
++_jitc->function->call.argf;
|
||||
if (!(_jitc->function->call.call & jit_call_varargs)) {
|
||||
/* in case of excess arguments */
|
||||
if (_jit->function->call.argi < 8)
|
||||
_jit->function->call.argi += 2;
|
||||
_jit->function->call.size += sizeof(jit_float32_t);
|
||||
if (_jitc->function->call.argi < 8)
|
||||
_jitc->function->call.argi += 2;
|
||||
_jitc->function->call.size += sizeof(jit_float32_t);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (_jit->function->call.argi < 8) {
|
||||
if (_jitc->function->call.argi < 8) {
|
||||
/* use reserved 8 bytes area */
|
||||
jit_stxi_d(alloca_offset - 8, JIT_FP, u);
|
||||
jit_ldxi(JIT_RA0 - _jit->function->call.argi, JIT_FP,
|
||||
jit_ldxi(JIT_RA0 - _jitc->function->call.argi, JIT_FP,
|
||||
alloca_offset - 8);
|
||||
_jit->function->call.argi++;
|
||||
jit_ldxi(JIT_RA0 - _jit->function->call.argi, JIT_FP,
|
||||
_jitc->function->call.argi++;
|
||||
jit_ldxi(JIT_RA0 - _jitc->function->call.argi, JIT_FP,
|
||||
alloca_offset - 4);
|
||||
_jit->function->call.argi++;
|
||||
_jitc->function->call.argi++;
|
||||
}
|
||||
else
|
||||
jit_stxi_f(_jit->function->call.size + params_offset, JIT_SP, u);
|
||||
_jit->function->call.size += sizeof(jit_float32_t);
|
||||
jit_stxi_f(_jitc->function->call.size + params_offset, JIT_SP, u);
|
||||
_jitc->function->call.size += sizeof(jit_float32_t);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -486,64 +486,64 @@ _jit_pushargi_f(jit_state_t *_jit, jit_float32_t u)
|
|||
{
|
||||
jit_int32_t regno;
|
||||
|
||||
assert(_jit->function);
|
||||
if (_jit->function->call.argf < 13) {
|
||||
jit_movi_d(JIT_FA0 - _jit->function->call.argf, u);
|
||||
++_jit->function->call.argf;
|
||||
if (!(_jit->function->call.call & jit_call_varargs)) {
|
||||
assert(_jitc->function);
|
||||
if (_jitc->function->call.argf < 13) {
|
||||
jit_movi_d(JIT_FA0 - _jitc->function->call.argf, u);
|
||||
++_jitc->function->call.argf;
|
||||
if (!(_jitc->function->call.call & jit_call_varargs)) {
|
||||
/* in case of excess arguments */
|
||||
if (_jit->function->call.argi < 8)
|
||||
_jit->function->call.argi += 2;
|
||||
_jit->function->call.size += sizeof(jit_float32_t);
|
||||
if (_jitc->function->call.argi < 8)
|
||||
_jitc->function->call.argi += 2;
|
||||
_jitc->function->call.size += sizeof(jit_float32_t);
|
||||
return;
|
||||
}
|
||||
}
|
||||
regno = jit_get_reg(jit_class_fpr);
|
||||
jit_movi_f(regno, u);
|
||||
if (_jit->function->call.argi < 8) {
|
||||
if (_jitc->function->call.argi < 8) {
|
||||
/* use reserved 8 bytes area */
|
||||
jit_stxi_d(alloca_offset - 8, JIT_FP, regno);
|
||||
jit_ldxi(JIT_RA0 - _jit->function->call.argi, JIT_FP,
|
||||
jit_ldxi(JIT_RA0 - _jitc->function->call.argi, JIT_FP,
|
||||
alloca_offset - 8);
|
||||
_jit->function->call.argi++;
|
||||
jit_ldxi(JIT_RA0 - _jit->function->call.argi, JIT_FP,
|
||||
_jitc->function->call.argi++;
|
||||
jit_ldxi(JIT_RA0 - _jitc->function->call.argi, JIT_FP,
|
||||
alloca_offset - 4);
|
||||
_jit->function->call.argi++;
|
||||
_jitc->function->call.argi++;
|
||||
}
|
||||
else
|
||||
jit_stxi_f(_jit->function->call.size + params_offset, JIT_SP, regno);
|
||||
_jit->function->call.size += sizeof(jit_float32_t);
|
||||
jit_stxi_f(_jitc->function->call.size + params_offset, JIT_SP, regno);
|
||||
_jitc->function->call.size += sizeof(jit_float32_t);
|
||||
jit_unget_reg(regno);
|
||||
}
|
||||
|
||||
void
|
||||
_jit_pushargr_d(jit_state_t *_jit, jit_int32_t u)
|
||||
{
|
||||
assert(_jit->function);
|
||||
if (_jit->function->call.argf < 13) {
|
||||
jit_movr_d(JIT_FA0 - _jit->function->call.argf, u);
|
||||
++_jit->function->call.argf;
|
||||
if (!(_jit->function->call.call & jit_call_varargs)) {
|
||||
assert(_jitc->function);
|
||||
if (_jitc->function->call.argf < 13) {
|
||||
jit_movr_d(JIT_FA0 - _jitc->function->call.argf, u);
|
||||
++_jitc->function->call.argf;
|
||||
if (!(_jitc->function->call.call & jit_call_varargs)) {
|
||||
/* in case of excess arguments */
|
||||
if (_jit->function->call.argi < 8)
|
||||
_jit->function->call.argi += 2;
|
||||
_jit->function->call.size += sizeof(jit_float64_t);
|
||||
if (_jitc->function->call.argi < 8)
|
||||
_jitc->function->call.argi += 2;
|
||||
_jitc->function->call.size += sizeof(jit_float64_t);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (_jit->function->call.argi < 8) {
|
||||
if (_jitc->function->call.argi < 8) {
|
||||
/* use reserved 8 bytes area */
|
||||
jit_stxi_d(alloca_offset - 8, JIT_FP, u);
|
||||
jit_ldxi(JIT_RA0 - _jit->function->call.argi, JIT_FP,
|
||||
jit_ldxi(JIT_RA0 - _jitc->function->call.argi, JIT_FP,
|
||||
alloca_offset - 8);
|
||||
_jit->function->call.argi++;
|
||||
jit_ldxi(JIT_RA0 - _jit->function->call.argi, JIT_FP,
|
||||
_jitc->function->call.argi++;
|
||||
jit_ldxi(JIT_RA0 - _jitc->function->call.argi, JIT_FP,
|
||||
alloca_offset - 4);
|
||||
_jit->function->call.argi++;
|
||||
_jitc->function->call.argi++;
|
||||
}
|
||||
else
|
||||
jit_stxi_d(_jit->function->call.size + params_offset, JIT_SP, u);
|
||||
_jit->function->call.size += sizeof(jit_float64_t);
|
||||
jit_stxi_d(_jitc->function->call.size + params_offset, JIT_SP, u);
|
||||
_jitc->function->call.size += sizeof(jit_float64_t);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -551,33 +551,33 @@ _jit_pushargi_d(jit_state_t *_jit, jit_float64_t u)
|
|||
{
|
||||
jit_int32_t regno;
|
||||
|
||||
assert(_jit->function);
|
||||
if (_jit->function->call.argf < 13) {
|
||||
jit_movi_d(JIT_FA0 - _jit->function->call.argf, u);
|
||||
++_jit->function->call.argf;
|
||||
if (!(_jit->function->call.call & jit_call_varargs)) {
|
||||
assert(_jitc->function);
|
||||
if (_jitc->function->call.argf < 13) {
|
||||
jit_movi_d(JIT_FA0 - _jitc->function->call.argf, u);
|
||||
++_jitc->function->call.argf;
|
||||
if (!(_jitc->function->call.call & jit_call_varargs)) {
|
||||
/* in case of excess arguments */
|
||||
if (_jit->function->call.argi < 8)
|
||||
_jit->function->call.argi += 2;
|
||||
_jit->function->call.size += sizeof(jit_float64_t);
|
||||
if (_jitc->function->call.argi < 8)
|
||||
_jitc->function->call.argi += 2;
|
||||
_jitc->function->call.size += sizeof(jit_float64_t);
|
||||
return;
|
||||
}
|
||||
}
|
||||
regno = jit_get_reg(jit_class_fpr);
|
||||
jit_movi_d(regno, u);
|
||||
if (_jit->function->call.argi < 8) {
|
||||
if (_jitc->function->call.argi < 8) {
|
||||
/* use reserved 8 bytes area */
|
||||
jit_stxi_d(alloca_offset - 8, JIT_FP, regno);
|
||||
jit_ldxi(JIT_RA0 - _jit->function->call.argi, JIT_FP,
|
||||
jit_ldxi(JIT_RA0 - _jitc->function->call.argi, JIT_FP,
|
||||
alloca_offset - 8);
|
||||
_jit->function->call.argi++;
|
||||
jit_ldxi(JIT_RA0 - _jit->function->call.argi, JIT_FP,
|
||||
_jitc->function->call.argi++;
|
||||
jit_ldxi(JIT_RA0 - _jitc->function->call.argi, JIT_FP,
|
||||
alloca_offset - 4);
|
||||
_jit->function->call.argi++;
|
||||
_jitc->function->call.argi++;
|
||||
}
|
||||
else
|
||||
jit_stxi_d(_jit->function->call.size + params_offset, JIT_SP, regno);
|
||||
_jit->function->call.size += sizeof(jit_float64_t);
|
||||
jit_stxi_d(_jitc->function->call.size + params_offset, JIT_SP, regno);
|
||||
_jitc->function->call.size += sizeof(jit_float64_t);
|
||||
jit_unget_reg(regno);
|
||||
}
|
||||
|
||||
|
@ -605,28 +605,28 @@ void
|
|||
_jit_finishr(jit_state_t *_jit, jit_int32_t r0)
|
||||
{
|
||||
jit_node_t *call;
|
||||
assert(_jit->function);
|
||||
if (_jit->function->self.alen < _jit->function->call.size)
|
||||
_jit->function->self.alen = _jit->function->call.size;
|
||||
assert(_jitc->function);
|
||||
if (_jitc->function->self.alen < _jitc->function->call.size)
|
||||
_jitc->function->self.alen = _jitc->function->call.size;
|
||||
call = jit_callr(r0);
|
||||
call->v.w = _jit->function->call.argi;
|
||||
call->w.w = _jit->function->call.argf;
|
||||
_jit->function->call.argi = _jit->function->call.argf = 0;
|
||||
_jit->prepare = 0;
|
||||
call->v.w = _jitc->function->call.argi;
|
||||
call->w.w = _jitc->function->call.argf;
|
||||
_jitc->function->call.argi = _jitc->function->call.argf = 0;
|
||||
_jitc->prepare = 0;
|
||||
}
|
||||
|
||||
jit_node_t *
|
||||
_jit_finishi(jit_state_t *_jit, jit_pointer_t i0)
|
||||
{
|
||||
jit_node_t *node;
|
||||
assert(_jit->function);
|
||||
if (_jit->function->self.alen < _jit->function->call.size)
|
||||
_jit->function->self.alen = _jit->function->call.size;
|
||||
assert(_jitc->function);
|
||||
if (_jitc->function->self.alen < _jitc->function->call.size)
|
||||
_jitc->function->self.alen = _jitc->function->call.size;
|
||||
node = jit_calli(i0);
|
||||
node->v.w = _jit->function->call.argi;
|
||||
node->w.w = _jit->function->call.argf;
|
||||
_jit->function->call.argi = _jit->function->call.argf = 0;
|
||||
_jit->prepare = 0;
|
||||
node->v.w = _jitc->function->call.argi;
|
||||
node->w.w = _jitc->function->call.argf;
|
||||
_jitc->function->call.argi = _jitc->function->call.argf = 0;
|
||||
_jitc->prepare = 0;
|
||||
return (node);
|
||||
}
|
||||
|
||||
|
@ -707,7 +707,7 @@ _emit_code(jit_state_t *_jit)
|
|||
jit_int32_t patch_offset;
|
||||
} undo;
|
||||
|
||||
_jit->function = NULL;
|
||||
_jitc->function = NULL;
|
||||
|
||||
jit_reglive_setup();
|
||||
|
||||
|
@ -798,8 +798,8 @@ _emit_code(jit_state_t *_jit)
|
|||
patch(word, node); \
|
||||
} \
|
||||
break
|
||||
for (node = _jit->head; node; node = node->next) {
|
||||
if (_jit->pc.uc >= _jit->code.end)
|
||||
for (node = _jitc->head; node; node = node->next) {
|
||||
if (_jit->pc.uc >= _jitc->code.end)
|
||||
return (NULL);
|
||||
|
||||
value = jit_classify(node->code);
|
||||
|
@ -1169,17 +1169,17 @@ _emit_code(jit_state_t *_jit)
|
|||
calli(node->u.w);
|
||||
break;
|
||||
case jit_code_prolog:
|
||||
_jit->function = _jit->functions.ptr + node->w.w;
|
||||
_jitc->function = _jitc->functions.ptr + node->w.w;
|
||||
undo.node = node;
|
||||
undo.word = _jit->pc.w;
|
||||
undo.patch_offset = _jit->patches.offset;
|
||||
undo.patch_offset = _jitc->patches.offset;
|
||||
restart_function:
|
||||
_jit->again = 0;
|
||||
_jitc->again = 0;
|
||||
prolog(node);
|
||||
break;
|
||||
case jit_code_epilog:
|
||||
assert(_jit->function == _jit->functions.ptr + node->w.w);
|
||||
if (_jit->again) {
|
||||
assert(_jitc->function == _jitc->functions.ptr + node->w.w);
|
||||
if (_jitc->again) {
|
||||
for (temp = undo.node->next;
|
||||
temp != node; temp = temp->next) {
|
||||
if (temp->code == jit_code_label ||
|
||||
|
@ -1188,14 +1188,14 @@ _emit_code(jit_state_t *_jit)
|
|||
}
|
||||
node = undo.node;
|
||||
_jit->pc.w = undo.word;
|
||||
_jit->patches.offset = undo.patch_offset;
|
||||
_jitc->patches.offset = undo.patch_offset;
|
||||
goto restart_function;
|
||||
}
|
||||
/* remember label is defined */
|
||||
node->flag |= jit_flag_patch;
|
||||
node->u.w = _jit->pc.w;
|
||||
epilog(node);
|
||||
_jit->function = NULL;
|
||||
_jitc->function = NULL;
|
||||
break;
|
||||
case jit_code_live:
|
||||
case jit_code_arg:
|
||||
|
@ -1219,10 +1219,10 @@ _emit_code(jit_state_t *_jit)
|
|||
#undef case_rw
|
||||
#undef case_rr
|
||||
|
||||
for (offset = 0; offset < _jit->patches.offset; offset++) {
|
||||
node = _jit->patches.ptr[offset].node;
|
||||
for (offset = 0; offset < _jitc->patches.offset; offset++) {
|
||||
node = _jitc->patches.ptr[offset].node;
|
||||
word = node->code == jit_code_movi ? node->v.n->u.w : node->u.n->u.w;
|
||||
patch_at(_jit->patches.ptr[offset].inst, word);
|
||||
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||
}
|
||||
|
||||
__clear_cache(_jit->code.ptr, _jit->pc.uc);
|
||||
|
@ -1279,15 +1279,15 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
|
|||
else
|
||||
flag = node->u.n->flag;
|
||||
assert(!(flag & jit_flag_patch));
|
||||
if (_jit->patches.offset >= _jit->patches.length) {
|
||||
_jit->patches.ptr = realloc(_jit->patches.ptr,
|
||||
(_jit->patches.length + 1024) *
|
||||
if (_jitc->patches.offset >= _jitc->patches.length) {
|
||||
_jitc->patches.ptr = realloc(_jitc->patches.ptr,
|
||||
(_jitc->patches.length + 1024) *
|
||||
sizeof(jit_patch_t));
|
||||
memset(_jit->patches.ptr + _jit->patches.length, 0,
|
||||
memset(_jitc->patches.ptr + _jitc->patches.length, 0,
|
||||
1024 * sizeof(jit_patch_t));
|
||||
_jit->patches.length += 1024;
|
||||
_jitc->patches.length += 1024;
|
||||
}
|
||||
_jit->patches.ptr[_jit->patches.offset].inst = instr;
|
||||
_jit->patches.ptr[_jit->patches.offset].node = node;
|
||||
++_jit->patches.offset;
|
||||
_jitc->patches.ptr[_jitc->patches.offset].inst = instr;
|
||||
_jitc->patches.ptr[_jitc->patches.offset].node = node;
|
||||
++_jitc->patches.offset;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue