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

* cont.c (rb_fiber_s_new): revert initializing VM stack.

* yarvcore.c (th_init2): ditto.
* vm.c, vm.h: fix to stop using Qundef on VM stack.  According to
  this change, VM stack should not include Qundef value.
* insns.def (putundef): removed.
* compile.c (iseq_compile_each): ditto.
* eval.c (eval): fix spacing.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-06-26 06:14:44 +00:00
parent 8bfcdf323f
commit 9315740101
8 changed files with 29 additions and 33 deletions

View file

@ -1,3 +1,18 @@
Tue Jun 26 15:04:06 2007 Koichi Sasada <ko1@atdot.net>
* cont.c (rb_fiber_s_new): revert initializing VM stack.
* yarvcore.c (th_init2): ditto.
* vm.c, vm.h: fix to stop using Qundef on VM stack. According to
this change, VM stack should not include Qundef value.
* insns.def (putundef): removed.
* compile.c (iseq_compile_each): ditto.
* eval.c (eval): fix spacing.
Tue Jun 26 04:03:50 2007 Koichi Sasada <ko1@atdot.net> Tue Jun 26 04:03:50 2007 Koichi Sasada <ko1@atdot.net>
* insnhelper.ci (vm_yield_with_cfunc), proc.c: fix Method#to_proc * insnhelper.ci (vm_yield_with_cfunc), proc.c: fix Method#to_proc

View file

@ -2787,7 +2787,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
ADD_LABEL(ret, end_label); ADD_LABEL(ret, end_label);
if (node->nd_state == Qundef) { if (node->nd_state == Qundef) {
ADD_INSN(ret, nd_line(node), putundef); /* ADD_INSN(ret, nd_line(node), putundef); */
rb_bug("unsupported: putundef");
} }
else { else {
ADD_INSN(ret, nd_line(node), putnil); ADD_INSN(ret, nd_line(node), putnil);

1
cont.c
View file

@ -474,7 +474,6 @@ rb_fiber_s_new(VALUE self)
th->stack = 0; th->stack = 0;
th->stack_size = FIBER_STACK_SIZE; th->stack_size = FIBER_STACK_SIZE;
th->stack = ALLOC_N(VALUE, th->stack_size); th->stack = ALLOC_N(VALUE, th->stack_size);
MEMZERO(th->stack, VALUE, th->stack_size);
th->cfp = (void *)(th->stack + th->stack_size); th->cfp = (void *)(th->stack + th->stack_size);
th->cfp--; th->cfp--;

1
eval.c
View file

@ -1670,7 +1670,6 @@ eval(VALUE self, VALUE src, VALUE scope, const char *file, int line)
VALUE iseqval; VALUE iseqval;
if (scope != Qnil) { if (scope != Qnil) {
if (CLASS_OF(scope) == rb_cBinding) { if (CLASS_OF(scope) == rb_cBinding) {
GetBindingPtr(scope, bind); GetBindingPtr(scope, bind);
envval = bind->env; envval = bind->env;

View file

@ -357,20 +357,6 @@ putself
val = GET_SELF(); val = GET_SELF();
} }
/**
@c put
@e put Qundef. DO NOT USE in NORMAL RUBY PROGRAM
@j put Qundef.
*/
DEFINE_INSN
putundef
()
()
(VALUE val)
{
val = Qundef;
}
/** /**
@c put @c put
@e put some object. @e put some object.

15
vm.c
View file

@ -190,7 +190,7 @@ vm_make_env_each(rb_thread_t *th, rb_control_frame_t *cfp,
VALUE *nenvptr; VALUE *nenvptr;
int i, local_size; int i, local_size;
if (ENV_IN_HEAP_P(envptr)) { if (ENV_IN_HEAP_P(th, envptr)) {
return ENV_VAL(envptr); return ENV_VAL(envptr);
} }
@ -198,7 +198,7 @@ vm_make_env_each(rb_thread_t *th, rb_control_frame_t *cfp,
VALUE *penvptr = GC_GUARDED_PTR_REF(*envptr); VALUE *penvptr = GC_GUARDED_PTR_REF(*envptr);
rb_control_frame_t *pcfp = cfp; rb_control_frame_t *pcfp = cfp;
if (ENV_IN_HEAP_P(penvptr)) { if (ENV_IN_HEAP_P(th, penvptr)) {
penvval = ENV_VAL(penvptr); penvval = ENV_VAL(penvptr);
} }
else { else {
@ -227,7 +227,7 @@ vm_make_env_each(rb_thread_t *th, rb_control_frame_t *cfp,
local_size = cfp->iseq->local_size; local_size = cfp->iseq->local_size;
} }
env->env_size = local_size + 1 + 4; env->env_size = local_size + 1 + 2;
env->local_size = local_size; env->local_size = local_size;
env->env = ALLOC_N(VALUE, env->env_size); env->env = ALLOC_N(VALUE, env->env_size);
env->prev_envval = penvval; env->prev_envval = penvval;
@ -243,10 +243,8 @@ vm_make_env_each(rb_thread_t *th, rb_control_frame_t *cfp,
*envptr = envval; /* GC mark */ *envptr = envval; /* GC mark */
nenvptr = &env->env[i - 1]; nenvptr = &env->env[i - 1];
nenvptr[1] = Qfalse; /* frame is not orphan */ nenvptr[1] = envval; /* frame self */
nenvptr[2] = Qundef; /* frame is in heap */ nenvptr[2] = penvval; /* frame prev env object */
nenvptr[3] = envval; /* frame self */
nenvptr[4] = penvval; /* frame prev env object */
/* reset lfp/dfp in cfp */ /* reset lfp/dfp in cfp */
cfp->dfp = nenvptr; cfp->dfp = nenvptr;
@ -296,7 +294,7 @@ collect_local_variables_in_env(rb_env_t *env, VALUE ary)
int int
vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary) vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary)
{ {
if (ENV_IN_HEAP_P(dfp)) { if (ENV_IN_HEAP_P(th, dfp)) {
rb_env_t *env; rb_env_t *env;
GetEnvPtr(ENV_VAL(dfp), env); GetEnvPtr(ENV_VAL(dfp), env);
collect_local_variables_in_env(env, ary); collect_local_variables_in_env(env, ary);
@ -313,6 +311,7 @@ vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp)
VALUE envval; VALUE envval;
envval = vm_make_env_each(th, cfp, cfp->dfp, cfp->lfp); envval = vm_make_env_each(th, cfp, cfp->dfp, cfp->lfp);
if (PROCDEBUG) { if (PROCDEBUG) {
check_env_value(envval); check_env_value(envval);
} }

12
vm.h
View file

@ -222,16 +222,14 @@ default: \
/* /*
env{ env{
env[0] // special (block or prev env) env[0] // special (block or prev env)
env[1] // orphan env[1] // env object
env[2] // in heap env[2] // prev env val
env[3] // env object
env[4] // prev env val
}; };
*/ */
#define ORPHAN_ENV_P(env) ((env)[1] == Qundef) #define ENV_IN_HEAP_P(th, env) \
#define ENV_IN_HEAP_P(env) ((env)[2] == Qundef) (!((th)->stack < (env) && (env) < ((th)->stack + (th)->stack_size)))
#define ENV_VAL(env) ((env)[3]) #define ENV_VAL(env) ((env)[1])
#define FRAME_MAGIC_METHOD 0xfaffff11 #define FRAME_MAGIC_METHOD 0xfaffff11
#define FRAME_MAGIC_BLOCK 0xfaffff21 #define FRAME_MAGIC_BLOCK 0xfaffff21

View file

@ -329,7 +329,6 @@ th_init2(rb_thread_t *th)
/* allocate thread stack */ /* allocate thread stack */
th->stack_size = RUBY_VM_THREAD_STACK_SIZE; th->stack_size = RUBY_VM_THREAD_STACK_SIZE;
th->stack = ALLOC_N(VALUE, th->stack_size); th->stack = ALLOC_N(VALUE, th->stack_size);
MEMZERO(th->stack, VALUE, th->stack_size);
th->cfp = (void *)(th->stack + th->stack_size); th->cfp = (void *)(th->stack + th->stack_size);
th->cfp--; th->cfp--;