mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_evalbody.ci: support OPT_CALL_THREADED_CODE.
* insns.def, vm.c, vm.h: ditto. * vm.h: add VM_CFP_CNT() and VM_SP_CNT(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
35ecb83d41
commit
c44e2cdd58
5 changed files with 48 additions and 13 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Jun 27 17:08:42 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* vm_evalbody.ci: support OPT_CALL_THREADED_CODE.
|
||||||
|
|
||||||
|
* insns.def, vm.c, vm.h: ditto.
|
||||||
|
|
||||||
|
* vm.h: add VM_CFP_CNT() and VM_SP_CNT().
|
||||||
|
|
||||||
Wed Jun 27 04:23:47 2007 Koichi Sasada <ko1@atdot.net>
|
Wed Jun 27 04:23:47 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* compile.c (iseq_compile_each): fix type error.
|
* compile.c (iseq_compile_each): fix type error.
|
||||||
|
|
12
insns.def
12
insns.def
|
@ -1325,8 +1325,8 @@ leave
|
||||||
{
|
{
|
||||||
if (OPT_CHECKED_RUN) {
|
if (OPT_CHECKED_RUN) {
|
||||||
if (reg_cfp->sp != reg_cfp->bp) {
|
if (reg_cfp->sp != reg_cfp->bp) {
|
||||||
rb_bug("Stack consistency error (sp: %p, bp: %p)",
|
rb_bug("Stack consistency error (sp: %d, bp: %d)",
|
||||||
reg_cfp->sp, reg_cfp->bp);
|
VM_SP_CNT(th, reg_cfp->sp), VM_SP_CNT(th, reg_cfp->bp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1346,8 +1346,12 @@ finish
|
||||||
(VALUE val)
|
(VALUE val)
|
||||||
(VALUE val)
|
(VALUE val)
|
||||||
{
|
{
|
||||||
|
#if OPT_CALL_THREADED_CODE
|
||||||
|
rb_bug("unused instruction on OPT_CALL_THREADED_CODE");
|
||||||
|
#else
|
||||||
th->cfp++;
|
th->cfp++;
|
||||||
return val;
|
return val;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
|
@ -1422,7 +1426,7 @@ throw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
th->state = state;
|
th->state = state;
|
||||||
return (VALUE) NEW_THROW_OBJECT(throwobj, (VALUE) pt, state);
|
THROW_EXCEPTION(NEW_THROW_OBJECT(throwobj, (VALUE) pt, state));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* continue throw */
|
/* continue throw */
|
||||||
|
@ -1440,7 +1444,7 @@ throw
|
||||||
else {
|
else {
|
||||||
th->state = FIX2INT(rb_ivar_get(err, idThrowState));
|
th->state = FIX2INT(rb_ivar_get(err, idThrowState));
|
||||||
}
|
}
|
||||||
return err;
|
THROW_EXCEPTION(err);
|
||||||
}
|
}
|
||||||
/* unreachable */
|
/* unreachable */
|
||||||
}
|
}
|
||||||
|
|
7
vm.c
7
vm.c
|
@ -409,7 +409,6 @@ vm_call0(rb_thread_t *th, VALUE klass, VALUE recv,
|
||||||
if (0) printf("id: %s, nd: %s, argc: %d, passed: %p\n",
|
if (0) printf("id: %s, nd: %s, argc: %d, passed: %p\n",
|
||||||
rb_id2name(id), ruby_node_name(nd_type(body)),
|
rb_id2name(id), ruby_node_name(nd_type(body)),
|
||||||
argc, th->passed_block);
|
argc, th->passed_block);
|
||||||
//SDR2(th->cfp);
|
|
||||||
|
|
||||||
if (th->passed_block) {
|
if (th->passed_block) {
|
||||||
blockptr = th->passed_block;
|
blockptr = th->passed_block;
|
||||||
|
@ -418,18 +417,20 @@ vm_call0(rb_thread_t *th, VALUE klass, VALUE recv,
|
||||||
switch (nd_type(body)) {
|
switch (nd_type(body)) {
|
||||||
case RUBY_VM_METHOD_NODE:{
|
case RUBY_VM_METHOD_NODE:{
|
||||||
rb_control_frame_t *reg_cfp;
|
rb_control_frame_t *reg_cfp;
|
||||||
|
VALUE iseqval = (VALUE)body->nd_body;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
rb_vm_set_finish_env(th);
|
rb_vm_set_finish_env(th);
|
||||||
reg_cfp = th->cfp;
|
reg_cfp = th->cfp;
|
||||||
|
|
||||||
CHECK_STACK_OVERFLOW(reg_cfp, argc);
|
CHECK_STACK_OVERFLOW(reg_cfp, argc + 1);
|
||||||
|
|
||||||
|
*reg_cfp->sp++ = recv;
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
*reg_cfp->sp++ = argv[i];
|
*reg_cfp->sp++ = argv[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
vm_setup_method(th, reg_cfp, argc, blockptr, 0, (VALUE)body->nd_body, recv, klass);
|
vm_setup_method(th, reg_cfp, argc, blockptr, 0, iseqval, recv, klass);
|
||||||
val = vm_eval_body(th);
|
val = vm_eval_body(th);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
15
vm.h
15
vm.h
|
@ -112,7 +112,7 @@ typedef rb_control_frame_t *
|
||||||
(*insn_func_type) (rb_thread_t *, rb_control_frame_t *)FASTCALL;
|
(*insn_func_type) (rb_thread_t *, rb_control_frame_t *)FASTCALL;
|
||||||
|
|
||||||
#define INSN_ENTRY(insn) \
|
#define INSN_ENTRY(insn) \
|
||||||
rb_control_frame_t * \
|
static rb_control_frame_t * \
|
||||||
LABEL(insn)(rb_thread_t *th, rb_control_frame_t *reg_cfp) FASTCALL {
|
LABEL(insn)(rb_thread_t *th, rb_control_frame_t *reg_cfp) FASTCALL {
|
||||||
|
|
||||||
#define END_INSN(insn) return reg_cfp;}
|
#define END_INSN(insn) return reg_cfp;}
|
||||||
|
@ -219,6 +219,10 @@ default: \
|
||||||
/************************************************/
|
/************************************************/
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
|
#define VM_CFP_CNT(th, cfp) \
|
||||||
|
((rb_control_frame_t *)(th->stack + th->stack_size) - (rb_control_frame_t *)(cfp))
|
||||||
|
#define VM_SP_CNT(th, sp) ((sp) - (th)->stack)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
env{
|
env{
|
||||||
env[0] // special (block or prev env)
|
env[0] // special (block or prev env)
|
||||||
|
@ -266,6 +270,15 @@ default: \
|
||||||
#define SET_THROWOBJ_STATE(obj, val) \
|
#define SET_THROWOBJ_STATE(obj, val) \
|
||||||
(RNODE((obj))->u3.value = (val))
|
(RNODE((obj))->u3.value = (val))
|
||||||
|
|
||||||
|
#if OPT_CALL_THREADED_CODE
|
||||||
|
#define THROW_EXCEPTION(exc) do { \
|
||||||
|
th->errinfo = (VALUE)(exc); \
|
||||||
|
return 0; \
|
||||||
|
} while (0)
|
||||||
|
#else
|
||||||
|
#define THROW_EXCEPTION(exc) return (exc)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SCREG(r) (reg_##r)
|
#define SCREG(r) (reg_##r)
|
||||||
|
|
||||||
/* VM state version */
|
/* VM state version */
|
||||||
|
|
|
@ -122,15 +122,24 @@ VALUE
|
||||||
vm_eval(rb_thread_t *th, VALUE initial)
|
vm_eval(rb_thread_t *th, VALUE initial)
|
||||||
{
|
{
|
||||||
register rb_control_frame_t *reg_cfp = th->cfp;
|
register rb_control_frame_t *reg_cfp = th->cfp;
|
||||||
SET_PC(reg_cfp->iseq->iseq_encoded);
|
VALUE ret;
|
||||||
|
|
||||||
while (*GET_PC()) {
|
while (*GET_PC()) {
|
||||||
reg_cfp = ((insn_func_type) (*GET_PC()))(th, reg_cfp);
|
reg_cfp = ((insn_func_type) (*GET_PC()))(th, reg_cfp);
|
||||||
|
|
||||||
|
if (reg_cfp == 0) {
|
||||||
|
VALUE err = th->errinfo;
|
||||||
|
th->errinfo = Qnil;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
{
|
|
||||||
VALUE ret = *--reg_cfp->sp;
|
if (th->cfp->magic != FRAME_MAGIC_FINISH) {
|
||||||
th->cfp--;
|
rb_bug("cfp consistency error");
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = *(th->cfp->sp-1); /* pop */
|
||||||
|
th->cfp++; /* pop cf */
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue