summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-22 10:55:02 (GMT)
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-22 10:55:02 (GMT)
commit0d775f2a3c402310b71a581e368f347c52af78e5 (patch)
treebc30b3a636d69901ca2742534704d7acd0daefef
parent2f5897e6b67d78d65c1aa3c9c16c0dfb65c38416 (diff)
* vm_core.h: separate rb_iseq_body into rb_iseq_constant_body and
rb_iseq_variable_body (rb_iseq_t::variable_body). rb_iseq_variable_body can be modified after compilation. * compile.c: use rb_iseq_t::variable_body. * iseq.c: ditto. * thread.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog13
-rw-r--r--compile.c18
-rw-r--r--iseq.c18
-rw-r--r--thread.c2
-rw-r--r--vm_core.h18
5 files changed, 40 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index 0ccecf2..95afc77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Wed Jul 22 19:52:45 2015 Koichi Sasada <ko1@atdot.net>
+
+ * vm_core.h: separate rb_iseq_body into rb_iseq_constant_body and
+ rb_iseq_variable_body (rb_iseq_t::variable_body).
+
+ rb_iseq_variable_body can be modified after compilation.
+
+ * compile.c: use rb_iseq_t::variable_body.
+
+ * iseq.c: ditto.
+
+ * thread.c: ditto.
+
Wed Jul 22 17:50:35 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* lib/matrix/eigenvalue_decomposition.rb: refine code style.
diff --git a/compile.c b/compile.c
index 1011e54..f570a6d 100644
--- a/compile.c
+++ b/compile.c
@@ -225,9 +225,9 @@ r_value(VALUE value)
#define ADD_TRACE(seq, line, event) \
do { \
- if ((event) == RUBY_EVENT_LINE && iseq->body->coverage && \
+ if ((event) == RUBY_EVENT_LINE && iseq->variable_body->coverage && \
(line) != iseq->compile_data->last_coverable_line) { \
- RARRAY_ASET(iseq->body->coverage, (line) - 1, INT2FIX(0)); \
+ RARRAY_ASET(iseq->variable_body->coverage, (line) - 1, INT2FIX(0)); \
iseq->compile_data->last_coverable_line = (line); \
ADD_INSN1((seq), (line), trace, INT2FIX(RUBY_EVENT_COVERAGE)); \
} \
@@ -608,26 +608,26 @@ rb_vm_insn_addr2insn(const void *addr) /* cold path */
VALUE *
rb_iseq_original_iseq(const rb_iseq_t *iseq) /* cold path */
{
- if (iseq->body->iseq) return iseq->body->iseq;
+ if (iseq->variable_body->iseq) return iseq->variable_body->iseq;
- iseq->body->iseq = ALLOC_N(VALUE, iseq->body->iseq_size);
+ iseq->variable_body->iseq = ALLOC_N(VALUE, iseq->body->iseq_size);
- MEMCPY(iseq->body->iseq, iseq->body->iseq_encoded, VALUE, iseq->body->iseq_size);
+ MEMCPY(iseq->variable_body->iseq, iseq->body->iseq_encoded, VALUE, iseq->body->iseq_size);
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
{
unsigned int i;
for (i = 0; i < iseq->body->iseq_size; /* */ ) {
- const void *addr = (const void *)iseq->body->iseq[i];
+ const void *addr = (const void *)iseq->variable_body->iseq[i];
const int insn = rb_vm_insn_addr2insn(addr);
- iseq->body->iseq[i] = insn;
+ iseq->variable_body->iseq[i] = insn;
i += insn_len(insn);
}
}
#endif
- return iseq->body->iseq;
+ return iseq->variable_body->iseq;
}
/*********************************************/
@@ -5299,7 +5299,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
rb_num_t cnt;
VALUE key;
- cnt = local_iseq->body->flip_cnt++ + VM_SVAR_FLIPFLOP_START;
+ cnt = local_iseq->variable_body->flip_cnt++ + VM_SVAR_FLIPFLOP_START;
key = INT2FIX(cnt);
ADD_INSN2(ret, line, getspecial, key, INT2FIX(0));
diff --git a/iseq.c b/iseq.c
index e4790e2..489be5f 100644
--- a/iseq.c
+++ b/iseq.c
@@ -92,7 +92,7 @@ rb_iseq_free(const rb_iseq_t *iseq)
ruby_xfree(iseq->body->param.keyword);
}
compile_data_free(iseq->compile_data);
- ruby_xfree(iseq->body->iseq);
+ ruby_xfree(iseq->variable_body->iseq);
ruby_xfree(iseq->body);
}
RUBY_FREE_LEAVE("iseq");
@@ -106,14 +106,17 @@ rb_iseq_mark(const rb_iseq_t *iseq)
RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->body->location.label), RSTRING_PTR(iseq->body->location.path));
if (iseq->body) {
- const struct rb_iseq_body *body = iseq->body;
+ const struct rb_iseq_constant_body *body = iseq->body;
RUBY_MARK_UNLESS_NULL(body->mark_ary);
RUBY_MARK_UNLESS_NULL(body->location.label);
RUBY_MARK_UNLESS_NULL(body->location.base_label);
RUBY_MARK_UNLESS_NULL(body->location.path);
RUBY_MARK_UNLESS_NULL(body->location.absolute_path);
- RUBY_MARK_UNLESS_NULL(body->coverage);
+ }
+
+ if (iseq->variable_body) {
+ RUBY_MARK_UNLESS_NULL(iseq->variable_body->coverage);
}
if (iseq->compile_data != 0) {
@@ -173,7 +176,8 @@ static rb_iseq_t *
iseq_alloc(void)
{
rb_iseq_t *iseq = (rb_iseq_t *)rb_imemo_new(imemo_iseq, 0, 0, 0, 0);
- iseq->body = ZALLOC(struct rb_iseq_body);
+ iseq->body = ZALLOC(struct rb_iseq_constant_body);
+ iseq->variable_body = ZALLOC(struct rb_iseq_variable_body);
return iseq;
}
@@ -264,13 +268,13 @@ prepare_iseq_build(rb_iseq_t *iseq,
iseq->compile_data->option = option;
iseq->compile_data->last_coverable_line = -1;
- RB_OBJ_WRITE(iseq, &iseq->body->coverage, Qfalse);
+ RB_OBJ_WRITE(iseq, &iseq->variable_body->coverage, Qfalse);
if (!GET_THREAD()->parse_in_eval) {
VALUE coverages = rb_get_coverages();
if (RTEST(coverages)) {
- RB_OBJ_WRITE(iseq, &iseq->body->coverage, rb_hash_lookup(coverages, path));
- if (NIL_P(iseq->body->coverage)) RB_OBJ_WRITE(iseq, &iseq->body->coverage, Qfalse);
+ RB_OBJ_WRITE(iseq, &iseq->variable_body->coverage, rb_hash_lookup(coverages, path));
+ if (NIL_P(iseq->variable_body->coverage)) RB_OBJ_WRITE(iseq, &iseq->variable_body->coverage, Qfalse);
}
}
diff --git a/thread.c b/thread.c
index 48115d8..8ca3f01 100644
--- a/thread.c
+++ b/thread.c
@@ -5227,7 +5227,7 @@ rb_check_deadlock(rb_vm_t *vm)
static void
update_coverage(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klass)
{
- VALUE coverage = GET_THREAD()->cfp->iseq->body->coverage;
+ VALUE coverage = GET_THREAD()->cfp->iseq->variable_body->coverage;
if (coverage && RBASIC(coverage)->klass == 0) {
long line = rb_sourceline() - 1;
long count;
diff --git a/vm_core.h b/vm_core.h
index f4c81fc..6e3d9cc 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -241,11 +241,7 @@ typedef struct rb_iseq_location_struct {
VALUE first_lineno; /* TODO: may be unsigned short */
} rb_iseq_location_t;
-struct rb_iseq_body {
- /***************/
- /* static data */
- /***************/
-
+struct rb_iseq_constant_body {
enum iseq_type {
ISEQ_TYPE_TOP,
ISEQ_TYPE_METHOD,
@@ -267,7 +263,6 @@ struct rb_iseq_body {
unsigned int line_info_size;
const VALUE mark_ary; /* Array: includes operands which should be GC marked */
- const VALUE coverage; /* coverage array */
/* insn info, must be freed */
struct iseq_line_info_entry *line_info_table;
@@ -360,12 +355,11 @@ struct rb_iseq_body {
/* for child iseq */
const struct rb_iseq_struct *parent_iseq;
struct rb_iseq_struct *local_iseq; /* local_iseq->flip_cnt can be modified */
+};
- /****************/
- /* dynamic data */
- /****************/
+struct rb_iseq_variable_body {
+ const VALUE coverage; /* coverage array */
- /* misc */
rb_num_t flip_cnt;
/* original iseq, before encoding
@@ -378,8 +372,8 @@ struct rb_iseq_body {
struct rb_iseq_struct {
VALUE flags;
struct iseq_compile_data *compile_data; /* used at compile time */
- struct rb_iseq_body *body;
- VALUE dummy1;
+ struct rb_iseq_constant_body *body;
+ struct rb_iseq_variable_body *variable_body;
VALUE dummy2;
};