Skip to content

Commit

Permalink
* method.h: remove rb_method_iseq_t::iseqval.
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
ko1 committed Jun 2, 2015
1 parent 8ff3ab5 commit ac88162
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
14 changes: 14 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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>

* proc.c (proc_curry): remove a debug line.
Expand Down
2 changes: 1 addition & 1 deletion class.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ clone_method(VALUE klass, ID mid, const rb_method_entry_t *me)
if (me->def->type == VM_METHOD_TYPE_ISEQ) {
VALUE newiseqval;
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_add_method_iseq(klass, mid, newiseqval, new_cref, me->def->flag);
RB_GC_GUARD(newiseqval);
Expand Down
2 changes: 1 addition & 1 deletion gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3932,7 +3932,7 @@ mark_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me)

switch (def->type) {
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);
break;
case VM_METHOD_TYPE_ATTRSET:
Expand Down
3 changes: 1 addition & 2 deletions method.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ typedef struct rb_iseq_struct rb_iseq_t;
typedef struct rb_method_iseq_struct {
rb_iseq_t * const iseqptr; /* should be separated from iseqval */
rb_cref_t * const cref; /* shoudl be marked */
const VALUE iseqval; /* should be marked */
} rb_method_iseq_t;

typedef struct rb_method_cfunc_struct {
Expand Down Expand Up @@ -120,7 +119,7 @@ typedef struct rb_method_definition_struct {
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_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_method_entry(VALUE klass, ID id, VALUE *define_class_ptr);
rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
Expand Down
9 changes: 2 additions & 7 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2046,8 +2046,7 @@ rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
case VM_METHOD_TYPE_BMETHOD:
return rb_proc_min_max_arity(def->body.proc, max);
case VM_METHOD_TYPE_ISEQ: {
rb_iseq_t *iseq;
GetISeqPtr(def->body.iseq.iseqval, iseq);
rb_iseq_t *iseq = def->body.iseq.iseqptr;
return rb_iseq_min_max_arity(iseq, max);
}
case VM_METHOD_TYPE_UNDEF:
Expand Down Expand Up @@ -2183,11 +2182,7 @@ method_def_iseq(const rb_method_definition_t *def)
{
switch (def->type) {
case VM_METHOD_TYPE_ISEQ:
{
rb_iseq_t *iseq;
GetISeqPtr(def->body.iseq.iseqval, iseq);
return iseq;
}
return def->body.iseq.iseqptr;
case VM_METHOD_TYPE_BMETHOD:
return get_proc_iseq(def->body.proc, 0);
case VM_METHOD_TYPE_ALIAS:
Expand Down
19 changes: 10 additions & 9 deletions vm_method.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_cref_t *method_cref, *cref = iseq_body->cref;
rb_iseq_t *iseq;
GetISeqPtr(iseq_body->iseqval, iseq);

/* setup iseq first (before invoking GC) */
DEF_OBJ_WRITE(&def->body.iseq.iseqval, iseq_body->iseqval);
DEF_OBJ_WRITE(&def->body.iseq.iseqptr, iseq);
DEF_OBJ_WRITE(&def->body.iseq.iseqptr, iseq_body->iseqptr);

if (0) vm_cref_dump("rb_method_definition_create", cref);

Expand Down Expand Up @@ -312,7 +309,7 @@ rb_method_definition_reset(rb_method_entry_t *me, rb_method_definition_t *def)
{
switch(def->type) {
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);
break;
case VM_METHOD_TYPE_IVAR:
Expand Down Expand Up @@ -558,8 +555,12 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_
void
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_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, &iseq_body, noex);
rb_iseq_t *iseq;
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 *
Expand Down Expand Up @@ -1281,7 +1282,7 @@ rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_defini

switch (d1->type) {
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:
return
d1->body.cfunc.func == d2->body.cfunc.func &&
Expand Down Expand Up @@ -1316,7 +1317,7 @@ rb_hash_method_definition(st_index_t hash, const rb_method_definition_t *def)

switch (def->type) {
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:
hash = rb_hash_uint(hash, (st_index_t)def->body.cfunc.func);
return rb_hash_uint(hash, def->body.cfunc.argc);
Expand Down

0 comments on commit ac88162

Please sign in to comment.