From 144ff322c7adcc600139da1cfacf0e98010c1bce Mon Sep 17 00:00:00 2001 From: ko1 Date: Sun, 24 Jun 2007 18:40:13 +0000 Subject: [PATCH] * insnhelper.ci (caller_setup_args): add need_block_check option. * insns.def: ditto. * yarvcore.h: add GetCoreDataFromValue(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ insnhelper.ci | 43 +++++++++++++++++++++++-------------------- insns.def | 8 ++++---- yarvcore.h | 21 +++++++++++++++------ 4 files changed, 50 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5b9ec08c6..0033f7f203 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Jun 25 03:37:20 2007 Koichi Sasada + + * insnhelper.ci (caller_setup_args): add need_block_check option. + + * insns.def: ditto. + + * yarvcore.h: add GetCoreDataFromValue(). + Mon Jun 25 02:14:30 2007 Koichi Sasada * call_cfunc.ci: removed. diff --git a/insnhelper.ci b/insnhelper.ci index 05cb6a03e8..02489f7dc3 100644 --- a/insnhelper.ci +++ b/insnhelper.ci @@ -191,37 +191,40 @@ vm_callee_setup_arg(rb_thread_t *th, rb_iseq_t *iseq, static inline int caller_setup_args(rb_thread_t *th, rb_control_frame_t *cfp, - VALUE flag, int argc, rb_iseq_t *blockiseq, rb_block_t **block) + VALUE flag, int argc, rb_iseq_t *blockiseq, + rb_block_t **block, int need_block_check) { rb_block_t *blockptr = 0; - if (flag & VM_CALL_ARGS_BLOCKARG_BIT) { - rb_proc_t *po; - VALUE proc; + if (need_block_check) { + if (flag & VM_CALL_ARGS_BLOCKARG_BIT) { + rb_proc_t *po; + VALUE proc; - proc = *(--cfp->sp); + proc = *(--cfp->sp); - if (proc != Qnil) { - if (!rb_obj_is_proc(proc)) { - proc = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc"); + if (proc != Qnil) { if (!rb_obj_is_proc(proc)) { - rb_raise(rb_eTypeError, - "wrong argument type %s (expected Proc)", - rb_obj_classname(proc)); + proc = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc"); + if (!rb_obj_is_proc(proc)) { + rb_raise(rb_eTypeError, + "wrong argument type %s (expected Proc)", + rb_obj_classname(proc)); + } } + GetProcPtr(proc, po); + blockptr = &po->block; + RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp)->proc = proc; + *block = blockptr; } - GetProcPtr(proc, po); - blockptr = &po->block; - RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp)->proc = proc; + } + else if (blockiseq) { + blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp); + blockptr->iseq = blockiseq; + blockptr->proc = 0; *block = blockptr; } } - else if (blockiseq) { - blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp); - blockptr->iseq = blockiseq; - blockptr->proc = 0; - *block = blockptr; - } /* expand top of stack? */ if (flag & VM_CALL_ARGS_SPLAT_BIT) { diff --git a/insns.def b/insns.def index a13dff6580..7487b6c2bd 100644 --- a/insns.def +++ b/insns.def @@ -1155,7 +1155,7 @@ send NODE *mn; VALUE recv, klass; rb_block_t *blockptr = 0; - rb_num_t num = caller_setup_args(th, GET_CFP(), op_flag, op_argc, blockiseq, &blockptr); + rb_num_t num = caller_setup_args(th, GET_CFP(), op_flag, op_argc, blockiseq, &blockptr, 1); rb_num_t flag = op_flag; ID id = op_id; @@ -1216,7 +1216,7 @@ invokesuper { rb_block_t *blockptr = 0; VALUE flag = op_flag; - int num = caller_setup_args(th, GET_CFP(), flag, op_argc, blockiseq, &blockptr); + int num = caller_setup_args(th, GET_CFP(), flag, op_argc, blockiseq, &blockptr, 1); rb_iseq_t *iseq = GET_ISEQ(); rb_iseq_t *ip = iseq; VALUE recv, klass; @@ -1292,11 +1292,11 @@ invokeblock iseq = block->iseq; if (BUILTIN_TYPE(iseq) != T_NODE) { - argc = caller_setup_args(th, GET_CFP(), flag, argc, 0, 0); + argc = caller_setup_args(th, GET_CFP(), flag, argc, 0, 0, 0); + CHECK_STACK_OVERFLOW(GET_CFP(), iseq->stack_max); DEC_SP(argc); - argc = vm_yield_setup_args(th, iseq, argc, GET_SP(), block_proc_is_lambda(block->proc)); INC_SP(argc); diff --git a/yarvcore.h b/yarvcore.h index 054056c4fb..3a23cd81ca 100644 --- a/yarvcore.h +++ b/yarvcore.h @@ -214,7 +214,16 @@ struct iseq_compile_data { const rb_compile_option_t *option; }; -#define GetISeqPtr(obj, ptr) Data_Get_Struct(obj, rb_iseq_t, ptr) +#if 1 +#define GetCoreDataFromValue(obj, type, ptr) do { \ + ptr = (type*)DATA_PTR(obj); \ +} while (0) +#else +#define GetCoreDataFromValue(obj, type, ptr) Data_Get_Struct(obj, type, ptr) +#endif + +#define GetISeqPtr(obj, ptr) \ + GetCoreDataFromValue(obj, rb_iseq_t, ptr) typedef struct rb_iseq_profile_struct { VALUE count; @@ -337,7 +346,7 @@ typedef struct rb_event_hook_struct { #define GetVMPtr(obj, ptr) \ - Data_Get_Struct(obj, rb_vm_t, ptr) + GetCoreDataFromValue(obj, rb_vm_t, ptr) typedef struct rb_vm_struct { VALUE self; @@ -395,7 +404,7 @@ typedef struct { } rb_block_t; #define GetThreadPtr(obj, ptr) \ - Data_Get_Struct(obj, rb_thread_t, ptr) + GetCoreDataFromValue(obj, rb_thread_t, ptr) enum rb_thread_status { THREAD_TO_KILL, @@ -538,7 +547,7 @@ struct global_entry { }; #define GetProcPtr(obj, ptr) \ - Data_Get_Struct(obj, rb_proc_t, ptr) + GetCoreDataFromValue(obj, rb_proc_t, ptr) typedef struct { rb_block_t block; @@ -552,7 +561,7 @@ typedef struct { } rb_proc_t; #define GetEnvPtr(obj, ptr) \ - Data_Get_Struct(obj, rb_env_t, ptr) + GetCoreDataFromValue(obj, rb_env_t, ptr) typedef struct { VALUE *env; @@ -563,7 +572,7 @@ typedef struct { } rb_env_t; #define GetBindingPtr(obj, ptr) \ - Data_Get_Struct(obj, rb_binding_t, ptr) + GetCoreDataFromValue(obj, rb_binding_t, ptr) typedef struct { VALUE env;