diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-06 19:00:03 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-06 19:00:03 +0000 |
commit | 8ee7d0767f7940baeae60ffa95afde93f3378c93 (patch) | |
tree | 2f90c7d6ab23acba9e00fa773fb76673123db3f8 | |
parent | b1c6339b0c2d3288eab5c45cb86ecd30c9b0dc9d (diff) | |
download | ruby-8ee7d0767f7940baeae60ffa95afde93f3378c93.tar.gz |
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 23 | ||||
-rw-r--r-- | blockinlining.c | 36 | ||||
-rw-r--r-- | compile.c | 156 | ||||
-rw-r--r-- | compile.h | 2 | ||||
-rw-r--r-- | error.c | 2 | ||||
-rw-r--r-- | eval.c | 119 | ||||
-rw-r--r-- | eval_error.h | 2 | ||||
-rw-r--r-- | eval_intern.h | 38 | ||||
-rw-r--r-- | eval_jump.h | 8 | ||||
-rw-r--r-- | eval_load.c | 4 | ||||
-rw-r--r-- | eval_method.h | 2 | ||||
-rw-r--r-- | eval_safe.h | 4 | ||||
-rw-r--r-- | gc.c | 16 | ||||
-rw-r--r-- | inits.c | 2 | ||||
-rw-r--r-- | insnhelper.h | 2 | ||||
-rw-r--r-- | insns.def | 34 | ||||
-rw-r--r-- | iseq.c | 102 | ||||
-rw-r--r-- | proc.c | 150 | ||||
-rw-r--r-- | process.c | 2 | ||||
-rw-r--r-- | ruby.h | 1 | ||||
-rw-r--r-- | signal.c | 8 | ||||
-rw-r--r-- | thread.c | 170 | ||||
-rw-r--r-- | thread_pthread.ci | 42 | ||||
-rw-r--r-- | thread_pthread.h | 4 | ||||
-rw-r--r-- | thread_win32.ci | 24 | ||||
-rw-r--r-- | thread_win32.h | 12 | ||||
-rw-r--r-- | vm.c | 276 | ||||
-rw-r--r-- | vm.h | 8 | ||||
-rw-r--r-- | vm_dump.c | 44 | ||||
-rw-r--r-- | vm_evalbody.ci | 16 | ||||
-rw-r--r-- | vm_macro.def | 18 | ||||
-rw-r--r-- | yarv.h | 33 | ||||
-rw-r--r-- | yarvcore.c | 90 | ||||
-rw-r--r-- | yarvcore.h | 186 |
34 files changed, 822 insertions, 814 deletions
@@ -1,3 +1,26 @@ +Wed Feb 7 03:39:32 2007 Koichi Sasada <ko1@atdot.net> + + * blockinlining.c, compile.c, compile.h, error.c, eval.c, + eval_intern.h, eval_jump.h, eval_load.c, eval_method.h, + eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c, + process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci, + vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def, + yarv.h, yarvcore.h, yarvcore.c: change type and macro names: + * yarv_*_t -> rb_*_t + * yarv_*_struct -> rb_*_struct + * yarv_tag -> rb_vm_tag + * YARV_* -> RUBY_VM_* + + * proc.c, vm.c: move functions about env object creation + from proc.c to vm.c. + + * proc.c, yarvcore.c: fix rb_cVM initialization place. + + * inits.c: change Init_ISeq() order (after Init_VM). + + * ruby.h, proc.c: change declaration place of rb_cEnv + from proc.c to ruby.c. + Tue Feb 06 22:06:45 2007 NARUSE, Yui <naruse@ruby-lang.org> * ext/nkf/nkf-utf8/{nkf.c,utf8tbl.c}: diff --git a/blockinlining.c b/blockinlining.c index 7a74f3492e..c599d57a49 100644 --- a/blockinlining.c +++ b/blockinlining.c @@ -17,7 +17,7 @@ VALUE yarv_new_iseqval(VALUE node, VALUE name, VALUE file, VALUE parent, VALUE type, VALUE block_opt, VALUE opt); static VALUE -yarv_iseq_special_block(yarv_iseq_t *iseq, void *builder) +yarv_iseq_special_block(rb_iseq_t *iseq, void *builder) { #if OPT_BLOCKINLINING VALUE parent = Qfalse; @@ -110,7 +110,7 @@ new_assign(NODE * lnode, NODE * rhs) } static NODE * -build_Integer_times_node(yarv_iseq_t *iseq, NODE * node, NODE * lnode, +build_Integer_times_node(rb_iseq_t *iseq, NODE * node, NODE * lnode, VALUE param_vars, VALUE local_vars) { /* Special Block for Integer#times @@ -183,17 +183,17 @@ build_Integer_times_node(yarv_iseq_t *iseq, NODE * node, NODE * lnode, VALUE yarv_invoke_Integer_times_special_block(VALUE num) { - yarv_thread_t *th = GET_THREAD(); - yarv_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]); + rb_thead_t *th = GET_THREAD(); + rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]); if (orig_block && BUILTIN_TYPE(orig_block->iseq) != T_NODE) { VALUE tsiseqval = yarv_iseq_special_block(orig_block->iseq, build_Integer_times_node); - yarv_iseq_t *tsiseq; + rb_iseq_t *tsiseq; VALUE argv[2], val; if (tsiseqval) { - yarv_block_t block = *orig_block; + rb_block_t block = *orig_block; GetISeqPtr(tsiseqval, tsiseq); block.iseq = tsiseq; th->cfp->lfp[0] = GC_GUARDED_PTR(&block); @@ -212,7 +212,7 @@ yarv_invoke_Integer_times_special_block(VALUE num) } static NODE * -build_Range_each_node(yarv_iseq_t *iseq, NODE * node, NODE * lnode, +build_Range_each_node(rb_iseq_t *iseq, NODE * node, NODE * lnode, VALUE param_vars, VALUE local_vars, ID mid) { /* Special Block for Range#each @@ -281,7 +281,7 @@ build_Range_each_node(yarv_iseq_t *iseq, NODE * node, NODE * lnode, } static NODE * -build_Range_each_node_LE(yarv_iseq_t *iseq, NODE * node, NODE * lnode, +build_Range_each_node_LE(rb_iseq_t *iseq, NODE * node, NODE * lnode, VALUE param_vars, VALUE local_vars) { return build_Range_each_node(iseq, node, lnode, @@ -289,7 +289,7 @@ build_Range_each_node_LE(yarv_iseq_t *iseq, NODE * node, NODE * lnode, } static NODE * -build_Range_each_node_LT(yarv_iseq_t *iseq, NODE * node, NODE * lnode, +build_Range_each_node_LT(rb_iseq_t *iseq, NODE * node, NODE * lnode, VALUE param_vars, VALUE local_vars) { return build_Range_each_node(iseq, node, lnode, @@ -300,19 +300,19 @@ VALUE yarv_invoke_Range_each_special_block(VALUE range, VALUE beg, VALUE end, int excl) { - yarv_thread_t *th = GET_THREAD(); - yarv_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]); + rb_thead_t *th = GET_THREAD(); + rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]); if (BUILTIN_TYPE(orig_block->iseq) != T_NODE) { void *builder = excl ? build_Range_each_node_LT : build_Range_each_node_LE; VALUE tsiseqval = yarv_iseq_special_block(orig_block->iseq, builder); - yarv_iseq_t *tsiseq; + rb_iseq_t *tsiseq; VALUE argv[2]; if (tsiseqval) { VALUE val; - yarv_block_t block = *orig_block; + rb_block_t block = *orig_block; GetISeqPtr(tsiseqval, tsiseq); block.iseq = tsiseq; th->cfp->lfp[0] = GC_GUARDED_PTR(&block); @@ -332,7 +332,7 @@ yarv_invoke_Range_each_special_block(VALUE range, static NODE * -build_Array_each_node(yarv_iseq_t *iseq, NODE * node, NODE * lnode, +build_Array_each_node(rb_iseq_t *iseq, NODE * node, NODE * lnode, VALUE param_vars, VALUE local_vars) { /* Special block for Array#each @@ -431,18 +431,18 @@ build_Array_each_node(yarv_iseq_t *iseq, NODE * node, NODE * lnode, VALUE yarv_invoke_Array_each_special_block(VALUE ary) { - yarv_thread_t *th = GET_THREAD(); - yarv_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]); + rb_thead_t *th = GET_THREAD(); + rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]); if (BUILTIN_TYPE(orig_block->iseq) != T_NODE) { VALUE tsiseqval = yarv_iseq_special_block(orig_block->iseq, build_Array_each_node); - yarv_iseq_t *tsiseq; + rb_iseq_t *tsiseq; VALUE argv[2]; if (tsiseqval) { VALUE val; - yarv_block_t block = *orig_block; + rb_block_t block = *orig_block; GetISeqPtr(tsiseqval, tsiseq); block.iseq = tsiseq; th->cfp->lfp[0] = GC_GUARDED_PTR(&block); @@ -93,37 +93,37 @@ static int insn_ret_num(int insn); static void ADD_ELEM(LINK_ANCHOR *anchor, LINK_ELEMENT *elem); -static INSN *new_insn_body(yarv_iseq_t *iseq, int line_no, +static INSN *new_insn_body(rb_iseq_t *iseq, int line_no, int insn_id, int argc, ...); -static LABEL *new_label_body(yarv_iseq_t *iseq, int line); +static LABEL *new_label_body(rb_iseq_t *iseq, int line); -static int iseq_compile_each(yarv_iseq_t *iseq, LINK_ANCHOR *anchor, +static int iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *anchor, NODE * n, int); -static int iseq_setup(yarv_iseq_t *iseq, LINK_ANCHOR *anchor); - -static int iseq_optimize(yarv_iseq_t *iseq, LINK_ANCHOR *anchor); -static int iseq_insns_unification(yarv_iseq_t *iseq, LINK_ANCHOR *anchor); -static int set_sequence_stackcaching(yarv_iseq_t *iseq, LINK_ANCHOR *anchor); -static int set_sequence(yarv_iseq_t *iseq, LINK_ANCHOR *anchor); - -static int set_exception_table(yarv_iseq_t *iseq); -static int set_localtbl(yarv_iseq_t *iseq, ID *tbl); -static int set_localtbl_eval(yarv_iseq_t *iseq, ID *tbl); -static int set_arguments(yarv_iseq_t *iseq, LINK_ANCHOR *anchor, NODE * node); -static NODE *set_block_local_tbl(yarv_iseq_t *iseq, NODE * node, +static int iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *anchor); + +static int iseq_optimize(rb_iseq_t *iseq, LINK_ANCHOR *anchor); +static int iseq_insns_unification(rb_iseq_t *iseq, LINK_ANCHOR *anchor); +static int set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *anchor); +static int set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor); + +static int set_exception_table(rb_iseq_t *iseq); +static int set_localtbl(rb_iseq_t *iseq, ID *tbl); +static int set_localtbl_eval(rb_iseq_t *iseq, ID *tbl); +static int set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *anchor, NODE * node); +static NODE *set_block_local_tbl(rb_iseq_t *iseq, NODE * node, LINK_ANCHOR *anchor); -static int set_exception_tbl(yarv_iseq_t *iseq); -static int set_optargs_table(yarv_iseq_t *iseq); +static int set_exception_tbl(rb_iseq_t *iseq); +static int set_optargs_table(rb_iseq_t *iseq); static int -iseq_add_mark_object(yarv_iseq_t *iseq, VALUE v) +iseq_add_mark_object(rb_iseq_t *iseq, VALUE v) { rb_ary_push(iseq->iseq_mark_ary, v); return COMPILE_OK; } static int -iseq_add_mark_object_compile_time(yarv_iseq_t *iseq, VALUE v) +iseq_add_mark_object_compile_time(rb_iseq_t *iseq, VALUE v) { rb_ary_push(iseq->compile_data->mark_ary, v); return COMPILE_OK; @@ -140,7 +140,7 @@ VALUE iseq_compile(VALUE self, NODE *narg) { DECL_ANCHOR(list_anchor); - yarv_iseq_t *iseq; + rb_iseq_t *iseq; NODE *node = (NODE *) narg; GetISeqPtr(self, iseq); @@ -272,7 +272,7 @@ iseq_compile(VALUE self, NODE *narg) VALUE th_eval(void *); static int -iseq_translate_direct_threaded_code(yarv_iseq_t *iseq) +iseq_translate_direct_threaded_code(rb_iseq_t *iseq) { #if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE @@ -305,7 +305,7 @@ iseq_translate_direct_threaded_code(yarv_iseq_t *iseq) static void * -compile_data_alloc(yarv_iseq_t *iseq, size_t size) +compile_data_alloc(rb_iseq_t *iseq, size_t size) { void *ptr = 0; struct iseq_compile_data_storage *storage = @@ -336,13 +336,13 @@ compile_data_alloc(yarv_iseq_t *iseq, size_t size) } static INSN * -compile_data_alloc_insn(yarv_iseq_t *iseq) +compile_data_alloc_insn(rb_iseq_t *iseq) { return (INSN *)compile_data_alloc(iseq, sizeof(INSN)); } static LABEL * -compile_data_alloc_label(yarv_iseq_t *iseq) +compile_data_alloc_label(rb_iseq_t *iseq) { return (LABEL *)compile_data_alloc(iseq, sizeof(LABEL)); } @@ -620,7 +620,7 @@ debug_list(LINK_ANCHOR *anchor) #endif static LABEL * -new_label_body(yarv_iseq_t *iseq, int line) +new_label_body(rb_iseq_t *iseq, int line) { LABEL *labelobj = compile_data_alloc_label(iseq); static int label_no = 0; @@ -635,7 +635,7 @@ new_label_body(yarv_iseq_t *iseq, int line) } static INSN * -new_insn_core(yarv_iseq_t *iseq, int line_no, +new_insn_core(rb_iseq_t *iseq, int line_no, int insn_id, int argc, VALUE *argv) { INSN *iobj = compile_data_alloc_insn(iseq); @@ -651,7 +651,7 @@ new_insn_core(yarv_iseq_t *iseq, int line_no, } static INSN * -new_insn_body(yarv_iseq_t *iseq, int line_no, int insn_id, int argc, ...) +new_insn_body(rb_iseq_t *iseq, int line_no, int insn_id, int argc, ...) { VALUE *operands = 0; va_list argv; @@ -669,7 +669,7 @@ new_insn_body(yarv_iseq_t *iseq, int line_no, int insn_id, int argc, ...) } static INSN * -new_insn_send(yarv_iseq_t *iseq, int line_no, +new_insn_send(rb_iseq_t *iseq, int line_no, VALUE id, VALUE argc, VALUE block, VALUE flag) { INSN *iobj = 0; @@ -685,22 +685,22 @@ new_insn_send(yarv_iseq_t *iseq, int line_no, } static VALUE -new_child_iseq(yarv_iseq_t *iseq, NODE *node, +new_child_iseq(rb_iseq_t *iseq, NODE *node, VALUE name, VALUE parent, VALUE type) { VALUE args[6]; VALUE ret; debugs("[new_child_iseq]> ---------------------------------------\n"); - ret = yarv_iseq_new_with_opt(node, name, iseq_filename(iseq->self), - parent, type, iseq->compile_data->option); + ret = rb_iseq_new_with_opt(node, name, iseq_filename(iseq->self), + parent, type, iseq->compile_data->option); debugs("[new_child_iseq]< ---------------------------------------\n"); iseq_add_mark_object(iseq, ret); return ret; } static int -iseq_setup(yarv_iseq_t *iseq, LINK_ANCHOR *anchor) +iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *anchor) { /* debugs("[compile step 2] (iseq_array_to_linkedlist)\n"); */ @@ -767,7 +767,7 @@ iseq_assemble_setup(VALUE self, VALUE args, VALUE locals, VALUE insn_ary) } int -set_exception_tbl(yarv_iseq_t *iseq) +set_exception_tbl(rb_iseq_t *iseq) { static ID id_dollar_bang; @@ -806,7 +806,7 @@ search_block_local_variables(NODE * node, VALUE local_vars) } static NODE * -search_block_local_parameters(yarv_iseq_t *iseq, NODE * lnode) +search_block_local_parameters(rb_iseq_t *iseq, NODE * lnode) { NODE *node = lnode; NODE *nelem; @@ -893,7 +893,7 @@ search_block_local_parameters(yarv_iseq_t *iseq, NODE * lnode) /* translate to block inlining code */ if (iseq->special_block_builder != 0) { - node = ((NODE * (*)(yarv_iseq_t *, NODE *, NODE *, VALUE, VALUE)) + node = ((NODE * (*)(rb_iseq_t *, NODE *, NODE *, VALUE, VALUE)) iseq->special_block_builder) (iseq, node, lnode->nd_var, param_vars, local_vars); } @@ -917,7 +917,7 @@ search_block_local_parameters(yarv_iseq_t *iseq, NODE * lnode) } static int -set_block_initializer(yarv_iseq_t *iseq, NODE * node, LINK_ANCHOR *anchor, int didx) +set_block_initializer(rb_iseq_t *iseq, NODE * node, LINK_ANCHOR *anchor, int didx) { DECL_ANCHOR(anc); LINK_ELEMENT *elem; @@ -947,7 +947,7 @@ set_block_initializer(yarv_iseq_t *iseq, NODE * node, LINK_ANCHOR *anchor, int d } static NODE * -set_block_local_tbl(yarv_iseq_t *iseq, NODE * node, LINK_ANCHOR *anchor) +set_block_local_tbl(rb_iseq_t *iseq, NODE * node, LINK_ANCHOR *anchor) { NODE *rnode; @@ -1049,7 +1049,7 @@ set_block_local_tbl(yarv_iseq_t *iseq, NODE * node, LINK_ANCHOR *anchor) } static int -get_dyna_var_idx_at_raw(yarv_iseq_t *iseq, ID id) +get_dyna_var_idx_at_raw(rb_iseq_t *iseq, ID id) { int i; for (i = 0; i < iseq->local_size; i++) { @@ -1061,7 +1061,7 @@ get_dyna_var_idx_at_raw(yarv_iseq_t *iseq, ID id) } static int -get_dyna_var_idx(yarv_iseq_t *iseq, ID id, int *level, int *ls) +get_dyna_var_idx(rb_iseq_t *iseq, ID id, int *level, int *ls) { int lv = 0, idx; @@ -1081,7 +1081,7 @@ get_dyna_var_idx(yarv_iseq_t *iseq, ID id, int *level, int *ls) */ static int -set_arguments(yarv_iseq_t *iseq, LINK_ANCHOR *optargs, NODE * node) +set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE * node) { int i, j; @@ -1146,7 +1146,7 @@ set_arguments(yarv_iseq_t *iseq, LINK_ANCHOR *optargs, NODE * node) } static int -set_localtbl(yarv_iseq_t *iseq, ID *tbl) +set_localtbl(rb_iseq_t *iseq, ID *tbl) { int size; if (tbl) { @@ -1164,7 +1164,7 @@ set_localtbl(yarv_iseq_t *iseq, ID *tbl) } static int -set_localtbl_eval(yarv_iseq_t *iseq, ID *tbl) +set_localtbl_eval(rb_iseq_t *iseq, ID *tbl) { int size; if (tbl) { @@ -1185,7 +1185,7 @@ set_localtbl_eval(yarv_iseq_t *iseq, ID *tbl) ruby insn object array -> raw instruction sequence */ static int -set_sequence(yarv_iseq_t *iseq, LINK_ANCHOR *anchor) +set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor) { LABEL *lobj; INSN *iobj; @@ -1320,7 +1320,7 @@ set_sequence(yarv_iseq_t *iseq, LINK_ANCHOR *anchor) case TS_ISEQ: /* iseq */ { VALUE v = operands[j]; - yarv_iseq_t *block = 0; + rb_iseq_t *block = 0; if (v) { GetISeqPtr(v, block); } @@ -1405,7 +1405,7 @@ label_get_sp(LABEL *lobj) } static int -set_exception_table(yarv_iseq_t *iseq) +set_exception_table(rb_iseq_t *iseq) { VALUE *tptr, *ptr; int tlen, i; @@ -1463,7 +1463,7 @@ set_exception_table(yarv_iseq_t *iseq) * expr2 */ static int -set_optargs_table(yarv_iseq_t *iseq) +set_optargs_table(rb_iseq_t *iseq) { int i; @@ -1521,7 +1521,7 @@ get_prev_insn(INSN *iobj) } static int -iseq_peephole_optimize(yarv_iseq_t *iseq, LINK_ELEMENT *list) +iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list) { INSN *iobj = (INSN *)list; again: @@ -1618,7 +1618,7 @@ insn_set_specialized_instruction(INSN *iobj, int insn_id) static int -iseq_specialized_instruction(yarv_iseq_t *iseq, INSN *iobj) +iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj) { if (iobj->insn_id == BIN(send)) { ID mid = SYM2ID(OPERAND_AT(iobj, 0)); @@ -1681,7 +1681,7 @@ iseq_specialized_instruction(yarv_iseq_t *iseq, INSN *iobj) } static int -iseq_optimize(yarv_iseq_t *iseq, LINK_ANCHOR *anchor) +iseq_optimize(rb_iseq_t *iseq, LINK_ANCHOR *anchor) { LINK_ELEMENT *list; const int do_peephole = iseq->compile_data->option->peephole_optimization; @@ -1708,7 +1708,7 @@ iseq_optimize(yarv_iseq_t *iseq, LINK_ANCHOR *anchor) #if OPT_INSTRUCTIONS_UNIFICATION static INSN * -new_unified_insn(yarv_iseq_t *iseq, +new_unified_insn(rb_iseq_t *iseq, int insn_id, int size, LINK_ELEMENT *seq_list) { INSN *iobj = 0; @@ -1748,7 +1748,7 @@ new_unified_insn(yarv_iseq_t *iseq, * It's future work (if compile time was bottle neck). */ static int -iseq_insns_unification(yarv_iseq_t *iseq, LINK_ANCHOR *anchor) +iseq_insns_unification(rb_iseq_t *iseq, LINK_ANCHOR *anchor) { #if OPT_INSTRUCTIONS_UNIFICATION LINK_ELEMENT *list; @@ -1860,7 +1860,7 @@ label_set_sc_state(LABEL *lobj, int state) #endif static int -set_sequence_stackcaching(yarv_iseq_t *iseq, LINK_ANCHOR *anchor) +set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *anchor) { #if OPT_STACK_CACHING LINK_ELEMENT *list; @@ -1952,7 +1952,7 @@ set_sequence_stackcaching(yarv_iseq_t *iseq, LINK_ANCHOR *anchor) static int -compile_dstr(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node) +compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node) { NODE *list = node->nd_next; VALUE lit = node->nd_lit; @@ -1972,7 +1972,7 @@ compile_dstr(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node) } static int -compile_branch_condition(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * cond, +compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * cond, LABEL *then_label, LABEL *else_label) { switch (nd_type(cond)) { @@ -2020,7 +2020,7 @@ compile_branch_condition(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * cond, } static int -compile_array(yarv_iseq_t *iseq, +compile_array(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node_root, VALUE opt_p) { NODE *node = node_root; @@ -2076,7 +2076,7 @@ case_when_optimizable_literal(NODE * node) } static VALUE -when_vals(yarv_iseq_t *iseq, LINK_ANCHOR *cond_seq, NODE *vals, LABEL *l1, VALUE special_literals) +when_vals(rb_iseq_t *iseq, LINK_ANCHOR *cond_seq, NODE *vals, LABEL *l1, VALUE special_literals) { while (vals) { VALUE lit; @@ -2103,7 +2103,7 @@ when_vals(yarv_iseq_t *iseq, LINK_ANCHOR *cond_seq, NODE *vals, LABEL *l1, VALUE } static int -make_masgn_lhs(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node) +make_masgn_lhs(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node) { switch (nd_type(node)) { @@ -2145,7 +2145,7 @@ make_masgn_lhs(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node) } static int -compile_massign(yarv_iseq_t *iseq, LINK_ANCHOR *ret, +compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * rhsn, NODE * splatn, NODE * lhsn, int llen) { if (lhsn != 0) { @@ -2265,7 +2265,7 @@ compile_massign(yarv_iseq_t *iseq, LINK_ANCHOR *ret, } static int -compile_colon2(yarv_iseq_t *iseq, NODE * node, +compile_colon2(rb_iseq_t *iseq, NODE * node, LINK_ANCHOR *pref, LINK_ANCHOR *body) { switch (nd_type(node)) { @@ -2292,7 +2292,7 @@ compile_colon2(yarv_iseq_t *iseq, NODE * node, } static int -compile_cpath(LINK_ANCHOR *ret, yarv_iseq_t *iseq, NODE *cpath) +compile_cpath(LINK_ANCHOR *ret, rb_iseq_t *iseq, NODE *cpath) { if(cpath->nd_head) { COMPILE(ret, "nd_else->nd_head", cpath->nd_head); @@ -2307,7 +2307,7 @@ compile_cpath(LINK_ANCHOR *ret, yarv_iseq_t *iseq, NODE *cpath) } static int -defined_expr(yarv_iseq_t *iseq, LINK_ANCHOR *ret, +defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, LABEL *lfinish, VALUE needstr) { char *estr = 0; @@ -2490,7 +2490,7 @@ defined_expr(yarv_iseq_t *iseq, LINK_ANCHOR *ret, #define BUFSIZE 0x100 static VALUE -make_name_for_block(yarv_iseq_t *iseq) +make_name_for_block(rb_iseq_t *iseq) { char buf[BUFSIZE]; if (iseq->parent_iseq == 0) { @@ -2498,7 +2498,7 @@ make_name_for_block(yarv_iseq_t *iseq) } else { int level = 1; - yarv_iseq_t *ip = iseq; + rb_iseq_t *ip = iseq; while (1) { if (ip->local_iseq != ip) { ip = ip->parent_iseq; @@ -2523,7 +2523,7 @@ make_name_with_str(const char *fmt, const char *str) } static void -add_ensure_range(yarv_iseq_t *iseq, struct ensure_range *erange, +add_ensure_range(rb_iseq_t *iseq, struct ensure_range *erange, LABEL *lstart, LABEL *lend) { struct ensure_range *ne = @@ -2541,7 +2541,7 @@ add_ensure_range(yarv_iseq_t *iseq, struct ensure_range *erange, } static void -add_ensure_iseq(LINK_ANCHOR *ret, yarv_iseq_t *iseq) +add_ensure_iseq(LINK_ANCHOR *ret, rb_iseq_t *iseq) { struct iseq_compile_data_ensure_node_stack *enlp = iseq->compile_data->ensure_node_stack; @@ -2567,7 +2567,7 @@ add_ensure_iseq(LINK_ANCHOR *ret, yarv_iseq_t *iseq) } static VALUE -setup_arg(yarv_iseq_t *iseq, LINK_ANCHOR *args, NODE *node, VALUE *flag) +setup_arg(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *node, VALUE *flag) { VALUE argc = INT2FIX(0); NODE *argn = node->nd_args; @@ -2632,7 +2632,7 @@ setup_arg(yarv_iseq_t *iseq, LINK_ANCHOR *args, NODE *node, VALUE *flag) poped: This node will be poped */ static int -iseq_compile_each(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) +iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) { VALUE tmp; /* reserved for macro */ int type; @@ -3002,7 +3002,7 @@ iseq_compile_each(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) COMPILE_ERROR(("Can't escape from eval with break")); } else { - yarv_iseq_t *ip = iseq->parent_iseq; + rb_iseq_t *ip = iseq->parent_iseq; while (ip) { level++; if (ip->compile_data->redo_label != 0) { @@ -3041,7 +3041,7 @@ iseq_compile_each(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) COMPILE_ERROR(("Can't escape from eval with next")); } else { - yarv_iseq_t *ip = iseq->parent_iseq; + rb_iseq_t *ip = iseq->parent_iseq; while (ip) { level = 0x8000; if (ip->type == ISEQ_TYPE_BLOCK) { @@ -3085,7 +3085,7 @@ iseq_compile_each(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) } } else { - yarv_iseq_t *ip = iseq->parent_iseq; + rb_iseq_t *ip = iseq->parent_iseq; unsigned long level = 0x8000 | 0x4000; while (ip) { if (ip->type == ISEQ_TYPE_BLOCK) { @@ -3682,7 +3682,7 @@ iseq_compile_each(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) else { /* NODE_ZSUPER */ int i; - yarv_iseq_t *liseq = iseq->local_iseq; + rb_iseq_t *liseq = iseq->local_iseq; argc = INT2FIX(liseq->argc); @@ -3779,7 +3779,7 @@ iseq_compile_each(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) break; } case NODE_RETURN:{ - yarv_iseq_t *is = iseq; + rb_iseq_t *is = iseq; while (is) { if (is->type == ISEQ_TYPE_TOP || is->type == ISEQ_TYPE_CLASS) { @@ -4398,7 +4398,7 @@ iseq_compile_each(yarv_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) INT2FIX(0)); } else { - yarv_iseq_t *ip = iseq; + rb_iseq_t *ip = iseq; int level = 0; while (ip) { if (ip->type == ISEQ_TYPE_RESCUE) { @@ -4588,7 +4588,7 @@ insn_data_to_s_detail(INSN *iobj) break; case TS_ISEQ: /* iseq */ { - yarv_iseq_t *iseq = (yarv_iseq_t *)OPERAND_AT(iobj, j); + rb_iseq_t *iseq = (rb_iseq_t *)OPERAND_AT(iobj, j); VALUE val = Qnil; if (iseq) { val = iseq->self; @@ -4692,7 +4692,7 @@ insns_name_array(void) } static LABEL * -register_label(yarv_iseq_t *iseq, struct st_table *labels_table, VALUE obj) +register_label(rb_iseq_t *iseq, struct st_table *labels_table, VALUE obj) { LABEL *label = 0; obj = rb_convert_type(obj, T_SYMBOL, "Symbol", "to_sym"); @@ -4732,7 +4732,7 @@ get_exception_sym2type(VALUE sym) VALUE iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt); static int -iseq_build_exception(yarv_iseq_t *iseq, struct st_table *labels_table, +iseq_build_exception(rb_iseq_t *iseq, struct st_table *labels_table, VALUE exception) { int i; @@ -4767,7 +4767,7 @@ iseq_build_exception(yarv_iseq_t *iseq, struct st_table *labels_table, struct st_table *insn_make_insn_table(void); static int -iseq_build_body(yarv_iseq_t *iseq, LINK_ANCHOR *anchor, +iseq_build_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor, VALUE body, VALUE line, struct st_table *labels_table) { /* TODO: body should be freezed */ @@ -4894,7 +4894,7 @@ iseq_build_body(yarv_iseq_t *iseq, LINK_ANCHOR *anchor, } VALUE -iseq_build_from_ary(yarv_iseq_t *iseq, VALUE line, +iseq_build_from_ary(rb_iseq_t *iseq, VALUE line, VALUE locals, VALUE args, VALUE exception, VALUE body) { int i; @@ -103,7 +103,7 @@ r_value(VALUE value) #define NEW_LABEL(l) new_label_body(iseq, l) #define iseq_filename(iseq) \ - (((yarv_iseq_t*)DATA_PTR(iseq))->file_name) + (((rb_iseq_t*)DATA_PTR(iseq))->file_name) #define NEW_ISEQVAL(node, name, type) \ new_child_iseq(iseq, node, name, 0, type) @@ -1473,7 +1473,7 @@ Init_syserr(void) static void err_append(const char *s) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); if (th->parse_in_eval) { if (NIL_P(th->errinfo)) { th->errinfo = rb_exc_new2(rb_eSyntaxError, s); @@ -182,7 +182,7 @@ ruby_cleanup(int ex) { int state; volatile VALUE err = GET_THREAD()->errinfo; - yarv_vm_t *vm = GET_THREAD()->vm; + rb_vm_t *vm = GET_THREAD()->vm; /* th->errinfo contains a NODE while break'ing */ if (RTEST(err) && (TYPE(err) != T_NODE) && @@ -466,13 +466,6 @@ rb_frozen_class_p(VALUE klass) #define MATCH_DATA *rb_svar(node->nd_cnt) -static VALUE -rb_obj_is_proc(proc) - VALUE proc; -{ - return yarv_obj_is_proc(proc); -} - void rb_add_event_hook(func, events) rb_event_hook_func_t func; @@ -886,7 +879,7 @@ rb_mod_protected_method_defined(VALUE mod, VALUE mid) return Qfalse; } -NORETURN(void th_iter_break _((yarv_thread_t *))); +NORETURN(void th_iter_break _((rb_thead_t *))); void rb_iter_break() @@ -903,7 +896,7 @@ rb_longjmp(tag, mesg) VALUE mesg; { VALUE at; - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); /* //while (th->cfp->pc == 0 || th->cfp->iseq == 0) { @@ -1088,7 +1081,7 @@ rb_jump_tag(tag) int rb_block_given_p() { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); if (GC_GUARDED_PTR_REF(th->cfp->lfp[0])) { return Qtrue; } @@ -1128,9 +1121,9 @@ rb_iterator_p() VALUE rb_f_block_given_p() { - yarv_thread_t *th = GET_THREAD(); - yarv_control_frame_t *cfp = th->cfp; - cfp = th_get_ruby_level_cfp(th, YARV_PREVIOUS_CONTROL_FRAME(cfp)); + rb_thead_t *th = GET_THREAD(); + rb_control_frame_t *cfp = th->cfp; + cfp = th_get_ruby_level_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)); if (GC_GUARDED_PTR_REF(cfp->lfp[0])) { return Qtrue; } @@ -1245,15 +1238,15 @@ rb_iterate(VALUE (*it_proc) (VALUE), VALUE data1, int state; volatile VALUE retval = Qnil; NODE *node = NEW_IFUNC(bl_proc, data2); - yarv_thread_t *th = GET_THREAD(); - yarv_control_frame_t *cfp = th->cfp; + rb_thead_t *th = GET_THREAD(); + rb_control_frame_t *cfp = th->cfp; TH_PUSH_TAG(th); state = TH_EXEC_TAG(); if (state == 0) { iter_retry: { - yarv_block_t *blockptr = GET_BLOCK_PTR_IN_CFP(th->cfp); + rb_block_t *blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(th->cfp); blockptr->iseq = (void *)node; blockptr->proc = 0; th->passed_block = blockptr; @@ -1524,7 +1517,7 @@ rb_method_missing(int argc, const VALUE *argv, VALUE obj) VALUE exc = rb_eNoMethodError; char *format = 0; NODE *cnode = ruby_current_node; - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); int last_call_status = th->method_missing_reason; if (argc == 0 || !SYMBOL_P(argv[0])) { rb_raise(rb_eArgError, "no id given"); @@ -1716,8 +1709,8 @@ VALUE rb_f_send(int argc, VALUE *argv, VALUE recv) { int scope = NOEX_PUBLIC; - yarv_thread_t *th = GET_THREAD(); - yarv_control_frame_t *cfp = YARV_PREVIOUS_CONTROL_FRAME(th->cfp); + rb_thead_t *th = GET_THREAD(); + rb_control_frame_t *cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); if (SPECIAL_CONST_P(cfp->sp[0])) { scope = NOEX_NOSUPER | NOEX_PRIVATE; @@ -1856,13 +1849,13 @@ make_backtrace(void) } static ID -frame_func_id(yarv_control_frame_t *cfp) +frame_func_id(rb_control_frame_t *cfp) { - yarv_iseq_t *iseq = cfp->iseq; + rb_iseq_t *iseq = cfp->iseq; if (!iseq) { return cfp->method_id; } - else if (YARV_IFUNC_P(iseq)) { + else if (RUBY_VM_IFUNC_P(iseq)) { return rb_intern("<ifunc>"); } else { @@ -1879,8 +1872,8 @@ rb_frame_this_func(void) ID rb_frame_callee(void) { - yarv_thread_t *th = GET_THREAD(); - yarv_control_frame_t *prev_cfp = YARV_PREVIOUS_CONTROL_FRAME(th->cfp); + rb_thead_t *th = GET_THREAD(); + rb_control_frame_t *prev_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); /* check if prev_cfp can be accessible */ if ((void *)(th->stack + th->stack_size) == (void *)(prev_cfp)) { return 0; @@ -1891,8 +1884,8 @@ rb_frame_callee(void) void rb_frame_pop(void) { - yarv_thread_t *th = GET_THREAD(); - th->cfp = YARV_PREVIOUS_CONTROL_FRAME(th->cfp); + rb_thead_t *th = GET_THREAD(); + th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); } static VALUE @@ -1904,8 +1897,8 @@ rb_frame_self(void) const char * rb_sourcefile(void) { - yarv_iseq_t *iseq = GET_THREAD()->cfp->iseq; - if (YARV_NORMAL_ISEQ_P(iseq)) { + rb_iseq_t *iseq = GET_THREAD()->cfp->iseq; + if (RUBY_VM_NORMAL_ISEQ_P(iseq)) { return RSTRING_PTR(iseq->file_name); } return 0; @@ -1914,12 +1907,12 @@ rb_sourcefile(void) int rb_sourceline(void) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); return th_get_sourceline(th->cfp); } -VALUE th_set_eval_stack(yarv_thread_t *, VALUE iseq); -VALUE th_eval_body(yarv_thread_t *); +VALUE th_set_eval_stack(rb_thead_t *, VALUE iseq); +VALUE th_eval_body(rb_thead_t *); static VALUE eval(VALUE self, VALUE src, VALUE scope, char *file, int line) @@ -1927,9 +1920,9 @@ eval(VALUE self, VALUE src, VALUE scope, char *file, int line) int state; VALUE result = Qundef; VALUE envval; - yarv_binding_t *bind = 0; - yarv_thread_t *th = GET_THREAD(); - yarv_env_t *env = NULL; + rb_binding_t *bind = 0; + rb_thead_t *th = GET_THREAD(); + rb_env_t *env = NULL; NODE *stored_cref_stack = 0; if (file == 0) { @@ -1939,7 +1932,7 @@ eval(VALUE self, VALUE src, VALUE scope, char *file, int line) } PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { - yarv_iseq_t *iseq; + rb_iseq_t *iseq; VALUE iseqval; if (scope != Qnil) { @@ -1958,8 +1951,8 @@ eval(VALUE self, VALUE src, VALUE scope, char *file, int line) th->base_block = &env->block; } else { - yarv_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp); - th->base_block = GET_BLOCK_PTR_IN_CFP(cfp); + rb_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp); + th->base_block = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp); th->base_block->iseq = cfp->iseq; /* TODO */ } @@ -2065,22 +2058,22 @@ rb_f_eval(int argc, VALUE *argv, VALUE self) return eval(self, src, scope, file, line); } -VALUE *th_cfp_svar(yarv_control_frame_t *cfp, int idx); +VALUE *th_cfp_svar(rb_control_frame_t *cfp, int idx); /* function to call func under the specified class/module context */ static VALUE exec_under(VALUE (*func) (VALUE), VALUE under, VALUE self, VALUE args) { VALUE val = Qnil; /* OK */ - yarv_thread_t *th = GET_THREAD(); - yarv_control_frame_t *cfp = th->cfp; - yarv_control_frame_t *pcfp = YARV_PREVIOUS_CONTROL_FRAME(cfp); + rb_thead_t *th = GET_THREAD(); + rb_control_frame_t *cfp = th->cfp; + rb_control_frame_t *pcfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); VALUE stored_self = pcfp->self; NODE *stored_cref = 0; NODE **pcref = 0; - yarv_block_t block; - yarv_block_t *blockptr; + rb_block_t block; + rb_block_t *blockptr; int state; /* replace environment */ @@ -2093,8 +2086,8 @@ exec_under(VALUE (*func) (VALUE), VALUE under, VALUE self, VALUE args) *th->cfp->lfp = GC_GUARDED_PTR(&block); } - while (!YARV_NORMAL_ISEQ_P(cfp->iseq)) { - cfp = YARV_PREVIOUS_CONTROL_FRAME(cfp); + while (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } pcref = (NODE **) th_cfp_svar(cfp, -1); @@ -2727,12 +2720,12 @@ VALUE rb_f_untrace_var(); static VALUE get_errinfo(void) { - yarv_thread_t *th = GET_THREAD(); - yarv_control_frame_t *cfp = th->cfp; - yarv_control_frame_t *end_cfp = YARV_END_CONTROL_FRAME(th); + rb_thead_t *th = GET_THREAD(); + rb_control_frame_t *cfp = th->cfp; + rb_control_frame_t *end_cfp = RUBY_VM_END_CONTROL_FRAME(th); - while (YARV_VALID_CONTROL_FRAME_P(cfp, end_cfp)) { - if (YARV_NORMAL_ISEQ_P(cfp->iseq)) { + while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp, end_cfp)) { + if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { if (cfp->iseq->type == ISEQ_TYPE_RESCUE) { return cfp->dfp[-1]; } @@ -2741,7 +2734,7 @@ get_errinfo(void) return cfp->dfp[-1]; } } - cfp = YARV_PREVIOUS_CONTROL_FRAME(cfp); + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } return Qnil; } @@ -2810,15 +2803,15 @@ errat_setter(VALUE val, ID id, VALUE *var) * local_variables #=> ["fred", "i"] */ -int th_collect_local_variables_in_heap(yarv_thread_t *th, VALUE *dfp, VALUE ary); +int th_collect_local_variables_in_heap(rb_thead_t *th, VALUE *dfp, VALUE ary); static VALUE rb_f_local_variables(void) { VALUE ary = rb_ary_new(); - yarv_thread_t *th = GET_THREAD(); - yarv_control_frame_t *cfp = - th_get_ruby_level_cfp(th, YARV_PREVIOUS_CONTROL_FRAME(th->cfp)); + rb_thead_t *th = GET_THREAD(); + rb_control_frame_t *cfp = + th_get_ruby_level_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp)); int i; while (1) { @@ -2843,7 +2836,7 @@ rb_f_local_variables(void) } else { while (cfp->dfp != dfp) { - cfp = YARV_PREVIOUS_CONTROL_FRAME(cfp); + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } } } @@ -2960,8 +2953,8 @@ Init_eval() VALUE rb_dvar_defined(ID id) { - yarv_thread_t *th = GET_THREAD(); - yarv_iseq_t *iseq; + rb_thead_t *th = GET_THREAD(); + rb_iseq_t *iseq; if (th->base_block && (iseq = th->base_block->iseq)) { while (iseq->type == ISEQ_TYPE_BLOCK || iseq->type == ISEQ_TYPE_RESCUE || @@ -2984,7 +2977,7 @@ rb_dvar_defined(ID id) void rb_scope_setup_top_local_tbl(ID *tbl) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); if (tbl) { if (th->top_local_tbl) { xfree(th->top_local_tbl); @@ -3000,7 +2993,7 @@ rb_scope_setup_top_local_tbl(ID *tbl) int rb_scope_base_local_tbl_size(void) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); if (th->base_block) { return th->base_block->iseq->local_iseq->local_size + 2 /* $_, $~ */ - 1 /* svar */ ; @@ -3013,7 +3006,7 @@ rb_scope_base_local_tbl_size(void) ID rb_scope_base_local_tbl_id(int i) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); switch (i) { case 0: return rb_intern("$_"); @@ -3028,7 +3021,7 @@ rb_scope_base_local_tbl_id(int i) int rb_dvar_current(void) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); if (th->base_block) { return 1; } diff --git a/eval_error.h b/eval_error.h index 757204b15f..91edcb8521 100644 --- a/eval_error.h +++ b/eval_error.h @@ -198,7 +198,7 @@ static int error_handle(int ex) { int status = EXIT_FAILURE; - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); if (thread_set_raised(th)) return EXIT_FAILURE; diff --git a/eval_intern.h b/eval_intern.h index be0b2c88a7..da51b0ba99 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -4,7 +4,7 @@ #define PASS_PASSED_BLOCK() \ (GET_THREAD()->passed_block = \ - GC_GUARDED_PTR_REF((yarv_block_t *)GET_THREAD()->cfp->lfp[0])) + GC_GUARDED_PTR_REF((rb_block_t *)GET_THREAD()->cfp->lfp[0])) #define UNSUPPORTED(func) \ @@ -189,8 +189,8 @@ extern int function_call_may_return_twice_false; #include <sys/stat.h> #define TH_PUSH_TAG(th) do { \ - yarv_thread_t * const _th = th; \ - struct yarv_tag _tag; \ + rb_thead_t * const _th = th; \ + struct rb_vm_tag _tag; \ _tag.tag = 0; \ _tag.prev = _th->tag; \ _th->tag = &_tag; @@ -278,8 +278,8 @@ extern VALUE sysstack_error; void rb_thread_cleanup _((void)); void rb_thread_wait_other_threads _((void)); -int thread_set_raised(yarv_thread_t *th); -int thread_reset_raised(yarv_thread_t *th); +int thread_set_raised(rb_thead_t *th); +int thread_reset_raised(rb_thead_t *th); VALUE rb_f_eval(int argc, VALUE *argv, VALUE self); VALUE rb_make_exception _((int argc, VALUE *argv)); @@ -289,23 +289,22 @@ NORETURN(void print_undef _((VALUE, ID))); NORETURN(void th_localjump_error(const char *, VALUE, int)); NORETURN(void th_jump_tag_but_local_jump(int, VALUE)); -rb_thread_t rb_vm_curr_thread(); -VALUE th_compile(yarv_thread_t *th, VALUE str, VALUE file, VALUE line); +VALUE th_compile(rb_thead_t *th, VALUE str, VALUE file, VALUE line); -NODE *th_get_cref(yarv_thread_t *th, yarv_iseq_t *iseq, yarv_control_frame_t *cfp); -NODE *th_cref_push(yarv_thread_t *th, VALUE, int); -NODE *th_set_special_cref(yarv_thread_t *th, VALUE *lfp, NODE * cref_stack); +NODE *th_get_cref(rb_thead_t *th, rb_iseq_t *iseq, rb_control_frame_t *cfp); +NODE *th_cref_push(rb_thead_t *th, VALUE, int); +NODE *th_set_special_cref(rb_thead_t *th, VALUE *lfp, NODE * cref_stack); -static yarv_control_frame_t * -th_get_ruby_level_cfp(yarv_thread_t *th, yarv_control_frame_t *cfp) +static rb_control_frame_t * +th_get_ruby_level_cfp(rb_thead_t *th, rb_control_frame_t *cfp) { - yarv_iseq_t *iseq = 0; - while (!YARV_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) { - if (YARV_NORMAL_ISEQ_P(cfp->iseq)) { + rb_iseq_t *iseq = 0; + while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) { + if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { iseq = cfp->iseq; break; } - cfp = YARV_PREVIOUS_CONTROL_FRAME(cfp); + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } if (!iseq) { return 0; @@ -316,12 +315,13 @@ th_get_ruby_level_cfp(yarv_thread_t *th, yarv_control_frame_t *cfp) static NODE * ruby_cref() { - yarv_thread_t *th = GET_THREAD(); - yarv_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp); + rb_thead_t *th = GET_THREAD(); + rb_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp); return th_get_cref(th, cfp->iseq, cfp); } -VALUE th_get_cbase(yarv_thread_t *th); +VALUE th_get_cbase(rb_thead_t *th); +VALUE rb_obj_is_proc(VALUE); #define ruby_cbase() th_get_cbase(GET_THREAD()) diff --git a/eval_jump.h b/eval_jump.h index d4fab68705..653172d16c 100644 --- a/eval_jump.h +++ b/eval_jump.h @@ -22,8 +22,8 @@ static VALUE rb_f_throw(int argc, VALUE *argv) { VALUE tag, value; - yarv_thread_t *th = GET_THREAD(); - struct yarv_tag *tt = th->tag; + rb_thead_t *th = GET_THREAD(); + struct rb_vm_tag *tt = th->tag; rb_scan_args(argc, argv, "11", &tag, &value); tag = ID2SYM(rb_to_id(tag)); @@ -94,7 +94,7 @@ rb_f_catch(VALUE dmy, VALUE tag) { int state; VALUE val = Qnil; /* OK */ - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); tag = ID2SYM(rb_to_id(tag)); PUSH_TAG(tag); @@ -138,7 +138,7 @@ static VALUE terminate_process(int status, const char *mesg, long mlen) { VALUE args[2]; - yarv_vm_t *vm = GET_THREAD()->vm; + rb_vm_t *vm = GET_THREAD()->vm; args[0] = INT2NUM(status); args[1] = rb_str_new(mesg, mlen); diff --git a/eval_load.c b/eval_load.c index bbe992171e..809f9654a1 100644 --- a/eval_load.c +++ b/eval_load.c @@ -111,7 +111,7 @@ rb_provide(const char *feature) VALUE rb_load_path; NORETURN(static void load_failed _((VALUE))); -void th_klass_init(yarv_thread_t *); +void th_klass_init(rb_thead_t *); void rb_load(VALUE fname, int wrap) @@ -339,7 +339,7 @@ rb_require_safe(VALUE fname, int safe) { VALUE result = Qnil; volatile VALUE errinfo = GET_THREAD()->errinfo; - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); int state; char *volatile ftptr = 0; diff --git a/eval_method.h b/eval_method.h index a99e6bea9a..5abf06d67b 100644 --- a/eval_method.h +++ b/eval_method.h @@ -156,7 +156,7 @@ rb_add_method(VALUE klass, ID mid, NODE * node, int noex) } if (mid == object_id || mid == __send || mid == __send_bang) { - if (node && nd_type(node) == YARV_METHOD_NODE) { + if (node && nd_type(node) == RUBY_VM_METHOD_NODE) { rb_warn("redefining `%s' may cause serious problem", rb_id2name(mid)); } diff --git a/eval_safe.h b/eval_safe.h index 6748ca87fe..76cb059ee5 100644 --- a/eval_safe.h +++ b/eval_safe.h @@ -36,7 +36,7 @@ static void safe_setter _((VALUE val)); void rb_set_safe_level(int level) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); if (level > th->safe_level) { if (level > SAFE_LEVEL_MAX) { @@ -56,7 +56,7 @@ static void safe_setter(VALUE val) { int level = NUM2INT(val); - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); if (level < th->safe_level) { rb_raise(rb_eSecurityError, @@ -482,13 +482,13 @@ rb_newobj_from_heap(void) #if USE_VALUE_CACHE static VALUE -rb_fill_value_cache(yarv_thread_t *th) +rb_fill_value_cache(rb_thead_t *th) { int i; VALUE rv; /* LOCK */ - for (i=0; i<YARV_VALUE_CACHE_SIZE; i++) { + for (i=0; i<RUBY_VM_VALUE_CACHE_SIZE; i++) { VALUE v = rb_newobj_from_heap(); th->value_cache[i] = v; @@ -505,7 +505,7 @@ VALUE rb_newobj(void) { #if USE_VALUE_CACHE && 1 - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); VALUE v = *th->value_cache_ptr; if (v) { @@ -562,7 +562,7 @@ static int grow_direction; static int stack_grow_direction(VALUE *addr) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); SET_STACK_END; if (STACK_END > addr) return grow_direction = 1; @@ -582,7 +582,7 @@ stack_grow_direction(VALUE *addr) int ruby_stack_length(VALUE **p) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); SET_STACK_END; if (p) *p = STACK_UPPER(STACK_END, STACK_START, STACK_END); return STACK_LENGTH; @@ -592,7 +592,7 @@ int ruby_stack_check(void) { int ret; - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); CHECK_STACK(ret); return ret; } @@ -1337,7 +1337,7 @@ garbage_collect(void) { struct gc_list *list; jmp_buf save_regs_gc_mark; - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); if (GC_NOTIFY) printf("start garbage_collect()\n"); @@ -1442,7 +1442,7 @@ garbage_collect(void) } void -yarv_machine_stack_mark(yarv_thread_t *th) +yarv_machine_stack_mark(rb_thead_t *th) { #if STACK_GROW_DIRECTION < 0 rb_gc_mark_locations(th->machine_stack_end, th->machine_stack_start); @@ -84,8 +84,8 @@ rb_call_inits() Init_GC(); Init_marshal(); Init_Enumerator(); - Init_ISeq(); Init_VM(); + Init_ISeq(); Init_Thread(); Init_version(); } diff --git a/insnhelper.h b/insnhelper.h index a2cb2e106c..b4ced7a50a 100644 --- a/insnhelper.h +++ b/insnhelper.h @@ -124,7 +124,7 @@ /* block */ #define GET_BLOCK_PTR() \ - ((yarv_block_t *)(GC_GUARDED_PTR_REF(GET_LFP()[0]))) + ((rb_block_t *)(GC_GUARDED_PTR_REF(GET_LFP()[0]))) #define CHECK_STACK_OVERFLOW(th, cfp, margin) \ (((VALUE *)(cfp)->sp) + (margin) >= ((VALUE *)cfp)) @@ -961,7 +961,7 @@ defined } break; case DEFINED_ZSUPER:{ - yarv_iseq_t *ip = GET_ISEQ(); + rb_iseq_t *ip = GET_ISEQ(); while (ip) { if (ip->defined_method_id) { break; @@ -1011,10 +1011,10 @@ postexe () () { - yarv_block_t *blockptr; + rb_block_t *blockptr; VALUE proc; - blockptr = GET_BLOCK_PTR_IN_CFP(GET_CFP()); + blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(GET_CFP()); blockptr->iseq = blockiseq; blockptr->proc = 0; @@ -1164,7 +1164,7 @@ send NODE *mn; VALUE recv; VALUE klass; - yarv_block_t *blockptr = 0; + rb_block_t *blockptr = 0; num_t num = op_argc; num_t flag = op_flag; ID id = op_id; @@ -1232,8 +1232,8 @@ send if (0) { LABEL_IS_SC(start_init_in_super): { - yarv_iseq_t *iseq = GET_ISEQ(); - yarv_iseq_t *ip = iseq; + rb_iseq_t *iseq = GET_ISEQ(); + rb_iseq_t *ip = iseq; num = tmp_num; flag = VM_CALL_FCALL_BIT; @@ -1251,12 +1251,12 @@ send if (ip != ip->local_iseq) { /* defined by method_defined() */ - yarv_control_frame_t *lcfp = GET_CFP(); + rb_control_frame_t *lcfp = GET_CFP(); while (lcfp->iseq != ip) { VALUE *tdfp = GET_PREV_DFP(lcfp->dfp); while (1) { - lcfp = YARV_PREVIOUS_CONTROL_FRAME(lcfp); + lcfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(lcfp); if (lcfp->dfp == tdfp) { break; } @@ -1287,7 +1287,7 @@ send #endif #endif macro_eval_invoke_method(recv, klass, id, num, mn, blockptr); - YARV_CHECK_INTS(); + RUBY_VM_CHECK_INTS(); } /** @@ -1326,8 +1326,8 @@ invokeblock (...) (VALUE val) // inc += 1 - num; { - yarv_block_t *block = GET_BLOCK_PTR(); - yarv_iseq_t *iseq; + rb_block_t *block = GET_BLOCK_PTR(); + rb_iseq_t *iseq; int argc = num; if (GET_ISEQ()->local_iseq->type != ISEQ_TYPE_METHOD || block == 0) { @@ -1392,7 +1392,7 @@ leave } } - YARV_CHECK_INTS(); + RUBY_VM_CHECK_INTS(); pop_frame(th); RESTORE_REGS(); } @@ -1451,7 +1451,7 @@ throw } } else if (state == TAG_RETURN) { - yarv_control_frame_t *cfp = GET_CFP(); + rb_control_frame_t *cfp = GET_CFP(); int is_orphan = 1; VALUE *dfp = GET_DFP(); @@ -1522,7 +1522,7 @@ jump () () { - YARV_CHECK_INTS(); + RUBY_VM_CHECK_INTS(); JUMP(dst); } @@ -1538,7 +1538,7 @@ branchif () { if (RTEST(val)) { - YARV_CHECK_INTS(); + RUBY_VM_CHECK_INTS(); JUMP(dst); } } @@ -1555,7 +1555,7 @@ branchunless () { if (!RTEST(val)) { - YARV_CHECK_INTS(); + RUBY_VM_CHECK_INTS(); JUMP(dst); } } @@ -2394,7 +2394,7 @@ opt_call_native_compiled () { #if __GNUC__ && OPT_USE_JIT_COMPILE - yarv_iseq_t *iseq = GET_ISEQ(); + rb_iseq_t *iseq = GET_ISEQ(); void *label = (void *)iseq->jit_compiled; breakpoint(); @@ -40,7 +40,7 @@ compile_data_free(struct iseq_compile_data *compile_data) static void iseq_free(void *ptr) { - yarv_iseq_t *iseq; + rb_iseq_t *iseq; FREE_REPORT_ENTER("iseq"); if (ptr) { @@ -67,7 +67,7 @@ iseq_free(void *ptr) static void iseq_mark(void *ptr) { - yarv_iseq_t *iseq; + rb_iseq_t *iseq; MARK_REPORT_ENTER("iseq"); if (ptr) { @@ -94,18 +94,18 @@ static VALUE iseq_alloc(VALUE klass) { VALUE volatile obj; - yarv_iseq_t *iseq; + rb_iseq_t *iseq; - obj = Data_Make_Struct(klass, yarv_iseq_t, iseq_mark, iseq_free, iseq); - MEMZERO(iseq, yarv_iseq_t, 1); + obj = Data_Make_Struct(klass, rb_iseq_t, iseq_mark, iseq_free, iseq); + MEMZERO(iseq, rb_iseq_t, 1); return obj; } static VALUE -prepare_iseq_build(yarv_iseq_t *iseq, +prepare_iseq_build(rb_iseq_t *iseq, VALUE name, VALUE file_name, VALUE parent, VALUE type, VALUE block_opt, - const yarv_compile_option_t *option) + const rb_compile_option_t *option) { iseq->name = name; iseq->defined_method_id = 0; @@ -133,7 +133,7 @@ prepare_iseq_build(yarv_iseq_t *iseq, iseq->cref_stack->nd_file = 0; } else if (parent) { - yarv_iseq_t *piseq; + rb_iseq_t *piseq; GetISeqPtr(parent, piseq); iseq->cref_stack = piseq->cref_stack; } @@ -162,13 +162,13 @@ prepare_iseq_build(yarv_iseq_t *iseq, iseq->local_iseq = iseq; } else { - yarv_iseq_t *piseq; + rb_iseq_t *piseq; GetISeqPtr(parent, piseq); iseq->local_iseq = piseq->local_iseq; } if (RTEST(parent)) { - yarv_iseq_t *piseq; + rb_iseq_t *piseq; GetISeqPtr(parent, piseq); iseq->parent_iseq = piseq; } @@ -177,7 +177,7 @@ prepare_iseq_build(yarv_iseq_t *iseq, } static VALUE -cleanup_iseq_build(yarv_iseq_t *iseq) +cleanup_iseq_build(rb_iseq_t *iseq) { struct iseq_compile_data *data = iseq->compile_data; iseq->compile_data = 0; @@ -191,7 +191,7 @@ cleanup_iseq_build(yarv_iseq_t *iseq) return Qtrue; } -static yarv_compile_option_t COMPILE_OPTION_DEFAULT = { +static rb_compile_option_t COMPILE_OPTION_DEFAULT = { OPT_INLINE_CONST_CACHE, /* int inline_const_cache; */ OPT_PEEPHOLE_OPTIMIZATION, /* int peephole_optimization; */ OPT_SPECIALISED_INSTRUCTION, /* int specialized_instruction; */ @@ -199,10 +199,10 @@ static yarv_compile_option_t COMPILE_OPTION_DEFAULT = { OPT_INSTRUCTIONS_UNIFICATION, /* int instructions_unification; */ OPT_STACK_CACHING, /* int stack_caching; */ }; -static const yarv_compile_option_t COMPILE_OPTION_FALSE; +static const rb_compile_option_t COMPILE_OPTION_FALSE; static void -make_compile_option(yarv_compile_option_t *option, VALUE opt) +make_compile_option(rb_compile_option_t *option, VALUE opt) { if (opt == Qnil) { *option = COMPILE_OPTION_DEFAULT; @@ -211,7 +211,7 @@ make_compile_option(yarv_compile_option_t *option, VALUE opt) *option = COMPILE_OPTION_FALSE; } else if (opt == Qtrue) { - memset(option, 1, sizeof(yarv_compile_option_t)); + memset(option, 1, sizeof(rb_compile_option_t)); } else if (CLASS_OF(opt) == rb_cHash) { #define SET_COMPILE_OPTION(o, h, mem) \ @@ -233,7 +233,7 @@ make_compile_option(yarv_compile_option_t *option, VALUE opt) } static VALUE -make_compile_option_value(yarv_compile_option_t *option) +make_compile_option_value(rb_compile_option_t *option) { VALUE opt = rb_hash_new(); #define SET_COMPILE_OPTION(o, h, mem) \ @@ -254,16 +254,16 @@ VALUE yarv_iseq_new(NODE *node, VALUE name, VALUE file_name, VALUE parent, VALUE type) { - return yarv_iseq_new_with_opt(node, name, file_name, parent, type, - &COMPILE_OPTION_DEFAULT); + return rb_iseq_new_with_opt(node, name, file_name, parent, type, + &COMPILE_OPTION_DEFAULT); } static VALUE yarv_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE file_name, VALUE parent, VALUE type, VALUE bopt, - const yarv_compile_option_t *option) + const rb_compile_option_t *option) { - yarv_iseq_t *iseq; + rb_iseq_t *iseq; VALUE self = iseq_alloc(rb_cISeq); GetISeqPtr(self, iseq); @@ -276,9 +276,9 @@ yarv_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE file_name, } VALUE -yarv_iseq_new_with_opt(NODE *node, VALUE name, VALUE file_name, - VALUE parent, VALUE type, - const yarv_compile_option_t *option) +rb_iseq_new_with_opt(NODE *node, VALUE name, VALUE file_name, + VALUE parent, VALUE type, + const rb_compile_option_t *option) { return yarv_iseq_new_with_bopt_and_opt(node, name, file_name, parent, type, Qfalse, option); @@ -292,7 +292,7 @@ yarv_iseq_new_with_bopt(NODE *node, VALUE name, VALUE file_name, bopt, &COMPILE_OPTION_DEFAULT); } -VALUE iseq_build_from_ary(yarv_iseq_t *iseq, VALUE line, +VALUE iseq_build_from_ary(rb_iseq_t *iseq, VALUE line, VALUE locals, VALUE args, VALUE exception, VALUE body); #define CHECK_ARRAY(v) rb_convert_type(v, T_ARRAY, "Array", "to_ary") @@ -310,8 +310,8 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) VALUE iseq_type; struct st_table *type_map = 0; - yarv_iseq_t *iseq; - yarv_compile_option_t option; + rb_iseq_t *iseq; + rb_compile_option_t option; /* [magic, major_version, minor_version, format_type, misc, * name, filename, line, @@ -398,7 +398,7 @@ iseq_s_compile(int argc, VALUE *argv, VALUE self) { VALUE str, file = Qnil, line = INT2FIX(1), opt = Qnil; NODE *node; - yarv_compile_option_t option; + rb_compile_option_t option; rb_scan_args(argc, argv, "13", &str, &file, &line, &opt); @@ -407,8 +407,8 @@ iseq_s_compile(int argc, VALUE *argv, VALUE self) node = compile_string(str, file, line); make_compile_option(&option, opt); - return yarv_iseq_new_with_opt(node, rb_str_new2("<main>"), file, Qfalse, - ISEQ_TYPE_TOP, &option); + return rb_iseq_new_with_opt(node, rb_str_new2("<main>"), file, Qfalse, + ISEQ_TYPE_TOP, &option); } static VALUE @@ -419,7 +419,7 @@ iseq_s_compile_file(int argc, VALUE *argv, VALUE self) VALUE f; NODE *node; const char *fname; - yarv_compile_option_t option; + rb_compile_option_t option; rb_scan_args(argc, argv, "11", &file, &opt); fname = StringValueCStr(file); @@ -429,23 +429,23 @@ iseq_s_compile_file(int argc, VALUE *argv, VALUE self) parser = rb_parser_new(); node = rb_parser_compile_file(parser, fname, f, NUM2INT(line)); make_compile_option(&option, opt); - return yarv_iseq_new_with_opt(node, rb_str_new2("<main>"), file, Qfalse, - ISEQ_TYPE_TOP, &option); + return rb_iseq_new_with_opt(node, rb_str_new2("<main>"), file, Qfalse, + ISEQ_TYPE_TOP, &option); } static VALUE iseq_s_compile_option_set(VALUE self, VALUE opt) { - yarv_compile_option_t option; + rb_compile_option_t option; make_compile_option(&option, opt); COMPILE_OPTION_DEFAULT = option; return make_compile_option_value(&option); } -static yarv_iseq_t * +static rb_iseq_t * iseq_check(VALUE val) { - yarv_iseq_t *iseq; + rb_iseq_t *iseq; GetISeqPtr(val, iseq); if (!iseq->name) { rb_raise(rb_eTypeError, "uninitialized InstructionSequence"); @@ -453,19 +453,19 @@ iseq_check(VALUE val) return iseq; } -VALUE yarv_th_eval(yarv_thread_t *th, VALUE iseqval); +VALUE rb_thread_eval(rb_thead_t *th, VALUE iseqval); static VALUE iseq_eval(VALUE self) { - return yarv_th_eval(GET_THREAD(), self); + return rb_thread_eval(GET_THREAD(), self); } static VALUE iseq_inspect(VALUE self) { char buff[0x100]; - yarv_iseq_t *iseq = iseq_check(self); + rb_iseq_t *iseq = iseq_check(self); snprintf(buff, sizeof(buff), "<ISeq:%s@%s>", RSTRING_PTR(iseq->name), RSTRING_PTR(iseq->file_name)); @@ -473,12 +473,12 @@ iseq_inspect(VALUE self) return rb_str_new2(buff); } -VALUE iseq_data_to_ary(yarv_iseq_t *iseq); +VALUE iseq_data_to_ary(rb_iseq_t *iseq); static VALUE iseq_to_a(VALUE self) { - yarv_iseq_t *iseq = iseq_check(self); + rb_iseq_t *iseq = iseq_check(self); return iseq_data_to_ary(iseq); } @@ -486,7 +486,7 @@ iseq_to_a(VALUE self) now, search algorithm is brute force. but this should be binary search. */ static unsigned short -find_line_no(yarv_iseq_t *iseqdat, unsigned long pos) +find_line_no(rb_iseq_t *iseqdat, unsigned long pos) { unsigned long i, size = iseqdat->insn_info_size; struct insn_info_struct *iiary = iseqdat->insn_info_tbl; @@ -501,7 +501,7 @@ find_line_no(yarv_iseq_t *iseqdat, unsigned long pos) } static unsigned short -find_prev_line_no(yarv_iseq_t *iseqdat, unsigned long pos) +find_prev_line_no(rb_iseq_t *iseqdat, unsigned long pos) { unsigned long i, size = iseqdat->insn_info_size; struct insn_info_struct *iiary = iseqdat->insn_info_tbl; @@ -521,7 +521,7 @@ find_prev_line_no(yarv_iseq_t *iseqdat, unsigned long pos) } static VALUE -insn_operand_intern(yarv_iseq_t *iseq, +insn_operand_intern(rb_iseq_t *iseq, int insn, int op_no, VALUE op, int len, int pos, VALUE *pnop, VALUE child) { @@ -543,7 +543,7 @@ insn_operand_intern(yarv_iseq_t *iseq, case TS_LINDEX: { - yarv_iseq_t *ip = iseq->local_iseq; + rb_iseq_t *ip = iseq->local_iseq; ret = rb_str_new2( @@ -552,7 +552,7 @@ insn_operand_intern(yarv_iseq_t *iseq, } case TS_DINDEX:{ if (insn == BIN(getdynamic) || insn == BIN(setdynamic)) { - yarv_iseq_t *ip = iseq; + rb_iseq_t *ip = iseq; int level = *pnop; int i; for (i = 0; i < level; i++) { @@ -578,7 +578,7 @@ insn_operand_intern(yarv_iseq_t *iseq, case TS_ISEQ: /* iseq */ { - yarv_iseq_t *iseq = (yarv_iseq_t *)op; + rb_iseq_t *iseq = (rb_iseq_t *)op; if (iseq) { ret = iseq->name; if (child) { @@ -617,7 +617,7 @@ insn_operand_intern(yarv_iseq_t *iseq, */ VALUE iseq_disasm_insn(VALUE ret, VALUE *iseq, int pos, - yarv_iseq_t *iseqdat, VALUE child) + rb_iseq_t *iseqdat, VALUE child) { int insn = iseq[pos]; int len = insn_len(insn); @@ -696,7 +696,7 @@ catch_type(int type) VALUE iseq_disasm(VALUE self) { - yarv_iseq_t *iseqdat = iseq_check(self); + rb_iseq_t *iseqdat = iseq_check(self); VALUE *iseq; VALUE str = rb_str_new(0, 0); VALUE child = rb_ary_new(); @@ -1080,7 +1080,7 @@ cdhash_each(VALUE key, VALUE value, VALUE ary) } VALUE -iseq_data_to_ary(yarv_iseq_t *iseq) +iseq_data_to_ary(rb_iseq_t *iseq) { int i, pos, opt = 0; VALUE *seq; @@ -1205,7 +1205,7 @@ iseq_data_to_ary(yarv_iseq_t *iseq) break; case TS_ISEQ: { - yarv_iseq_t *iseq = (yarv_iseq_t *)*seq; + rb_iseq_t *iseq = (rb_iseq_t *)*seq; if (iseq) { VALUE val = iseq_data_to_ary(iseq); rb_ary_push(ary, val); @@ -1260,7 +1260,7 @@ iseq_data_to_ary(yarv_iseq_t *iseq) struct catch_table_entry *entry = &iseq->catch_table[i]; rb_ary_push(ary, exception_type2symbol(entry->type)); if (entry->iseq) { - yarv_iseq_t *eiseq; + rb_iseq_t *eiseq; GetISeqPtr(entry->iseq, eiseq); rb_ary_push(ary, iseq_data_to_ary(eiseq)); } @@ -24,66 +24,11 @@ VALUE rb_cUnboundMethod; VALUE rb_cMethod; VALUE rb_cBinding; VALUE rb_cProc; -VALUE rb_cEnv; static VALUE bmcall(VALUE, VALUE); static int method_arity(VALUE); static VALUE rb_obj_is_method(VALUE m); -/* Env */ - -static void -env_free(void *ptr) -{ - yarv_env_t *env; - FREE_REPORT_ENTER("env"); - if (ptr) { - env = ptr; - FREE_UNLESS_NULL(env->env); - ruby_xfree(ptr); - } - FREE_REPORT_LEAVE("env"); -} - -static void -env_mark(void *ptr) -{ - yarv_env_t *env; - MARK_REPORT_ENTER("env"); - if (ptr) { - env = ptr; - if (env->env) { - /* TODO: should mark more restricted range */ - GC_INFO("env->env\n"); - rb_gc_mark_locations(env->env, env->env + env->env_size); - } - GC_INFO("env->prev_envval\n"); - MARK_UNLESS_NULL(env->prev_envval); - - if (env->block.iseq) { - if (BUILTIN_TYPE(env->block.iseq) == T_NODE) { - MARK_UNLESS_NULL((VALUE)env->block.iseq); - } - else { - MARK_UNLESS_NULL(env->block.iseq->self); - } - } - } - MARK_REPORT_LEAVE("env"); -} - -VALUE -yarv_env_alloc(void) -{ - VALUE obj; - yarv_env_t *env; - obj = Data_Make_Struct(rb_cEnv, yarv_env_t, env_mark, env_free, env); - env->env = 0; - env->prev_envval = 0; - env->block.iseq = 0; - return obj; -} - /* Proc */ static void @@ -99,14 +44,14 @@ proc_free(void *ptr) static void proc_mark(void *ptr) { - yarv_proc_t *proc; + rb_proc_t *proc; MARK_REPORT_ENTER("proc"); if (ptr) { proc = ptr; MARK_UNLESS_NULL(proc->envval); MARK_UNLESS_NULL(proc->blockprocval); MARK_UNLESS_NULL((VALUE)proc->special_cref_stack); - if (proc->block.iseq && YARV_IFUNC_P(proc->block.iseq)) { + if (proc->block.iseq && RUBY_VM_IFUNC_P(proc->block.iseq)) { MARK_UNLESS_NULL((VALUE)(proc->block.iseq)); } } @@ -117,20 +62,20 @@ static VALUE proc_alloc(VALUE klass) { VALUE obj; - yarv_proc_t *proc; - obj = Data_Make_Struct(klass, yarv_proc_t, proc_mark, proc_free, proc); - MEMZERO(proc, yarv_proc_t, 1); + rb_proc_t *proc; + obj = Data_Make_Struct(klass, rb_proc_t, proc_mark, proc_free, proc); + MEMZERO(proc, rb_proc_t, 1); return obj; } VALUE -yarv_proc_alloc(void) +rb_proc_alloc(void) { return proc_alloc(rb_cProc); } VALUE -yarv_obj_is_proc(VALUE proc) +rb_obj_is_proc(VALUE proc) { if (TYPE(proc) == T_DATA && RDATA(proc)->dfree == (RUBY_DATA_FUNC) proc_free) { @@ -145,7 +90,7 @@ static VALUE proc_dup(VALUE self) { VALUE procval = proc_alloc(rb_cProc); - yarv_proc_t *src, *dst; + rb_proc_t *src, *dst; GetProcPtr(self, src); GetProcPtr(procval, dst); @@ -158,12 +103,6 @@ proc_dup(VALUE self) } static VALUE -yarv_proc_dup(VALUE self) -{ - return proc_dup(self); -} - -static VALUE proc_clone(VALUE self) { VALUE procval = proc_dup(self); @@ -176,7 +115,7 @@ proc_clone(VALUE self) static void binding_free(void *ptr) { - yarv_binding_t *bind; + rb_binding_t *bind; FREE_REPORT_ENTER("binding"); if (ptr) { bind = ptr; @@ -188,7 +127,7 @@ binding_free(void *ptr) static void binding_mark(void *ptr) { - yarv_binding_t *bind; + rb_binding_t *bind; MARK_REPORT_ENTER("binding"); if (ptr) { bind = ptr; @@ -202,10 +141,10 @@ static VALUE binding_alloc(VALUE klass) { VALUE obj; - yarv_binding_t *bind; - obj = Data_Make_Struct(klass, yarv_binding_t, + rb_binding_t *bind; + obj = Data_Make_Struct(klass, rb_binding_t, binding_mark, binding_free, bind); - MEMZERO(bind, yarv_binding_t, 1); + MEMZERO(bind, rb_binding_t, 1); return obj; } @@ -213,7 +152,7 @@ static VALUE binding_dup(VALUE self) { VALUE bindval = binding_alloc(rb_cBinding); - yarv_binding_t *src, *dst; + rb_binding_t *src, *dst; GetBindingPtr(self, src); GetBindingPtr(bindval, dst); dst->env = src->env; @@ -232,10 +171,10 @@ binding_clone(VALUE self) VALUE rb_binding_new(void) { - yarv_thread_t *th = GET_THREAD(); - yarv_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp); + rb_thead_t *th = GET_THREAD(); + rb_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp); VALUE bindval = binding_alloc(rb_cBinding); - yarv_binding_t *bind; + rb_binding_t *bind; GetBindingPtr(bindval, bind); bind->env = th_make_env_object(th, cfp); @@ -302,18 +241,18 @@ static VALUE proc_new(VALUE klass, int is_lambda) { VALUE procval = Qnil; - yarv_thread_t *th = GET_THREAD(); - yarv_control_frame_t *cfp = th->cfp; - yarv_block_t *block; + rb_thead_t *th = GET_THREAD(); + rb_control_frame_t *cfp = th->cfp; + rb_block_t *block; if ((GC_GUARDED_PTR_REF(cfp->lfp[0])) != 0 && - !YARV_CLASS_SPECIAL_P(cfp->lfp[0])) { + !RUBY_VM_CLASS_SPECIAL_P(cfp->lfp[0])) { block = GC_GUARDED_PTR_REF(cfp->lfp[0]); } else { - cfp = YARV_PREVIOUS_CONTROL_FRAME(cfp); + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); if ((GC_GUARDED_PTR_REF(cfp->lfp[0])) != 0 && - !YARV_CLASS_SPECIAL_P(cfp->lfp[0])) { + !RUBY_VM_CLASS_SPECIAL_P(cfp->lfp[0])) { block = GC_GUARDED_PTR_REF(cfp->lfp[0]); if (is_lambda) { @@ -326,11 +265,11 @@ proc_new(VALUE klass, int is_lambda) } } - cfp = YARV_PREVIOUS_CONTROL_FRAME(cfp); + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); procval = th_make_proc(th, cfp, block); if (is_lambda) { - yarv_proc_t *proc; + rb_proc_t *proc; GetProcPtr(procval, proc); proc->is_lambda = Qtrue; } @@ -403,7 +342,7 @@ proc_lambda(void) VALUE proc_invoke(VALUE self, VALUE args, VALUE alt_self, VALUE alt_klass) { - yarv_proc_t *proc; + rb_proc_t *proc; GetProcPtr(self, proc); /* ignore self and klass */ @@ -448,7 +387,7 @@ proc_invoke(VALUE self, VALUE args, VALUE alt_self, VALUE alt_klass) static VALUE proc_call(int argc, VALUE *argv, VALUE procval) { - yarv_proc_t *proc; + rb_proc_t *proc; GetProcPtr(procval, proc); return th_invoke_proc(GET_THREAD(), proc, proc->block.self, argc, argv); } @@ -456,7 +395,7 @@ proc_call(int argc, VALUE *argv, VALUE procval) static VALUE proc_yield(int argc, VALUE *argv, VALUE procval) { - yarv_proc_t *proc; + rb_proc_t *proc; GetProcPtr(procval, proc); return th_invoke_proc(GET_THREAD(), proc, proc->block.self, argc, argv); } @@ -490,8 +429,8 @@ rb_proc_call(VALUE proc, VALUE args) static VALUE proc_arity(VALUE self) { - yarv_proc_t *proc; - yarv_iseq_t *iseq; + rb_proc_t *proc; + rb_iseq_t *iseq; GetProcPtr(self, proc); iseq = proc->block.iseq; if (iseq && BUILTIN_TYPE(iseq) != T_NODE) { @@ -531,7 +470,7 @@ proc_eq(VALUE self, VALUE other) if (TYPE(other) == T_DATA && RBASIC(other)->klass == rb_cProc && CLASS_OF(self) == CLASS_OF(other)) { - yarv_proc_t *p1, *p2; + rb_proc_t *p1, *p2; GetProcPtr(self, p1); GetProcPtr(other, p2); if (p1->block.iseq == p2->block.iseq && p1->envval == p2->envval) { @@ -553,7 +492,7 @@ static VALUE proc_hash(VALUE self) { int hash; - yarv_proc_t *proc; + rb_proc_t *proc; GetProcPtr(self, proc); hash = (long)proc->block.iseq; hash ^= (long)proc->envval; @@ -573,14 +512,14 @@ static VALUE proc_to_s(VALUE self) { VALUE str = 0; - yarv_proc_t *proc; + rb_proc_t *proc; char *cname = rb_obj_classname(self); - yarv_iseq_t *iseq; + rb_iseq_t *iseq; GetProcPtr(self, proc); iseq = proc->block.iseq; - if (YARV_NORMAL_ISEQ_P(iseq)) { + if (RUBY_VM_NORMAL_ISEQ_P(iseq)) { int line_no = 0; if (iseq->insn_info_tbl) { @@ -963,7 +902,7 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod) else if (argc == 2) { id = rb_to_id(argv[0]); body = argv[1]; - if (!rb_obj_is_method(body) && !yarv_obj_is_proc(body)) { + if (!rb_obj_is_method(body) && !rb_obj_is_proc(body)) { rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc/Method)", rb_obj_classname(body)); @@ -989,9 +928,9 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod) } node = method->body; } - else if (yarv_obj_is_proc(body)) { - yarv_proc_t *proc; - body = yarv_proc_dup(body); + else if (rb_obj_is_proc(body)) { + rb_proc_t *proc; + body = proc_dup(body); GetProcPtr(body, proc); if (BUILTIN_TYPE(proc->block.iseq) != T_NODE) { proc->block.iseq->defined_method_id = id; @@ -1221,8 +1160,8 @@ rb_node_arity(NODE* body) if (body->nd_opt || body->nd_rest) n = -n - 1; return n; - case YARV_METHOD_NODE:{ - yarv_iseq_t *iseq; + case RUBY_VM_METHOD_NODE:{ + rb_iseq_t *iseq; GetISeqPtr((VALUE)body->nd_body, iseq); if (iseq->arg_rest == 0 && iseq->arg_opts == 0) { return iseq->argc; @@ -1378,7 +1317,7 @@ rb_proc_new( VALUE (*func)(ANYARGS), /* VALUE yieldarg[, VALUE procarg] */ VALUE val) { - yarv_proc_t *proc; + rb_proc_t *proc; VALUE procval = rb_iterate((VALUE(*)(VALUE))mproc, 0, func, val); GetProcPtr(procval, proc); ((NODE*)proc->block.iseq)->u3.state = 1; @@ -1466,11 +1405,6 @@ localjump_reason(VALUE exc) void Init_Proc(void) { - /* Env */ - rb_cVM = rb_define_class("VM", rb_cObject); /* TODO: should be moved to suitable place */ - rb_cEnv = rb_define_class_under(rb_cVM, "Env", rb_cObject); - rb_undef_alloc_func(rb_cEnv); - /* Proc */ rb_cProc = rb_define_class("Proc", rb_cObject); rb_undef_alloc_func(rb_cProc); @@ -200,7 +200,7 @@ static VALUE rb_cProcStatus; void rb_last_status_set(int status, rb_pid_t pid) { - yarv_vm_t *vm = GET_VM(); + rb_vm_t *vm = GET_VM(); vm->last_status = rb_obj_alloc(rb_cProcStatus); rb_iv_set(vm->last_status, "status", INT2FIX(status)); rb_iv_set(vm->last_status, "pid", INT2FIX(pid)); @@ -712,6 +712,7 @@ RUBY_EXTERN VALUE rb_cTrueClass; RUBY_EXTERN VALUE rb_cUnboundMethod; RUBY_EXTERN VALUE rb_cISeq; RUBY_EXTERN VALUE rb_cVM; +RUBY_EXTERN VALUE rb_cEnv; RUBY_EXTERN VALUE rb_eException; RUBY_EXTERN VALUE rb_eStandardError; @@ -392,7 +392,7 @@ ruby_nativethread_signal(int signum, sighandler_t handler) static RETSIGTYPE sighandler(int sig) { - yarv_vm_t *vm = GET_VM(); /* fix me for Multi-VM */ + rb_vm_t *vm = GET_VM(); /* fix me for Multi-VM */ ATOMIC_INC(vm->signal_buff[sig]); ATOMIC_INC(vm->bufferd_signal_size); } @@ -431,7 +431,7 @@ rb_enable_interrupt(void) } int -rb_get_next_signal(yarv_vm_t *vm) +rb_get_next_signal(rb_vm_t *vm) { int i, sig = 0; @@ -496,7 +496,7 @@ rb_trap_exit(void) } void -rb_signal_exec(yarv_thread_t *th, int sig) +rb_signal_exec(rb_thead_t *th, int sig) { VALUE cmd = rb_get_trap_cmd(sig); @@ -528,7 +528,7 @@ rb_signal_exec(yarv_thread_t *th, int sig) rb_thread_signal_exit(th); } else { - yarv_proc_t *proc; + rb_proc_t *proc; VALUE signum = INT2FIX(sig); GetProcPtr(cmd, proc); th_invoke_proc(th, proc, proc->block.self, 1, &signum); @@ -28,7 +28,7 @@ scheduling, running thread release GVL. If running thread try blocking operation, this thread must release GVL and another thread can continue this flow. After blocking operation, thread - must check interrupt (YARV_CHECK_INTS). + must check interrupt (RUBY_VM_CHECK_INTS). Every VM can run parallel. @@ -52,14 +52,14 @@ #define THREAD_DEBUG 0 static void sleep_for_polling(); -static void sleep_timeval(yarv_thread_t *th, struct timeval time); -static void sleep_wait_for_interrupt(yarv_thread_t *th, double sleepsec); -static void sleep_forever(yarv_thread_t *th); +static void sleep_timeval(rb_thead_t *th, struct timeval time); +static void sleep_wait_for_interrupt(rb_thead_t *th, double sleepsec); +static void sleep_forever(rb_thead_t *th); static double timeofday(); struct timeval rb_time_interval(VALUE); -static int rb_thread_dead(yarv_thread_t *th); +static int rb_thread_dead(rb_thead_t *th); -void rb_signal_exec(yarv_thread_t *th, int sig); +void rb_signal_exec(rb_thead_t *th, int sig); void rb_disable_interrupt(); static VALUE eKillSignal = INT2FIX(0); @@ -76,12 +76,12 @@ st_delete_wrap(st_table * table, VALUE key) #define THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION -static void native_thread_interrupt(yarv_thread_t *th); -static void yarv_set_interrupt_function(yarv_thread_t *th, yarv_interrupt_function_t *func, int is_return); -static void yarv_clear_interrupt_function(yarv_thread_t *th); +static void native_thread_interrupt(rb_thead_t *th); +static void yarv_set_interrupt_function(rb_thead_t *th, rb_interrupt_function_t *func, int is_return); +static void yarv_clear_interrupt_function(rb_thead_t *th); #define GVL_UNLOCK_RANGE(exec) do { \ - yarv_thread_t *__th = GET_THREAD(); \ + rb_thead_t *__th = GET_THREAD(); \ int __prev_status = __th->status; \ yarv_set_interrupt_function(__th, native_thread_interrupt, 0); \ __th->status = THREAD_STOPPED; \ @@ -94,7 +94,7 @@ static void yarv_clear_interrupt_function(yarv_thread_t *th); if (__th->status == THREAD_STOPPED) { \ __th->status = __prev_status; \ } \ - YARV_CHECK_INTS(); \ + RUBY_VM_CHECK_INTS(); \ } while(0) #if THREAD_DEBUG @@ -125,7 +125,7 @@ void thread_debug(const char *fmt, ...); #if THREAD_DEBUG static int debug_mutex_initialized = 1; -static yarv_thread_lock_t debug_mutex; +static rb_thread_lock_t debug_mutex; void thread_debug(const char *fmt, ...) @@ -148,10 +148,10 @@ thread_debug(const char *fmt, ...) static void -yarv_set_interrupt_function(yarv_thread_t *th, yarv_interrupt_function_t *func, int is_return) +yarv_set_interrupt_function(rb_thead_t *th, rb_interrupt_function_t *func, int is_return) { check_ints: - YARV_CHECK_INTS(); + RUBY_VM_CHECK_INTS(); native_mutex_lock(&th->interrupt_lock); if (th->interrupt_flag) { native_mutex_unlock(&th->interrupt_lock); @@ -169,7 +169,7 @@ yarv_set_interrupt_function(yarv_thread_t *th, yarv_interrupt_function_t *func, } static void -yarv_clear_interrupt_function(yarv_thread_t *th) +yarv_clear_interrupt_function(rb_thead_t *th) { native_mutex_lock(&th->interrupt_lock); th->interrupt_function = 0; @@ -177,7 +177,7 @@ yarv_clear_interrupt_function(yarv_thread_t *th) } static void -rb_thread_interrupt(yarv_thread_t *th) +rb_thread_interrupt(rb_thead_t *th) { native_mutex_lock(&th->interrupt_lock); th->interrupt_flag = 1; @@ -193,10 +193,10 @@ rb_thread_interrupt(yarv_thread_t *th) static int -terminate_i(st_data_t key, st_data_t val, yarv_thread_t *main_thread) +terminate_i(st_data_t key, st_data_t val, rb_thead_t *main_thread) { VALUE thval = key; - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thval, th); if (th != main_thread) { @@ -214,8 +214,8 @@ terminate_i(st_data_t key, st_data_t val, yarv_thread_t *main_thread) void rb_thread_terminate_all(void) { - yarv_thread_t *th = GET_THREAD(); /* main thread */ - yarv_vm_t *vm = th->vm; + rb_thead_t *th = GET_THREAD(); /* main thread */ + rb_vm_t *vm = th->vm; if (vm->main_thread != th) { rb_bug("rb_thread_terminate_all: called by child thread (%p, %p)", vm->main_thread, th); } @@ -230,24 +230,24 @@ rb_thread_terminate_all(void) } -VALUE th_eval_body(yarv_thread_t *th); +VALUE th_eval_body(rb_thead_t *th); static void thread_cleanup_func(void *th_ptr) { - yarv_thread_t *th = th_ptr; + rb_thead_t *th = th_ptr; th->status = THREAD_KILLED; th->machine_stack_start = th->machine_stack_end = 0; } static int -thread_start_func_2(yarv_thread_t *th, VALUE *stack_start) +thread_start_func_2(rb_thead_t *th, VALUE *stack_start) { int state; VALUE args = th->first_args; - yarv_proc_t *proc; - yarv_thread_t *join_th; + rb_proc_t *proc; + rb_thead_t *join_th; th->machine_stack_start = stack_start; th->thgroup = th->vm->thgroup_default; @@ -256,7 +256,7 @@ thread_start_func_2(yarv_thread_t *th, VALUE *stack_start) native_mutex_lock(&th->vm->global_interpreter_lock); { thread_debug("thread start (get lock): %p\n", th); - yarv_set_current_running_thread(th); + rb_thread_set_current(th); TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { @@ -293,16 +293,14 @@ thread_start_func_2(yarv_thread_t *th, VALUE *stack_start) return 0; } -VALUE yarv_thread_alloc(VALUE klass); - static VALUE thread_create_core(VALUE klass, VALUE args, VALUE (*fn)(ANYARGS), void *arg) { - yarv_thread_t *th; + rb_thead_t *th; VALUE thval; /* create thread object */ - thval = yarv_thread_alloc(klass); + thval = rb_thread_alloc(klass); GetThreadPtr(thval, th); /* setup thread environment */ @@ -348,9 +346,9 @@ rb_thread_create(VALUE (*fn)(ANYARGS), void *arg) VALUE th_make_jump_tag_but_local_jump(int state, VALUE val); static VALUE -thread_join(yarv_thread_t *target_th, double delay) +thread_join(rb_thead_t *target_th, double delay) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); double now, limit = timeofday() + delay; thread_debug("thread_join (thid: %p)\n", target_th->thread_id); @@ -440,7 +438,7 @@ thread_join(yarv_thread_t *target_th, double delay) static VALUE thread_join_m(int argc, VALUE *argv, VALUE self) { - yarv_thread_t *target_th; + rb_thead_t *target_th; double delay = DELAY_INFTY; VALUE limit; @@ -467,7 +465,7 @@ thread_join_m(int argc, VALUE *argv, VALUE self) static VALUE thread_value(VALUE self) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(self, th); thread_join(th, DELAY_INFTY); return th->value; @@ -492,14 +490,14 @@ double2timeval(double d) } static void -sleep_forever(yarv_thread_t *th) +sleep_forever(rb_thead_t *th) { native_sleep(th, 0); - YARV_CHECK_INTS(); + RUBY_VM_CHECK_INTS(); } static void -sleep_timeval(yarv_thread_t *th, struct timeval tv) +sleep_timeval(rb_thead_t *th, struct timeval tv) { native_sleep(th, &tv); } @@ -520,13 +518,13 @@ timeofday(void) } static void -sleep_wait_for_interrupt(yarv_thread_t *th, double sleepsec) +sleep_wait_for_interrupt(rb_thead_t *th, double sleepsec) { sleep_timeval(th, double2timeval(sleepsec)); } static void -sleep_for_polling(yarv_thread_t *th) +sleep_for_polling(rb_thead_t *th) { struct timeval time; time.tv_sec = 0; @@ -537,7 +535,7 @@ sleep_for_polling(yarv_thread_t *th) void rb_thread_wait_for(struct timeval time) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); sleep_timeval(th, time); } @@ -545,7 +543,7 @@ void rb_thread_polling(void) { if (!rb_thread_alone()) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); sleep_for_polling(th); } } @@ -563,7 +561,7 @@ rb_thread_schedule() { thread_debug("rb_thread_schedule\n"); if (!rb_thread_alone()) { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); thread_debug("rb_thread_schedule/switch start\n"); @@ -574,10 +572,10 @@ rb_thread_schedule() } native_mutex_lock(&th->vm->global_interpreter_lock); - yarv_set_current_running_thread(th); + rb_thread_set_current(th); thread_debug("rb_thread_schedule/switch done\n"); - YARV_CHECK_INTS(); + RUBY_VM_CHECK_INTS(); } } @@ -592,10 +590,10 @@ rb_thread_s_critical(VALUE self) VALUE -rb_thread_run_parallel(VALUE(*func)(yarv_thread_t *th, void *), void *data) +rb_thread_run_parallel(VALUE(*func)(rb_thead_t *th, void *), void *data) { VALUE val; - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); GVL_UNLOCK_RANGE({ val = func(th, data); @@ -637,7 +635,7 @@ thread_s_pass(VALUE klass) */ void -yarv_thread_execute_interrupts(yarv_thread_t *th) +rb_thread_execute_interrupts(rb_thead_t *th) { while (th->interrupt_flag) { int status = th->status; @@ -655,14 +653,14 @@ yarv_thread_execute_interrupts(yarv_thread_t *th) if (th->throwed_errinfo) { VALUE err = th->throwed_errinfo; th->throwed_errinfo = 0; - thread_debug("yarv_thread_execute_interrupts: %p\n", err); + thread_debug("rb_thread_execute_interrupts: %p\n", err); if (err == eKillSignal) { th->errinfo = INT2FIX(TAG_FATAL); TH_JUMP_TAG(th, TAG_FATAL); } else if (err == eTerminateSignal) { - struct yarv_tag *tag = th->tag; + struct rb_vm_tag *tag = th->tag; /* rewind to toplevel stack */ while (th->tag->prev) { @@ -693,13 +691,13 @@ rb_gc_mark_threads() /*****************************************************/ static void -rb_thread_ready(yarv_thread_t *th) +rb_thread_ready(rb_thead_t *th) { rb_thread_interrupt(th); } static VALUE -yarv_thread_raise(int argc, VALUE *argv, yarv_thread_t *th) +yarv_thread_raise(int argc, VALUE *argv, rb_thead_t *th) { VALUE exc; @@ -719,7 +717,7 @@ rb_thread_signal_raise(void *thptr, const char *sig) { VALUE argv[1]; char buf[BUFSIZ]; - yarv_thread_t *th = thptr; + rb_thead_t *th = thptr; if (sig == 0) { return; /* should not happen */ @@ -734,7 +732,7 @@ rb_thread_signal_exit(void *thptr) { VALUE argv[1]; VALUE args[2]; - yarv_thread_t *th = thptr; + rb_thead_t *th = thptr; args[0] = INT2NUM(EXIT_SUCCESS); args[1] = rb_str_new2("exit"); @@ -743,7 +741,7 @@ rb_thread_signal_exit(void *thptr) } int -thread_set_raised(yarv_thread_t *th) +thread_set_raised(rb_thead_t *th) { if (th->raised_flag) { return 1; @@ -753,7 +751,7 @@ thread_set_raised(yarv_thread_t *th) } int -thread_reset_raised(yarv_thread_t *th) +thread_reset_raised(rb_thead_t *th) { if (th->raised_flag == 0) { return 0; @@ -790,7 +788,7 @@ rb_thread_fd_close(int fd) static VALUE thread_raise_m(int argc, VALUE *argv, VALUE self) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(self, th); yarv_thread_raise(argc, argv, th); return Qnil; @@ -812,7 +810,7 @@ thread_raise_m(int argc, VALUE *argv, VALUE self) VALUE rb_thread_kill(VALUE thread) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thread, th); @@ -892,7 +890,7 @@ rb_thread_exit() VALUE rb_thread_wakeup(VALUE thread) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thread, th); if (th->status == THREAD_KILLED) { @@ -967,7 +965,7 @@ static int thread_list_i(st_data_t key, st_data_t val, void *data) { VALUE ary = (VALUE)data; - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr((VALUE)key, th); switch (th->status) { @@ -1109,7 +1107,7 @@ rb_thread_s_abort_exc_set(VALUE self, VALUE val) static VALUE rb_thread_abort_exc(VALUE thread) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thread, th); return th->abort_on_exception ? Qtrue : Qfalse; } @@ -1127,7 +1125,7 @@ rb_thread_abort_exc(VALUE thread) static VALUE rb_thread_abort_exc_set(VALUE thread, VALUE val) { - yarv_thread_t *th; + rb_thead_t *th; rb_secure(4); GetThreadPtr(thread, th); @@ -1149,7 +1147,7 @@ rb_thread_abort_exc_set(VALUE thread, VALUE val) VALUE rb_thread_group(VALUE thread) { - yarv_thread_t *th; + rb_thead_t *th; VALUE group; GetThreadPtr(thread, th); group = th->thgroup; @@ -1161,7 +1159,7 @@ rb_thread_group(VALUE thread) } static const char * -thread_status_name(enum yarv_thread_status status) +thread_status_name(enum rb_thread_status status) { switch (status) { case THREAD_RUNNABLE: @@ -1178,7 +1176,7 @@ thread_status_name(enum yarv_thread_status status) } static int -rb_thread_dead(yarv_thread_t *th) +rb_thread_dead(rb_thead_t *th) { return th->status == THREAD_KILLED; } @@ -1210,7 +1208,7 @@ rb_thread_dead(yarv_thread_t *th) static VALUE rb_thread_status(VALUE thread) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thread, th); if (rb_thread_dead(th)) { @@ -1239,7 +1237,7 @@ rb_thread_status(VALUE thread) static VALUE rb_thread_alive_p(VALUE thread) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thread, th); if (rb_thread_dead(th)) @@ -1262,7 +1260,7 @@ rb_thread_alive_p(VALUE thread) static VALUE rb_thread_stop_p(VALUE thread) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thread, th); if (rb_thread_dead(th)) @@ -1287,7 +1285,7 @@ rb_thread_stop_p(VALUE thread) static VALUE rb_thread_safe_level(VALUE thread) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thread, th); return INT2NUM(th->safe_level); @@ -1304,7 +1302,7 @@ static VALUE rb_thread_inspect(VALUE thread) { char *cname = rb_obj_classname(thread); - yarv_thread_t *th; + rb_thead_t *th; const char *status; VALUE str; @@ -1319,7 +1317,7 @@ rb_thread_inspect(VALUE thread) VALUE rb_thread_local_aref(VALUE thread, ID id) { - yarv_thread_t *th; + rb_thead_t *th; VALUE val; GetThreadPtr(thread, th); @@ -1365,7 +1363,7 @@ rb_thread_aref(VALUE thread, VALUE id) VALUE rb_thread_local_aset(VALUE thread, ID id, VALUE val) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thread, th); if (rb_safe_level() >= 4 && th != GET_THREAD()) { @@ -1415,7 +1413,7 @@ rb_thread_aset(VALUE self, ID id, VALUE val) static VALUE rb_thread_key_p(VALUE self, ID id) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(self, th); if (!th->local_storage) { @@ -1462,7 +1460,7 @@ rb_thread_alone() static VALUE rb_thread_keys(VALUE self) { - yarv_thread_t *th; + rb_thead_t *th; VALUE ary = rb_ary_new(); GetThreadPtr(self, th); @@ -1485,7 +1483,7 @@ rb_thread_keys(VALUE self) static VALUE rb_thread_priority(VALUE thread) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thread, th); return INT2NUM(th->priority); } @@ -1517,7 +1515,7 @@ rb_thread_priority(VALUE thread) static VALUE rb_thread_priority_set(VALUE thread, VALUE prio) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thread, th); rb_secure(4); @@ -1734,7 +1732,7 @@ rb_gc_set_stack_end(VALUE **stack_end_p) } void -rb_gc_save_machine_context(yarv_thread_t *th) +rb_gc_save_machine_context(rb_thead_t *th) { rb_gc_set_stack_end(&th->machine_stack_end); setjmp(th->machine_regs); @@ -1744,12 +1742,12 @@ rb_gc_save_machine_context(yarv_thread_t *th) * */ -int rb_get_next_signal(yarv_vm_t *vm); +int rb_get_next_signal(rb_vm_t *vm); static void timer_thread_function(void) { - yarv_vm_t *vm = GET_VM(); /* TODO: fix me for Multi-VM */ + rb_vm_t *vm = GET_VM(); /* TODO: fix me for Multi-VM */ vm->running_thread->interrupt_flag = 1; if (vm->bufferd_signal_size && vm->main_thread->exec_signal == 0) { @@ -1786,8 +1784,8 @@ rb_thread_start_timer_thread(void) void rb_thread_atfork(void) { - yarv_thread_t *th = GET_THREAD(); - yarv_vm_t *vm = th->vm; + rb_thead_t *th = GET_THREAD(); + rb_vm_t *vm = th->vm; vm->main_thread = th; st_free_table(vm->living_threads); @@ -1854,7 +1852,7 @@ thgroup_list_i(st_data_t key, st_data_t val, st_data_t data) VALUE thread = (VALUE)key; VALUE ary = ((struct thgroup_list_params *)data)->ary; VALUE group = ((struct thgroup_list_params *)data)->group; - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thread, th); if (th->thgroup == group) { @@ -1965,7 +1963,7 @@ thgroup_enclosed_p(VALUE group) static VALUE thgroup_add(VALUE group, VALUE thread) { - yarv_thread_t *th; + rb_thead_t *th; struct thgroup *data; rb_secure(4); @@ -2001,8 +1999,8 @@ thgroup_add(VALUE group, VALUE thread) */ typedef struct mutex_struct { - yarv_thread_t *th; - yarv_thread_lock_t lock; + rb_thead_t *th; + rb_thread_lock_t lock; } mutex_t; #define GetMutexVal(obj, tobj) \ @@ -2375,7 +2373,7 @@ Init_Thread(void) rb_define_method(cThGroup, "add", thgroup_add, 1); { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); th->thgroup = th->vm->thgroup_default = rb_obj_alloc(cThGroup); rb_define_const(cThGroup, "Default", th->thgroup); } @@ -2402,7 +2400,7 @@ Init_Thread(void) /* main thread setting */ { /* acquire global interpreter lock */ - yarv_thread_lock_t *lp = &GET_THREAD()->vm->global_interpreter_lock; + rb_thread_lock_t *lp = &GET_THREAD()->vm->global_interpreter_lock; native_mutex_initialize(lp); native_mutex_lock(lp); native_mutex_initialize(&GET_THREAD()->interrupt_lock); diff --git a/thread_pthread.ci b/thread_pthread.ci index fe7086dc61..c5f2ebbac7 100644 --- a/thread_pthread.ci +++ b/thread_pthread.ci @@ -21,10 +21,10 @@ #define native_cleanup_pop pthread_cleanup_pop #define native_thread_yield() sched_yield() -static void yarv_add_signal_thread_list(yarv_thread_t *th); -static void yarv_remove_signal_thread_list(yarv_thread_t *th); +static void yarv_add_signal_thread_list(rb_thead_t *th); +static void yarv_remove_signal_thread_list(rb_thead_t *th); -static yarv_thread_lock_t signal_thread_list_lock; +static rb_thread_lock_t signal_thread_list_lock; static void null_func() @@ -40,10 +40,10 @@ Init_native_thread() } NOINLINE(static int - thread_start_func_2(yarv_thread_t *th, VALUE *stack_start)); + thread_start_func_2(rb_thead_t *th, VALUE *stack_start)); void static thread_cleanup_func(void *th_ptr); -static yarv_thread_t *register_cached_thread_and_wait(void); +static rb_thead_t *register_cached_thread_and_wait(void); #define USE_THREAD_CACHE 0 @@ -54,7 +54,7 @@ thread_start_func_1(void *th_ptr) thread_start: #endif { - yarv_thread_t *th = th_ptr; + rb_thead_t *th = th_ptr; VALUE stack_start; /* ignore self and klass */ @@ -70,7 +70,7 @@ thread_start_func_1(void *th_ptr) #if USE_THREAD_CACHE if (1) { /* cache thread */ - yarv_thread_t *th; + rb_thead_t *th; if ((th = register_cached_thread_and_wait()) != 0) { th_ptr = (void *)th; th->thread_id = pthread_self(); @@ -86,18 +86,18 @@ void rb_thread_create_control_thread(void); static pthread_mutex_t thread_cache_lock = PTHREAD_MUTEX_INITIALIZER; struct cached_thread_entry { - volatile yarv_thread_t **th_area; + volatile rb_thead_t **th_area; pthread_cond_t *cond; struct cached_thread_entry *next; }; struct cached_thread_entry *cached_thread_root; -static yarv_thread_t * +static rb_thead_t * register_cached_thread_and_wait(void) { pthread_cond_t cond = PTHREAD_COND_INITIALIZER; - volatile yarv_thread_t *th_area = 0; + volatile rb_thead_t *th_area = 0; struct cached_thread_entry *entry = (struct cached_thread_entry *)malloc(sizeof(struct cached_thread_entry)); @@ -140,11 +140,11 @@ register_cached_thread_and_wait(void) } pthread_mutex_unlock(&thread_cache_lock); - return (yarv_thread_t *)th_area; + return (rb_thead_t *)th_area; } static int -use_cached_thread(yarv_thread_t *th) +use_cached_thread(rb_thead_t *th) { int result = 0; #if USE_THREAD_CACHE @@ -170,7 +170,7 @@ use_cached_thread(yarv_thread_t *th) } static int -native_thread_create(yarv_thread_t *th) +native_thread_create(rb_thead_t *th) { int err = 0; @@ -215,7 +215,7 @@ native_thread_join(pthread_t th) } static void -native_thread_apply_priority(yarv_thread_t *th) +native_thread_apply_priority(rb_thead_t *th) { struct sched_param sp; int policy; @@ -237,14 +237,14 @@ native_thread_apply_priority(yarv_thread_t *th) } static void -interrupt_using_pthread_cond_signal(yarv_thread_t *th) +interrupt_using_pthread_cond_signal(rb_thead_t *th) { thread_debug("interrupt_using_pthread_cond_signal (%p)\n", th); pthread_cond_signal(&th->native_thread_data.sleep_cond); } static void -native_thread_send_interrupt_signal(yarv_thread_t *th) +native_thread_send_interrupt_signal(rb_thead_t *th) { thread_debug("native_thread_send_interrupt_signal (%p)\n", th->thread_id); if (th) { @@ -253,7 +253,7 @@ native_thread_send_interrupt_signal(yarv_thread_t *th) } static void -native_sleep(yarv_thread_t *th, struct timeval *tv) +native_sleep(rb_thead_t *th, struct timeval *tv) { int prev_status = th->status; struct timespec ts; @@ -308,13 +308,13 @@ native_sleep(yarv_thread_t *th, struct timeval *tv) } static void -native_thread_interrupt(yarv_thread_t *th) +native_thread_interrupt(rb_thead_t *th) { yarv_add_signal_thread_list(th); } struct yarv_signal_thread_list { - yarv_thread_t *th; + rb_thead_t *th; struct yarv_signal_thread_list *prev; struct yarv_signal_thread_list *next; }; @@ -345,7 +345,7 @@ print_signal_list(char *str) } static void -yarv_add_signal_thread_list(yarv_thread_t *th) +yarv_add_signal_thread_list(rb_thead_t *th) { if (!th->native_thread_data.signal_thread_list) { FGLOCK(&signal_thread_list_lock, { @@ -371,7 +371,7 @@ yarv_add_signal_thread_list(yarv_thread_t *th) } static void -yarv_remove_signal_thread_list(yarv_thread_t *th) +yarv_remove_signal_thread_list(rb_thead_t *th) { if (th->native_thread_data.signal_thread_list) { FGLOCK(&signal_thread_list_lock, { diff --git a/thread_pthread.h b/thread_pthread.h index 9783edea98..29306e0e19 100644 --- a/thread_pthread.h +++ b/thread_pthread.h @@ -13,8 +13,8 @@ #define THREAD_PTHREAD_H_INCLUDED #include <pthread.h> -typedef pthread_t yarv_thread_id_t; -typedef pthread_mutex_t yarv_thread_lock_t; +typedef pthread_t rb_thread_id_t; +typedef pthread_mutex_t rb_thread_lock_t; #define native_mutex_lock pthread_mutex_lock #define native_mutex_unlock pthread_mutex_unlock diff --git a/thread_win32.ci b/thread_win32.ci index 3dd66932e1..27ea4f0117 100644 --- a/thread_win32.ci +++ b/thread_win32.ci @@ -23,7 +23,7 @@ static void Init_native_thread() { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), @@ -53,7 +53,7 @@ w32_show_error_message() } static int -w32_wait_event(HANDLE event, DWORD timeout, yarv_thread_t *th) +w32_wait_event(HANDLE event, DWORD timeout, rb_thead_t *th) { HANDLE events[2]; int count = 0; @@ -94,7 +94,7 @@ w32_wait_event(HANDLE event, DWORD timeout, yarv_thread_t *th) } static void -native_sleep(yarv_thread_t *th, struct timeval *tv) +native_sleep(rb_thead_t *th, struct timeval *tv) { DWORD msec; if (tv) { @@ -120,7 +120,7 @@ native_sleep(yarv_thread_t *th, struct timeval *tv) } int -native_mutex_lock(yarv_thread_lock_t *lock) +native_mutex_lock(rb_thread_lock_t *lock) { #if USE_WIN32_MUTEX DWORD result; @@ -156,7 +156,7 @@ native_mutex_lock(yarv_thread_lock_t *lock) } int -native_mutex_unlock(yarv_thread_lock_t *lock) +native_mutex_unlock(rb_thread_lock_t *lock) { #if USE_WIN32_MUTEX thread_debug("release mutex: %p\n", *lock); @@ -168,7 +168,7 @@ native_mutex_unlock(yarv_thread_lock_t *lock) } int -native_mutex_trylock(yarv_thread_lock_t *lock) +native_mutex_trylock(rb_thread_lock_t *lock) { #if USE_WIN32MUTEX int result; @@ -188,7 +188,7 @@ native_mutex_trylock(yarv_thread_lock_t *lock) } void -native_mutex_initialize(yarv_thread_lock_t *lock) +native_mutex_initialize(rb_thread_lock_t *lock) { #if USE_WIN32MUTEX *lock = CreateMutex(NULL, FALSE, NULL); @@ -199,13 +199,13 @@ native_mutex_initialize(yarv_thread_lock_t *lock) } NOINLINE(static int - thread_start_func_2(yarv_thread_t *th, VALUE *stack_start)); + thread_start_func_2(rb_thead_t *th, VALUE *stack_start)); void static thread_cleanup_func(void *th_ptr); static unsigned int _stdcall thread_start_func_1(void *th_ptr) { - yarv_thread_t *th = th_ptr; + rb_thead_t *th = th_ptr; VALUE stack_start; /* run */ th->native_thread_data.interrupt_event = CreateEvent(0, TRUE, FALSE, 0); @@ -241,7 +241,7 @@ w32_create_thread(DWORD stack_size, void *func, void *val) } static int -native_thread_create(yarv_thread_t *th) +native_thread_create(rb_thead_t *th) { size_t stack_size = 4 * 1024 - sizeof(int); /* 4KB */ @@ -266,7 +266,7 @@ native_thread_join(HANDLE th) } static void -native_thread_apply_priority(yarv_thread_t *th) +native_thread_apply_priority(rb_thead_t *th) { int priority = th->priority; if (th->priority > 0) { @@ -283,7 +283,7 @@ native_thread_apply_priority(yarv_thread_t *th) } static void -native_thread_interrupt(yarv_thread_t *th) +native_thread_interrupt(rb_thead_t *th) { thread_debug("native_thread_interrupt: %p\n", th); SetEvent(th->native_thread_data.interrupt_event); diff --git a/thread_win32.h b/thread_win32.h index 8be59b0c1b..c02e406795 100644 --- a/thread_win32.h +++ b/thread_win32.h @@ -18,13 +18,13 @@ WINBASEAPI BOOL WINAPI TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection); -typedef HANDLE yarv_thread_id_t; -typedef CRITICAL_SECTION yarv_thread_lock_t; +typedef HANDLE rb_thread_id_t; +typedef CRITICAL_SECTION rb_thread_lock_t; -int native_mutex_lock(yarv_thread_lock_t *); -int native_mutex_unlock(yarv_thread_lock_t *); -int native_mutex_trylock(yarv_thread_lock_t *); -void native_mutex_initialize(yarv_thread_lock_t *); +int native_mutex_lock(rb_thread_lock_t *); +int native_mutex_unlock(rb_thread_lock_t *); +int native_mutex_trylock(rb_thread_lock_t *); +void native_mutex_initialize(rb_thread_lock_t *); typedef struct native_thread_data_struct { HANDLE interrupt_event; @@ -12,6 +12,7 @@ #include "ruby.h" #include "node.h" #include "st.h" +#include "gc.h" #include "yarvcore.h" #include "vm.h" @@ -20,6 +21,8 @@ #include "insns.inc" #include "eval_intern.h" +VALUE rb_cEnv; + #define PROCDEBUG 0 #define VM_DEBUG 0 @@ -38,12 +41,12 @@ void vm_analysis_register(int reg, int isset); void vm_analysis_insn(int insn); static inline VALUE - th_invoke_yield_cfunc(yarv_thread_t *th, yarv_block_t *block, + th_invoke_yield_cfunc(rb_thead_t *th, rb_block_t *block, VALUE self, int argc, VALUE *argv); -VALUE th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc, +VALUE th_invoke_proc(rb_thead_t *th, rb_proc_t *proc, VALUE self, int argc, VALUE *argv); -VALUE th_eval_body(yarv_thread_t *th); +VALUE th_eval_body(rb_thead_t *th); static NODE *lfp_get_special_cref(VALUE *lfp); static NODE *lfp_set_special_cref(VALUE *lfp, NODE * cref); @@ -66,13 +69,13 @@ rb_vm_change_state(void) /* * prepare stack frame */ -static inline yarv_control_frame_t * -push_frame(yarv_thread_t *th, yarv_iseq_t *iseq, VALUE magic, +static inline rb_control_frame_t * +push_frame(rb_thead_t *th, rb_iseq_t *iseq, VALUE magic, VALUE self, VALUE specval, VALUE *pc, VALUE *sp, VALUE *lfp, int local_size) { VALUE *dfp; - yarv_control_frame_t *cfp; + rb_control_frame_t *cfp; int i; /* nil initialize */ @@ -112,14 +115,14 @@ push_frame(yarv_thread_t *th, yarv_iseq_t *iseq, VALUE magic, } static inline void -pop_frame(yarv_thread_t *th) +pop_frame(rb_thead_t *th) { #if COLLECT_PROFILE - yarv_control_frame_t *cfp = th->cfp; + rb_control_frame_t *cfp = th->cfp; - if (YARV_NORMAL_ISEQ_P(cfp->iseq)) { + if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { VALUE current_time = clock(); - yarv_control_frame_t *cfp = th->cfp; + rb_control_frame_t *cfp = th->cfp; cfp->prof_time_self = current_time - cfp->prof_time_self; (cfp+1)->prof_time_chld += cfp->prof_time_self; @@ -131,13 +134,13 @@ pop_frame(yarv_thread_t *th) } #endif - th->cfp = YARV_PREVIOUS_CONTROL_FRAME(th->cfp); + th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); } EXTERN VALUE ruby_top_self; VALUE -th_set_finish_env(yarv_thread_t *th) +th_set_finish_env(rb_thead_t *th) { push_frame(th, 0, FRAME_MAGIC_FINISH, Qnil, th->cfp->lfp[0], 0, @@ -147,9 +150,9 @@ th_set_finish_env(yarv_thread_t *th) } void -th_set_top_stack(yarv_thread_t *th, VALUE iseqval) +th_set_top_stack(rb_thead_t *th, VALUE iseqval) { - yarv_iseq_t *iseq; + rb_iseq_t *iseq; GetISeqPtr(iseqval, iseq); if (iseq->type != ISEQ_TYPE_TOP) { @@ -165,10 +168,10 @@ th_set_top_stack(yarv_thread_t *th, VALUE iseqval) } VALUE -th_set_eval_stack(yarv_thread_t *th, VALUE iseqval) +th_set_eval_stack(rb_thead_t *th, VALUE iseqval) { - yarv_iseq_t *iseq; - yarv_block_t *block = th->base_block; + rb_iseq_t *iseq; + rb_block_t *block = th->base_block; GetISeqPtr(iseqval, iseq); /* for return */ @@ -179,14 +182,69 @@ th_set_eval_stack(yarv_thread_t *th, VALUE iseqval) return 0; } -static int check_env(yarv_env_t *env); + +/* Env */ + +static void +env_free(void *ptr) +{ + rb_env_t *env; + FREE_REPORT_ENTER("env"); + if (ptr) { + env = ptr; + FREE_UNLESS_NULL(env->env); + ruby_xfree(ptr); + } + FREE_REPORT_LEAVE("env"); +} + +static void +env_mark(void *ptr) +{ + rb_env_t *env; + MARK_REPORT_ENTER("env"); + if (ptr) { + env = ptr; + if (env->env) { + /* TODO: should mark more restricted range */ + GC_INFO("env->env\n"); + rb_gc_mark_locations(env->env, env->env + env->env_size); + } + GC_INFO("env->prev_envval\n"); + MARK_UNLESS_NULL(env->prev_envval); + + if (env->block.iseq) { + if (BUILTIN_TYPE(env->block.iseq) == T_NODE) { + MARK_UNLESS_NULL((VALUE)env->block.iseq); + } + else { + MARK_UNLESS_NULL(env->block.iseq->self); + } + } + } + MARK_REPORT_LEAVE("env"); +} + +static VALUE +env_alloc(void) +{ + VALUE obj; + rb_env_t *env; + obj = Data_Make_Struct(rb_cEnv, rb_env_t, env_mark, env_free, env); + env->env = 0; + env->prev_envval = 0; + env->block.iseq = 0; + return obj; +} + +static int check_env(rb_env_t *env); static VALUE -th_make_env_each(yarv_thread_t *th, yarv_control_frame_t *cfp, +th_make_env_each(rb_thead_t *th, rb_control_frame_t *cfp, VALUE *envptr, VALUE *endptr) { VALUE envval, penvval = 0; - yarv_env_t *env; + rb_env_t *env; VALUE *nenvptr; int i, local_size; @@ -196,7 +254,7 @@ th_make_env_each(yarv_thread_t *th, yarv_control_frame_t *cfp, if (envptr != endptr) { VALUE *penvptr = GC_GUARDED_PTR_REF(*envptr); - yarv_control_frame_t *pcfp = cfp; + rb_control_frame_t *pcfp = cfp; if (ENV_IN_HEAP_P(penvptr)) { penvval = ENV_VAL(penvptr); @@ -217,10 +275,10 @@ th_make_env_each(yarv_thread_t *th, yarv_control_frame_t *cfp, } /* allocate env */ - envval = yarv_env_alloc(); + envval = env_alloc(); GetEnvPtr(envval, env); - if (!YARV_NORMAL_ISEQ_P(cfp->iseq)) { + if (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { local_size = 2; } else { @@ -235,7 +293,7 @@ th_make_env_each(yarv_thread_t *th, yarv_control_frame_t *cfp, for (i = 0; i <= local_size; i++) { env->env[i] = envptr[-local_size + i]; // dp(env->env[i]); - if (YARV_NORMAL_ISEQ_P(cfp->iseq)) { + if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { /* clear value stack for GC */ // envptr[-local_size + i] = 0; } @@ -266,7 +324,7 @@ th_make_env_each(yarv_thread_t *th, yarv_control_frame_t *cfp, rb_bug("illegal svar"); } - if (!YARV_NORMAL_ISEQ_P(cfp->iseq)) { + if (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { /* TODO */ env->block.iseq = 0; } @@ -276,7 +334,7 @@ th_make_env_each(yarv_thread_t *th, yarv_control_frame_t *cfp, static VALUE check_env_value(VALUE envval); static int -check_env(yarv_env_t *env) +check_env(rb_env_t *env) { printf("---\n"); printf("envptr: %p\n", &env->block.dfp[0]); @@ -299,7 +357,7 @@ check_env(yarv_env_t *env) static VALUE check_env_value(VALUE envval) { - yarv_env_t *env; + rb_env_t *env; GetEnvPtr(envval, env); if (check_env(env)) { @@ -310,7 +368,7 @@ check_env_value(VALUE envval) } static int -collect_local_variables_in_env(yarv_env_t *env, VALUE ary) +collect_local_variables_in_env(rb_env_t *env, VALUE ary) { int i; if (env->block.lfp == env->block.dfp) { @@ -330,10 +388,10 @@ collect_local_variables_in_env(yarv_env_t *env, VALUE ary) } int -th_collect_local_variables_in_heap(yarv_thread_t *th, VALUE *dfp, VALUE ary) +th_collect_local_variables_in_heap(rb_thead_t *th, VALUE *dfp, VALUE ary) { if (ENV_IN_HEAP_P(dfp)) { - yarv_env_t *env; + rb_env_t *env; GetEnvPtr(ENV_VAL(dfp), env); collect_local_variables_in_env(env, ary); return 1; @@ -345,7 +403,7 @@ th_collect_local_variables_in_heap(yarv_thread_t *th, VALUE *dfp, VALUE ary) VALUE -th_make_env_object(yarv_thread_t *th, yarv_control_frame_t *cfp) +th_make_env_object(rb_thead_t *th, rb_control_frame_t *cfp) { VALUE envval; // SDR2(cfp); @@ -357,18 +415,18 @@ th_make_env_object(yarv_thread_t *th, yarv_control_frame_t *cfp) } static VALUE -th_make_proc_from_block(yarv_thread_t *th, yarv_control_frame_t *cfp, - yarv_block_t *block) +th_make_proc_from_block(rb_thead_t *th, rb_control_frame_t *cfp, + rb_block_t *block) { VALUE procval; - yarv_control_frame_t *bcfp; + rb_control_frame_t *bcfp; VALUE *bdfp; /* to gc mark */ if (block->proc) { return block->proc; } - bcfp = GET_CFP_FROM_BLOCK_PTR(block); + bcfp = RUBY_VM_GET_CFP_FROM_BLOCK_PTR(block); bdfp = bcfp->dfp; procval = th_make_proc(th, bcfp, block); return procval; @@ -377,19 +435,19 @@ th_make_proc_from_block(yarv_thread_t *th, yarv_control_frame_t *cfp, struct RObject *rb; VALUE -th_make_proc(yarv_thread_t *th, yarv_control_frame_t *cfp, - yarv_block_t *block) +th_make_proc(rb_thead_t *th, rb_control_frame_t *cfp, + rb_block_t *block) { VALUE procval, envval, blockprocval = 0; - yarv_proc_t *proc; + rb_proc_t *proc; if (GC_GUARDED_PTR_REF(cfp->lfp[0])) { - if (!YARV_CLASS_SPECIAL_P(cfp->lfp[0])) { - yarv_proc_t *p; + if (!RUBY_VM_CLASS_SPECIAL_P(cfp->lfp[0])) { + rb_proc_t *p; blockprocval = th_make_proc_from_block(th, cfp, - (yarv_block_t *)GC_GUARDED_PTR_REF(*cfp-> + (rb_block_t *)GC_GUARDED_PTR_REF(*cfp-> lfp)); GetProcPtr(blockprocval, p); *cfp->lfp = GC_GUARDED_PTR(&p->block); @@ -400,7 +458,7 @@ th_make_proc(yarv_thread_t *th, yarv_control_frame_t *cfp, if (PROCDEBUG) { check_env_value(envval); } - procval = yarv_proc_alloc(); + procval = rb_proc_alloc(); GetProcPtr(procval, proc); proc->blockprocval = blockprocval; proc->block.self = block->self; @@ -424,11 +482,11 @@ th_make_proc(yarv_thread_t *th, yarv_control_frame_t *cfp, } static inline VALUE -th_invoke_bmethod(yarv_thread_t *th, ID id, VALUE procval, VALUE recv, +th_invoke_bmethod(rb_thead_t *th, ID id, VALUE procval, VALUE recv, VALUE klass, int argc, VALUE *argv) { - yarv_control_frame_t *cfp = th->cfp; - yarv_proc_t *proc; + rb_control_frame_t *cfp = th->cfp; + rb_proc_t *proc; VALUE val; VALUE values[2] = { id, RCLASS(klass)->super, @@ -442,12 +500,12 @@ th_invoke_bmethod(yarv_thread_t *th, ID id, VALUE procval, VALUE recv, } VALUE -th_call0(yarv_thread_t *th, VALUE klass, VALUE recv, +th_call0(rb_thead_t *th, VALUE klass, VALUE recv, VALUE id, ID oid, int argc, const VALUE *argv, NODE * body, int nosuper) { VALUE val; - yarv_block_t *blockptr = 0; + rb_block_t *blockptr = 0; if (0) printf("id: %s, nd: %s, argc: %d, passed: %p\n", rb_id2name(id), node_name(nd_type(body)), @@ -459,8 +517,8 @@ th_call0(yarv_thread_t *th, VALUE klass, VALUE recv, th->passed_block = 0; } switch (nd_type(body)) { - case YARV_METHOD_NODE:{ - yarv_control_frame_t *reg_cfp; + case RUBY_VM_METHOD_NODE:{ + rb_control_frame_t *reg_cfp; int i; const int flag = 0; @@ -475,8 +533,8 @@ th_call0(yarv_thread_t *th, VALUE klass, VALUE recv, break; } case NODE_CFUNC: { - yarv_control_frame_t *reg_cfp = th->cfp; - yarv_control_frame_t *cfp = + rb_control_frame_t *reg_cfp = th->cfp; + rb_control_frame_t *cfp = push_frame(th, 0, FRAME_MAGIC_CFUNC, recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 1); @@ -520,7 +578,7 @@ th_call0(yarv_thread_t *th, VALUE klass, VALUE recv, default: rb_bug("unsupported: th_call0"); } - YARV_CHECK_INTS(); + RUBY_VM_CHECK_INTS(); return val; } @@ -544,14 +602,14 @@ search_super_klass(VALUE klass, VALUE recv) } VALUE -th_call_super(yarv_thread_t *th, int argc, const VALUE *argv) +th_call_super(rb_thead_t *th, int argc, const VALUE *argv) { VALUE recv = th->cfp->self; VALUE klass; ID id; NODE *body; int nosuper = 0; - yarv_control_frame_t *cfp = th->cfp; + rb_control_frame_t *cfp = th->cfp; if (!th->cfp->iseq) { klass = cfp->method_klass; @@ -583,7 +641,7 @@ th_call_super(yarv_thread_t *th, int argc, const VALUE *argv) } static inline VALUE -th_invoke_yield_cfunc(yarv_thread_t *th, yarv_block_t *block, +th_invoke_yield_cfunc(rb_thead_t *th, rb_block_t *block, VALUE self, int argc, VALUE *argv) { NODE *ifunc = (NODE *) block->iseq; @@ -611,7 +669,7 @@ th_invoke_yield_cfunc(yarv_thread_t *th, yarv_block_t *block, } static inline int -th_yield_setup_args(yarv_iseq_t *iseq, int argc, VALUE *argv) +th_yield_setup_args(rb_iseq_t *iseq, int argc, VALUE *argv) { int i; @@ -689,11 +747,11 @@ th_yield_setup_args(yarv_iseq_t *iseq, int argc, VALUE *argv) } static VALUE -invoke_block(yarv_thread_t *th, yarv_block_t *block, VALUE self, int argc, VALUE *argv, int magic) +invoke_block(rb_thead_t *th, rb_block_t *block, VALUE self, int argc, VALUE *argv, int magic) { VALUE val; if (BUILTIN_TYPE(block->iseq) != T_NODE) { - yarv_iseq_t *iseq = block->iseq; + rb_iseq_t *iseq = block->iseq; int i; th_set_finish_env(th); @@ -722,9 +780,9 @@ invoke_block(yarv_thread_t *th, yarv_block_t *block, VALUE self, int argc, VALUE } VALUE -th_invoke_yield(yarv_thread_t *th, int argc, VALUE *argv) +th_invoke_yield(rb_thead_t *th, int argc, VALUE *argv) { - yarv_block_t *block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]); + rb_block_t *block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]); if (block == 0) { th_localjump_error("no block given", Qnil, 0); @@ -734,14 +792,14 @@ th_invoke_yield(yarv_thread_t *th, int argc, VALUE *argv) } VALUE -th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc, +th_invoke_proc(rb_thead_t *th, rb_proc_t *proc, VALUE self, int argc, VALUE *argv) { VALUE val = Qundef; int state; volatile int stored_safe = th->safe_level; volatile NODE *stored_special_cref_stack; - yarv_control_frame_t * volatile cfp = th->cfp; + rb_control_frame_t * volatile cfp = th->cfp; TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { @@ -791,7 +849,7 @@ static VALUE * lfp_svar(VALUE *lfp, int cnt) { struct RValues *val; - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); if (th->local_lfp != lfp) { val = (struct RValues *)lfp[-1]; @@ -829,7 +887,7 @@ lfp_svar(VALUE *lfp, int cnt) VALUE * -th_cfp_svar(yarv_control_frame_t *cfp, int cnt) +th_cfp_svar(rb_control_frame_t *cfp, int cnt) { while (cfp->pc == 0) { cfp++; @@ -838,27 +896,27 @@ th_cfp_svar(yarv_control_frame_t *cfp, int cnt) } VALUE * -th_svar(yarv_thread_t *th, int cnt) +th_svar(rb_thead_t *th, int cnt) { - yarv_control_frame_t *cfp = th->cfp; + rb_control_frame_t *cfp = th->cfp; return th_cfp_svar(cfp, cnt); } VALUE * thread_svar(VALUE self, int cnt) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(self, th); return th_svar(th, cnt); } int -th_get_sourceline(yarv_control_frame_t *cfp) +th_get_sourceline(rb_control_frame_t *cfp) { int line_no = 0; - yarv_iseq_t *iseq = cfp->iseq; + rb_iseq_t *iseq = cfp->iseq; - if (YARV_NORMAL_ISEQ_P(iseq)) { + if (RUBY_VM_NORMAL_ISEQ_P(iseq)) { int i; int pos = cfp->pc - cfp->iseq->iseq_encoded; @@ -875,9 +933,9 @@ th_get_sourceline(yarv_control_frame_t *cfp) } static VALUE -th_backtrace_each(yarv_thread_t *th, - yarv_control_frame_t *limit_cfp, - yarv_control_frame_t *cfp, +th_backtrace_each(rb_thead_t *th, + rb_control_frame_t *limit_cfp, + rb_control_frame_t *cfp, char *file, int line_no, VALUE ary) { VALUE str; @@ -886,7 +944,7 @@ th_backtrace_each(yarv_thread_t *th, str = 0; if (cfp->iseq != 0) { if (cfp->pc != 0) { - yarv_iseq_t *iseq = cfp->iseq; + rb_iseq_t *iseq = cfp->iseq; line_no = th_get_sourceline(cfp); file = RSTRING_PTR(iseq->file_name); @@ -902,17 +960,17 @@ th_backtrace_each(yarv_thread_t *th, rb_id2name(cfp->callee_id)); rb_ary_push(ary, str); } - cfp = YARV_NEXT_CONTROL_FRAME(cfp); + cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp); } return rb_ary_reverse(ary); } VALUE -th_backtrace(yarv_thread_t *th, int lev) +th_backtrace(rb_thead_t *th, int lev) { VALUE ary; - yarv_control_frame_t *cfp = th->cfp; - yarv_control_frame_t *top_of_cfp = (void *)(th->stack + th->stack_size); + rb_control_frame_t *cfp = th->cfp; + rb_control_frame_t *top_of_cfp = (void *)(th->stack + th->stack_size); top_of_cfp -= 2; if (lev < 0) { @@ -929,7 +987,7 @@ th_backtrace(yarv_thread_t *th, int lev) ary = rb_ary_new(); } - ary = th_backtrace_each(th, YARV_NEXT_CONTROL_FRAME(cfp), + ary = th_backtrace_each(th, RUBY_VM_NEXT_CONTROL_FRAME(cfp), top_of_cfp, "", 0, ary); return ary; } @@ -937,7 +995,7 @@ th_backtrace(yarv_thread_t *th, int lev) VALUE thread_backtrace(VALUE self, int level) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(self, th); return th_backtrace(th, level); } @@ -962,8 +1020,8 @@ lfp_get_special_cref(VALUE *lfp) static void check_svar(void) { - yarv_thread_t *th = GET_THREAD(); - yarv_control_frame_t *cfp = th->cfp; + rb_thead_t *th = GET_THREAD(); + rb_control_frame_t *cfp = th->cfp; while ((void *)(cfp + 1) < (void *)(th->stack + th->stack_size)) { /* printf("cfp: %p\n", cfp->magic); */ if (cfp->lfp && cfp->lfp[-1] != Qnil && @@ -998,7 +1056,7 @@ lfp_set_special_cref(VALUE *lfp, NODE * cref) } NODE * -th_set_special_cref(yarv_thread_t *th, VALUE *lfp, NODE * cref_stack) +th_set_special_cref(rb_thead_t *th, VALUE *lfp, NODE * cref_stack) { return lfp_set_special_cref(lfp, cref_stack); } @@ -1014,7 +1072,7 @@ debug_cref(NODE *cref) } static NODE * -get_cref(yarv_iseq_t *iseq, VALUE *lfp) +get_cref(rb_iseq_t *iseq, VALUE *lfp) { NODE *cref; if ((cref = lfp_get_special_cref(lfp)) != 0) { @@ -1030,16 +1088,16 @@ get_cref(yarv_iseq_t *iseq, VALUE *lfp) } NODE * -th_get_cref(yarv_thread_t *th, yarv_iseq_t *iseq, yarv_control_frame_t *cfp) +th_get_cref(rb_thead_t *th, rb_iseq_t *iseq, rb_control_frame_t *cfp) { return get_cref(iseq, cfp->lfp); } NODE * -th_cref_push(yarv_thread_t *th, VALUE klass, int noex) +th_cref_push(rb_thead_t *th, VALUE klass, int noex) { NODE *cref = NEW_BLOCK(klass); - yarv_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp); + rb_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp); cref->nd_file = 0; cref->nd_next = get_cref(cfp->iseq, cfp->lfp); @@ -1048,9 +1106,9 @@ th_cref_push(yarv_thread_t *th, VALUE klass, int noex) } VALUE -th_get_cbase(yarv_thread_t *th) +th_get_cbase(rb_thead_t *th) { - yarv_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp); + rb_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp); NODE *cref = get_cref(cfp->iseq, cfp->lfp); VALUE klass = Qundef; @@ -1064,7 +1122,7 @@ th_get_cbase(yarv_thread_t *th) } EVALBODY_HELPER_FUNCTION VALUE -eval_get_ev_const(yarv_thread_t *th, yarv_iseq_t *iseq, +eval_get_ev_const(rb_thead_t *th, rb_iseq_t *iseq, VALUE klass, ID id, int is_defined) { VALUE val; @@ -1135,7 +1193,7 @@ eval_get_ev_const(yarv_thread_t *th, yarv_iseq_t *iseq, } EVALBODY_HELPER_FUNCTION VALUE -eval_get_cvar_base(yarv_thread_t *th, yarv_iseq_t *iseq) +eval_get_cvar_base(rb_thead_t *th, rb_iseq_t *iseq) { NODE *cref = get_cref(iseq, th->cfp->lfp); VALUE klass = Qnil; @@ -1153,8 +1211,8 @@ eval_get_cvar_base(yarv_thread_t *th, yarv_iseq_t *iseq) } EVALBODY_HELPER_FUNCTION void -eval_define_method(yarv_thread_t *th, VALUE obj, - ID id, yarv_iseq_t *miseq, num_t is_singleton, NODE *cref) +eval_define_method(rb_thead_t *th, VALUE obj, + ID id, rb_iseq_t *miseq, num_t is_singleton, NODE *cref) { NODE *newbody; int noex = cref->nd_visi; @@ -1179,7 +1237,7 @@ eval_define_method(yarv_thread_t *th, VALUE obj, COPY_CREF(miseq->cref_stack, cref); miseq->klass = klass; miseq->defined_method_id = id; - newbody = NEW_NODE(YARV_METHOD_NODE, 0, miseq->self, 0); + newbody = NEW_NODE(RUBY_VM_METHOD_NODE, 0, miseq->self, 0); rb_add_method(klass, id, newbody, noex); if (!is_singleton && noex == NOEX_MODFUNC) { @@ -1189,10 +1247,10 @@ eval_define_method(yarv_thread_t *th, VALUE obj, } EVALBODY_HELPER_FUNCTION VALUE -eval_method_missing(yarv_thread_t *th, ID id, VALUE recv, int num, - yarv_block_t *blockptr, int opt) +eval_method_missing(rb_thead_t *th, ID id, VALUE recv, int num, + rb_block_t *blockptr, int opt) { - yarv_control_frame_t *reg_cfp = th->cfp; + rb_control_frame_t *reg_cfp = th->cfp; VALUE *argv = STACK_ADDR_FROM_TOP(num + 1); VALUE val; argv[0] = ID2SYM(id); @@ -1318,9 +1376,9 @@ th_jump_tag_but_local_jump(int state, VALUE val) } void -th_iter_break(yarv_thread_t *th) +th_iter_break(rb_thead_t *th) { - yarv_control_frame_t *cfp = th->cfp; + rb_control_frame_t *cfp = th->cfp; VALUE *dfp = GC_GUARDED_PTR_REF(*cfp->dfp); th->state = TAG_BREAK; @@ -1404,12 +1462,12 @@ yarv_init_redefined_flag() VALUE *pc; // cfp[0] VALUE *sp; // cfp[1] VALUE *bp; // cfp[2] - yarv_iseq_t *iseq; // cfp[3] + rb_iseq_t *iseq; // cfp[3] VALUE magic; // cfp[4] VALUE self; // cfp[5] VALUE *lfp; // cfp[6] VALUE *dfp; // cfp[7] - yarv_iseq_t * block_iseq; // cfp[8] + rb_iseq_t * block_iseq; // cfp[8] VALUE proc; // cfp[9] always 0 }; @@ -1417,7 +1475,7 @@ yarv_init_redefined_flag() VALUE self; VALUE *lfp; VALUE *dfp; - yarv_iseq_t *block_iseq; + rb_iseq_t *block_iseq; }; struct PROC { @@ -1469,24 +1527,24 @@ yarv_init_redefined_flag() VALUE *pc; // 0 VALUE *sp; // stack pointer VALUE *bp; // base pointer (used in exception) - yarv_iseq_t *iseq; // cmi + rb_iseq_t *iseq; // cmi VALUE magic; // C_METHOD_FRAME VALUE self; // ? VALUE *lfp; // lfp VALUE *dfp; // == lfp - yarv_iseq_t * block_iseq; // + rb_iseq_t * block_iseq; // VALUE proc; // always 0 }; struct C_BLOCK_CONTROL_FRAME { VALUE *pc; // point only "finish" insn VALUE *sp; // sp - yarv_iseq_t *iseq; // ? + rb_iseq_t *iseq; // ? VALUE magic; // C_METHOD_FRAME VALUE self; // needed? VALUE *lfp; // lfp VALUE *dfp; // lfp - yarv_iseq_t * block_iseq; // 0 + rb_iseq_t * block_iseq; // 0 }; struct C_METHDO_FRAME{ @@ -1497,7 +1555,7 @@ yarv_init_redefined_flag() VALUE -th_eval_body(yarv_thread_t *th) +th_eval_body(rb_thead_t *th) { int state; VALUE result, err; @@ -1518,7 +1576,7 @@ th_eval_body(yarv_thread_t *th) struct catch_table_entry *entry; unsigned long epc, cont_pc, cont_sp; VALUE catch_iseqval; - yarv_control_frame_t *cfp; + rb_control_frame_t *cfp; VALUE *escape_dfp = NULL; VALUE type; @@ -1666,7 +1724,7 @@ th_eval_body(yarv_thread_t *th) if (catch_iseqval != 0) { /* found catch table */ - yarv_iseq_t *catch_iseq; + rb_iseq_t *catch_iseq; /* enter catch scope */ GetISeqPtr(catch_iseqval, catch_iseq); @@ -101,12 +101,12 @@ error ! #define ELABEL(x) #define LABEL_PTR(x) &LABEL(x) -typedef yarv_control_frame_t * - (*insn_func_type) (yarv_thread_t *, yarv_control_frame_t *)FASTCALL; +typedef rb_control_frame_t * + (*insn_func_type) (rb_thead_t *, rb_control_frame_t *)FASTCALL; #define INSN_ENTRY(insn) \ - yarv_control_frame_t * \ - LABEL(insn)(yarv_thread_t *th, yarv_control_frame_t *reg_cfp) FASTCALL { + rb_control_frame_t * \ + LABEL(insn)(rb_thead_t *th, rb_control_frame_t *reg_cfp) FASTCALL { #define END_INSN(insn) return reg_cfp;} @@ -19,7 +19,7 @@ #define MAX_POSBUF 128 static void -control_frame_dump(yarv_thread_t *th, yarv_control_frame_t *cfp) +control_frame_dump(rb_thead_t *th, rb_control_frame_t *cfp) { int pc = -1, bp = -1, line = 0; unsigned int lfp = cfp->lfp - th->stack; @@ -94,7 +94,7 @@ control_frame_dump(yarv_thread_t *th, yarv_control_frame_t *cfp) } if (cfp->iseq != 0) { - if (YARV_IFUNC_P(cfp->iseq)) { + if (RUBY_VM_IFUNC_P(cfp->iseq)) { iseq_name = "<ifunc>"; } else { @@ -115,7 +115,7 @@ control_frame_dump(yarv_thread_t *th, yarv_control_frame_t *cfp) } fprintf(stderr, "c:%04ld ", - (yarv_control_frame_t *)(th->stack + th->stack_size) - cfp); + (rb_control_frame_t *)(th->stack + th->stack_size) - cfp); if (pc == -1) { fprintf(stderr, "p:---- "); } @@ -139,7 +139,7 @@ control_frame_dump(yarv_thread_t *th, yarv_control_frame_t *cfp) } void -vm_stack_dump_raw(yarv_thread_t *th, yarv_control_frame_t *cfp) +vm_stack_dump_raw(rb_thead_t *th, rb_control_frame_t *cfp) { VALUE *sp = cfp->sp, *bp = cfp->bp; VALUE *lfp = cfp->lfp; @@ -173,7 +173,7 @@ vm_stack_dump_raw(yarv_thread_t *th, yarv_control_frame_t *cfp) } void -env_dump_raw(yarv_env_t *env, VALUE *lfp, VALUE *dfp) +env_dump_raw(rb_env_t *env, VALUE *lfp, VALUE *dfp) { int i; fprintf(stderr, "-- env --------------------\n"); @@ -201,9 +201,9 @@ env_dump_raw(yarv_env_t *env, VALUE *lfp, VALUE *dfp) } void -proc_dump_raw(yarv_proc_t *proc) +proc_dump_raw(rb_proc_t *proc) { - yarv_env_t *env; + rb_env_t *env; char *selfstr; VALUE val = rb_inspect(proc->block.self); selfstr = StringValueCStr(val); @@ -217,13 +217,13 @@ proc_dump_raw(yarv_proc_t *proc) void stack_dump_th(VALUE thval) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thval, th); vm_stack_dump_raw(th, th->cfp); } void -stack_dump_each(yarv_thread_t *th, yarv_control_frame_t *cfp) +stack_dump_each(rb_thead_t *th, rb_control_frame_t *cfp) { int i; @@ -234,7 +234,7 @@ stack_dump_each(yarv_thread_t *th, yarv_control_frame_t *cfp) int argc, local_size; const char *name; - yarv_iseq_t *iseq = cfp->iseq; + rb_iseq_t *iseq = cfp->iseq; if (iseq == 0) { if (cfp->method_id) { @@ -247,7 +247,7 @@ stack_dump_each(yarv_thread_t *th, yarv_control_frame_t *cfp) local_size = 0; } } - else if (YARV_IFUNC_P(iseq)) { + else if (RUBY_VM_IFUNC_P(iseq)) { argc = 0; local_size = 0; name = "<ifunc>"; @@ -316,15 +316,15 @@ stack_dump_each(yarv_thread_t *th, yarv_control_frame_t *cfp) void -debug_print_register(yarv_thread_t *th) +debug_print_register(rb_thead_t *th) { - yarv_control_frame_t *cfp = th->cfp; + rb_control_frame_t *cfp = th->cfp; int pc = -1; int lfp = cfp->lfp - th->stack; int dfp = cfp->dfp - th->stack; int cfpi; - if (YARV_NORMAL_ISEQ_P(cfp->iseq)) { + if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { pc = cfp->pc - cfp->iseq->iseq_encoded; } @@ -333,7 +333,7 @@ debug_print_register(yarv_thread_t *th) if (dfp < 0 || dfp > th->stack_size) dfp = -1; - cfpi = ((yarv_control_frame_t *)(th->stack + th->stack_size)) - cfp; + cfpi = ((rb_control_frame_t *)(th->stack + th->stack_size)) - cfp; fprintf(stderr, " [PC] %04d, [SP] %04ld, [LFP] %04d, [DFP] %04d, [CFP] %04d\n", pc, cfp->sp - th->stack, lfp, dfp, cfpi); } @@ -341,15 +341,15 @@ debug_print_register(yarv_thread_t *th) void thread_dump_regs(VALUE thval) { - yarv_thread_t *th; + rb_thead_t *th; GetThreadPtr(thval, th); debug_print_register(th); } void -debug_print_pre(yarv_thread_t *th, yarv_control_frame_t *cfp) +debug_print_pre(rb_thead_t *th, rb_control_frame_t *cfp) { - yarv_iseq_t *iseq = cfp->iseq; + rb_iseq_t *iseq = cfp->iseq; if (iseq != 0 && cfp->magic != FRAME_MAGIC_FINISH) { VALUE *seq = iseq->iseq; @@ -365,7 +365,7 @@ debug_print_pre(yarv_thread_t *th, yarv_control_frame_t *cfp) } void -debug_print_post(yarv_thread_t *th, yarv_control_frame_t *cfp +debug_print_post(rb_thead_t *th, rb_control_frame_t *cfp #if OPT_STACK_CACHING , VALUE reg_a, VALUE reg_b #endif @@ -563,8 +563,8 @@ vm_analysis_register(int reg, int isset) VALUE thread_dump_state(VALUE self) { - yarv_thread_t *th; - yarv_control_frame_t *cfp; + rb_thead_t *th; + rb_control_frame_t *cfp; GetThreadPtr(self, th); cfp = th->cfp; @@ -578,7 +578,7 @@ thread_dump_state(VALUE self) void yarv_bug() { - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); VALUE bt; if (GET_THREAD()->vm) { diff --git a/vm_evalbody.ci b/vm_evalbody.ci index 87cd9ee4e2..85a2a12034 100644 --- a/vm_evalbody.ci +++ b/vm_evalbody.ci @@ -26,11 +26,11 @@ #endif /* #define DECL_SC_REG(r, reg) VALUE reg_##r */ -typedef yarv_iseq_t *ISEQ; +typedef rb_iseq_t *ISEQ; #if !OPT_CALL_THREADED_CODE VALUE -th_eval(yarv_thread_t *th, VALUE initial) +th_eval(rb_thead_t *th, VALUE initial) { #if OPT_STACK_CACHING @@ -46,16 +46,16 @@ th_eval(yarv_thread_t *th, VALUE initial) #if __GNUC__ && __i386__ DECL_SC_REG(VALUE *, pc, "di"); - DECL_SC_REG(yarv_control_frame_t *, cfp, "si"); + DECL_SC_REG(rb_control_frame_t *, cfp, "si"); #define USE_MACHINE_REGS 1 #elif __GNUC__ && __x86_64__ DECL_SC_REG(VALUE *, pc, "14"); - DECL_SC_REG(yarv_control_frame_t *, cfp, "15"); + DECL_SC_REG(rb_control_frame_t *, cfp, "15"); #define USE_MACHINE_REGS 1 #else - register yarv_control_frame_t *reg_cfp; + register rb_control_frame_t *reg_cfp; VALUE *reg_pc; #endif @@ -77,7 +77,7 @@ th_eval(yarv_thread_t *th, VALUE initial) #endif ID tmp_id; - yarv_block_t *tmp_blockptr; + rb_block_t *tmp_blockptr; num_t tmp_num; #if OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE @@ -123,9 +123,9 @@ get_insns_address_table() } VALUE -th_eval(yarv_thread_t *th, VALUE initial) +th_eval(rb_thead_t *th, VALUE initial) { - register yarv_control_frame_t *reg_cfp = th->cfp; + register rb_control_frame_t *reg_cfp = th->cfp; SET_PC(reg_cfp->iseq->iseq_encoded); while (*GET_PC()) { diff --git a/vm_macro.def b/vm_macro.def index e08fb14938..8add12e6fa 100644 --- a/vm_macro.def +++ b/vm_macro.def @@ -6,14 +6,14 @@ MACRO macro_eval_setup_send_arguments(num, blockptr, flag, blockiseq) { if (flag & VM_CALL_ARGS_BLOCKARG_BIT) { - yarv_proc_t *po; + rb_proc_t *po; VALUE proc; proc = TOPN(0); if (proc != Qnil) { - if (!yarv_obj_is_proc(proc)) { + if (!rb_obj_is_proc(proc)) { proc = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc"); - if (!yarv_obj_is_proc(proc)) { + if (!rb_obj_is_proc(proc)) { rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc)", rb_obj_classname(proc)); @@ -21,12 +21,12 @@ MACRO macro_eval_setup_send_arguments(num, blockptr, flag, blockiseq) } GetProcPtr(proc, po); blockptr = &po->block; - GET_BLOCK_PTR_IN_CFP(reg_cfp)->proc = proc; + RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp)->proc = proc; } INC_SP(-1); } else if (blockiseq) { - blockptr = GET_BLOCK_PTR_IN_CFP(reg_cfp); + blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp); blockptr->iseq = blockiseq; blockptr->proc = 0; } @@ -56,7 +56,7 @@ MACRO macro_eval_setup_send_arguments(num, blockptr, flag, blockiseq) MACRO macro_eval_invoke_cfunc(num, id, recv, klass, mn, blockptr) { - yarv_control_frame_t *cfp = + rb_control_frame_t *cfp = push_frame(th, 0, FRAME_MAGIC_CFUNC, recv, (VALUE) blockptr, 0, GET_SP(), 0, 1); cfp->callee_id = id; /* TODO */ @@ -77,7 +77,7 @@ MACRO macro_eval_invoke_cfunc(num, id, recv, klass, mn, blockptr) MACRO macro_eval_invoke_func(niseqval, recv, klass, blockptr, num) { - yarv_iseq_t *niseq; + rb_iseq_t *niseq; VALUE *sp = GET_SP(); VALUE *rsp = sp - num - 1; int opt_pc = 0, clear_local_size, i; @@ -173,7 +173,7 @@ MACRO macro_eval_invoke_func(niseqval, recv, klass, blockptr, num) if (blockptr) { /* make Proc object */ if (blockptr->proc == 0) { - yarv_proc_t *proc; + rb_proc_t *proc; reg_cfp->sp = sp; arg_block_val = th_make_proc(th, GET_CFP(), blockptr); GetProcPtr(arg_block_val, proc); @@ -274,7 +274,7 @@ MACRO macro_eval_invoke_method(recv, klass, id, num, mn, blockptr) node = mn->nd_body; switch (nd_type(node)) { - case YARV_METHOD_NODE:{ + case RUBY_VM_METHOD_NODE:{ macro_eval_invoke_func(node->nd_body, recv, klass, blockptr, num); NEXT_INSN(); @@ -34,10 +34,10 @@ RUBY_EXTERN int yarvIsWorking; #endif -#if YARV_THREAD_MODEL == 2 +#if RUBY_VM_THREAD_MODEL == 2 -extern yarv_thread_t *yarvCurrentThread; -extern yarv_vm_t *theYarvVM; +extern rb_thead_t *yarvCurrentThread; +extern rb_vm_t *theYarvVM; static inline VALUE yarv_get_current_running_thread_value(void) @@ -45,7 +45,7 @@ yarv_get_current_running_thread_value(void) return yarvCurrentThread->self; } -static inline yarv_thread_t * +static inline rb_thead_t * yarv_get_current_running_thread(void) { return yarvCurrentThread; @@ -55,15 +55,15 @@ yarv_get_current_running_thread(void) #define GET_THREAD() yarvCurrentThread static inline void -yarv_set_current_running_thread_raw(yarv_thread_t *th) +rb_thread_set_current_raw(rb_thead_t *th) { yarvCurrentThread = th; } static inline void -yarv_set_current_running_thread(yarv_thread_t *th) +rb_thread_set_current(rb_thead_t *th) { - yarv_set_current_running_thread_raw(th); + rb_thread_set_current_raw(th); th->vm->running_thread = th; } @@ -73,33 +73,32 @@ yarv_set_current_running_thread(yarv_thread_t *th) void rb_vm_change_state(); -VALUE th_invoke_yield(yarv_thread_t *th, int argc, VALUE *argv); +VALUE th_invoke_yield(rb_thead_t *th, int argc, VALUE *argv); -VALUE th_call0(yarv_thread_t *th, VALUE klass, VALUE recv, +VALUE th_call0(rb_thead_t *th, VALUE klass, VALUE recv, VALUE id, ID oid, int argc, const VALUE *argv, NODE * body, int nosuper); VALUE *yarv_svar(int); -VALUE th_call_super(yarv_thread_t *th, int argc, const VALUE *argv); +VALUE th_call_super(rb_thead_t *th, int argc, const VALUE *argv); VALUE yarv_backtrace(int lev); VALUE yarvcore_eval_parsed(NODE *node, VALUE file); -VALUE th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc, +VALUE th_invoke_proc(rb_thead_t *th, rb_proc_t *proc, VALUE self, int argc, VALUE *argv); -VALUE th_make_proc(yarv_thread_t *th, yarv_control_frame_t *cfp, - yarv_block_t *block); -VALUE th_make_env_object(yarv_thread_t *th, yarv_control_frame_t *cfp); +VALUE th_make_proc(rb_thead_t *th, rb_control_frame_t *cfp, + rb_block_t *block); +VALUE th_make_env_object(rb_thead_t *th, rb_control_frame_t *cfp); VALUE yarvcore_eval(VALUE self, VALUE str, VALUE file, VALUE line); int yarv_block_given_p(void); VALUE yarv_load(char *); -VALUE yarv_obj_is_proc(VALUE); -int th_get_sourceline(yarv_control_frame_t *); -VALUE th_backtrace(yarv_thread_t *, int); +int th_get_sourceline(rb_control_frame_t *); +VALUE th_backtrace(rb_thead_t *, int); void yarv_bug(void); #endif diff --git a/yarvcore.c b/yarvcore.c index 32b136737c..c3a654c410 100644 --- a/yarvcore.c +++ b/yarvcore.c @@ -71,14 +71,14 @@ unsigned long yarvGlobalStateVersion = 1; #define va_init_list(a,b) va_start(a) #endif -VALUE yarv_th_eval(yarv_thread_t *th, VALUE iseqval); +VALUE rb_thread_eval(rb_thead_t *th, VALUE iseqval); /************/ /* YARVCore */ /************/ -yarv_thread_t *yarvCurrentThread = 0; -yarv_vm_t *theYarvVM = 0; +rb_thead_t *yarvCurrentThread = 0; +rb_vm_t *theYarvVM = 0; static VALUE yarvVMArray = Qnil; RUBY_EXTERN int rb_thread_critical; @@ -91,7 +91,7 @@ yarv_load(char *file) NODE *node; VALUE iseq; volatile int critical; - yarv_thread_t *th = GET_THREAD(); + rb_thead_t *th = GET_THREAD(); critical = rb_thread_critical; rb_thread_critical = Qtrue; @@ -110,11 +110,11 @@ yarv_load(char *file) iseq = yarv_iseq_new(node, rb_str_new2("<top (required)>"), rb_str_new2(file), Qfalse, ISEQ_TYPE_TOP); - yarv_th_eval(GET_THREAD(), iseq); + rb_thread_eval(GET_THREAD(), iseq); return 0; } -VALUE *th_svar(yarv_thread_t *self, int cnt); +VALUE *th_svar(rb_thead_t *self, int cnt); VALUE * rb_svar(int cnt) @@ -172,11 +172,11 @@ compile_string(VALUE str, VALUE file, VALUE line) static VALUE yarvcore_eval_iseq(VALUE iseq) { - return yarv_th_eval(GET_THREAD(), iseq); + return rb_thread_eval(GET_THREAD(), iseq); } static VALUE -th_compile_from_node(yarv_thread_t *th, NODE * node, VALUE file) +th_compile_from_node(rb_thead_t *th, NODE * node, VALUE file) { VALUE iseq; if (th->base_block) { @@ -194,7 +194,7 @@ th_compile_from_node(yarv_thread_t *th, NODE * node, VALUE file) } VALUE -th_compile(yarv_thread_t *th, VALUE str, VALUE file, VALUE line) +th_compile(rb_thead_t *th, VALUE str, VALUE file, VALUE line) { NODE *node = (NODE *) compile_string(str, file, line); return th_compile_from_node(th, (NODE *) node, file); @@ -226,7 +226,7 @@ vm_free(void *ptr) { FREE_REPORT_ENTER("vm"); if (ptr) { - yarv_vm_t *vmobj = ptr; + rb_vm_t *vmobj = ptr; st_free_table(vmobj->living_threads); /* TODO: MultiVM Instance */ @@ -251,7 +251,7 @@ vm_mark(void *ptr) MARK_REPORT_ENTER("vm"); GC_INFO("-------------------------------------------------\n"); if (ptr) { - yarv_vm_t *vm = ptr; + rb_vm_t *vm = ptr; if (vm->living_threads) { st_foreach(vm->living_threads, vm_mark_each_thread_func, 0); } @@ -266,8 +266,8 @@ static VALUE vm_alloc(VALUE klass) { VALUE volatile obj; - yarv_vm_t *vm; - obj = Data_Make_Struct(klass, yarv_vm_t, vm_mark, vm_free, vm); + rb_vm_t *vm; + obj = Data_Make_Struct(klass, rb_vm_t, vm_mark, vm_free, vm); vm->self = obj; vm->mark_object_ary = rb_ary_new(); @@ -275,9 +275,9 @@ vm_alloc(VALUE klass) } static void -vm_init2(yarv_vm_t *vm) +vm_init2(rb_vm_t *vm) { - MEMZERO(vm, yarv_vm_t, 1); + MEMZERO(vm, rb_vm_t, 1); } /**********/ @@ -287,7 +287,7 @@ vm_init2(yarv_vm_t *vm) static void thread_free(void *ptr) { - yarv_thread_t *th; + rb_thead_t *th; FREE_REPORT_ENTER("thread"); if (ptr) { @@ -321,20 +321,20 @@ thread_free(void *ptr) FREE_REPORT_LEAVE("thread"); } -void yarv_machine_stack_mark(yarv_thread_t *th); +void yarv_machine_stack_mark(rb_thead_t *th); static void thread_mark(void *ptr) { - yarv_thread_t *th = NULL; + rb_thead_t *th = NULL; MARK_REPORT_ENTER("thread"); if (ptr) { th = ptr; if (th->stack) { VALUE *p = th->stack; VALUE *sp = th->cfp->sp; - yarv_control_frame_t *cfp = th->cfp; - yarv_control_frame_t *limit_cfp = + rb_control_frame_t *cfp = th->cfp; + rb_control_frame_t *limit_cfp = (void *)(th->stack + th->stack_size); while (p < sp) { @@ -342,7 +342,7 @@ thread_mark(void *ptr) } while (cfp != limit_cfp) { rb_gc_mark(cfp->proc); - cfp = YARV_PREVIOUS_CONTROL_FRAME(cfp); + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } } @@ -374,21 +374,21 @@ static VALUE thread_alloc(VALUE klass) { VALUE volatile obj; - yarv_thread_t *th; - obj = Data_Make_Struct(klass, yarv_thread_t, + rb_thead_t *th; + obj = Data_Make_Struct(klass, rb_thead_t, thread_mark, thread_free, th); return obj; } static void -th_init2(yarv_thread_t *th) +th_init2(rb_thead_t *th) { - MEMZERO(th, yarv_thread_t, 1); + MEMZERO(th, rb_thead_t, 1); /* allocate thread stack */ - th->stack = ALLOC_N(VALUE, YARV_THREAD_STACK_SIZE); + th->stack = ALLOC_N(VALUE, RUBY_VM_THREAD_STACK_SIZE); - th->stack_size = YARV_THREAD_STACK_SIZE; + th->stack_size = RUBY_VM_THREAD_STACK_SIZE; th->cfp = (void *)(th->stack + th->stack_size); th->cfp--; @@ -412,13 +412,13 @@ th_init2(yarv_thread_t *th) } void -th_klass_init(yarv_thread_t *th) +th_klass_init(rb_thead_t *th) { /* */ } static void -th_init(yarv_thread_t *th) +th_init(rb_thead_t *th) { th_init2(th); th_klass_init(th); @@ -427,8 +427,8 @@ th_init(yarv_thread_t *th) static VALUE thread_init(VALUE self) { - yarv_thread_t *th; - yarv_vm_t *vm = GET_THREAD()->vm; + rb_thead_t *th; + rb_vm_t *vm = GET_THREAD()->vm; GetThreadPtr(self, th); th_init(th); @@ -438,18 +438,18 @@ thread_init(VALUE self) } VALUE -yarv_thread_alloc(VALUE klass) +rb_thread_alloc(VALUE klass) { VALUE self = thread_alloc(klass); thread_init(self); return self; } -VALUE th_eval_body(yarv_thread_t *th); -void th_set_top_stack(yarv_thread_t *, VALUE iseq); +VALUE th_eval_body(rb_thead_t *th); +void th_set_top_stack(rb_thead_t *, VALUE iseq); VALUE -yarv_th_eval(yarv_thread_t *th, VALUE iseqval) +rb_thread_eval(rb_thead_t *th, VALUE iseqval) { VALUE val; volatile VALUE tmp; @@ -536,7 +536,11 @@ Init_VM(void) /* ::VM */ rb_cVM = rb_define_class("VM", rb_cObject); rb_undef_alloc_func(rb_cVM); - + + /* Env */ + rb_cEnv = rb_define_class_under(rb_cVM, "Env", rb_cObject); + rb_undef_alloc_func(rb_cEnv); + /* ::Thread */ rb_cThread = rb_define_class("Thread", rb_cObject); rb_undef_alloc_func(rb_cThread); @@ -610,8 +614,8 @@ Init_VM(void) VALUE vmval = vm_alloc(rb_cVM); VALUE thval; - yarv_vm_t *vm; - yarv_thread_t *th; + rb_vm_t *vm; + rb_thead_t *th; vm = theYarvVM; xfree(RDATA(vmval)->data); @@ -623,7 +627,7 @@ Init_VM(void) rb_ary_push(yarvVMArray, vm->self); /* create main thread */ - thval = yarv_thread_alloc(rb_cThread); + thval = rb_thread_alloc(rb_cThread); GetThreadPtr(thval, th); vm->main_thread = th; @@ -631,7 +635,7 @@ Init_VM(void) GET_THREAD()->vm = vm; thread_free(GET_THREAD()); th->vm = vm; - yarv_set_current_running_thread(th); + rb_thread_set_current(th); th->machine_stack_start = rb_gc_stack_start; vm->living_threads = st_init_numtable(); @@ -644,8 +648,8 @@ void Init_yarv(void) { /* VM bootstrap: phase 1 */ - yarv_vm_t *vm = ALLOC(yarv_vm_t); - yarv_thread_t *th = ALLOC(yarv_thread_t); + rb_vm_t *vm = ALLOC(rb_vm_t); + rb_thead_t *th = ALLOC(rb_thead_t); vm_init2(vm); theYarvVM = vm; @@ -653,6 +657,6 @@ Init_yarv(void) th_init2(th); th->vm = vm; th->machine_stack_start = rb_gc_stack_start; - yarv_set_current_running_thread_raw(th); + rb_thread_set_current_raw(th); } diff --git a/yarvcore.h b/yarvcore.h index 06b563ba2a..25ea517a83 100644 --- a/yarvcore.h +++ b/yarvcore.h @@ -13,7 +13,7 @@ #ifndef _YARVCORE_H_INCLUDED_ #define _YARVCORE_H_INCLUDED_ -#define YARV_THREAD_MODEL 2 +#define RUBY_VM_THREAD_MODEL 2 #include <setjmp.h> @@ -184,14 +184,14 @@ struct iseq_compile_data_storage { struct iseq_compile_data_ensure_node_stack; -typedef struct yarv_compile_option_struct { +typedef struct rb_compile_option_struct { int inline_const_cache; int peephole_optimization; int specialized_instruction; int operands_unification; int instructions_unification; int stack_caching; -} yarv_compile_option_t; +} rb_compile_option_t; struct iseq_compile_data { /* GC is needed */ @@ -212,20 +212,20 @@ struct iseq_compile_data { struct iseq_compile_data_storage *storage_head; struct iseq_compile_data_storage *storage_current; int last_line; - const yarv_compile_option_t *option; + const rb_compile_option_t *option; }; -#define GetISeqPtr(obj, ptr) Data_Get_Struct(obj, yarv_iseq_t, ptr) +#define GetISeqPtr(obj, ptr) Data_Get_Struct(obj, rb_iseq_t, ptr) -typedef struct yarv_iseq_profile_struct { +typedef struct rb_iseq_profile_struct { VALUE count; VALUE time_self; VALUE time_cumu; /* cumulative */ -} yarv_iseq_profile_t; +} rb_iseq_profile_t; -struct yarv_iseq_struct; +struct rb_iseq_struct; -struct yarv_iseq_struct { +struct rb_iseq_struct { /* instruction sequence type */ VALUE type; @@ -288,8 +288,8 @@ struct yarv_iseq_struct { int catch_table_size; /* for child iseq */ - struct yarv_iseq_struct *parent_iseq; - struct yarv_iseq_struct *local_iseq; + struct rb_iseq_struct *parent_iseq; + struct rb_iseq_struct *local_iseq; /* block inlining */ NODE *node; @@ -299,25 +299,25 @@ struct yarv_iseq_struct { /* misc */ ID defined_method_id; /* for define_method */ - yarv_iseq_profile_t profile; - + rb_iseq_profile_t profile; + struct iseq_compile_data *compile_data; }; -typedef struct yarv_iseq_struct yarv_iseq_t; +typedef struct rb_iseq_struct rb_iseq_t; #define GetVMPtr(obj, ptr) \ - Data_Get_Struct(obj, yarv_vm_t, ptr) + Data_Get_Struct(obj, rb_vm_t, ptr) -struct yarv_thread_struct; +struct rb_thread_struct; -typedef struct yarv_vm_struct { +typedef struct rb_vm_struct { VALUE self; - yarv_thread_lock_t global_interpreter_lock; + rb_thread_lock_t global_interpreter_lock; - struct yarv_thread_struct *main_thread; - struct yarv_thread_struct *running_thread; + struct rb_thread_struct *main_thread; + struct rb_thread_struct *running_thread; st_table *living_threads; VALUE thgroup_default; @@ -332,18 +332,18 @@ typedef struct yarv_vm_struct { int signal_buff[RUBY_NSIG]; int bufferd_signal_size; -} yarv_vm_t; +} rb_vm_t; typedef struct { VALUE *pc; /* cfp[0] */ VALUE *sp; /* cfp[1] */ VALUE *bp; /* cfp[2] */ - yarv_iseq_t *iseq; /* cfp[3] */ + rb_iseq_t *iseq; /* cfp[3] */ VALUE magic; /* cfp[4] */ VALUE self; /* cfp[5] / block[0] */ VALUE *lfp; /* cfp[6] / block[1] */ VALUE *dfp; /* cfp[7] / block[2] */ - yarv_iseq_t *block_iseq; /* cfp[8] / block[3] */ + rb_iseq_t *block_iseq; /* cfp[8] / block[3] */ VALUE proc; /* cfp[9] / block[4] */ ID callee_id; /* cfp[10] */ ID method_id; /* cfp[11] saved in special case */ @@ -351,20 +351,20 @@ typedef struct { VALUE prof_time_self; /* cfp[13] */ VALUE prof_time_chld; /* cfp[14] */ VALUE dummy; /* cfp[15] */ -} yarv_control_frame_t; +} rb_control_frame_t; typedef struct { VALUE self; /* share with method frame if it's only block */ VALUE *lfp; /* share with method frame if it's only block */ VALUE *dfp; /* share with method frame if it's only block */ - yarv_iseq_t *iseq; + rb_iseq_t *iseq; VALUE proc; -} yarv_block_t; +} rb_block_t; #define GetThreadPtr(obj, ptr) \ - Data_Get_Struct(obj, yarv_thread_t, ptr) + Data_Get_Struct(obj, rb_thead_t, ptr) -enum yarv_thread_status { +enum rb_thread_status { THREAD_TO_KILL, THREAD_RUNNABLE, THREAD_STOPPED, @@ -380,27 +380,27 @@ typedef struct { typedef jmp_buf rb_jmpbuf_t; #endif -struct yarv_tag { +struct rb_vm_tag { rb_jmpbuf_t buf; VALUE tag; VALUE retval; - struct yarv_tag *prev; + struct rb_vm_tag *prev; }; -typedef void yarv_interrupt_function_t(struct yarv_thread_struct *); +typedef void rb_interrupt_function_t(struct rb_thread_struct *); -#define YARV_VALUE_CACHE_SIZE 0x1000 +#define RUBY_VM_VALUE_CACHE_SIZE 0x1000 #define USE_VALUE_CACHE 1 -typedef struct yarv_thread_struct +typedef struct rb_thread_struct { VALUE self; - yarv_vm_t *vm; + rb_vm_t *vm; /* execution information */ VALUE *stack; /* must free, must mark */ unsigned long stack_size; - yarv_control_frame_t *cfp; + rb_control_frame_t *cfp; int safe_level; int raised_flag; @@ -408,20 +408,20 @@ typedef struct yarv_thread_struct int state; /* for rb_iterate */ - yarv_block_t *passed_block; + rb_block_t *passed_block; /* passed via parse.y, eval.c (rb_scope_setup_local_tbl) */ ID *top_local_tbl; /* eval env */ - yarv_block_t *base_block; + rb_block_t *base_block; VALUE *local_lfp; VALUE local_svar; /* thread control */ - yarv_thread_id_t thread_id; - enum yarv_thread_status status; + rb_thread_id_t thread_id; + enum rb_thread_status status; int priority; native_thread_data_t native_thread_data; @@ -434,22 +434,22 @@ typedef struct yarv_thread_struct int exec_signal; int interrupt_flag; - yarv_interrupt_function_t *interrupt_function; - yarv_thread_lock_t interrupt_lock; + rb_interrupt_function_t *interrupt_function; + rb_thread_lock_t interrupt_lock; - struct yarv_tag *tag; + struct rb_vm_tag *tag; int parse_in_eval; /* storage */ st_table *local_storage; #if USE_VALUE_CACHE - VALUE value_cache[YARV_VALUE_CACHE_SIZE + 1]; + VALUE value_cache[RUBY_VM_VALUE_CACHE_SIZE + 1]; VALUE *value_cache_ptr; #endif - struct yarv_thread_struct *join_list_next; - struct yarv_thread_struct *join_list_head; + struct rb_thread_struct *join_list_next; + struct rb_thread_struct *join_list_head; VALUE first_proc; VALUE first_args; @@ -467,30 +467,30 @@ typedef struct yarv_thread_struct /* misc */ int method_missing_reason; int abort_on_exception; -} yarv_thread_t; +} rb_thead_t; /** node -> yarv instruction sequence object */ VALUE iseq_compile(VALUE self, NODE *node); -VALUE yarv_iseq_new(NODE *node, VALUE name, VALUE file, - VALUE parent, VALUE type); +VALUE rb_iseq_new(NODE *node, VALUE name, VALUE file, + VALUE parent, VALUE type); -VALUE yarv_iseq_new_with_bopt(NODE *node, VALUE name, VALUE file_name, - VALUE parent, VALUE type, VALUE bopt); +VALUE rb_iseq_new_with_bopt(NODE *node, VALUE name, VALUE file_name, + VALUE parent, VALUE type, VALUE bopt); -VALUE yarv_iseq_new_with_opt(NODE *node, VALUE name, VALUE file, - VALUE parent, VALUE type, - const yarv_compile_option_t *opt); +VALUE rb_iseq_new_with_opt(NODE *node, VALUE name, VALUE file, + VALUE parent, VALUE type, + const rb_compile_option_t *opt); /** disassemble instruction sequence */ -VALUE iseq_disasm(VALUE self); -VALUE iseq_disasm_insn(VALUE str, VALUE *iseqval, int pos, - yarv_iseq_t *iseq, VALUE child); -char *node_name(int node); +VALUE ruby_iseq_disasm(VALUE self); +VALUE ruby_iseq_disasm_insn(VALUE str, VALUE *iseqval, int pos, + rb_iseq_t *iseq, VALUE child); +char *ruby_node_name(int node); /* each thread has this size stack : 2MB */ -#define YARV_THREAD_STACK_SIZE (128 * 1024) +#define RUBY_VM_THREAD_STACK_SIZE (128 * 1024) /* from ruby 1.9 variable.c */ @@ -500,10 +500,10 @@ struct global_entry { }; #define GetProcPtr(obj, ptr) \ - Data_Get_Struct(obj, yarv_proc_t, ptr) + Data_Get_Struct(obj, rb_proc_t, ptr) typedef struct { - yarv_block_t block; + rb_block_t block; VALUE envval; /* for GC mark */ VALUE blockprocval; @@ -511,26 +511,26 @@ typedef struct { int is_lambda; NODE *special_cref_stack; -} yarv_proc_t; +} rb_proc_t; #define GetEnvPtr(obj, ptr) \ - Data_Get_Struct(obj, yarv_env_t, ptr) + Data_Get_Struct(obj, rb_env_t, ptr) typedef struct { VALUE *env; int env_size; int local_size; VALUE prev_envval; /* for GC mark */ - yarv_block_t block; -} yarv_env_t; + rb_block_t block; +} rb_env_t; #define GetBindingPtr(obj, ptr) \ - Data_Get_Struct(obj, yarv_binding_t, ptr) + Data_Get_Struct(obj, rb_binding_t, ptr) typedef struct { VALUE env; NODE *cref_stack; -} yarv_binding_t; +} rb_binding_t; /* used by compile time and send insn */ @@ -558,27 +558,26 @@ typedef VALUE CDHASH; #define GC_GUARDED_PTR_REF(p) ((void *)(((VALUE)p) & ~0x03)) #define GC_GUARDED_PTR_P(p) (((VALUE)p) & 0x01) -#define YARV_METHOD_NODE NODE_METHOD +#define RUBY_VM_METHOD_NODE NODE_METHOD -#define YARV_PREVIOUS_CONTROL_FRAME(cfp) (cfp+1) -#define YARV_NEXT_CONTROL_FRAME(cfp) (cfp-1) -#define YARV_END_CONTROL_FRAME(th) \ - ((yarv_control_frame_t *)((th)->stack + (th)->stack_size)) -#define YARV_VALID_CONTROL_FRAME_P(cfp, ecfp) \ +#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) (cfp+1) +#define RUBY_VM_NEXT_CONTROL_FRAME(cfp) (cfp-1) +#define RUBY_VM_END_CONTROL_FRAME(th) \ + ((rb_control_frame_t *)((th)->stack + (th)->stack_size)) +#define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \ ((void *)(ecfp) > (void *)(cfp)) -#define YARV_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \ - (!YARV_VALID_CONTROL_FRAME_P((cfp), YARV_END_CONTROL_FRAME(th))) +#define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \ + (!RUBY_VM_VALID_CONTROL_FRAME_P((cfp), RUBY_VM_END_CONTROL_FRAME(th))) -#define YARV_IFUNC_P(ptr) (BUILTIN_TYPE(ptr) == T_NODE) -#define YARV_NORMAL_ISEQ_P(ptr) \ - (ptr && !YARV_IFUNC_P(ptr)) +#define RUBY_VM_IFUNC_P(ptr) (BUILTIN_TYPE(ptr) == T_NODE) +#define RUBY_VM_NORMAL_ISEQ_P(ptr) \ + (ptr && !RUBY_VM_IFUNC_P(ptr)) -#define YARV_CLASS_SPECIAL_P(ptr) (((VALUE)(ptr)) & 0x02) -#define YARV_BLOCK_PTR_P(ptr) (!YARV_CLASS_SPECIAL_P(ptr) && GC_GUARDED_PTR_REF(ptr)) +#define RUBY_VM_CLASS_SPECIAL_P(ptr) (((VALUE)(ptr)) & 0x02) -#define GET_BLOCK_PTR_IN_CFP(cfp) ((yarv_block_t *)(&(cfp)->self)) -#define GET_CFP_FROM_BLOCK_PTR(b) \ - ((yarv_control_frame_t *)((VALUE *)(b) - 5)) +#define RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp) ((rb_block_t *)(&(cfp)->self)) +#define RUBY_VM_GET_CFP_FROM_BLOCK_PTR(b) \ + ((rb_control_frame_t *)((VALUE *)(b) - 5)) /* defined? */ @@ -595,12 +594,11 @@ typedef VALUE CDHASH; /* VM related object allocate functions */ /* TODO: should be static functions */ -VALUE yarv_thread_alloc(VALUE klass); -VALUE yarv_env_alloc(void); -VALUE yarv_proc_alloc(void); +VALUE rb_thread_alloc(VALUE klass); +VALUE rb_proc_alloc(void); /* for debug */ -extern void vm_stack_dump_raw(yarv_thread_t *, yarv_control_frame_t *); +extern void vm_stack_dump_raw(rb_thead_t *, rb_control_frame_t *); #define SDR() vm_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp) #define SDR2(cfp) vm_stack_dump_raw(GET_THREAD(), (cfp)) @@ -609,28 +607,28 @@ extern void vm_stack_dump_raw(yarv_thread_t *, yarv_control_frame_t *); #include "yarv.h" #define GVL_UNLOCK_BEGIN() do { \ - yarv_thread_t *_th_stored = GET_THREAD(); \ + rb_thead_t *_th_stored = GET_THREAD(); \ rb_gc_save_machine_context(_th_stored); \ native_mutex_unlock(&_th_stored->vm->global_interpreter_lock) #define GVL_UNLOCK_END() \ native_mutex_lock(&_th_stored->vm->global_interpreter_lock); \ - yarv_set_current_running_thread(_th_stored); \ + rb_thread_set_current(_th_stored); \ } while(0) NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p)); -NOINLINE(void rb_gc_save_machine_context(yarv_thread_t *)); +NOINLINE(void rb_gc_save_machine_context(rb_thead_t *)); -void yarv_thread_execute_interrupts(yarv_thread_t *); +void rb_thread_execute_interrupts(rb_thead_t *); -#define YARV_CHECK_INTS_TH(th) do { \ +#define RUBY_VM_CHECK_INTS_TH(th) do { \ if(th->interrupt_flag){ \ /* TODO: trap something event */ \ - yarv_thread_execute_interrupts(th); \ + rb_thread_execute_interrupts(th); \ } \ } while (0) -#define YARV_CHECK_INTS() \ - YARV_CHECK_INTS_TH(GET_THREAD()) +#define RUBY_VM_CHECK_INTS() \ + RUBY_VM_CHECK_INTS_TH(GET_THREAD()) #endif /* _YARVCORE_H_INCLUDED_ */ |