зеркало из https://github.com/github/ruby.git
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting unused variables and removing yarv.h. This commit doesn't change any behavior of ruby/vm. * yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h). * error.c, eval_intern.h: include yarvcore.h instead yarv.h * rename some functions: * debug.[ch]: debug_*() -> ruby_debug_*() * iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm() * iseq.c: node_name() -> ruby_node_name() * vm.c: yarv_check_redefinition_opt_method() -> rb_vm_check_redefinition_opt_method() * some refactoring with checking -Wall. * array.c: remove rb_ary_ptr() (unused) and remove unused local variables. * object.c: add a prototype of rb_mod_module_exec(). * eval_intern.h (ruby_cref): set it inline. * eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal(). * parse.y: add a prototype of rb_parse_in_eval() (in eval.c). * process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c). * thread.c: remove raw_gets() function (unused) and fix some format mismatch (format mismatchs have remained yet. this is todo). * thread.c (rb_thread_wait_fd_rw): fix typo on label name. * thread_pthread.ci: comment out codes with USE_THREAD_CACHE. * vm.c (rb_svar, rb_backref_get, rb_backref_get, rb_lastline_get, rb_lastline_set) : moved from yarvcore.c. * vm.c (yarv_init_redefined_flag): add a prototype and rename yarv_opt_method_table to vm_opt_method_table. * vm.c (rb_thread_eval): moved from yarvcore.c. * yarvcore.c: remove unused global variables and fix to use nsdr(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
8ee7d0767f
Коммит
44aef0b53f
50
ChangeLog
50
ChangeLog
|
@ -1,3 +1,53 @@
|
|||
Wed Feb 7 09:35:32 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* this commit is a result of refactoring. only renaming functions,
|
||||
moving definitions place, add/remove prototypes, deleting
|
||||
unused variables and removing yarv.h.
|
||||
This commit doesn't change any behavior of ruby/vm.
|
||||
|
||||
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
|
||||
|
||||
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
|
||||
|
||||
* rename some functions:
|
||||
* debug.[ch]: debug_*() -> ruby_debug_*()
|
||||
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
|
||||
* iseq.c: node_name() -> ruby_node_name()
|
||||
* vm.c: yarv_check_redefinition_opt_method() ->
|
||||
rb_vm_check_redefinition_opt_method()
|
||||
|
||||
* some refactoring with checking -Wall.
|
||||
|
||||
* array.c: remove rb_ary_ptr() (unused) and remove unused
|
||||
local variables.
|
||||
|
||||
* object.c: add a prototype of rb_mod_module_exec().
|
||||
|
||||
* eval_intern.h (ruby_cref): set it inline.
|
||||
|
||||
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
|
||||
|
||||
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
|
||||
|
||||
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
|
||||
|
||||
* thread.c: remove raw_gets() function (unused) and fix some format
|
||||
mismatch (format mismatchs have remained yet. this is todo).
|
||||
|
||||
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
|
||||
|
||||
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
|
||||
|
||||
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
|
||||
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
|
||||
|
||||
* vm.c (yarv_init_redefined_flag): add a prototype and rename
|
||||
yarv_opt_method_table to vm_opt_method_table.
|
||||
|
||||
* vm.c (rb_thread_eval): moved from yarvcore.c.
|
||||
|
||||
* yarvcore.c: remove unused global variables and fix to use nsdr().
|
||||
|
||||
Wed Feb 7 03:39:32 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
|
||||
|
|
9
array.c
9
array.c
|
@ -65,12 +65,6 @@ ary_iter_check(VALUE ary)
|
|||
return rb_ensure(func, (ary), each_unlock, (ary));\
|
||||
} while (0)
|
||||
|
||||
static VALUE *
|
||||
rb_ary_ptr(VALUE ary)
|
||||
{
|
||||
return RARRAY_PTR(ary);
|
||||
}
|
||||
|
||||
static inline void
|
||||
rb_ary_modify_check(VALUE ary)
|
||||
{
|
||||
|
@ -1148,7 +1142,6 @@ VALUE yarv_invoke_Array_each_special_block(VALUE ary);
|
|||
VALUE
|
||||
rb_ary_each(VALUE ary)
|
||||
{
|
||||
long i;
|
||||
VALUE val;
|
||||
|
||||
RETURN_ENUMERATOR(ary, 0, 0);
|
||||
|
@ -1811,7 +1804,7 @@ rb_ary_delete(VALUE ary, VALUE item)
|
|||
VALUE
|
||||
rb_ary_delete_at(VALUE ary, long pos)
|
||||
{
|
||||
long i, len = RARRAY_LEN(ary);
|
||||
long len = RARRAY_LEN(ary);
|
||||
VALUE del;
|
||||
|
||||
if (pos >= len) return Qnil;
|
||||
|
|
|
@ -43,11 +43,11 @@ yarv_iseq_special_block(rb_iseq_t *iseq, void *builder)
|
|||
if (iseq->parent_iseq) {
|
||||
parent = iseq->parent_iseq->self;
|
||||
}
|
||||
iseqval = yarv_iseq_new_with_bopt(iseq->node, iseq->name, iseq->file_name,
|
||||
iseqval = rb_iseq_new_with_bopt(iseq->node, iseq->name, iseq->file_name,
|
||||
parent, iseq->type,
|
||||
GC_GUARDED_PTR(builder));
|
||||
if (0) {
|
||||
printf("%s\n", RSTRING_PTR(iseq_disasm(iseqval)));
|
||||
printf("%s\n", RSTRING_PTR(ruby_iseq_disasm(iseqval)));
|
||||
}
|
||||
iseq->cached_special_block = iseqval;
|
||||
iseq->cached_special_block_builder = builder;
|
||||
|
@ -104,7 +104,7 @@ new_assign(NODE * lnode, NODE * rhs)
|
|||
args);
|
||||
}
|
||||
default:
|
||||
rb_bug("unimplemented (block inlining): %s", node_name(nd_type(lnode)));
|
||||
rb_bug("unimplemented (block inlining): %s", ruby_node_name(nd_type(lnode)));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
27
common.mk
27
common.mk
|
@ -396,26 +396,25 @@ eval.$(OBJEXT): {$(VPATH)}eval.c {$(VPATH)}eval_intern.h \
|
|||
{$(VPATH)}ruby.h config.h {$(VPATH)}yarvcore.h \
|
||||
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
|
||||
{$(VPATH)}node.h {$(VPATH)}util.h \
|
||||
{$(VPATH)}rubysig.h {$(VPATH)}st.h {$(VPATH)}dln.h {$(VPATH)}yarv.h
|
||||
{$(VPATH)}rubysig.h {$(VPATH)}st.h {$(VPATH)}dln.h
|
||||
eval_load.$(OBJEXT): {$(VPATH)}eval_load.c {$(VPATH)}eval_intern.h \
|
||||
{$(VPATH)}ruby.h config.h \
|
||||
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
|
||||
{$(VPATH)}node.h {$(VPATH)}util.h {$(VPATH)}yarvcore.h \
|
||||
{$(VPATH)}rubysig.h {$(VPATH)}st.h {$(VPATH)}dln.h {$(VPATH)}yarv.h
|
||||
{$(VPATH)}rubysig.h {$(VPATH)}st.h {$(VPATH)}dln.h
|
||||
proc.$(OBJEXT): {$(VPATH)}proc.c {$(VPATH)}eval_intern.h \
|
||||
{$(VPATH)}ruby.h config.h {$(VPATH)}yarvcore.h \
|
||||
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
|
||||
{$(VPATH)}node.h {$(VPATH)}util.h \
|
||||
{$(VPATH)}rubysig.h {$(VPATH)}st.h {$(VPATH)}dln.h {$(VPATH)}yarv.h
|
||||
{$(VPATH)}rubysig.h {$(VPATH)}st.h {$(VPATH)}dln.h
|
||||
|
||||
thread.$(OBJEXT): {$(VPATH)}thread.c {$(VPATH)}eval_intern.h \
|
||||
{$(VPATH)}thread_win32.h {$(VPATH)}thread_pthread.h \
|
||||
{$(VPATH)}thread_win32.ci {$(VPATH)}thread_pthread.ci \
|
||||
{$(VPATH)}ruby.h config.h \
|
||||
{$(VPATH)}ruby.h {$(VPATH)}yarvcore.h config.h \
|
||||
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
|
||||
{$(VPATH)}node.h {$(VPATH)}util.h \
|
||||
{$(VPATH)}rubysig.h {$(VPATH)}st.h {$(VPATH)}dln.h \
|
||||
{$(VPATH)}yarv.h {$(VPATH)}yarvcore.h
|
||||
{$(VPATH)}rubysig.h {$(VPATH)}st.h {$(VPATH)}dln.h
|
||||
|
||||
file.$(OBJEXT): {$(VPATH)}file.c {$(VPATH)}ruby.h config.h \
|
||||
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
|
||||
|
@ -507,17 +506,17 @@ version.$(OBJEXT): {$(VPATH)}version.c {$(VPATH)}ruby.h config.h \
|
|||
compile.$(OBJEXT): {$(VPATH)}compile.c {$(VPATH)}yarvcore.h \
|
||||
{$(VPATH)}compile.h {$(VPATH)}debug.h {$(VPATH)}ruby.h config.h \
|
||||
{$(VPATH)}defines.h {$(VPATH)}missing.h {$(VPATH)}intern.h \
|
||||
{$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}yarv.h \
|
||||
{$(VPATH)}st.h {$(VPATH)}node.h \
|
||||
{$(VPATH)}insns.inc {$(VPATH)}insns_info.inc {$(VPATH)}optinsn.inc \
|
||||
{$(VPATH)}opt_sc.inc {$(VPATH)}optunifs.inc {$(VPATH)}vm_opts.h
|
||||
iseq.$(OBJEXT): {$(VPATH)}iseq.c {$(VPATH)}yarvcore.h {$(VPATH)}debug.h \
|
||||
{$(VPATH)}ruby.h {$(VPATH)}defines.h {$(VPATH)}missing.h \
|
||||
{$(VPATH)}intern.h {$(VPATH)}st.h {$(VPATH)}yarv.h \
|
||||
{$(VPATH)}intern.h {$(VPATH)}st.h \
|
||||
{$(VPATH)}gc.h {$(VPATH)}vm_opts.h \
|
||||
{$(VPATH)}insns.inc {$(VPATH)}insns_info.inc
|
||||
vm.$(OBJEXT): {$(VPATH)}vm.c {$(VPATH)}vm.h {$(VPATH)}insnhelper.h \
|
||||
{$(VPATH)}yarvcore.h {$(VPATH)}debug.h {$(VPATH)}ruby.h config.h\
|
||||
{$(VPATH)}node.h {$(VPATH)}yarv.h {$(VPATH)}version.h \
|
||||
{$(VPATH)}node.h {$(VPATH)}version.h \
|
||||
{$(VPATH)}util.h {$(VPATH)}rubysig.h {$(VPATH)}dln.h \
|
||||
{$(VPATH)}vm_evalbody.ci {$(VPATH)}call_cfunc.ci \
|
||||
{$(VPATH)}insns.inc {$(VPATH)}vm.inc {$(VPATH)}vmtc.inc \
|
||||
|
@ -525,17 +524,17 @@ vm.$(OBJEXT): {$(VPATH)}vm.c {$(VPATH)}vm.h {$(VPATH)}insnhelper.h \
|
|||
vm_dump.$(OBJEXT): {$(VPATH)}yarvcore.h {$(VPATH)}vm.h config.h \
|
||||
{$(VPATH)}ruby.h {$(VPATH)}defines.h {$(VPATH)}missing.h \
|
||||
{$(VPATH)}intern.h {$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}debug.h \
|
||||
{$(VPATH)}yarv.h {$(VPATH)}version.h {$(VPATH)}vm_opts.h
|
||||
{$(VPATH)}version.h {$(VPATH)}vm_opts.h
|
||||
yarvcore.$(OBJEXT): {$(VPATH)}yarvcore.c {$(VPATH)}yarvcore.h \
|
||||
{$(VPATH)}debug.h {$(VPATH)}ruby.h config.h {$(VPATH)}defines.h \
|
||||
{$(VPATH)}missing.h {$(VPATH)}intern.h {$(VPATH)}st.h \
|
||||
{$(VPATH)}node.h {$(VPATH)}yarv.h {$(VPATH)}gc.h {$(VPATH)}vm_opts.h
|
||||
{$(VPATH)}node.h {$(VPATH)}gc.h {$(VPATH)}vm_opts.h
|
||||
debug.$(OBJEXT): {$(VPATH)}debug.h {$(VPATH)}ruby.h {$(VPATH)}defines.h \
|
||||
{$(VPATH)}missing.h {$(VPATH)}intern.h {$(VPATH)}st.h config.h \
|
||||
{$(VPATH)}st.h
|
||||
blockinlining.$(OBJEXT): {$(VPATH)}ruby.h {$(VPATH)}defines.h \
|
||||
{$(VPATH)}missing.h {$(VPATH)}intern.h {$(VPATH)}st.h config.h \
|
||||
{$(VPATH)}node.h {$(VPATH)}yarv.h {$(VPATH)}yarvcore.h \
|
||||
{$(VPATH)}node.h {$(VPATH)}yarvcore.h \
|
||||
{$(VPATH)}debug.h {$(VPATH)}vm_opts.h
|
||||
|
||||
|
||||
|
@ -610,8 +609,8 @@ vmasm: vm.$(ASMEXT)
|
|||
# vm.o : CFLAGS += -fno-crossjumping
|
||||
|
||||
run.gdb:
|
||||
echo b debug_breakpoint > run.gdb
|
||||
# echo handle SIGINT nostop >> run.gdb
|
||||
echo b ruby_debug_breakpoint > run.gdb
|
||||
# echo handle SIGINT nostop >> run.gdb
|
||||
# echo handle SIGPIPE nostop >> run.gdb
|
||||
echo run >> run.gdb
|
||||
|
||||
|
|
32
compile.c
32
compile.c
|
@ -27,6 +27,8 @@
|
|||
#define va_init_list(a,b) va_start(a)
|
||||
#endif
|
||||
|
||||
VALUE iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt);
|
||||
|
||||
/* types */
|
||||
|
||||
#define ISEQ_ELEMENT_NONE INT2FIX(0x00)
|
||||
|
@ -83,7 +85,6 @@ static long gl_tmp = 0;
|
|||
static void debug_list(LINK_ANCHOR *anchor);
|
||||
#endif
|
||||
|
||||
static void dump_disasm_anchor(LINK_ANCHOR *anc);
|
||||
static void dump_disasm_list(LINK_ELEMENT *elem);
|
||||
|
||||
static int insn_data_length(INSN *iobj);
|
||||
|
@ -688,7 +689,6 @@ static VALUE
|
|||
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");
|
||||
|
@ -750,7 +750,7 @@ iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
|
|||
GC_CHECK();
|
||||
|
||||
if (CPDEBUG > 1) {
|
||||
VALUE str = iseq_disasm(iseq->self);
|
||||
VALUE str = ruby_iseq_disasm(iseq->self);
|
||||
printf("%s\n", StringValueCStr(str));
|
||||
fflush(stdout);
|
||||
}
|
||||
|
@ -2002,12 +2002,12 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * cond,
|
|||
case NODE_LIT: /* NODE_LIT is always not true */
|
||||
case NODE_TRUE:
|
||||
case NODE_STR:
|
||||
/* printf("useless conditon eliminate (%s)\n", node_name(nd_type(cond))); */
|
||||
/* printf("useless conditon eliminate (%s)\n", ruby_node_name(nd_type(cond))); */
|
||||
ADD_INSNL(ret, nd_line(cond), jump, then_label);
|
||||
break;
|
||||
case NODE_FALSE:
|
||||
case NODE_NIL:
|
||||
/* printf("useless conditon eliminate (%s)\n", node_name(nd_type(cond))); */
|
||||
/* printf("useless conditon eliminate (%s)\n", ruby_node_name(nd_type(cond))); */
|
||||
ADD_INSNL(ret, nd_line(cond), jump, else_label);
|
||||
break;
|
||||
default:
|
||||
|
@ -2249,7 +2249,7 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *ret,
|
|||
COMPILE(ret, "rhs to ary (splat/default)", rhsn);
|
||||
ADD_INSN2(ret, nd_line(rhsn), expandarray, INT2FIX(llen),
|
||||
INT2FIX(lhs_splat));
|
||||
/* rb_bug("unknown rhs: %s", node_name(nd_type(rhsn))); */
|
||||
/* rb_bug("unknown rhs: %s", ruby_node_name(nd_type(rhsn))); */
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -2469,7 +2469,7 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
|
|||
|
||||
ADD_CATCH_ENTRY(CATCH_TYPE_ENSURE, lstart, lend, ensure, lfinish);
|
||||
return 1;
|
||||
/* rb_bug("unimplemented defined: %s", node_name(nd_type(node))); */
|
||||
/* rb_bug("unimplemented defined: %s", ruby_node_name(nd_type(node))); */
|
||||
} /* end of default */
|
||||
}
|
||||
|
||||
|
@ -2571,7 +2571,6 @@ setup_arg(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *node, VALUE *flag)
|
|||
{
|
||||
VALUE argc = INT2FIX(0);
|
||||
NODE *argn = node->nd_args;
|
||||
NODE *argp = 0;
|
||||
DECL_ANCHOR(arg_block);
|
||||
DECL_ANCHOR(args_push);
|
||||
|
||||
|
@ -2718,7 +2717,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
}
|
||||
case NODE_CASE:{
|
||||
NODE *vals;
|
||||
NODE *val;
|
||||
NODE *tempnode = node;
|
||||
LABEL *endlabel, *elselabel;
|
||||
DECL_ANCHOR(head);
|
||||
|
@ -2736,7 +2734,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
type = nd_type(node);
|
||||
|
||||
if (type != NODE_WHEN) {
|
||||
COMPILE_ERROR(("NODE_CASE: unexpected node. must be NODE_WHEN, but %s", node_name(type)));
|
||||
COMPILE_ERROR(("NODE_CASE: unexpected node. must be NODE_WHEN, but %s", ruby_node_name(type)));
|
||||
}
|
||||
|
||||
endlabel = NEW_LABEL(nd_line(node));
|
||||
|
@ -2772,7 +2770,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
ADD_INSNL(cond_seq, nd_line(val), branchif, l1);
|
||||
}
|
||||
else {
|
||||
rb_bug("NODE_CASAE: unknown node (%s)", node_name(nd_type(vals)));
|
||||
rb_bug("NODE_CASAE: unknown node (%s)", ruby_node_name(nd_type(vals)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -3768,7 +3766,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
break;
|
||||
|
||||
default:
|
||||
rb_bug("can't make hash with this node: %s", node_name(type));
|
||||
rb_bug("can't make hash with this node: %s", ruby_node_name(type));
|
||||
}
|
||||
|
||||
ADD_INSN1(ret, nd_line(node), newhash, size);
|
||||
|
@ -4531,7 +4529,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
COMPILE_ERROR(("BUG: unknown node (default): %s", node_name(type)));
|
||||
COMPILE_ERROR(("BUG: unknown node (default): %s", ruby_node_name(type)));
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
@ -4629,12 +4627,6 @@ insn_data_to_s_detail(INSN *iobj)
|
|||
return str;
|
||||
}
|
||||
|
||||
static void
|
||||
dump_disasm_anchor(LINK_ANCHOR *anc)
|
||||
{
|
||||
dump_disasm_list(FIRST_ELEMENT(anc));
|
||||
}
|
||||
|
||||
static void
|
||||
dump_disasm_list(struct iseq_link_element *link)
|
||||
{
|
||||
|
@ -4729,8 +4721,6 @@ get_exception_sym2type(VALUE sym)
|
|||
return 0;
|
||||
}
|
||||
|
||||
VALUE iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt);
|
||||
|
||||
static int
|
||||
iseq_build_exception(rb_iseq_t *iseq, struct st_table *labels_table,
|
||||
VALUE exception)
|
||||
|
|
10
compile.h
10
compile.h
|
@ -42,7 +42,7 @@
|
|||
|
||||
#define debugp(header, value) \
|
||||
(debug_indent(0, CPDEBUG, gl_node_level * 2), \
|
||||
debug_value(0, CPDEBUG, header, value))
|
||||
ruby_debug_value(0, CPDEBUG, header, value))
|
||||
|
||||
#define debugi(header, id) \
|
||||
(debug_indent(0, CPDEBUG, gl_node_level * 2), \
|
||||
|
@ -50,19 +50,19 @@
|
|||
|
||||
#define debugp_param(header, value) \
|
||||
(debug_indent(1, CPDEBUG, gl_node_level * 2), \
|
||||
debug_value(1, CPDEBUG, header, value))
|
||||
ruby_debug_value(1, CPDEBUG, header, value))
|
||||
|
||||
#define debugp_verbose(header, value) \
|
||||
(debug_indent(2, CPDEBUG, gl_node_level * 2), \
|
||||
debug_value(2, CPDEBUG, header, value))
|
||||
ruby_debug_value(2, CPDEBUG, header, value))
|
||||
|
||||
#define debugp_verbose_node(header, value) \
|
||||
(debug_indent(10, CPDEBUG, gl_node_level * 2), \
|
||||
debug_value(10, CPDEBUG, header, value))
|
||||
ruby_debug_value(10, CPDEBUG, header, value))
|
||||
|
||||
#define debug_nodeprint(node) \
|
||||
debug_indent(-1, CPDEBUG, gl_node_level*2); \
|
||||
printf("node: %s (%d)\n", node_name(nd_type(node)), nd_line(node)); \
|
||||
printf("node: %s (%d)\n", ruby_node_name(nd_type(node)), nd_line(node)); \
|
||||
gl_node_level ++;
|
||||
|
||||
#define debug_nodeprint_close() gl_node_level --;
|
||||
|
|
14
debug.c
14
debug.c
|
@ -14,7 +14,7 @@
|
|||
#include "debug.h"
|
||||
|
||||
void
|
||||
debug_indent(int level, int debug_level, int indent_level)
|
||||
ruby_debug_indent(int level, int debug_level, int indent_level)
|
||||
{
|
||||
if (level < debug_level) {
|
||||
int i;
|
||||
|
@ -26,7 +26,7 @@ debug_indent(int level, int debug_level, int indent_level)
|
|||
}
|
||||
|
||||
VALUE
|
||||
debug_value(int level, int debug_level, char *header, VALUE obj)
|
||||
ruby_debug_value(int level, int debug_level, char *header, VALUE obj)
|
||||
{
|
||||
if (level < debug_level) {
|
||||
VALUE str;
|
||||
|
@ -39,13 +39,13 @@ debug_value(int level, int debug_level, char *header, VALUE obj)
|
|||
}
|
||||
|
||||
void
|
||||
debug_v(VALUE v)
|
||||
ruby_debug_v(VALUE v)
|
||||
{
|
||||
debug_value(0, 1, "", v);
|
||||
ruby_debug_value(0, 1, "", v);
|
||||
}
|
||||
|
||||
ID
|
||||
debug_id(int level, int debug_level, char *header, ID id)
|
||||
ruby_debug_id(int level, int debug_level, char *header, ID id)
|
||||
{
|
||||
if (level < debug_level) {
|
||||
fprintf(stderr, "DBG> %s: %s\n", header, rb_id2name(id));
|
||||
|
@ -55,7 +55,7 @@ debug_id(int level, int debug_level, char *header, ID id)
|
|||
}
|
||||
|
||||
void
|
||||
gc_check_func(void)
|
||||
ruby_debug_gc_check_func(void)
|
||||
{
|
||||
int i;
|
||||
#define GCMKMAX 0x10
|
||||
|
@ -66,7 +66,7 @@ gc_check_func(void)
|
|||
}
|
||||
|
||||
void
|
||||
debug_breakpoint(void)
|
||||
ruby_debug_breakpoint(void)
|
||||
{
|
||||
/* */
|
||||
}
|
||||
|
|
20
debug.h
20
debug.h
|
@ -15,16 +15,16 @@
|
|||
|
||||
#include <ruby.h>
|
||||
|
||||
VALUE debug_value(int level, int debug_level, char *header, VALUE v);
|
||||
ID debug_id(int level, int debug_level, char *header, ID id);
|
||||
void debug_indent(int level, int debug_level, int indent_level);
|
||||
#define dpv(h,v) ruby_debug_value(-1, 0, h, v)
|
||||
#define dp(v) ruby_debug_value(-1, 0, "", v)
|
||||
#define dpi(i) ruby_debug_id (-1, 0, "", i)
|
||||
#define bp() ruby_debug_breakpoint()
|
||||
|
||||
#define dpv(h,v) debug_value(-1, 0, h, v)
|
||||
#define dp(v) debug_value(-1, 0, "", v)
|
||||
#define dpi(i) debug_id (-1, 0, "", i)
|
||||
#define bp() debug_breakpoint()
|
||||
|
||||
void gc_check_func();
|
||||
VALUE ruby_debug_value(int level, int debug_level, char *header, VALUE v);
|
||||
ID ruby_debug_id(int level, int debug_level, char *header, ID id);
|
||||
void ruby_debug_indent(int level, int debug_level, int indent_level);
|
||||
void ruby_debug_breakpoint(void);
|
||||
void ruby_debug_gc_check_func();
|
||||
|
||||
#if GCDEBUG == 1
|
||||
|
||||
|
@ -35,7 +35,7 @@ void gc_check_func();
|
|||
|
||||
#define GC_CHECK() \
|
||||
(printf("** %s:%d gc start\n", __FILE__, __LINE__), \
|
||||
gc_check_func(), \
|
||||
ruby_debug_gc_check_func(), \
|
||||
printf("** end\n"))
|
||||
|
||||
#else
|
||||
|
|
2
error.c
2
error.c
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "ruby.h"
|
||||
#include "st.h"
|
||||
#include "yarv.h"
|
||||
#include "yarvcore.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
|
13
eval.c
13
eval.c
|
@ -1645,7 +1645,7 @@ rb_call(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope)
|
|||
//static int level;
|
||||
//int i;
|
||||
//for(i=0; i<level; i++){printf(" ");}
|
||||
//printf("invoke %s (%s)\n", rb_id2name(mid), node_name(nd_type(body)));
|
||||
//printf("invoke %s (%s)\n", rb_id2name(mid), ruby_node_name(nd_type(body)));
|
||||
//level++;
|
||||
//printf("%s with %d args\n", rb_id2name(mid), argc);
|
||||
*/
|
||||
|
@ -1655,7 +1655,7 @@ rb_call(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope)
|
|||
/*
|
||||
//level--;
|
||||
//for(i=0; i<level; i++){printf(" ");}
|
||||
//printf("done %s (%s)\n", rb_id2name(mid), node_name(nd_type(body)));
|
||||
//printf("done %s (%s)\n", rb_id2name(mid), ruby_node_name(nd_type(body)));
|
||||
*/
|
||||
return val;
|
||||
}
|
||||
|
@ -1911,9 +1911,6 @@ rb_sourceline(void)
|
|||
return th_get_sourceline(th->cfp);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -1964,7 +1961,8 @@ eval(VALUE self, VALUE src, VALUE scope, char *file, int line)
|
|||
th_set_eval_stack(th, iseqval);
|
||||
th->base_block = 0;
|
||||
if (0) { /* for debug */
|
||||
printf("%s\n", RSTRING_PTR(iseq_disasm(iseqval)));
|
||||
extern VALUE ruby_iseq_disasm(VALUE);
|
||||
printf("%s\n", RSTRING_PTR(ruby_iseq_disasm(iseqval)));
|
||||
}
|
||||
|
||||
/* save new env */
|
||||
|
@ -2179,9 +2177,10 @@ specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
|
|||
SafeStringValue(argv[0]);
|
||||
}
|
||||
if (argc > 3) {
|
||||
char *name = rb_id2name(rb_frame_callee());
|
||||
rb_raise(rb_eArgError,
|
||||
"wrong number of arguments: %s(src) or %s{..}",
|
||||
rb_frame_callee(), rb_frame_callee());
|
||||
name, name);
|
||||
}
|
||||
if (argc > 2)
|
||||
line = NUM2INT(argv[2]);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "node.h"
|
||||
#include "util.h"
|
||||
#include "rubysig.h"
|
||||
#include "yarv.h"
|
||||
#include "yarvcore.h"
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
|
@ -312,7 +312,7 @@ th_get_ruby_level_cfp(rb_thead_t *th, rb_control_frame_t *cfp)
|
|||
return cfp;
|
||||
}
|
||||
|
||||
static NODE *
|
||||
static inline NODE *
|
||||
ruby_cref()
|
||||
{
|
||||
rb_thead_t *th = GET_THREAD();
|
||||
|
@ -322,6 +322,8 @@ ruby_cref()
|
|||
|
||||
VALUE th_get_cbase(rb_thead_t *th);
|
||||
VALUE rb_obj_is_proc(VALUE);
|
||||
void rb_vm_check_redefinition_opt_method(NODE *node);
|
||||
void rb_thread_terminate_all(void);
|
||||
|
||||
#define ruby_cbase() th_get_cbase(GET_THREAD())
|
||||
|
||||
|
|
30
eval_load.c
30
eval_load.c
|
@ -111,7 +111,33 @@ rb_provide(const char *feature)
|
|||
VALUE rb_load_path;
|
||||
|
||||
NORETURN(static void load_failed _((VALUE)));
|
||||
void th_klass_init(rb_thead_t *);
|
||||
|
||||
RUBY_EXTERN NODE *ruby_eval_tree;
|
||||
|
||||
static VALUE
|
||||
rb_load_internal(char *file)
|
||||
{
|
||||
NODE *node;
|
||||
VALUE iseq;
|
||||
rb_thead_t *th = GET_THREAD();
|
||||
|
||||
{
|
||||
th->parse_in_eval++;
|
||||
node = (NODE *)rb_load_file(file);
|
||||
th->parse_in_eval--;
|
||||
node = ruby_eval_tree;
|
||||
}
|
||||
|
||||
if (ruby_nerrs > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
iseq = rb_iseq_new(node, rb_str_new2("<top (required)>"),
|
||||
rb_str_new2(file), Qfalse, ISEQ_TYPE_TOP);
|
||||
|
||||
rb_thread_eval(GET_THREAD(), iseq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rb_load(VALUE fname, int wrap)
|
||||
|
@ -141,7 +167,7 @@ rb_load(VALUE fname, int wrap)
|
|||
PUSH_TAG(PROT_NONE);
|
||||
state = EXEC_TAG();
|
||||
if (state == 0) {
|
||||
yarv_load(RSTRING_PTR(fname));
|
||||
rb_load_internal(RSTRING_PTR(fname));
|
||||
}
|
||||
POP_TAG();
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ rb_add_method(VALUE klass, ID mid, NODE * node, int noex)
|
|||
if (st_lookup(RCLASS(klass)->m_tbl, mid, (st_data_t *)&old_node)) {
|
||||
if (old_node) {
|
||||
if (nd_type(old_node->nd_body->nd_body) == NODE_CFUNC) {
|
||||
yarv_check_redefinition_opt_method(old_node);
|
||||
rb_vm_check_redefinition_opt_method(old_node);
|
||||
}
|
||||
if (RTEST(ruby_verbose) && old_node->nd_cnt == 0 && old_node->nd_body) {
|
||||
rb_warning("method redefined; discarding old %s", rb_id2name(mid));
|
||||
|
|
30
iseq.c
30
iseq.c
|
@ -251,7 +251,7 @@ make_compile_option_value(rb_compile_option_t *option)
|
|||
}
|
||||
|
||||
VALUE
|
||||
yarv_iseq_new(NODE *node, VALUE name, VALUE file_name,
|
||||
rb_iseq_new(NODE *node, VALUE name, VALUE file_name,
|
||||
VALUE parent, VALUE type)
|
||||
{
|
||||
return rb_iseq_new_with_opt(node, name, file_name, parent, type,
|
||||
|
@ -259,7 +259,7 @@ yarv_iseq_new(NODE *node, VALUE name, VALUE file_name,
|
|||
}
|
||||
|
||||
static VALUE
|
||||
yarv_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE file_name,
|
||||
rb_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE file_name,
|
||||
VALUE parent, VALUE type, VALUE bopt,
|
||||
const rb_compile_option_t *option)
|
||||
{
|
||||
|
@ -280,15 +280,15 @@ 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,
|
||||
return rb_iseq_new_with_bopt_and_opt(node, name, file_name, parent, type,
|
||||
Qfalse, option);
|
||||
}
|
||||
|
||||
VALUE
|
||||
yarv_iseq_new_with_bopt(NODE *node, VALUE name, VALUE file_name,
|
||||
rb_iseq_new_with_bopt(NODE *node, VALUE name, VALUE file_name,
|
||||
VALUE parent, VALUE type, VALUE bopt)
|
||||
{
|
||||
return yarv_iseq_new_with_bopt_and_opt(node, name, file_name, parent, type,
|
||||
return rb_iseq_new_with_bopt_and_opt(node, name, file_name, parent, type,
|
||||
bopt, &COMPILE_OPTION_DEFAULT);
|
||||
}
|
||||
|
||||
|
@ -453,8 +453,6 @@ iseq_check(VALUE val)
|
|||
return iseq;
|
||||
}
|
||||
|
||||
VALUE rb_thread_eval(rb_thead_t *th, VALUE iseqval);
|
||||
|
||||
static VALUE
|
||||
iseq_eval(VALUE self)
|
||||
{
|
||||
|
@ -606,7 +604,7 @@ insn_operand_intern(rb_iseq_t *iseq,
|
|||
break;
|
||||
|
||||
default:
|
||||
rb_bug("iseq_disasm: unknown operand type: %c", type);
|
||||
rb_bug("ruby_iseq_disasm: unknown operand type: %c", type);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -616,7 +614,7 @@ insn_operand_intern(rb_iseq_t *iseq,
|
|||
* Iseq -> Iseq inspect object
|
||||
*/
|
||||
VALUE
|
||||
iseq_disasm_insn(VALUE ret, VALUE *iseq, int pos,
|
||||
ruby_iseq_disasm_insn(VALUE ret, VALUE *iseq, int pos,
|
||||
rb_iseq_t *iseqdat, VALUE child)
|
||||
{
|
||||
int insn = iseq[pos];
|
||||
|
@ -694,7 +692,7 @@ catch_type(int type)
|
|||
}
|
||||
|
||||
VALUE
|
||||
iseq_disasm(VALUE self)
|
||||
ruby_iseq_disasm(VALUE self)
|
||||
{
|
||||
rb_iseq_t *iseqdat = iseq_check(self);
|
||||
VALUE *iseq;
|
||||
|
@ -728,7 +726,7 @@ iseq_disasm(VALUE self)
|
|||
(int)entry->end, (int)entry->sp, (int)entry->cont);
|
||||
rb_str_cat2(str, buff);
|
||||
if (entry->iseq) {
|
||||
rb_str_concat(str, iseq_disasm(entry->iseq));
|
||||
rb_str_concat(str, ruby_iseq_disasm(entry->iseq));
|
||||
}
|
||||
}
|
||||
if (iseqdat->catch_table_size != 0) {
|
||||
|
@ -788,19 +786,19 @@ iseq_disasm(VALUE self)
|
|||
|
||||
/* show each line */
|
||||
for (i = 0; i < size;) {
|
||||
i += iseq_disasm_insn(str, iseq, i, iseqdat, child);
|
||||
i += ruby_iseq_disasm_insn(str, iseq, i, iseqdat, child);
|
||||
}
|
||||
|
||||
for (i = 0; i < RARRAY_LEN(child); i++) {
|
||||
VALUE isv = rb_ary_entry(child, i);
|
||||
rb_str_concat(str, iseq_disasm(isv));
|
||||
rb_str_concat(str, ruby_iseq_disasm(isv));
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char *
|
||||
node_name(int node)
|
||||
ruby_node_name(int node)
|
||||
{
|
||||
switch (node) {
|
||||
case NODE_METHOD:
|
||||
|
@ -1031,7 +1029,7 @@ int
|
|||
debug_node(NODE *node)
|
||||
{
|
||||
printf("node type: %d\n", nd_type(node));
|
||||
printf("node name: %s\n", node_name(nd_type(node)));
|
||||
printf("node name: %s\n", ruby_node_name(nd_type(node)));
|
||||
printf("node filename: %s\n", node->nd_file);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1335,7 +1333,7 @@ Init_ISeq(void)
|
|||
rb_cISeq = rb_define_class_under(rb_cVM, "InstructionSequence", rb_cObject);
|
||||
rb_define_alloc_func(rb_cISeq, iseq_alloc);
|
||||
rb_define_method(rb_cISeq, "inspect", iseq_inspect, 0);
|
||||
rb_define_method(rb_cISeq, "disasm", iseq_disasm, 0);
|
||||
rb_define_method(rb_cISeq, "disasm", ruby_iseq_disasm, 0);
|
||||
rb_define_method(rb_cISeq, "to_a", iseq_to_a, 0);
|
||||
rb_define_method(rb_cISeq, "eval", iseq_eval, 0);
|
||||
|
||||
|
|
2
object.c
2
object.c
|
@ -1257,6 +1257,8 @@ rb_class_s_alloc(VALUE klass)
|
|||
* a.meth2 #=> "bye"
|
||||
*/
|
||||
|
||||
extern VALUE rb_mod_module_exec(int argc, VALUE *argv, VALUE mod);
|
||||
|
||||
static VALUE
|
||||
rb_mod_initialize(VALUE module)
|
||||
{
|
||||
|
|
2
parse.y
2
parse.y
|
@ -4698,6 +4698,8 @@ rb_compile_string(const char *f, VALUE s, int line)
|
|||
return rb_parser_compile_string(vparser, f, s, line);
|
||||
}
|
||||
|
||||
int rb_parse_in_eval(void);
|
||||
|
||||
NODE*
|
||||
rb_parser_compile_string(volatile VALUE vparser, const char *f, VALUE s, int line)
|
||||
{
|
||||
|
|
|
@ -898,6 +898,8 @@ proc_detach(VALUE obj, VALUE pid)
|
|||
char *strtok();
|
||||
#endif
|
||||
|
||||
void rb_thread_stop_timer_thread(void);
|
||||
|
||||
#define before_exec() \
|
||||
(rb_enable_interrupt(), rb_thread_stop_timer_thread())
|
||||
#define after_exec() \
|
||||
|
|
30
thread.c
30
thread.c
|
@ -229,9 +229,6 @@ rb_thread_terminate_all(void)
|
|||
system_working = 0;
|
||||
}
|
||||
|
||||
|
||||
VALUE th_eval_body(rb_thead_t *th);
|
||||
|
||||
static void
|
||||
thread_cleanup_func(void *th_ptr)
|
||||
{
|
||||
|
@ -240,7 +237,6 @@ thread_cleanup_func(void *th_ptr)
|
|||
th->machine_stack_start = th->machine_stack_end = 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
thread_start_func_2(rb_thead_t *th, VALUE *stack_start)
|
||||
{
|
||||
|
@ -653,15 +649,13 @@ rb_thread_execute_interrupts(rb_thead_t *th)
|
|||
if (th->throwed_errinfo) {
|
||||
VALUE err = th->throwed_errinfo;
|
||||
th->throwed_errinfo = 0;
|
||||
thread_debug("rb_thread_execute_interrupts: %p\n", err);
|
||||
thread_debug("rb_thread_execute_interrupts: %ld\n", err);
|
||||
|
||||
if (err == eKillSignal) {
|
||||
th->errinfo = INT2FIX(TAG_FATAL);
|
||||
TH_JUMP_TAG(th, TAG_FATAL);
|
||||
}
|
||||
else if (err == eTerminateSignal) {
|
||||
struct rb_vm_tag *tag = th->tag;
|
||||
|
||||
/* rewind to toplevel stack */
|
||||
while (th->tag->prev) {
|
||||
th->tag = th->tag->prev;
|
||||
|
@ -824,7 +818,7 @@ rb_thread_kill(VALUE thread)
|
|||
rb_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
thread_debug("rb_thread_kill: %p (%p)\n", th, th->thread_id);
|
||||
thread_debug("rb_thread_kill: %p (%p)\n", th, (void *)th->thread_id);
|
||||
|
||||
rb_thread_interrupt(th);
|
||||
th->throwed_errinfo = eKillSignal;
|
||||
|
@ -1635,7 +1629,8 @@ rb_thread_wait_fd_rw(int fd, char c)
|
|||
case'w':
|
||||
GVL_UNLOCK_RANGE(result = select(fd + 1, 0, rb_fd_ptr(&set), 0, 0));
|
||||
break;
|
||||
defaut:
|
||||
|
||||
default:
|
||||
rb_bug("unknown wait type: %c", c);
|
||||
}
|
||||
}
|
||||
|
@ -1793,23 +1788,6 @@ rb_thread_atfork(void)
|
|||
st_insert(vm->living_threads, th->self, (st_data_t) th->thread_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* for tests
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
raw_gets(VALUE klass)
|
||||
{
|
||||
char buff[100];
|
||||
GVL_UNLOCK_BEGIN();
|
||||
{
|
||||
fgets(buff, 100, stdin);
|
||||
}
|
||||
GVL_UNLOCK_END();
|
||||
return rb_str_new2(buff);
|
||||
}
|
||||
|
||||
|
||||
struct thgroup {
|
||||
int enclosed;
|
||||
VALUE group;
|
||||
|
|
|
@ -43,8 +43,6 @@ NOINLINE(static int
|
|||
thread_start_func_2(rb_thead_t *th, VALUE *stack_start));
|
||||
void static thread_cleanup_func(void *th_ptr);
|
||||
|
||||
static rb_thead_t *register_cached_thread_and_wait(void);
|
||||
|
||||
#define USE_THREAD_CACHE 0
|
||||
|
||||
static void *
|
||||
|
@ -71,6 +69,7 @@ thread_start_func_1(void *th_ptr)
|
|||
if (1) {
|
||||
/* cache thread */
|
||||
rb_thead_t *th;
|
||||
static rb_thead_t *register_cached_thread_and_wait(void);
|
||||
if ((th = register_cached_thread_and_wait()) != 0) {
|
||||
th_ptr = (void *)th;
|
||||
th->thread_id = pthread_self();
|
||||
|
@ -83,14 +82,15 @@ thread_start_func_1(void *th_ptr)
|
|||
|
||||
void rb_thread_create_control_thread(void);
|
||||
|
||||
static pthread_mutex_t thread_cache_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
struct cached_thread_entry {
|
||||
volatile rb_thead_t **th_area;
|
||||
pthread_cond_t *cond;
|
||||
struct cached_thread_entry *next;
|
||||
};
|
||||
|
||||
|
||||
#if USE_THREAD_CACHE
|
||||
static pthread_mutex_t thread_cache_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
struct cached_thread_entry *cached_thread_root;
|
||||
|
||||
static rb_thead_t *
|
||||
|
@ -142,6 +142,7 @@ register_cached_thread_and_wait(void)
|
|||
|
||||
return (rb_thead_t *)th_area;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
use_cached_thread(rb_thead_t *th)
|
||||
|
@ -331,6 +332,7 @@ static struct yarv_signal_thread_list signal_thread_list_anchor = {
|
|||
native_mutex_unlock(lock); \
|
||||
} while (0)
|
||||
|
||||
#if 0 /* for debug */
|
||||
static void
|
||||
print_signal_list(char *str)
|
||||
{
|
||||
|
@ -343,6 +345,7 @@ print_signal_list(char *str)
|
|||
}
|
||||
thread_debug("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
yarv_add_signal_thread_list(rb_thead_t *th)
|
||||
|
|
80
vm.c
80
vm.c
|
@ -508,7 +508,7 @@ th_call0(rb_thead_t *th, VALUE klass, VALUE recv,
|
|||
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)),
|
||||
rb_id2name(id), ruby_node_name(nd_type(body)),
|
||||
argc, th->passed_block);
|
||||
//SDR2(th->cfp);
|
||||
|
||||
|
@ -798,13 +798,12 @@ th_invoke_proc(rb_thead_t *th, rb_proc_t *proc,
|
|||
VALUE val = Qundef;
|
||||
int state;
|
||||
volatile int stored_safe = th->safe_level;
|
||||
volatile NODE *stored_special_cref_stack;
|
||||
volatile NODE *stored_special_cref_stack =
|
||||
lfp_set_special_cref(proc->block.lfp, proc->special_cref_stack);
|
||||
rb_control_frame_t * volatile cfp = th->cfp;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
stored_special_cref_stack =
|
||||
lfp_set_special_cref(proc->block.lfp, proc->special_cref_stack);
|
||||
th->safe_level = proc->safe_level;
|
||||
|
||||
val = invoke_block(th, &proc->block, self, argc, argv,
|
||||
|
@ -895,7 +894,7 @@ th_cfp_svar(rb_control_frame_t *cfp, int cnt)
|
|||
return lfp_svar(cfp->lfp, cnt);
|
||||
}
|
||||
|
||||
VALUE *
|
||||
static VALUE *
|
||||
th_svar(rb_thead_t *th, int cnt)
|
||||
{
|
||||
rb_control_frame_t *cfp = th->cfp;
|
||||
|
@ -903,11 +902,43 @@ th_svar(rb_thead_t *th, int cnt)
|
|||
}
|
||||
|
||||
VALUE *
|
||||
thread_svar(VALUE self, int cnt)
|
||||
rb_svar(int cnt)
|
||||
{
|
||||
rb_thead_t *th;
|
||||
GetThreadPtr(self, th);
|
||||
return th_svar(th, cnt);
|
||||
return th_svar(GET_THREAD(), cnt);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_backref_get(void)
|
||||
{
|
||||
VALUE *var = rb_svar(1);
|
||||
if (var) {
|
||||
return *var;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
void
|
||||
rb_backref_set(VALUE val)
|
||||
{
|
||||
VALUE *var = rb_svar(1);
|
||||
*var = val;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_lastline_get(void)
|
||||
{
|
||||
VALUE *var = rb_svar(0);
|
||||
if (var) {
|
||||
return *var;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
void
|
||||
rb_lastline_set(VALUE val)
|
||||
{
|
||||
VALUE *var = rb_svar(0);
|
||||
*var = val;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1387,14 +1418,14 @@ th_iter_break(rb_thead_t *th)
|
|||
}
|
||||
|
||||
static VALUE yarv_redefined_flag = 0;
|
||||
static st_table *yarv_opt_method_table = 0;
|
||||
static st_table *vm_opt_method_table = 0;
|
||||
|
||||
void
|
||||
yarv_check_redefinition_opt_method(NODE *node)
|
||||
rb_vm_check_redefinition_opt_method(NODE *node)
|
||||
{
|
||||
VALUE bop;
|
||||
|
||||
if (st_lookup(yarv_opt_method_table, (st_data_t)node, &bop)) {
|
||||
if (st_lookup(vm_opt_method_table, (st_data_t)node, &bop)) {
|
||||
yarv_redefined_flag |= bop;
|
||||
}
|
||||
}
|
||||
|
@ -1405,15 +1436,15 @@ add_opt_method(VALUE klass, ID mid, VALUE bop)
|
|||
NODE *node;
|
||||
if (st_lookup(RCLASS(klass)->m_tbl, mid, (void *)&node) &&
|
||||
nd_type(node->nd_body->nd_body) == NODE_CFUNC) {
|
||||
st_insert(yarv_opt_method_table, (st_data_t)node, (st_data_t)bop);
|
||||
st_insert(vm_opt_method_table, (st_data_t)node, (st_data_t)bop);
|
||||
}
|
||||
else {
|
||||
rb_bug("undefined optimized method", mid);
|
||||
rb_bug("undefined optimized method: %s", rb_id2name(mid));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
yarv_init_redefined_flag()
|
||||
yarv_init_redefined_flag(void)
|
||||
{
|
||||
VALUE register_info[] = {
|
||||
idPLUS, BOP_PLUS, rb_cFixnum, rb_cFloat, rb_cString, rb_cArray, 0,
|
||||
|
@ -1432,7 +1463,7 @@ yarv_init_redefined_flag()
|
|||
0,
|
||||
};
|
||||
VALUE *ptr = register_info;
|
||||
yarv_opt_method_table = st_init_numtable();
|
||||
vm_opt_method_table = st_init_numtable();
|
||||
|
||||
while (*ptr) {
|
||||
ID mid = *ptr++;
|
||||
|
@ -1758,3 +1789,20 @@ th_eval_body(rb_thead_t *th)
|
|||
TH_POP_TAG();
|
||||
return result;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_thread_eval(rb_thead_t *th, VALUE iseqval)
|
||||
{
|
||||
VALUE val;
|
||||
volatile VALUE tmp;
|
||||
|
||||
th_set_top_stack(th, iseqval);
|
||||
|
||||
if (!rb_const_defined(rb_cObject, rb_intern("TOPLEVEL_BINDING"))) {
|
||||
rb_define_global_const("TOPLEVEL_BINDING", rb_binding_new());
|
||||
}
|
||||
val = th_eval_body(th);
|
||||
tmp = iseqval; /* prohibit tail call optimization */
|
||||
return val;
|
||||
}
|
||||
|
||||
|
|
|
@ -355,7 +355,7 @@ debug_print_pre(rb_thead_t *th, rb_control_frame_t *cfp)
|
|||
VALUE *seq = iseq->iseq;
|
||||
int pc = cfp->pc - iseq->iseq_encoded;
|
||||
|
||||
iseq_disasm_insn(0, seq, pc, iseq, 0);
|
||||
ruby_iseq_disasm_insn(0, seq, pc, iseq, 0);
|
||||
}
|
||||
|
||||
#if VMDEBUG > 3
|
||||
|
|
|
@ -325,7 +325,7 @@ MACRO macro_eval_invoke_method(recv, klass, id, num, mn, blockptr)
|
|||
break;
|
||||
}
|
||||
default:{
|
||||
printf("node: %s\n", node_name(nd_type(node)));
|
||||
printf("node: %s\n", ruby_node_name(nd_type(node)));
|
||||
rb_bug("eval_invoke_method: unreachable");
|
||||
/* unreachable */
|
||||
break;
|
||||
|
|
104
yarv.h
104
yarv.h
|
@ -1,104 +0,0 @@
|
|||
/**********************************************************************
|
||||
|
||||
yarv.h -
|
||||
|
||||
$Author$
|
||||
$Date$
|
||||
|
||||
Copyright (C) 2004-2006 Koichi Sasada
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
#include <ruby.h>
|
||||
#include <node.h>
|
||||
#include "yarvcore.h"
|
||||
|
||||
#ifndef _YARV_H_INCLUDED_
|
||||
#define _YARV_H_INCLUDED_
|
||||
|
||||
|
||||
VALUE yarv_yield(VALUE val);
|
||||
|
||||
/* original API */
|
||||
|
||||
#if YARVEXT
|
||||
RUBY_EXTERN int yarvIsWorking;
|
||||
#define IS_YARV_WORKING() (yarvIsWorking)
|
||||
#define SET_YARV_START() (yarvIsWorking = 1)
|
||||
#define SET_YARV_STOP() (yarvIsWorking = 0)
|
||||
#else
|
||||
#define IS_YARV_WORKING() 1
|
||||
#define SET_YARV_START()
|
||||
#define SET_YARV_STOP()
|
||||
#endif
|
||||
|
||||
|
||||
#if RUBY_VM_THREAD_MODEL == 2
|
||||
|
||||
extern rb_thead_t *yarvCurrentThread;
|
||||
extern rb_vm_t *theYarvVM;
|
||||
|
||||
static inline VALUE
|
||||
yarv_get_current_running_thread_value(void)
|
||||
{
|
||||
return yarvCurrentThread->self;
|
||||
}
|
||||
|
||||
static inline rb_thead_t *
|
||||
yarv_get_current_running_thread(void)
|
||||
{
|
||||
return yarvCurrentThread;
|
||||
}
|
||||
|
||||
#define GET_VM() theYarvVM
|
||||
#define GET_THREAD() yarvCurrentThread
|
||||
|
||||
static inline void
|
||||
rb_thread_set_current_raw(rb_thead_t *th)
|
||||
{
|
||||
yarvCurrentThread = th;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rb_thread_set_current(rb_thead_t *th)
|
||||
{
|
||||
rb_thread_set_current_raw(th);
|
||||
th->vm->running_thread = th;
|
||||
}
|
||||
|
||||
#else
|
||||
#error "unsupported thread model"
|
||||
#endif
|
||||
|
||||
void rb_vm_change_state();
|
||||
|
||||
VALUE th_invoke_yield(rb_thead_t *th, int argc, VALUE *argv);
|
||||
|
||||
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(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(rb_thead_t *th, rb_proc_t *proc,
|
||||
VALUE self, int argc, VALUE *argv);
|
||||
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 *);
|
||||
int th_get_sourceline(rb_control_frame_t *);
|
||||
VALUE th_backtrace(rb_thead_t *, int);
|
||||
void yarv_bug(void);
|
||||
|
||||
#endif
|
113
yarvcore.c
113
yarvcore.c
|
@ -14,7 +14,6 @@
|
|||
#include "node.h"
|
||||
|
||||
#include "yarvcore.h"
|
||||
#include "yarv.h"
|
||||
#include "gc.h"
|
||||
|
||||
VALUE rb_cVM;
|
||||
|
@ -71,8 +70,6 @@ unsigned long yarvGlobalStateVersion = 1;
|
|||
#define va_init_list(a,b) va_start(a)
|
||||
#endif
|
||||
|
||||
VALUE rb_thread_eval(rb_thead_t *th, VALUE iseqval);
|
||||
|
||||
/************/
|
||||
/* YARVCore */
|
||||
/************/
|
||||
|
@ -81,80 +78,7 @@ rb_thead_t *yarvCurrentThread = 0;
|
|||
rb_vm_t *theYarvVM = 0;
|
||||
static VALUE yarvVMArray = Qnil;
|
||||
|
||||
RUBY_EXTERN int rb_thread_critical;
|
||||
RUBY_EXTERN int ruby_nerrs;
|
||||
RUBY_EXTERN NODE *ruby_eval_tree;
|
||||
|
||||
VALUE
|
||||
yarv_load(char *file)
|
||||
{
|
||||
NODE *node;
|
||||
VALUE iseq;
|
||||
volatile int critical;
|
||||
rb_thead_t *th = GET_THREAD();
|
||||
|
||||
critical = rb_thread_critical;
|
||||
rb_thread_critical = Qtrue;
|
||||
{
|
||||
th->parse_in_eval++;
|
||||
node = (NODE *)rb_load_file(file);
|
||||
th->parse_in_eval--;
|
||||
node = ruby_eval_tree;
|
||||
}
|
||||
rb_thread_critical = critical;
|
||||
|
||||
if (ruby_nerrs > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
iseq = yarv_iseq_new(node, rb_str_new2("<top (required)>"),
|
||||
rb_str_new2(file), Qfalse, ISEQ_TYPE_TOP);
|
||||
|
||||
rb_thread_eval(GET_THREAD(), iseq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VALUE *th_svar(rb_thead_t *self, int cnt);
|
||||
|
||||
VALUE *
|
||||
rb_svar(int cnt)
|
||||
{
|
||||
return th_svar(GET_THREAD(), cnt);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_backref_get(void)
|
||||
{
|
||||
VALUE *var = rb_svar(1);
|
||||
if (var) {
|
||||
return *var;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
void
|
||||
rb_backref_set(VALUE val)
|
||||
{
|
||||
VALUE *var = rb_svar(1);
|
||||
*var = val;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_lastline_get(void)
|
||||
{
|
||||
VALUE *var = rb_svar(0);
|
||||
if (var) {
|
||||
return *var;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
void
|
||||
rb_lastline_set(VALUE val)
|
||||
{
|
||||
VALUE *var = rb_svar(0);
|
||||
*var = val;
|
||||
}
|
||||
|
||||
static NODE *
|
||||
compile_string(VALUE str, VALUE file, VALUE line)
|
||||
|
@ -180,14 +104,14 @@ th_compile_from_node(rb_thead_t *th, NODE * node, VALUE file)
|
|||
{
|
||||
VALUE iseq;
|
||||
if (th->base_block) {
|
||||
iseq = yarv_iseq_new(node,
|
||||
iseq = rb_iseq_new(node,
|
||||
th->base_block->iseq->name,
|
||||
file,
|
||||
th->base_block->iseq->self,
|
||||
ISEQ_TYPE_EVAL);
|
||||
}
|
||||
else {
|
||||
iseq = yarv_iseq_new(node, rb_str_new2("<main>"), file,
|
||||
iseq = rb_iseq_new(node, rb_str_new2("<main>"), file,
|
||||
Qfalse, ISEQ_TYPE_TOP);
|
||||
}
|
||||
return iseq;
|
||||
|
@ -411,17 +335,10 @@ th_init2(rb_thead_t *th)
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
th_klass_init(rb_thead_t *th)
|
||||
{
|
||||
/* */
|
||||
}
|
||||
|
||||
static void
|
||||
th_init(rb_thead_t *th)
|
||||
{
|
||||
th_init2(th);
|
||||
th_klass_init(th);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -445,25 +362,6 @@ rb_thread_alloc(VALUE klass)
|
|||
return self;
|
||||
}
|
||||
|
||||
VALUE th_eval_body(rb_thead_t *th);
|
||||
void th_set_top_stack(rb_thead_t *, VALUE iseq);
|
||||
|
||||
VALUE
|
||||
rb_thread_eval(rb_thead_t *th, VALUE iseqval)
|
||||
{
|
||||
VALUE val;
|
||||
volatile VALUE tmp;
|
||||
|
||||
th_set_top_stack(th, iseqval);
|
||||
|
||||
if (!rb_const_defined(rb_cObject, rb_intern("TOPLEVEL_BINDING"))) {
|
||||
rb_define_global_const("TOPLEVEL_BINDING", rb_binding_new());
|
||||
}
|
||||
val = th_eval_body(th);
|
||||
tmp = iseqval; /* prohibit tail call optimization */
|
||||
return val;
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
VALUE insns_name_array(void);
|
||||
|
@ -500,8 +398,7 @@ nsdr(void)
|
|||
return ary;
|
||||
}
|
||||
|
||||
char yarv_version[0x20];
|
||||
char *yarv_options = ""
|
||||
static char *yarv_options = ""
|
||||
#if OPT_DIRECT_THREADED_CODE
|
||||
"[direct threaded code] "
|
||||
#elif OPT_TOKEN_THREADED_CODE
|
||||
|
@ -530,6 +427,8 @@ char *yarv_options = ""
|
|||
#endif
|
||||
;
|
||||
|
||||
void yarv_init_redefined_flag(void);
|
||||
|
||||
void
|
||||
Init_VM(void)
|
||||
{
|
||||
|
@ -560,7 +459,7 @@ Init_VM(void)
|
|||
|
||||
/* debug functions ::VM::SDR(), ::VM::NSDR() */
|
||||
rb_define_singleton_method(rb_cVM, "SDR", sdr, 0);
|
||||
rb_define_singleton_method(rb_cVM, "NSDR", sdr, 0);
|
||||
rb_define_singleton_method(rb_cVM, "NSDR", nsdr, 0);
|
||||
|
||||
/* Symbols */
|
||||
symIFUNC = ID2SYM(rb_intern("<IFUNC>"));
|
||||
|
|
65
yarvcore.h
65
yarvcore.h
|
@ -470,17 +470,10 @@ typedef struct rb_thread_struct
|
|||
} rb_thead_t;
|
||||
|
||||
/** node -> yarv instruction sequence object */
|
||||
VALUE iseq_compile(VALUE self, NODE *node);
|
||||
|
||||
VALUE rb_iseq_new(NODE *node, VALUE name, VALUE file,
|
||||
VALUE parent, VALUE type);
|
||||
|
||||
VALUE rb_iseq_new_with_bopt(NODE *node, VALUE name, VALUE file_name,
|
||||
VALUE parent, VALUE type, VALUE bopt);
|
||||
|
||||
VALUE rb_iseq_new_with_opt(NODE *node, VALUE name, VALUE file,
|
||||
VALUE parent, VALUE type,
|
||||
const rb_compile_option_t *opt);
|
||||
VALUE rb_iseq_compile(VALUE self, NODE *node);
|
||||
VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE);
|
||||
VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE);
|
||||
VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, const rb_compile_option_t*);
|
||||
|
||||
/** disassemble instruction sequence */
|
||||
VALUE ruby_iseq_disasm(VALUE self);
|
||||
|
@ -543,7 +536,7 @@ typedef struct {
|
|||
#define VM_CALL_SUPER_BIT (0x01 << 7)
|
||||
#define VM_CALL_SEND_BIT (0x01 << 8)
|
||||
|
||||
/* inline method cache */
|
||||
/* inline (method|const) cache */
|
||||
#define NEW_INLINE_CACHE_ENTRY() NEW_WHILE(Qundef, 0, 0)
|
||||
#define ic_klass u1.value
|
||||
#define ic_method u2.node
|
||||
|
@ -551,9 +544,12 @@ typedef struct {
|
|||
#define ic_vmstat u3.cnt
|
||||
typedef NODE *IC;
|
||||
|
||||
void rb_vm_change_state();
|
||||
|
||||
typedef VALUE CDHASH;
|
||||
|
||||
|
||||
|
||||
#define GC_GUARDED_PTR(p) ((VALUE)((VALUE)(p) | 0x01))
|
||||
#define GC_GUARDED_PTR_REF(p) ((void *)(((VALUE)p) & ~0x03))
|
||||
#define GC_GUARDED_PTR_P(p) (((VALUE)p) & 0x01)
|
||||
|
@ -592,6 +588,7 @@ typedef VALUE CDHASH;
|
|||
#define DEFINED_ZSUPER INT2FIX(9)
|
||||
#define DEFINED_FUNC INT2FIX(10)
|
||||
|
||||
|
||||
/* VM related object allocate functions */
|
||||
/* TODO: should be static functions */
|
||||
VALUE rb_thread_alloc(VALUE klass);
|
||||
|
@ -599,12 +596,52 @@ VALUE rb_proc_alloc(void);
|
|||
|
||||
/* for debug */
|
||||
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 SDR() vm_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp)
|
||||
#define SDR2(cfp) vm_stack_dump_raw(GET_THREAD(), (cfp))
|
||||
void yarv_bug(void);
|
||||
|
||||
|
||||
/* functions about thread/vm execution */
|
||||
|
||||
VALUE rb_thread_eval(rb_thead_t *th, VALUE iseqval);
|
||||
void rb_enable_interrupt(void);
|
||||
void rb_disable_interrupt(void);
|
||||
|
||||
VALUE th_eval_body(rb_thead_t *th);
|
||||
VALUE th_set_eval_stack(rb_thead_t *, VALUE iseq);
|
||||
VALUE th_call_super(rb_thead_t *th, int argc, const VALUE *argv);
|
||||
VALUE th_invoke_proc(rb_thead_t *th, rb_proc_t *proc, VALUE self, int argc, VALUE *argv);
|
||||
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 th_backtrace(rb_thead_t *, int);
|
||||
|
||||
VALUE th_invoke_yield(rb_thead_t *th, int argc, VALUE *argv);
|
||||
VALUE th_call0(rb_thead_t *th, VALUE klass, VALUE recv,
|
||||
VALUE id, ID oid, int argc, const VALUE *argv,
|
||||
NODE * body, int nosuper);
|
||||
|
||||
int th_get_sourceline(rb_control_frame_t *);
|
||||
|
||||
VALUE yarvcore_eval_parsed(NODE *node, VALUE file);
|
||||
VALUE yarvcore_eval(VALUE self, VALUE str, VALUE file, VALUE line);
|
||||
|
||||
/* for thread */
|
||||
|
||||
#include "yarv.h"
|
||||
#if RUBY_VM_THREAD_MODEL == 2
|
||||
extern rb_thead_t *yarvCurrentThread;
|
||||
extern rb_vm_t *theYarvVM;
|
||||
|
||||
#define GET_VM() theYarvVM
|
||||
#define GET_THREAD() yarvCurrentThread
|
||||
#define rb_thread_set_current_raw(th) (yarvCurrentThread = th)
|
||||
#define rb_thread_set_current(th) do { \
|
||||
rb_thread_set_current_raw(th); \
|
||||
th->vm->running_thread = th; \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
#error "unsupported thread model"
|
||||
#endif
|
||||
|
||||
#define GVL_UNLOCK_BEGIN() do { \
|
||||
rb_thead_t *_th_stored = GET_THREAD(); \
|
||||
|
|
Загрузка…
Ссылка в новой задаче