* method.h: remove rb_method_iseq_t::iseqval.

While making a r50728, iseqval is needed (to mark correctly),
  but now just iseqptr is enough.
* class.c: catch up this fix.
* gc.c: ditto.
* proc.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2015-06-02 14:32:33 +00:00
parent 8ff3ab515c
commit ac88162198
6 changed files with 29 additions and 20 deletions

View File

@ -1,3 +1,17 @@
Tue Jun 2 23:27:18 2015 Koichi Sasada <ko1@atdot.net>
* method.h: remove rb_method_iseq_t::iseqval.
While making a r50728, iseqval is needed (to mark correctly),
but now just iseqptr is enough.
* class.c: catch up this fix.
* gc.c: ditto.
* proc.c: ditto.
* vm_method.c: ditto.
Tue Jun 2 21:29:28 2015 Koichi Sasada <ko1@atdot.net> Tue Jun 2 21:29:28 2015 Koichi Sasada <ko1@atdot.net>
* proc.c (proc_curry): remove a debug line. * proc.c (proc_curry): remove a debug line.

View File

@ -247,7 +247,7 @@ clone_method(VALUE klass, ID mid, const rb_method_entry_t *me)
if (me->def->type == VM_METHOD_TYPE_ISEQ) { if (me->def->type == VM_METHOD_TYPE_ISEQ) {
VALUE newiseqval; VALUE newiseqval;
rb_cref_t *new_cref; rb_cref_t *new_cref;
newiseqval = rb_iseq_clone(me->def->body.iseq.iseqval, klass); newiseqval = rb_iseq_clone(me->def->body.iseq.iseqptr->self, klass);
rb_vm_rewrite_cref_stack(me->def->body.iseq.cref, me->klass, klass, &new_cref); rb_vm_rewrite_cref_stack(me->def->body.iseq.cref, me->klass, klass, &new_cref);
rb_add_method_iseq(klass, mid, newiseqval, new_cref, me->def->flag); rb_add_method_iseq(klass, mid, newiseqval, new_cref, me->def->flag);
RB_GC_GUARD(newiseqval); RB_GC_GUARD(newiseqval);

2
gc.c
View File

@ -3932,7 +3932,7 @@ mark_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me)
switch (def->type) { switch (def->type) {
case VM_METHOD_TYPE_ISEQ: case VM_METHOD_TYPE_ISEQ:
gc_mark(objspace, def->body.iseq.iseqval); gc_mark(objspace, def->body.iseq.iseqptr->self);
gc_mark(objspace, (VALUE)def->body.iseq.cref); gc_mark(objspace, (VALUE)def->body.iseq.cref);
break; break;
case VM_METHOD_TYPE_ATTRSET: case VM_METHOD_TYPE_ATTRSET:

View File

@ -74,7 +74,6 @@ typedef struct rb_iseq_struct rb_iseq_t;
typedef struct rb_method_iseq_struct { typedef struct rb_method_iseq_struct {
rb_iseq_t * const iseqptr; /* should be separated from iseqval */ rb_iseq_t * const iseqptr; /* should be separated from iseqval */
rb_cref_t * const cref; /* shoudl be marked */ rb_cref_t * const cref; /* shoudl be marked */
const VALUE iseqval; /* should be marked */
} rb_method_iseq_t; } rb_method_iseq_t;
typedef struct rb_method_cfunc_struct { typedef struct rb_method_cfunc_struct {
@ -120,7 +119,7 @@ typedef struct rb_method_definition_struct {
UNDEFINED_METHOD_ENTRY_P((def)->body.orig_me)) UNDEFINED_METHOD_ENTRY_P((def)->body.orig_me))
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex); void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
void rb_add_method_iseq(VALUE klass, ID mid, VALUE iseq, rb_cref_t *cref, rb_method_flag_t noex); void rb_add_method_iseq(VALUE klass, ID mid, VALUE iseqval, rb_cref_t *cref, rb_method_flag_t noex);
rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex); rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex);
rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr); rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr);
rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id); rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);

9
proc.c
View File

@ -2046,8 +2046,7 @@ rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
case VM_METHOD_TYPE_BMETHOD: case VM_METHOD_TYPE_BMETHOD:
return rb_proc_min_max_arity(def->body.proc, max); return rb_proc_min_max_arity(def->body.proc, max);
case VM_METHOD_TYPE_ISEQ: { case VM_METHOD_TYPE_ISEQ: {
rb_iseq_t *iseq; rb_iseq_t *iseq = def->body.iseq.iseqptr;
GetISeqPtr(def->body.iseq.iseqval, iseq);
return rb_iseq_min_max_arity(iseq, max); return rb_iseq_min_max_arity(iseq, max);
} }
case VM_METHOD_TYPE_UNDEF: case VM_METHOD_TYPE_UNDEF:
@ -2183,11 +2182,7 @@ method_def_iseq(const rb_method_definition_t *def)
{ {
switch (def->type) { switch (def->type) {
case VM_METHOD_TYPE_ISEQ: case VM_METHOD_TYPE_ISEQ:
{ return def->body.iseq.iseqptr;
rb_iseq_t *iseq;
GetISeqPtr(def->body.iseq.iseqval, iseq);
return iseq;
}
case VM_METHOD_TYPE_BMETHOD: case VM_METHOD_TYPE_BMETHOD:
return get_proc_iseq(def->body.proc, 0); return get_proc_iseq(def->body.proc, 0);
case VM_METHOD_TYPE_ALIAS: case VM_METHOD_TYPE_ALIAS:

View File

@ -226,12 +226,9 @@ rb_method_definition_set(rb_method_definition_t *def, void *opts)
{ {
rb_method_iseq_t *iseq_body = (rb_method_iseq_t *)opts; rb_method_iseq_t *iseq_body = (rb_method_iseq_t *)opts;
rb_cref_t *method_cref, *cref = iseq_body->cref; rb_cref_t *method_cref, *cref = iseq_body->cref;
rb_iseq_t *iseq;
GetISeqPtr(iseq_body->iseqval, iseq);
/* setup iseq first (before invoking GC) */ /* setup iseq first (before invoking GC) */
DEF_OBJ_WRITE(&def->body.iseq.iseqval, iseq_body->iseqval); DEF_OBJ_WRITE(&def->body.iseq.iseqptr, iseq_body->iseqptr);
DEF_OBJ_WRITE(&def->body.iseq.iseqptr, iseq);
if (0) vm_cref_dump("rb_method_definition_create", cref); if (0) vm_cref_dump("rb_method_definition_create", cref);
@ -312,7 +309,7 @@ rb_method_definition_reset(rb_method_entry_t *me, rb_method_definition_t *def)
{ {
switch(def->type) { switch(def->type) {
case VM_METHOD_TYPE_ISEQ: case VM_METHOD_TYPE_ISEQ:
RB_OBJ_WRITTEN(me, Qundef, def->body.iseq.iseqval); RB_OBJ_WRITTEN(me, Qundef, def->body.iseq.iseqptr->self);
RB_OBJ_WRITTEN(me, Qundef, def->body.iseq.cref); RB_OBJ_WRITTEN(me, Qundef, def->body.iseq.cref);
break; break;
case VM_METHOD_TYPE_IVAR: case VM_METHOD_TYPE_IVAR:
@ -558,8 +555,12 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_
void void
rb_add_method_iseq(VALUE klass, ID mid, VALUE iseqval, rb_cref_t *cref, rb_method_flag_t noex) rb_add_method_iseq(VALUE klass, ID mid, VALUE iseqval, rb_cref_t *cref, rb_method_flag_t noex)
{ {
rb_method_iseq_t iseq_body = {NULL, cref, iseqval}; rb_iseq_t *iseq;
rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, &iseq_body, noex); GetISeqPtr(iseqval, iseq);
{
rb_method_iseq_t iseq_body = {iseq, cref};
rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, &iseq_body, noex);
}
} }
static rb_method_entry_t * static rb_method_entry_t *
@ -1281,7 +1282,7 @@ rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_defini
switch (d1->type) { switch (d1->type) {
case VM_METHOD_TYPE_ISEQ: case VM_METHOD_TYPE_ISEQ:
return d1->body.iseq.iseqval == d2->body.iseq.iseqval; return d1->body.iseq.iseqptr == d2->body.iseq.iseqptr;
case VM_METHOD_TYPE_CFUNC: case VM_METHOD_TYPE_CFUNC:
return return
d1->body.cfunc.func == d2->body.cfunc.func && d1->body.cfunc.func == d2->body.cfunc.func &&
@ -1316,7 +1317,7 @@ rb_hash_method_definition(st_index_t hash, const rb_method_definition_t *def)
switch (def->type) { switch (def->type) {
case VM_METHOD_TYPE_ISEQ: case VM_METHOD_TYPE_ISEQ:
return rb_hash_uint(hash, (st_index_t)def->body.iseq.iseqval); return rb_hash_uint(hash, (st_index_t)def->body.iseq.iseqptr);
case VM_METHOD_TYPE_CFUNC: case VM_METHOD_TYPE_CFUNC:
hash = rb_hash_uint(hash, (st_index_t)def->body.cfunc.func); hash = rb_hash_uint(hash, (st_index_t)def->body.cfunc.func);
return rb_hash_uint(hash, def->body.cfunc.argc); return rb_hash_uint(hash, def->body.cfunc.argc);