summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-21 22:52:59 (GMT)
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-21 22:52:59 (GMT)
commite4198a73d406d9a9f61a6db2d2a243c0f5267679 (patch)
treee77fa8d9817f9ff7c53864e373784f902b4368c1 /vm_method.c
parent6053426a669386353a6b7fe11f3d3ea8d3c11e7c (diff)
* make rb_iseq_t T_IMEMO object (type is imemo_iseq).
All contents of previous rb_iseq_t is in rb_iseq_t::body. Remove rb_iseq_t::self because rb_iseq_t is an object. RubyVM::InstructionSequence is wrapper object points T_IMEMO/iseq. So RubyVM::ISeq.of(something) method returns different wrapper objects but they point the same T_IMEMO/iseq object. This patch is big, but most of difference is replacement of iseq->xxx to iseq->body->xxx. (previous) rb_iseq_t::compile_data is also located to rb_iseq_t::compile_data. It was moved from rb_iseq_body::compile_data. Now rb_iseq_t has empty two pointers. I will split rb_iseq_body data into static data and dynamic data. * compile.c: rename some functions/macros. Now, we don't need to separate iseq and iseqval (only VALUE). * eval.c (ruby_exec_internal): `n' is rb_iseq_t (T_IMEMO/iseq). * ext/objspace/objspace.c (count_imemo_objects): count T_IMEMO/iseq. * gc.c: check T_IMEMO/iseq. * internal.h: add imemo_type::imemo_iseq. * iseq.c: define RubyVM::InstructionSequnce as T_OBJECT. Methods are implemented by functions named iseqw_.... * load.c (rb_load_internal0): rb_iseq_new_top() returns rb_iseq_t (T_IMEMO/iesq). * method.h (rb_add_method_iseq): accept rb_iseq_t (T_IMEMO/iseq). * vm_core.h (GetISeqPtr): removed because it is not T_DATA now. * vm_core.h (struct rb_iseq_body): remove padding for [Bug #10037][ruby-core:63721]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/vm_method.c b/vm_method.c
index 0ae14c8..1364e5a 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -254,7 +254,7 @@ method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *def,
cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
if (cfp && (line = rb_vm_get_sourceline(cfp))) {
- VALUE location = rb_ary_new3(2, cfp->iseq->location.path, INT2FIX(line));
+ VALUE location = rb_ary_new3(2, cfp->iseq->body->location.path, INT2FIX(line));
RB_OBJ_WRITE(me, &def->body.attr.location, rb_ary_freeze(location));
}
else {
@@ -296,7 +296,7 @@ method_definition_reset(const rb_method_entry_t *me)
switch(def->type) {
case VM_METHOD_TYPE_ISEQ:
- RB_OBJ_WRITTEN(me, Qundef, def->body.iseq.iseqptr->self);
+ RB_OBJ_WRITTEN(me, Qundef, def->body.iseq.iseqptr);
RB_OBJ_WRITTEN(me, Qundef, def->body.iseq.cref);
break;
case VM_METHOD_TYPE_ATTRSET:
@@ -512,9 +512,9 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil
default:
break;
}
- if (iseq && !NIL_P(iseq->location.path)) {
- int line = iseq->line_info_table ? FIX2INT(rb_iseq_first_lineno(iseq->self)) : 0;
- rb_compile_warning(RSTRING_PTR(iseq->location.path), line,
+ if (iseq && !NIL_P(iseq->body->location.path)) {
+ int line = iseq->body->line_info_table ? FIX2INT(rb_iseq_first_lineno(iseq)) : 0;
+ rb_compile_warning(RSTRING_PTR(iseq->body->location.path), line,
"previous definition of %"PRIsVALUE" was here",
rb_id2str(old_def->original_id));
}
@@ -583,19 +583,16 @@ 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_visibility_t visi)
+rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi)
{
- rb_iseq_t *iseq;
struct { /* should be same fields with rb_method_iseq_struct */
- rb_iseq_t *iseqptr;
+ const rb_iseq_t *iseqptr;
rb_cref_t *cref;
} iseq_body;
- GetISeqPtr(iseqval, iseq);
iseq_body.iseqptr = iseq;
iseq_body.cref = cref;
rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, &iseq_body, visi);
- RB_GC_GUARD(iseqval);
}
static rb_method_entry_t *