1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* yarvcore.h, vm.h: rename th_invoke_yield() to th_yield().

* blockinlining.c: ditto.
* eval.c: ditto.
* vm.c, insns.def: rename th_invoke_yield_cfunc()
  to th_yield_with_cfunc().
* yarvcore.h, yarvcore.c: rename theYarvVM to ruby_current_vm and
  yarvCurrentThread to ruby_current_thread.  remove yarvVMArray.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-02-26 22:51:33 +00:00
parent 3623df9bc6
commit 8a1b1c2b41
7 changed files with 40 additions and 30 deletions

View file

@ -1,3 +1,17 @@
Tue Feb 27 07:47:24 2007 Koichi Sasada <ko1@atdot.net>
* yarvcore.h, vm.h: rename th_invoke_yield() to th_yield().
* blockinlining.c: ditto.
* eval.c: ditto.
* vm.c, insns.def: rename th_invoke_yield_cfunc()
to th_yield_with_cfunc().
* yarvcore.h, yarvcore.c: rename theYarvVM to ruby_current_vm and
yarvCurrentThread to ruby_current_thread. remove yarvVMArray.
Tue Feb 27 00:45:23 2007 Minero Aoki <aamine@loveruby.net> Tue Feb 27 00:45:23 2007 Minero Aoki <aamine@loveruby.net>
* test/ruby/test_optimization.rb: restore method before calling * test/ruby/test_optimization.rb: restore method before calling

View file

@ -199,7 +199,7 @@ yarv_invoke_Integer_times_special_block(VALUE num)
th->cfp->lfp[0] = GC_GUARDED_PTR(&block); th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
argv[0] = INT2FIX(0); argv[0] = INT2FIX(0);
argv[1] = num; argv[1] = num;
val = th_invoke_yield(th, 2, argv); val = th_yield(th, 2, argv);
if (val == Qundef) { if (val == Qundef) {
return num; return num;
} }
@ -318,7 +318,7 @@ yarv_invoke_Range_each_special_block(VALUE range,
th->cfp->lfp[0] = GC_GUARDED_PTR(&block); th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
argv[0] = beg; argv[0] = beg;
argv[1] = end; argv[1] = end;
val = th_invoke_yield(th, 2, argv); val = th_yield(th, 2, argv);
if (val == Qundef) { if (val == Qundef) {
return range; return range;
} }
@ -448,7 +448,7 @@ yarv_invoke_Array_each_special_block(VALUE ary)
th->cfp->lfp[0] = GC_GUARDED_PTR(&block); th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
argv[0] = 0; argv[0] = 0;
argv[1] = ary; argv[1] = ary;
val = th_invoke_yield(th, 2, argv); val = th_yield(th, 2, argv);
if (val == Qundef) { if (val == Qundef) {
return ary; return ary;
} }

5
eval.c
View file

@ -1140,8 +1140,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */ , int flags,
int avalue) int avalue)
{ {
if (avalue) { if (avalue) {
return th_invoke_yield(GET_THREAD(), return th_yield(GET_THREAD(), RARRAY_LEN(val), RARRAY_PTR(val));
RARRAY_LEN(val), RARRAY_PTR(val));
} }
else { else {
int argc = (val == Qundef) ? 0 : 1; int argc = (val == Qundef) ? 0 : 1;
@ -1153,7 +1152,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */ , int flags,
argv = RARRAY_PTR(argv[0]); argv = RARRAY_PTR(argv[0]);
} }
*/ */
return th_invoke_yield(GET_THREAD(), argc, argv); return th_yield(GET_THREAD(), argc, argv);
} }
} }

View file

@ -1360,8 +1360,8 @@ invokeblock
/* unreachable */ /* unreachable */
} }
else { else {
val = th_invoke_yield_cfunc(th, block, block->self, val = th_yield_with_cfunc(th, block, block->self,
num, STACK_ADDR_FROM_TOP(num)); num, STACK_ADDR_FROM_TOP(num));
POPN(num); POPN(num);
} }
} }

13
vm.c
View file

@ -41,8 +41,9 @@ void vm_analysis_register(int reg, int isset);
void vm_analysis_insn(int insn); void vm_analysis_insn(int insn);
static inline VALUE static inline VALUE
th_invoke_yield_cfunc(rb_thread_t *th, rb_block_t *block, th_yield_cfunc(rb_thread_t *th, rb_block_t *block,
VALUE self, int argc, VALUE *argv); VALUE self, int argc, VALUE *argv);
VALUE th_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE th_invoke_proc(rb_thread_t *th, rb_proc_t *proc,
VALUE self, int argc, VALUE *argv); VALUE self, int argc, VALUE *argv);
@ -647,8 +648,8 @@ rb_call_super(int argc, const VALUE *argv)
} }
static inline VALUE static inline VALUE
th_invoke_yield_cfunc(rb_thread_t *th, rb_block_t *block, th_yield_with_cfunc(rb_thread_t *th, rb_block_t *block,
VALUE self, int argc, VALUE *argv) VALUE self, int argc, VALUE *argv)
{ {
NODE *ifunc = (NODE *) block->iseq; NODE *ifunc = (NODE *) block->iseq;
VALUE val; VALUE val;
@ -780,13 +781,13 @@ invoke_block(rb_thread_t *th, rb_block_t *block, VALUE self, int argc, VALUE *ar
argc = 1; argc = 1;
argv = &args; argv = &args;
} }
val = th_invoke_yield_cfunc(th, block, block->self, argc, argv); val = th_yield_with_cfunc(th, block, block->self, argc, argv);
} }
return val; return val;
} }
VALUE VALUE
th_invoke_yield(rb_thread_t *th, int argc, VALUE *argv) th_yield(rb_thread_t *th, int argc, VALUE *argv)
{ {
rb_block_t *block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]); rb_block_t *block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);

View file

@ -71,9 +71,9 @@ ID id__send_bang;
/* YARVCore */ /* YARVCore */
/************/ /************/
rb_thread_t *yarvCurrentThread = 0; rb_thread_t *ruby_current_thread = 0;
rb_vm_t *theYarvVM = 0; rb_vm_t *ruby_current_vm = 0;
static VALUE yarvVMArray = Qnil; static VALUE ruby_vm_list = Qnil;
RUBY_EXTERN int ruby_nerrs; RUBY_EXTERN int ruby_nerrs;
@ -153,7 +153,7 @@ vm_free(void *ptr)
/* TODO: MultiVM Instance */ /* TODO: MultiVM Instance */
/* VM object should not be cleaned by GC */ /* VM object should not be cleaned by GC */
/* ruby_xfree(ptr); */ /* ruby_xfree(ptr); */
/* theYarvVM = 0; */ /* ruby_current_vm = 0; */
} }
FREE_REPORT_LEAVE("vm"); FREE_REPORT_LEAVE("vm");
} }
@ -521,16 +521,12 @@ Init_VM(void)
rb_vm_t *vm; rb_vm_t *vm;
rb_thread_t *th; rb_thread_t *th;
vm = theYarvVM; vm = ruby_current_vm;
xfree(RDATA(vmval)->data); xfree(RDATA(vmval)->data);
RDATA(vmval)->data = vm; RDATA(vmval)->data = vm;
vm->self = vmval; vm->self = vmval;
yarvVMArray = rb_ary_new();
rb_register_mark_object(yarvVMArray);
rb_ary_push(yarvVMArray, vm->self);
/* create main thread */ /* create main thread */
thval = rb_thread_alloc(rb_cThread); thval = rb_thread_alloc(rb_cThread);
GetThreadPtr(thval, th); GetThreadPtr(thval, th);
@ -557,7 +553,7 @@ Init_yarv(void)
rb_thread_t *th = ALLOC(rb_thread_t); rb_thread_t *th = ALLOC(rb_thread_t);
vm_init2(vm); vm_init2(vm);
theYarvVM = vm; ruby_current_vm = vm;
th_init2(th); th_init2(th);
th->vm = vm; th->vm = vm;

View file

@ -609,7 +609,7 @@ VALUE th_make_proc(rb_thread_t *th, rb_control_frame_t *cfp, rb_block_t *block);
VALUE th_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp); VALUE th_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
VALUE th_backtrace(rb_thread_t *, int); VALUE th_backtrace(rb_thread_t *, int);
VALUE th_invoke_yield(rb_thread_t *th, int argc, VALUE *argv); VALUE th_yield(rb_thread_t *th, int argc, VALUE *argv);
VALUE th_call0(rb_thread_t *th, VALUE klass, VALUE recv, VALUE th_call0(rb_thread_t *th, VALUE klass, VALUE recv,
VALUE id, ID oid, int argc, const VALUE *argv, VALUE id, ID oid, int argc, const VALUE *argv,
NODE * body, int nosuper); NODE * body, int nosuper);
@ -622,12 +622,12 @@ VALUE yarvcore_eval(VALUE self, VALUE str, VALUE file, VALUE line);
/* for thread */ /* for thread */
#if RUBY_VM_THREAD_MODEL == 2 #if RUBY_VM_THREAD_MODEL == 2
extern rb_thread_t *yarvCurrentThread; extern rb_thread_t *ruby_current_thread;
extern rb_vm_t *theYarvVM; extern rb_vm_t *ruby_current_vm;
#define GET_VM() theYarvVM #define GET_VM() ruby_current_vm
#define GET_THREAD() yarvCurrentThread #define GET_THREAD() ruby_current_thread
#define rb_thread_set_current_raw(th) (yarvCurrentThread = th) #define rb_thread_set_current_raw(th) (ruby_current_thread = th)
#define rb_thread_set_current(th) do { \ #define rb_thread_set_current(th) do { \
rb_thread_set_current_raw(th); \ rb_thread_set_current_raw(th); \
th->vm->running_thread = th; \ th->vm->running_thread = th; \