summaryrefslogtreecommitdiff
path: root/vm_eval.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-21 22:52:59 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-21 22:52:59 +0000
commite4198a73d406d9a9f61a6db2d2a243c0f5267679 (patch)
treee77fa8d9817f9ff7c53864e373784f902b4368c1 /vm_eval.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_eval.c')
-rw-r--r--vm_eval.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/vm_eval.c b/vm_eval.c
index ff4abf5..a3ed8fa 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -20,7 +20,7 @@ static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *a
static inline VALUE vm_yield(rb_thread_t *th, int argc, const VALUE *argv);
static inline VALUE vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, const rb_block_t *blockargptr);
static VALUE vm_exec(rb_thread_t *th);
-static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const rb_cref_t *cref, rb_block_t *base_block);
+static void vm_set_eval_stack(rb_thread_t * th, const rb_iseq_t *iseq, const rb_cref_t *cref, rb_block_t *base_block);
static int vm_collect_local_variables_in_heap(rb_thread_t *th, const VALUE *dfp, const struct local_var_list *vars);
static VALUE rb_eUncaughtThrow;
@@ -1234,8 +1234,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
if ((state = TH_EXEC_TAG()) == 0) {
rb_cref_t *cref = cref_arg;
rb_binding_t *bind = 0;
- rb_iseq_t *iseq;
- volatile VALUE iseqval;
+ const rb_iseq_t *iseq;
VALUE absolute_path = Qnil;
VALUE fname;
@@ -1282,7 +1281,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
/* make eval iseq */
th->parse_in_eval++;
th->mild_compile_error++;
- iseqval = rb_iseq_compile_with_option(src, fname, absolute_path, INT2FIX(line), base_block, Qnil);
+ iseq = rb_iseq_compile_with_option(src, fname, absolute_path, INT2FIX(line), base_block, Qnil);
th->mild_compile_error--;
th->parse_in_eval--;
@@ -1297,17 +1296,16 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
cref = rb_vm_get_cref(base_block->ep);
}
}
- vm_set_eval_stack(th, iseqval, cref, base_block);
+ vm_set_eval_stack(th, iseq, cref, base_block);
RB_GC_GUARD(crefval);
if (0) { /* for debug */
- VALUE disasm = rb_iseq_disasm(iseqval);
+ VALUE disasm = rb_iseq_disasm(iseq);
printf("%s\n", StringValuePtr(disasm));
}
/* save new env */
- GetISeqPtr(iseqval, iseq);
- if (bind && iseq->local_table_size > 0) {
+ if (bind && iseq->body->local_table_size > 0) {
bind->env = vm_make_env_object(th, th->cfp);
}
@@ -2050,8 +2048,8 @@ rb_f_local_variables(void)
local_var_list_init(&vars);
while (cfp) {
if (cfp->iseq) {
- for (i = 0; i < cfp->iseq->local_table_size; i++) {
- local_var_list_add(&vars, cfp->iseq->local_table[i]);
+ for (i = 0; i < cfp->iseq->body->local_table_size; i++) {
+ local_var_list_add(&vars, cfp->iseq->body->local_table[i]);
}
}
if (!VM_EP_LEP_P(cfp->ep)) {
@@ -2117,7 +2115,7 @@ rb_current_realfilepath(void)
rb_thread_t *th = GET_THREAD();
rb_control_frame_t *cfp = th->cfp;
cfp = vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
- if (cfp != 0) return cfp->iseq->location.absolute_path;
+ if (cfp != 0) return cfp->iseq->body->location.absolute_path;
return Qnil;
}