summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-05 07:04:39 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-05 07:04:39 (GMT)
commitbc6e61f149deaf1f74e04af9c5e32683e6b39644 (patch)
treeab64ee958d73d4b7ccc58e7bddde5f9437e7a5ac
parent04dfc46ad0918964260d095b8f58e35eff5a33af (diff)
compile.c: do not dump pointers
* compile.c (ibf_dump_iseq_each): do not dump succ_index_table pointer. positions are dumped as integer arrays. pointer values are meaningless outside the process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--compile.c14
-rw-r--r--iseq.c13
-rw-r--r--iseq.h2
3 files changed, 16 insertions, 13 deletions
diff --git a/compile.c b/compile.c
index 33bc026..13d5fba 100644
--- a/compile.c
+++ b/compile.c
@@ -8612,9 +8612,9 @@ ibf_load_insns_info_body(const struct ibf_load *load, const struct rb_iseq_const
}
static unsigned int *
-ibf_dump_insns_info_positions(struct ibf_dump *dump, const rb_iseq_t *iseq)
+ibf_dump_insns_info_positions(struct ibf_dump *dump, const struct rb_iseq_constant_body *body)
{
- return IBF_W(iseq->body->insns_info.positions, unsigned int, iseq->body->insns_info.size);
+ return IBF_W(body->insns_info.positions, unsigned int, body->insns_info.size);
}
static unsigned int *
@@ -8765,7 +8765,10 @@ static ibf_offset_t
ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
struct rb_iseq_constant_body dump_body;
+ unsigned int *positions;
+#if VM_INSN_INFO_TABLE_IMPL == 2
dump_body = *iseq->body;
+#endif
dump_body.location.pathobj = ibf_dump_object(dump, dump_body.location.pathobj); /* TODO: freeze */
dump_body.location.base_label = ibf_dump_object(dump, dump_body.location.base_label);
@@ -8776,11 +8779,12 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
dump_body.param.keyword = ibf_dump_param_keyword(dump, iseq);
dump_body.insns_info.body = ibf_dump_insns_info_body(dump, iseq);
#if VM_INSN_INFO_TABLE_IMPL == 2
- rb_iseq_insns_info_decode_positions(iseq);
+ positions = rb_iseq_insns_info_decode_positions(&dump_body);
+ dump_body.insns_info.positions = positions;
#endif
- dump_body.insns_info.positions = ibf_dump_insns_info_positions(dump, iseq);
+ dump_body.insns_info.positions = ibf_dump_insns_info_positions(dump, &dump_body);
#if VM_INSN_INFO_TABLE_IMPL == 2
- rb_iseq_insns_info_encode_positions(iseq);
+ ruby_xfree(positions);
#endif
dump_body.local_table = ibf_dump_local_table(dump, iseq);
dump_body.catch_table = ibf_dump_catch_table(dump, iseq);
diff --git a/iseq.c b/iseq.c
index 9c0122a..68ad9a3 100644
--- a/iseq.c
+++ b/iseq.c
@@ -498,15 +498,14 @@ rb_iseq_insns_info_encode_positions(const rb_iseq_t *iseq)
#endif
}
-void
-rb_iseq_insns_info_decode_positions(const rb_iseq_t *iseq)
+unsigned int *
+rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body)
{
#if VM_INSN_INFO_TABLE_IMPL == 2
- int size = iseq->body->insns_info.size;
- int max_pos = iseq->body->iseq_size;
- struct succ_index_table *sd = iseq->body->insns_info.succ_index_table;
- if (iseq->body->insns_info.positions) ruby_xfree(iseq->body->insns_info.positions);
- iseq->body->insns_info.positions = succ_index_table_invert(max_pos, sd, size);
+ int size = body->insns_info.size;
+ int max_pos = body->iseq_size;
+ struct succ_index_table *sd = body->insns_info.succ_index_table;
+ return succ_index_table_invert(max_pos, sd, size);
#endif
}
diff --git a/iseq.h b/iseq.h
index 0a0edd9..de8beff 100644
--- a/iseq.h
+++ b/iseq.h
@@ -143,6 +143,7 @@ VALUE iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt);
void ibf_load_iseq_complete(rb_iseq_t *iseq);
const rb_iseq_t *iseq_ibf_load(VALUE str);
VALUE iseq_ibf_load_extra_data(VALUE str);
+unsigned int *rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body);
RUBY_SYMBOL_EXPORT_BEGIN
@@ -164,7 +165,6 @@ void rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events);
void rb_iseq_trace_set_all(rb_event_flag_t turnon_events);
void rb_iseq_trace_on_all(void);
void rb_iseq_insns_info_encode_positions(const rb_iseq_t *iseq);
-void rb_iseq_insns_info_decode_positions(const rb_iseq_t *iseq);
VALUE rb_iseqw_new(const rb_iseq_t *iseq);
const rb_iseq_t *rb_iseqw_to_iseq(VALUE iseqw);