mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* yarvcore.h: rename rb_control_frame_t#magic to flag.
* vm.h: add VM_FRAME_TYPE() and VM_FRAME_FLAG(). * cont.c, insnhelper.ci, insns.def, vm.c, vm_dump.c, vm_evalbody.ci, yarvcore.c: apply above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6a858e554c
commit
0d0ef6eccc
10 changed files with 53 additions and 45 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Thu Jul 5 19:45:55 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* yarvcore.h: rename rb_control_frame_t#magic to flag.
|
||||||
|
|
||||||
|
* vm.h: add VM_FRAME_TYPE() and VM_FRAME_FLAG().
|
||||||
|
|
||||||
|
* cont.c, insnhelper.ci, insns.def, vm.c, vm_dump.c,
|
||||||
|
vm_evalbody.ci, yarvcore.c: apply above changes.
|
||||||
|
|
||||||
Thu Jul 5 19:16:14 2007 Koichi Sasada <ko1@atdot.net>
|
Thu Jul 5 19:16:14 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* test/ruby/test_basicinstructions.rb: remove an assertion using
|
* test/ruby/test_basicinstructions.rb: remove an assertion using
|
||||||
|
|
2
cont.c
2
cont.c
|
@ -489,7 +489,7 @@ rb_fiber_s_new(VALUE self)
|
||||||
*th->cfp->lfp = 0;
|
*th->cfp->lfp = 0;
|
||||||
th->cfp->dfp = th->stack;
|
th->cfp->dfp = th->stack;
|
||||||
th->cfp->self = Qnil;
|
th->cfp->self = Qnil;
|
||||||
th->cfp->magic = 0;
|
th->cfp->flag = 0;
|
||||||
th->cfp->iseq = 0;
|
th->cfp->iseq = 0;
|
||||||
th->cfp->proc = 0;
|
th->cfp->proc = 0;
|
||||||
th->cfp->block_iseq = 0;
|
th->cfp->block_iseq = 0;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
/* control stack frame */
|
/* control stack frame */
|
||||||
|
|
||||||
static inline rb_control_frame_t *
|
static inline rb_control_frame_t *
|
||||||
vm_push_frame(rb_thread_t *th, rb_iseq_t *iseq, VALUE magic,
|
vm_push_frame(rb_thread_t *th, rb_iseq_t *iseq, VALUE type,
|
||||||
VALUE self, VALUE specval, VALUE *pc,
|
VALUE self, VALUE specval, VALUE *pc,
|
||||||
VALUE *sp, VALUE *lfp, int local_size)
|
VALUE *sp, VALUE *lfp, int local_size)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,7 @@ vm_push_frame(rb_thread_t *th, rb_iseq_t *iseq, VALUE magic,
|
||||||
cfp->sp = sp + 1;
|
cfp->sp = sp + 1;
|
||||||
cfp->bp = sp + 1;
|
cfp->bp = sp + 1;
|
||||||
cfp->iseq = iseq;
|
cfp->iseq = iseq;
|
||||||
cfp->magic = magic;
|
cfp->flag = VM_FRAME_FLAG(type);
|
||||||
cfp->self = self;
|
cfp->self = self;
|
||||||
cfp->lfp = lfp;
|
cfp->lfp = lfp;
|
||||||
cfp->dfp = dfp;
|
cfp->dfp = dfp;
|
||||||
|
|
|
@ -1406,7 +1406,7 @@ throw
|
||||||
rb_bug("VM (throw): can't find break base.");
|
rb_bug("VM (throw): can't find break base.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfp->magic == FRAME_MAGIC_LAMBDA) {
|
if (VM_FRAME_TYPE(cfp) == FRAME_MAGIC_LAMBDA) {
|
||||||
/* lambda{... break ...} */
|
/* lambda{... break ...} */
|
||||||
is_orphan = 0;
|
is_orphan = 0;
|
||||||
pt = dfp;
|
pt = dfp;
|
||||||
|
@ -1465,7 +1465,7 @@ throw
|
||||||
*/
|
*/
|
||||||
while ((VALUE *) cfp < th->stack + th->stack_size) {
|
while ((VALUE *) cfp < th->stack + th->stack_size) {
|
||||||
if (GET_DFP() == dfp) {
|
if (GET_DFP() == dfp) {
|
||||||
if (cfp->magic == FRAME_MAGIC_LAMBDA) {
|
if (VM_FRAME_TYPE(cfp) == FRAME_MAGIC_LAMBDA) {
|
||||||
/* in lambda */
|
/* in lambda */
|
||||||
is_orphan = 0;
|
is_orphan = 0;
|
||||||
break;
|
break;
|
||||||
|
|
14
vm.c
14
vm.c
|
@ -547,7 +547,7 @@ invoke_block(rb_thread_t *th, rb_block_t *block, VALUE self, int argc, VALUE *ar
|
||||||
if (BUILTIN_TYPE(block->iseq) != T_NODE) {
|
if (BUILTIN_TYPE(block->iseq) != T_NODE) {
|
||||||
rb_iseq_t *iseq = block->iseq;
|
rb_iseq_t *iseq = block->iseq;
|
||||||
int i, opt_pc;
|
int i, opt_pc;
|
||||||
int magic = block_proc_is_lambda(block->proc) ?
|
int type = block_proc_is_lambda(block->proc) ?
|
||||||
FRAME_MAGIC_LAMBDA : FRAME_MAGIC_BLOCK;
|
FRAME_MAGIC_LAMBDA : FRAME_MAGIC_BLOCK;
|
||||||
|
|
||||||
rb_vm_set_finish_env(th);
|
rb_vm_set_finish_env(th);
|
||||||
|
@ -559,11 +559,11 @@ invoke_block(rb_thread_t *th, rb_block_t *block, VALUE self, int argc, VALUE *ar
|
||||||
th->cfp->sp[i] = argv[i];
|
th->cfp->sp[i] = argv[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
opt_pc = vm_yield_setup_args(th, iseq, argc, th->cfp->sp, magic == FRAME_MAGIC_LAMBDA);
|
opt_pc = vm_yield_setup_args(th, iseq, argc, th->cfp->sp, type == FRAME_MAGIC_LAMBDA);
|
||||||
argc = iseq->arg_size;
|
argc = iseq->arg_size;
|
||||||
th->cfp->sp += argc;
|
th->cfp->sp += argc;
|
||||||
|
|
||||||
vm_push_frame(th, iseq, magic,
|
vm_push_frame(th, iseq, type,
|
||||||
self, GC_GUARDED_PTR(block->dfp),
|
self, GC_GUARDED_PTR(block->dfp),
|
||||||
iseq->iseq_encoded + opt_pc, th->cfp->sp, block->lfp,
|
iseq->iseq_encoded + opt_pc, th->cfp->sp, block->lfp,
|
||||||
iseq->local_size - argc);
|
iseq->local_size - argc);
|
||||||
|
@ -783,7 +783,7 @@ check_svar(void)
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
rb_control_frame_t *cfp = th->cfp;
|
rb_control_frame_t *cfp = th->cfp;
|
||||||
while ((void *)(cfp + 1) < (void *)(th->stack + th->stack_size)) {
|
while ((void *)(cfp + 1) < (void *)(th->stack + th->stack_size)) {
|
||||||
/* printf("cfp: %p\n", cfp->magic); */
|
/* printf("cfp: %p\n", cfp->type); */
|
||||||
if (cfp->lfp && cfp->lfp[-1] != Qnil &&
|
if (cfp->lfp && cfp->lfp[-1] != Qnil &&
|
||||||
TYPE(cfp->lfp[-1]) != T_VALUES) {
|
TYPE(cfp->lfp[-1]) != T_VALUES) {
|
||||||
/* dp(cfp->lfp[-1]); */
|
/* dp(cfp->lfp[-1]); */
|
||||||
|
@ -1050,12 +1050,12 @@ yarv_init_redefined_flag(void)
|
||||||
VALUE *pc; // cfp[0]
|
VALUE *pc; // cfp[0]
|
||||||
VALUE *sp; // cfp[1]
|
VALUE *sp; // cfp[1]
|
||||||
VALUE *bp; // cfp[2]
|
VALUE *bp; // cfp[2]
|
||||||
rb_iseq_t *iseq; // cfp[3]
|
rb_iseq_t *iseq; // cfp[3]
|
||||||
VALUE magic; // cfp[4]
|
VALUE flag; // cfp[4]
|
||||||
VALUE self; // cfp[5]
|
VALUE self; // cfp[5]
|
||||||
VALUE *lfp; // cfp[6]
|
VALUE *lfp; // cfp[6]
|
||||||
VALUE *dfp; // cfp[7]
|
VALUE *dfp; // cfp[7]
|
||||||
rb_iseq_t * block_iseq; // cfp[8]
|
rb_iseq_t * block_iseq; // cfp[8]
|
||||||
VALUE proc; // cfp[9] always 0
|
VALUE proc; // cfp[9] always 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
33
vm.h
33
vm.h
|
@ -231,26 +231,25 @@ while (0)
|
||||||
(!((th)->stack < (env) && (env) < ((th)->stack + (th)->stack_size)))
|
(!((th)->stack < (env) && (env) < ((th)->stack + (th)->stack_size)))
|
||||||
#define ENV_VAL(env) ((env)[1])
|
#define ENV_VAL(env) ((env)[1])
|
||||||
|
|
||||||
#define FRAME_MAGIC_METHOD 0xfaffff11
|
#define FRAME_MAGIC_METHOD 0x11
|
||||||
#define FRAME_MAGIC_BLOCK 0xfaffff21
|
#define FRAME_MAGIC_BLOCK 0x21
|
||||||
#define FRAME_MAGIC_CLASS 0xfaffff31
|
#define FRAME_MAGIC_CLASS 0x31
|
||||||
#define FRAME_MAGIC_TOP 0xfaffff41
|
#define FRAME_MAGIC_TOP 0x41
|
||||||
#define FRAME_MAGIC_FINISH 0xfaffff51
|
#define FRAME_MAGIC_FINISH 0x51
|
||||||
#define FRAME_MAGIC_CFUNC 0xfaffff61
|
#define FRAME_MAGIC_CFUNC 0x61
|
||||||
#define FRAME_MAGIC_PROC 0xfaffff71
|
#define FRAME_MAGIC_PROC 0x71
|
||||||
#define FRAME_MAGIC_IFUNC 0xfaffff81
|
#define FRAME_MAGIC_IFUNC 0x81
|
||||||
#define FRAME_MAGIC_EVAL 0xfaffff91
|
#define FRAME_MAGIC_EVAL 0x91
|
||||||
#define FRAME_MAGIC_LAMBDA 0xfaffffa1
|
#define FRAME_MAGIC_LAMBDA 0xa1
|
||||||
|
#define FRAME_MAGIC_MASK 0xff
|
||||||
|
|
||||||
#define CHECK_FRAME_MAGIC(magic) \
|
#define VM_FRAME_FLAG(type) ((VALUE)((type) & FRAME_MAGIC_MASK))
|
||||||
{ \
|
|
||||||
if((magic & 0xffffff00) != 0xfaffff00){ \
|
#define VM_FRAME_TYPE(cfp) \
|
||||||
rb_bug("YARV Stack frame error: %08x", magic); \
|
((cfp)->flag & FRAME_MAGIC_MASK)
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define RUBYVM_CFUNC_FRAME_P(cfp) \
|
#define RUBYVM_CFUNC_FRAME_P(cfp) \
|
||||||
((cfp)->magic == FRAME_MAGIC_CFUNC)
|
(VM_FRAME_TYPE(cfp) == FRAME_MAGIC_CFUNC)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Excception
|
* Excception
|
||||||
|
|
26
vm_dump.c
26
vm_dump.c
|
@ -46,7 +46,7 @@ control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
|
||||||
bp = cfp->bp - th->stack;
|
bp = cfp->bp - th->stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cfp->magic) {
|
switch (VM_FRAME_TYPE(cfp)) {
|
||||||
case FRAME_MAGIC_TOP:
|
case FRAME_MAGIC_TOP:
|
||||||
magic = "TOP";
|
magic = "TOP";
|
||||||
break;
|
break;
|
||||||
|
@ -263,15 +263,15 @@ stack_dump_each(rb_thread_t *th, rb_control_frame_t *cfp)
|
||||||
|
|
||||||
/* stack trace header */
|
/* stack trace header */
|
||||||
|
|
||||||
if (cfp->magic == FRAME_MAGIC_METHOD ||
|
if (VM_FRAME_TYPE(cfp) == FRAME_MAGIC_METHOD ||
|
||||||
cfp->magic == FRAME_MAGIC_TOP ||
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_TOP ||
|
||||||
cfp->magic == FRAME_MAGIC_BLOCK ||
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_BLOCK ||
|
||||||
cfp->magic == FRAME_MAGIC_CLASS ||
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_CLASS ||
|
||||||
cfp->magic == FRAME_MAGIC_PROC ||
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_PROC ||
|
||||||
cfp->magic == FRAME_MAGIC_LAMBDA ||
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_LAMBDA ||
|
||||||
cfp->magic == FRAME_MAGIC_CFUNC ||
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_CFUNC ||
|
||||||
cfp->magic == FRAME_MAGIC_IFUNC ||
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_IFUNC ||
|
||||||
cfp->magic == FRAME_MAGIC_EVAL) {
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_EVAL) {
|
||||||
|
|
||||||
VALUE *ptr = dfp - local_size;
|
VALUE *ptr = dfp - local_size;
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ stack_dump_each(rb_thread_t *th, rb_control_frame_t *cfp)
|
||||||
ptr - th->stack);
|
ptr - th->stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cfp->magic == FRAME_MAGIC_FINISH) {
|
else if (VM_FRAME_TYPE(cfp) == FRAME_MAGIC_FINISH) {
|
||||||
if ((th)->stack + (th)->stack_size > (VALUE *)(cfp + 2)) {
|
if ((th)->stack + (th)->stack_size > (VALUE *)(cfp + 2)) {
|
||||||
stack_dump_each(th, cfp + 1);
|
stack_dump_each(th, cfp + 1);
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ stack_dump_each(rb_thread_t *th, rb_control_frame_t *cfp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_bug("unsupport frame type: %08lx", cfp->magic);
|
rb_bug("unsupport frame type: %08lx", VM_FRAME_TYPE(cfp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ debug_print_pre(rb_thread_t *th, rb_control_frame_t *cfp)
|
||||||
{
|
{
|
||||||
rb_iseq_t *iseq = cfp->iseq;
|
rb_iseq_t *iseq = cfp->iseq;
|
||||||
|
|
||||||
if (iseq != 0 && cfp->magic != FRAME_MAGIC_FINISH) {
|
if (iseq != 0 && VM_FRAME_TYPE(cfp) != FRAME_MAGIC_FINISH) {
|
||||||
VALUE *seq = iseq->iseq;
|
VALUE *seq = iseq->iseq;
|
||||||
int pc = cfp->pc - iseq->iseq_encoded;
|
int pc = cfp->pc - iseq->iseq_encoded;
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ vm_eval(rb_thread_t *th, VALUE initial)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (th->cfp->magic != FRAME_MAGIC_FINISH) {
|
if (VM_FRAME_TYPE(th->cfp) != FRAME_MAGIC_FINISH) {
|
||||||
rb_bug("cfp consistency error");
|
rb_bug("cfp consistency error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,7 @@ th_init2(rb_thread_t *th)
|
||||||
*th->cfp->lfp = 0;
|
*th->cfp->lfp = 0;
|
||||||
th->cfp->dfp = th->stack;
|
th->cfp->dfp = th->stack;
|
||||||
th->cfp->self = Qnil;
|
th->cfp->self = Qnil;
|
||||||
th->cfp->magic = 0;
|
th->cfp->flag = 0;
|
||||||
th->cfp->iseq = 0;
|
th->cfp->iseq = 0;
|
||||||
th->cfp->proc = 0;
|
th->cfp->proc = 0;
|
||||||
th->cfp->block_iseq = 0;
|
th->cfp->block_iseq = 0;
|
||||||
|
|
|
@ -387,7 +387,7 @@ typedef struct {
|
||||||
VALUE *sp; /* cfp[1] */
|
VALUE *sp; /* cfp[1] */
|
||||||
VALUE *bp; /* cfp[2] */
|
VALUE *bp; /* cfp[2] */
|
||||||
rb_iseq_t *iseq; /* cfp[3] */
|
rb_iseq_t *iseq; /* cfp[3] */
|
||||||
VALUE magic; /* cfp[4] */
|
VALUE flag; /* cfp[4] */
|
||||||
VALUE self; /* cfp[5] / block[0] */
|
VALUE self; /* cfp[5] / block[0] */
|
||||||
VALUE *lfp; /* cfp[6] / block[1] */
|
VALUE *lfp; /* cfp[6] / block[1] */
|
||||||
VALUE *dfp; /* cfp[7] / block[2] */
|
VALUE *dfp; /* cfp[7] / block[2] */
|
||||||
|
|
Loading…
Reference in a new issue