diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-21 22:52:59 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-21 22:52:59 +0000 |
commit | e4198a73d406d9a9f61a6db2d2a243c0f5267679 (patch) | |
tree | e77fa8d9817f9ff7c53864e373784f902b4368c1 /proc.c | |
parent | 6053426a669386353a6b7fe11f3d3ea8d3c11e7c (diff) | |
download | ruby-e4198a73d406d9a9f61a6db2d2a243c0f5267679.tar.gz |
* 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 'proc.c')
-rw-r--r-- | proc.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -369,8 +369,8 @@ get_local_variable_ptr(VALUE envval, ID lid) iseq = env->block.iseq; if (RUBY_VM_NORMAL_ISEQ_P(iseq)) { - for (i=0; i<iseq->local_table_size; i++) { - if (iseq->local_table[i] == lid) { + for (i=0; i<iseq->body->local_table_size; i++) { + if (iseq->body->local_table[i] == lid) { return &env->env[i]; } } @@ -735,7 +735,7 @@ proc_call(int argc, VALUE *argv, VALUE procval) GetProcPtr(procval, proc); iseq = proc->block.iseq; - if (RUBY_VM_IFUNC_P(iseq) || iseq->param.flags.has_block) { + if (RUBY_VM_IFUNC_P(iseq) || iseq->body->param.flags.has_block) { if (rb_block_given_p()) { rb_proc_t *passed_proc; RB_GC_GUARD(passed_procval) = rb_block_proc(); @@ -847,11 +847,11 @@ proc_arity(VALUE self) static inline int rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max) { - *max = iseq->param.flags.has_rest == FALSE ? - iseq->param.lead_num + iseq->param.opt_num + iseq->param.post_num + - (iseq->param.flags.has_kw == TRUE || iseq->param.flags.has_kwrest == TRUE) + *max = iseq->body->param.flags.has_rest == FALSE ? + iseq->body->param.lead_num + iseq->body->param.opt_num + iseq->body->param.post_num + + (iseq->body->param.flags.has_kw == TRUE || iseq->body->param.flags.has_kwrest == TRUE) : UNLIMITED_ARGUMENTS; - return iseq->param.lead_num + iseq->param.post_num + (iseq->param.flags.has_kw && iseq->param.keyword->required_num > 0); + return iseq->body->param.lead_num + iseq->body->param.post_num + (iseq->body->param.flags.has_kw && iseq->body->param.keyword->required_num > 0); } static int @@ -950,9 +950,9 @@ iseq_location(const rb_iseq_t *iseq) VALUE loc[2]; if (!iseq) return Qnil; - loc[0] = iseq->location.path; - if (iseq->line_info_table) { - loc[1] = rb_iseq_first_lineno(iseq->self); + loc[0] = iseq->body->location.path; + if (iseq->body->line_info_table) { + loc[1] = rb_iseq_first_lineno(iseq); } else { loc[1] = Qnil; @@ -1066,11 +1066,11 @@ proc_to_s(VALUE self) if (RUBY_VM_NORMAL_ISEQ_P(iseq)) { int first_lineno = 0; - if (iseq->line_info_table) { - first_lineno = FIX2INT(rb_iseq_first_lineno(iseq->self)); + if (iseq->body->line_info_table) { + first_lineno = FIX2INT(rb_iseq_first_lineno(iseq)); } str = rb_sprintf("#<%s:%p@%"PRIsVALUE":%d%s>", cname, (void *)self, - iseq->location.path, first_lineno, is_lambda); + iseq->body->location.path, first_lineno, is_lambda); } else { str = rb_sprintf("#<%s:%p%s>", cname, (void *)proc->block.iseq, @@ -2558,8 +2558,8 @@ proc_binding(VALUE self) } if (iseq) { - bind->path = iseq->location.path; - bind->first_lineno = FIX2INT(rb_iseq_first_lineno(iseq->self)); + bind->path = iseq->body->location.path; + bind->first_lineno = FIX2INT(rb_iseq_first_lineno(iseq)); } else { bind->path = Qnil; |