aboutsummaryrefslogtreecommitdiffstats
path: root/iseq.h
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-02 13:58:07 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-02 13:58:07 +0000
commit2962b6e063e4e6e8bd4b8be5c45166972caf41c2 (patch)
treef46856c3f6070bba675fee950b04724a8227464c /iseq.h
parentafd564ee3f7f2c42359e20d5083a214f82744812 (diff)
downloadruby-2962b6e063e4e6e8bd4b8be5c45166972caf41c2.tar.gz
* vm_core.h, iseq.h: remove rb_iseq_t::variable_body.
Fields in rb_iseq_t::variable_body are contained by rb_iseq_t::body::mark_ary (hidden Array object). Index 0 to 2 of mark_ary are reserved by these objects. * iseq.c: catch up this fix. * compile.c (rb_iseq_original_iseq): trivial rewrite. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.h')
-rw-r--r--iseq.h41
1 files changed, 36 insertions, 5 deletions
diff --git a/iseq.h b/iseq.h
index 73416ab327..2b18d56893 100644
--- a/iseq.h
+++ b/iseq.h
@@ -23,12 +23,43 @@ rb_call_info_kw_arg_bytes(int keyword_len)
return sizeof(struct rb_call_info_kw_arg) + sizeof(VALUE) * (keyword_len - 1);
}
+enum iseq_mark_ary_index {
+ ISEQ_MARK_ARY_COVERAGE = 0,
+ ISEQ_MARK_ARY_FLIP_CNT = 1,
+ ISEQ_MARK_ARY_ORIGINAL_ISEQ = 2,
+};
+
+#define ISEQ_MARK_ARY(iseq) (iseq)->body->mark_ary
+
+#define ISEQ_COVERAGE(iseq) RARRAY_AREF(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_COVERAGE)
+#define ISEQ_COVERAGE_SET(iseq, cov) RARRAY_ASET(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_COVERAGE, cov)
+
+static inline int
+ISEQ_FLIP_CNT_INCREMENT(const rb_iseq_t *iseq)
+{
+ VALUE cntv = RARRAY_AREF(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_FLIP_CNT);
+ int cnt = FIX2INT(cntv);
+ RARRAY_ASET(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_FLIP_CNT, INT2FIX(cnt+1));
+ return cnt;
+}
+
+static inline VALUE *
+ISEQ_ORIGINAL_ISEQ(const rb_iseq_t *iseq)
+{
+ VALUE str = RARRAY_AREF(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_ORIGINAL_ISEQ);
+ if (RTEST(str)) return (VALUE *)RSTRING_PTR(str);
+ return NULL;
+}
+
+static inline VALUE *
+ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
+{
+ VALUE str = rb_str_tmp_new(size * sizeof(VALUE));
+ RARRAY_ASET(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_ORIGINAL_ISEQ, str);
+ return (VALUE *)RSTRING_PTR(str);
+}
+
#define ISEQ_COMPILE_DATA(iseq) (iseq)->compile_data_
-#define ISEQ_COVERAGE(iseq) (iseq)->variable_body->coverage_
-#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE((iseq), &(iseq)->variable_body->coverage_, cov)
-#define ISEQ_FLIP_CNT_INCREMENT(iseq) ((iseq)->variable_body->flip_cnt_++)
-#define ISEQ_ORIGINAL_ISEQ(iseq) (iseq)->variable_body->iseq_
-#define ISEQ_ORIGINAL_ISEQ_ALLOC(iseq, size) (ISEQ_ORIGINAL_ISEQ(iseq) = ALLOC_N(VALUE, size))
RUBY_SYMBOL_EXPORT_BEGIN