ruby-changes:50892
From: nobu <ko1@a...>
Date: Thu, 5 Apr 2018 16:04:45 +0900 (JST)
Subject: [ruby-changes:50892] nobu:r63099 (trunk): compile.c: do not dump pointers
nobu 2018-04-05 16:04:39 +0900 (Thu, 05 Apr 2018) New Revision: 63099 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63099 Log: 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. Modified files: trunk/compile.c trunk/iseq.c trunk/iseq.h Index: iseq.c =================================================================== --- iseq.c (revision 63098) +++ iseq.c (revision 63099) @@ -498,15 +498,14 @@ rb_iseq_insns_info_encode_positions(cons https://github.com/ruby/ruby/blob/trunk/iseq.c#L498 #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 } Index: iseq.h =================================================================== --- iseq.h (revision 63098) +++ iseq.h (revision 63099) @@ -143,6 +143,7 @@ VALUE iseq_ibf_dump(const rb_iseq_t *ise https://github.com/ruby/ruby/blob/trunk/iseq.h#L143 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 * https://github.com/ruby/ruby/blob/trunk/iseq.h#L165 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); Index: compile.c =================================================================== --- compile.c (revision 63098) +++ compile.c (revision 63099) @@ -8612,9 +8612,9 @@ ibf_load_insns_info_body(const struct ib https://github.com/ruby/ruby/blob/trunk/compile.c#L8612 } 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 https://github.com/ruby/ruby/blob/trunk/compile.c#L8765 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 https://github.com/ruby/ruby/blob/trunk/compile.c#L8779 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/