mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
* 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
This commit is contained in:
parent
6053426a66
commit
e4198a73d4
25 changed files with 1155 additions and 1138 deletions
17
vm_method.c
17
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 *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue