yarv-diff:153
From: ko1 atdot.net
Date: 13 Dec 2005 18:54:07 -0000
Subject: [yarv-diff:153] r312 - in trunk: . yarvtest
Author: ko1
Date: 2005-12-14 03:54:07 +0900 (Wed, 14 Dec 2005)
New Revision: 312
Modified:
trunk/ChangeLog
trunk/compile.c
trunk/eval.c
trunk/insns.def
trunk/intern.h
trunk/test.rb
trunk/vm.c
trunk/vm.h
trunk/vm_dump.c
trunk/vm_macro.def
trunk/yarvcore.h
trunk/yarvtest/test_bin.rb
Log:
2005-12-14(Wed) 03:49:40 +0900 Koichi Sasada <ko1 atdot.net>
* compile.c : change rescue/ensure iseq name
* eval.c, intern.h : fix a prototype
* insns.def, yarvcore.h : add trace_function
* vm.c : fix deadly bug (illegal pointer cast)
* vm_dump.c : remove unused local variables
* vm_macro.def : add parameter size check
* yarvtest/test_bin.rb : comment out 2 assertions
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/ChangeLog 2005-12-13 18:54:07 UTC (rev 312)
@@ -4,6 +4,23 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+2005-12-14(Wed) 03:49:40 +0900 Koichi Sasada <ko1 atdot.net>
+
+ * compile.c : change rescue/ensure iseq name
+
+ * eval.c, intern.h : fix a prototype
+
+ * insns.def, yarvcore.h : add trace_function
+
+ * vm.c : fix deadly bug (illegal pointer cast)
+
+ * vm_dump.c : remove unused local variables
+
+ * vm_macro.def : add parameter size check
+
+ * yarvtest/test_bin.rb : comment out 2 assertions
+
+
2005-12-13(Tue) 03:55:27 +0900 Koichi Sasada <ko1 atdot.net>
* eval_proc.c : fix indent
Modified: trunk/compile.c
===================================================================
--- trunk/compile.c 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/compile.c 2005-12-13 18:54:07 UTC (rev 312)
@@ -2798,8 +2798,9 @@
LABEL *lstart = NEW_LABEL(nd_line(node));
LABEL *lend = NEW_LABEL(nd_line(node));
LABEL *lcont = NEW_LABEL(nd_line(node));
- VALUE rescue = NEW_CHILD_ISEQVAL(node->nd_resq, rb_str_new2("rescue"),
- ISEQ_TYPE_RESCUE);
+ VALUE rescue = NEW_CHILD_ISEQVAL(
+ node->nd_resq, rb_str_concat(rb_str_new2("rescue in "), iseq->name),
+ ISEQ_TYPE_RESCUE);
ADD_LABEL(ret, lstart);
COMPILE(ret, "rescue head", node->nd_head);
@@ -2854,8 +2855,10 @@
}
case NODE_ENSURE:{
DECL_ANCHOR(ensr);
- VALUE ensure = NEW_CHILD_ISEQVAL(node->nd_ensr, rb_str_new2("ensure"),
- ISEQ_TYPE_ENSURE);
+ VALUE ensure = NEW_CHILD_ISEQVAL(
+ node->nd_ensr,
+ rb_str_concat(rb_str_new2("ensure in "), iseq->name),
+ ISEQ_TYPE_ENSURE);
LABEL * lstart = NEW_LABEL(nd_line(node));
LABEL * lend = NEW_LABEL(nd_line(node));
LABEL * lcont = NEW_LABEL(nd_line(node));
Modified: trunk/eval.c
===================================================================
--- trunk/eval.c 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/eval.c 2005-12-13 18:54:07 UTC (rev 312)
@@ -116,7 +116,7 @@
# endif
#endif
-NORETURN(void rb_thread_start_1 _((void)));
+NORETURN(void rb_thread_start_1(void));
void Init_yarv(void);
void
Modified: trunk/insns.def
===================================================================
--- trunk/insns.def 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/insns.def 2005-12-13 18:54:07 UTC (rev 312)
@@ -1044,6 +1044,23 @@
rb_set_end_proc(call_yarv_end_proc, proc);
}
+/**
+ @c setting
+ @e trace
+ @j trace
+ */
+DEFINE_INSN
+trace
+(ulong flag, VALUE args)
+()
+()
+{
+ /* TODO: trace instruction design */
+ if(GET_VM()->trace_flag & flag){
+ /* */
+ }
+}
+
/**********************************************************/
/* deal with control flow 1: class/module */
/**********************************************************/
Modified: trunk/intern.h
===================================================================
--- trunk/intern.h 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/intern.h 2005-12-13 18:54:07 UTC (rev 312)
@@ -582,6 +582,6 @@
VALUE rb_time_succ(VALUE);
void Init_stack(VALUE*);
void rb_frame_pop(void);
-void rb_thread_start_1(void);
+NORETURN(void rb_thread_start_1(void));
#endif /* RUBY_INTERN_H */
Modified: trunk/test.rb
===================================================================
--- trunk/test.rb 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/test.rb 2005-12-13 18:54:07 UTC (rev 312)
@@ -1,9 +1,25 @@
+require 'pathname'
+__END__
+require 'test/unit'
+ def m a, aa, b = 0, c = 1, &pr
+ [a, b, c, pr]
+ end
+
+ m(1, 2)
+__END__
+require 'test/unit'
__END__
+['a', 'b'].each(&File.method(:basename).to_proc)
-pr = File.method(:basename)
-#pr = pr.to_proc
-#p pr
-['a', 'b'].each(&pr)
+__END__
-__END__
+def m
+end
+
+def add &pr
+end
+
+add(&method(:m))
+add(&method(:m))
+
Modified: trunk/vm.c
===================================================================
--- trunk/vm.c 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/vm.c 2005-12-13 18:54:07 UTC (rev 312)
@@ -167,6 +167,7 @@
if(envptr != endptr){
VALUE *penvptr = GC_GUARDED_PTR_REF(*envptr);
yarv_control_frame_t *pcfp = cfp;
+
if(ENV_IN_HEAP_P(penvptr)){
penvval = ENV_VAL(penvptr);
}
@@ -342,6 +343,7 @@
if(GC_GUARDED_PTR_REF(cfp->lfp[0]) != 0 &&
!(cfp->lfp[0] & 0x02) /* not class scope */){
yarv_proc_t *p;
+
blockprocval =
th_make_proc_from_block(th, cfp, (yarv_block_t *)GC_GUARDED_PTR_REF(*cfp->lfp));
GetProcVal(blockprocval, p);
@@ -365,12 +367,14 @@
proc->envval = envval;
/* set cref */
- if(cfp->iseq && cfp->iseq->klass_nest_stack){
- block->iseq->klass_nest_stack = cfp->iseq->klass_nest_stack;
+ if(BUILTIN_TYPE(block->iseq) != T_NODE){
+ if(cfp->iseq && cfp->iseq->klass_nest_stack){
+ block->iseq->klass_nest_stack = cfp->iseq->klass_nest_stack;
+ }
+ else{
+ block->iseq->klass_nest_stack = rb_ary_dup(th->klass_nest_stack);
+ }
}
- else{
- block->iseq->klass_nest_stack = rb_ary_dup(th->klass_nest_stack);
- }
return procval;
}
Modified: trunk/vm.h
===================================================================
--- trunk/vm.h 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/vm.h 2005-12-13 18:54:07 UTC (rev 312)
@@ -33,7 +33,7 @@
#if 0
#undef VMDEBUG
-#define VMDEBUG 3
+#define VMDEBUG 1
#endif
// #define COLLECT_USAGE_ANALYSIS
Modified: trunk/vm_dump.c
===================================================================
--- trunk/vm_dump.c 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/vm_dump.c 2005-12-13 18:54:07 UTC (rev 312)
@@ -150,17 +150,14 @@
void
stack_dump_each(yarv_thread_t *th, yarv_control_frame_t *cfp)
{
- int i, lim = 1;
+ int i;
VALUE rstr;
- VALUE *ptr;
VALUE *sp = cfp->sp;
- VALUE *bp = cfp->bp;
VALUE *lfp = cfp->lfp;
VALUE *dfp = cfp->dfp;
int argc, local_size;
- int rewind = 0;
char *name;
yarv_iseq_t *iseq = cfp->iseq;
Modified: trunk/vm_macro.def
===================================================================
--- trunk/vm_macro.def 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/vm_macro.def 2005-12-13 18:54:07 UTC (rev 312)
@@ -145,6 +145,14 @@
/* block argument */
if(niseq->arg_block != 0){
VALUE arg_block_val = Qnil;
+
+ if(!((niseq->arg_rest && num == niseq->arg_rest) ||
+ (niseq->arg_opts && num == niseq->argc + niseq->arg_opts - 1) ||
+ num == niseq->argc)){
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
+ num, niseq->argc);
+ }
+
if(blockptr){
/* make Proc object */
if(blockptr->proc == 0){
@@ -158,7 +166,7 @@
arg_block_val = blockptr->proc;
}
}
-
+
rsp[1 + niseq->arg_block - 1] = arg_block_val;
sp++;
clear_local_size--;
Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/yarvcore.h 2005-12-13 18:54:07 UTC (rev 312)
@@ -248,7 +248,7 @@
/* instruction sequence type */
int type;
-
+
/* klass/module nest information stack */
VALUE klass_nest_stack; /* Array */
VALUE klass;
@@ -280,10 +280,13 @@
VALUE self;
yarv_thread_lock_t global_interpreter_lock;
- int thread_critical;
+ unsigned long thread_critical;
VALUE main_thread;
st_table *living_threads;
- int interrupt_flag;
+
+ unsigned long interrupt_flag;
+
+ unsigned long trace_flag;
} yarv_vm_t;
typedef struct{
Modified: trunk/yarvtest/test_bin.rb
===================================================================
--- trunk/yarvtest/test_bin.rb 2005-12-12 18:59:03 UTC (rev 311)
+++ trunk/yarvtest/test_bin.rb 2005-12-13 18:54:07 UTC (rev 312)
@@ -94,8 +94,8 @@
def test_range
ae %q((1..2))
ae %q((1...2))
- #ae %q(((1+1)..(2+2)))
- #ae %q(((1+1)...(2+2)))
+ ae %q(((1+1)..(2+2)))
+ ae %q(((1+1)...(2+2)))
end
def test_not
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml