Browse Source

implement nesting in the interpreter backend

pull/15/head
Jakob Löw 6 years ago
parent
commit
217a496c9f
  1. 11
      jit/jit-insn.c
  2. 5
      jit/jit-interp-opcodes.ops
  3. 17
      jit/jit-rules-interp.c

11
jit/jit-insn.c

@ -6308,7 +6308,16 @@ jit_insn_get_frame_pointer(jit_function_t func)
break;
}
}
jit_insn_incoming_reg(func, value, reg);
if(reg < JIT_NUM_REGS)
{
jit_insn_incoming_reg(func, value, reg);
}
else
{
jit_insn_incoming_frame_posn(func, value, 0);
value = jit_insn_address_of(func, value);
}
return value;
}

5
jit/jit-interp-opcodes.ops

@ -178,11 +178,6 @@ opcodes(JIT_INTERP_OP_,
op_def("pop") { }
op_def("pop_2") { }
op_def("pop_3") { }
/*
* Nested function call handling.
*/
op_def("import_local") { "JIT_OPCODE_NINT_ARG_TWO" }
op_def("import_arg") { "JIT_OPCODE_NINT_ARG_TWO" }
/*
* Marker opcode for the end of a function.
*/

17
jit/jit-rules-interp.c

@ -287,11 +287,18 @@ int _jit_create_entry_insns(jit_function_t func)
flipped when we output the argument opcodes for interpretation */
offset = -1;
/* If the function is nested, then we need two extra parameters
to pass the pointer to the parent's local variables and arguments */
/* If the function is nested, then we an extra parameter
to pass the pointer to the parent's frame */
if(func->nested_parent)
{
offset -= 2;
value = jit_value_create(func, jit_type_void_ptr);
if(!jit_insn_incoming_frame_posn(func, value, offset))
{
return 0;
}
jit_function_set_parent_frame(func, value);
--offset;
}
/* Allocate the structure return pointer */
@ -974,7 +981,7 @@ load_value(jit_gencode_t gen, jit_value_t value, int index)
default:
return;
}
opcode = _jit_load_opcode(opcode, value->type, value, 0);
opcode = _jit_load_opcode(opcode, value->type);
offset = value->frame_offset;
}
else
@ -994,7 +1001,7 @@ load_value(jit_gencode_t gen, jit_value_t value, int index)
default:
return;
}
opcode = _jit_load_opcode(opcode, value->type, value, 0);
opcode = _jit_load_opcode(opcode, value->type);
offset = -(value->frame_offset + 1);
}

Loading…
Cancel
Save