parrotcode: Parrot Interpreter | |
Contents | C |
src/interpreter.c - Parrot Interpreter
The interpreter API handles running the operations.
The predereferenced code chunk is pre-initialized with the opcode function pointers,
addresses,
or opnumbers of the prederef__
opcode.
This opcode then calls the do_prederef()
function,
which then fills in the real function,
address or op number.
Since the prederef__
opcode returns the same pc_prederef
it was passed,
the runops loop will re-execute the same location,
which will then have the pointer to the real prederef
opfunc and prederef
args.
Pointer arithmetic is used to determine the index into the bytecode corresponding to the currect opcode. The bytecode and prederef arrays have the same number of elements since there is a one-to-one mapping.
static void prederef_args(void **pc_prederef, Interp *interpreter, opcode_t *pc, op_info_t *opinfo)
do_prederef()
to deal with any arguments.pc_prederef
is the current opcode.void do_prederef(void **pc_prederef, Parrot_Interp interpreter, int type)
pc_prederef
is the current opcode,
and type
is the run core type.static void turn_ev_check(Parrot_Interp interpreter, int on)
event_checker
opcode,
or restores original op in all branch locations of the opcode stream.on
is true,
this is being called from the event handler thread.static oplib_init_f get_op_lib_init(int core_op, int which, PMC *lib)
op_lib
init function.core_op
indicates whether the opcode represents a core Parrot operation.which
is the run core type.core_op
will be 0 and lib
will be a ParrotLibrary
PMC.static void load_prederef(Interp *interpreter, int which)
interpreter->op_lib
= prederefed oplib.static void init_prederef(Interp *interpreter, int which)
func_table
,
file prederef.code.static void stop_prederef(Interp *interpreter)
void exec_init_prederef(Interp *interpreter, void *prederef_arena)
interpreter->op_lib
= prederefed oplibop_lib
has a copy in the interpreter structure - but get the op_code
lookup function from standard core prederef has no op_info_table
void *init_jit(Interp *interpreter, opcode_t *pc)
void prepare_for_run(Parrot_Interp interpreter)
static opcode_t *runops_jit(Interp *interpreter, opcode_t *pc)
static opcode_t *runops_exec(Interp *interpreter, opcode_t *pc)
static opcode_t *runops_prederef(Interp *interpreter, opcode_t *pc)
pc_prederef
instead of pc,
and calls prederef opfuncs instead of regular opfuncs.pc_prederef
in case we have exited the loop under restart conditions (such as with interpreter flag changing ops).init_prederef()
and stop_prederef()
would be best placed elsewhere,
since we would re-pay the costs of loading the prederef oplib every time we dropped out of and back into this core.
For now,
however,
this implementation should do fine.
Since dropping out of and back into cores is expected to be rare (at the time of implementation that only occurs for interpreter flag changing ops).static opcode_t *runops_cgp(Interp *interpreter, opcode_t *pc)
goto
,
predereferenced core.static opcode_t *runops_switch(Interp *interpreter, opcode_t *pc)
switch
core.void runops_int(Interp *interpreter, size_t offset)
Interp_flags
when a restart
opcode is encountered a different core my be selected and evaluation of opcode continues.static void setup_event_func_ptrs(Parrot_Interp interpreter)
func_table
containing pointers (or addresses) of the check_event__
opcode.void dynop_register(Parrot_Interp interpreter, PMC *lib_pmc)
static void dynop_register_xx(Parrot_Interp interpreter, PMC *lib_pmc, size_t n_old, size_t n_new, oplib_init_f init_func)
op_lib
with other cores.static void dynop_register_switch(Parrot_Interp interpreter, PMC *lib_pmc, size_t n_old, size_t n_new)
static void notify_func_table(Parrot_Interp interpreter, void *table, int on)
void disable_event_checking(Parrot_Interp interpreter)
void enable_event_checking(Parrot_Interp interpreter)
enable_event_checking()
is called async by the event handler thread.
All action done from here has to be async safe.include/parrot/interpreter.h, src/inter_cb.c, src/inter_create.c, src/inter_misc.c, src/inter_run.c.
|