diff options
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 73 |
1 files changed, 26 insertions, 47 deletions
@@ -12,10 +12,17 @@ #include "ruby/node.h" #include "ruby/st.h" #include "ruby/encoding.h" + #include "gc.h" +#include "vm_core.h" +#include "eval_intern.h" -#include "insnhelper.h" +#include "vm_insnhelper.h" #include "vm_insnhelper.c" +#include "vm_exec.h" +#include "vm_exec.c" + +#include "vm_method.c" #include "vm_eval.c" #define BUFSIZE 0x100 @@ -27,6 +34,8 @@ VALUE rb_cEnv; VALUE rb_mRubyVMFrozenCore; VALUE ruby_vm_global_state_version = 1; +VALUE ruby_vm_redefined_flag = 0; + rb_thread_t *ruby_current_thread = 0; rb_vm_t *ruby_current_vm = 0; @@ -34,14 +43,6 @@ void vm_analysis_operand(int insn, int n, VALUE op); void vm_analysis_register(int reg, int isset); void vm_analysis_insn(int insn); -#if OPT_STACK_CACHING -static VALUE finish_insn_seq[1] = { BIN(finish_SC_ax_ax) }; -#elif OPT_CALL_THREADED_CODE -static VALUE const finish_insn_seq[1] = { 0 }; -#else -static VALUE finish_insn_seq[1] = { BIN(finish) }; -#endif - void rb_vm_change_state(void) { @@ -132,6 +133,18 @@ vm_get_ruby_level_caller_cfp(rb_thread_t *th, rb_control_frame_t *cfp) /* Env */ +/* + env{ + env[0] // special (block or prev env) + env[1] // env object + env[2] // prev env val + }; + */ + +#define ENV_IN_HEAP_P(th, env) \ + (!((th)->stack < (env) && (env) < ((th)->stack + (th)->stack_size))) +#define ENV_VAL(env) ((env)[1]) + static void env_free(void * const ptr) { @@ -471,7 +484,7 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block, th->cfp->dfp[-1] = (VALUE)cref; } - return vm_eval_body(th); + return vm_exec(th); } else { return vm_yield_with_cfunc(th, block, self, argc, argv, blockptr); @@ -743,37 +756,6 @@ debug_cref(NODE *cref) } #endif -static NODE * -vm_cref_push(rb_thread_t *th, VALUE klass, int noex) -{ - rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(th, th->cfp); - NODE *cref = NEW_BLOCK(klass); - cref->nd_file = 0; - cref->nd_visi = noex; - - if (cfp) { - cref->nd_next = vm_get_cref(cfp->iseq, cfp->lfp, cfp->dfp); - } - - return cref; -} - -static inline VALUE -vm_get_cbase(const rb_iseq_t *iseq, const VALUE *lfp, const VALUE *dfp) -{ - NODE *cref = vm_get_cref(iseq, lfp, dfp); - VALUE klass = Qundef; - - while (cref) { - if ((klass = cref->nd_clss) != 0) { - break; - } - cref = cref->nd_next; - } - - return klass; -} - VALUE rb_vm_cbase(void) { @@ -887,7 +869,6 @@ rb_iter_break(void) /* optimization: redefine management */ -VALUE ruby_vm_redefined_flag = 0; static st_table *vm_opt_method_table = 0; static void @@ -944,8 +925,6 @@ vm_init_redefined_flag(void) /* evaluator body */ -#include "vm_evalbody.c" - /* finish VMe (h1) finish VM finish F1 F2 @@ -1048,7 +1027,7 @@ vm_init_redefined_flag(void) static VALUE -vm_eval_body(rb_thread_t *th) +vm_exec(rb_thread_t *th) { int state; VALUE result, err; @@ -1059,7 +1038,7 @@ vm_eval_body(rb_thread_t *th) _tag.retval = Qnil; if ((state = EXEC_TAG()) == 0) { vm_loop_start: - result = vm_eval(th, initial); + result = vm_exec_core(th, initial); if ((state = th->state) != 0) { err = result; th->state = 0; @@ -1264,7 +1243,7 @@ rb_iseq_eval(VALUE iseqval) if (!rb_const_defined(rb_cObject, rb_intern("TOPLEVEL_BINDING"))) { rb_define_global_const("TOPLEVEL_BINDING", rb_binding_new()); } - val = vm_eval_body(th); + val = vm_exec(th); tmp = iseqval; /* prohibit tail call optimization */ return val; } |