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

* 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
This commit is contained in:
ko1 2007-06-24 18:40:13 +00:00
parent 7980e653e5
commit 144ff322c7
4 changed files with 50 additions and 30 deletions

View file

@ -1,3 +1,11 @@
Mon Jun 25 03:37:20 2007 Koichi Sasada <ko1@atdot.net>
* 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 <ko1@atdot.net>
* call_cfunc.ci: removed.

View file

@ -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) {

View file

@ -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);

View file

@ -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;