From a05cd1f55a80d3b159d986e24d67252d9a890d25 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 23 Sep 2008 00:20:28 +0000 Subject: * common.mk: clean up - remove blockinlining.$(OBJEXT) to built - make ENCODING_H_INCLDUES variable (include/ruby/encoding.h) - make VM_CORE_H_INCLUDES variable (vm_core.h) - simplify rules. - make depends rule to output depend status using gcc -MM. * include/ruby/mvm.h, include/ruby/vm.h: rename mvm.h to vm.h. * include/ruby.h: ditto. * load.c: add inclusion explicitly. * enumerator.c, object.c, parse.y, thread.c, vm_dump.c: remove useless inclusion. * eval_intern.h: cleanup inclusion. * vm_core.h: rb_thread_t should be defined in this file. * vm_evalbody.c, vm_exec.c: rename vm_evalbody.c to vm_exec.c. * vm.h, vm_exec.h: rename vm.h to vm_exec.h. * insnhelper.h, vm_insnhelper.h: rename insnhelper.h to vm_insnhelper.h. * vm.c, vm_insnhelper.c, vm_insnhelper.h: - rename vm_eval() to vm_exec_core(). - rename vm_eval_body() to vm_exec(). - cleanup include order. * vm_method.c: fix comment. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm.c | 73 ++++++++++++++++++++++++-------------------------------------------- 1 file changed, 26 insertions(+), 47 deletions(-) (limited to 'vm.c') diff --git a/vm.c b/vm.c index 7841b4339..634924779 100644 --- a/vm.c +++ b/vm.c @@ -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; } -- cgit