1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* iseq.h: introduce ISEQ_ORIGINAL_ISEQ() and

ISEQ_ORIGINAL_ISEQ_ALLOC() macro.

* compile.c: use them to access original iseq buffer.

* iseq.c: ditto.

* vm_core.h: rename iseq field to support this fix.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2015-12-02 08:20:35 +00:00
parent a9c0cf4ff0
commit cfd1157f11
5 changed files with 27 additions and 13 deletions

View file

@ -1,3 +1,14 @@
Wed Dec 2 17:19:02 2015 Koichi Sasada <ko1@atdot.net>
* iseq.h: introduce ISEQ_ORIGINAL_ISEQ() and
ISEQ_ORIGINAL_ISEQ_ALLOC() macro.
* compile.c: use them to access original iseq buffer.
* iseq.c: ditto.
* vm_core.h: rename iseq field to support this fix.
Wed Dec 2 17:10:32 2015 Koichi Sasada <ko1@atdot.net>
* iseq.h: introduce ISEQ_FLIP_CNT_INCREMENT() macro.

View file

@ -641,26 +641,26 @@ rb_vm_insn_addr2insn(const void *addr) /* cold path */
VALUE *
rb_iseq_original_iseq(const rb_iseq_t *iseq) /* cold path */
{
if (iseq->variable_body->iseq) return iseq->variable_body->iseq;
VALUE *original_code;
iseq->variable_body->iseq = ALLOC_N(VALUE, iseq->body->iseq_size);
MEMCPY(iseq->variable_body->iseq, iseq->body->iseq_encoded, VALUE, iseq->body->iseq_size);
if (ISEQ_ORIGINAL_ISEQ(iseq)) return ISEQ_ORIGINAL_ISEQ(iseq);
original_code = ISEQ_ORIGINAL_ISEQ_ALLOC(iseq, iseq->body->iseq_size);
MEMCPY(ISEQ_ORIGINAL_ISEQ(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->variable_body->iseq[i];
const void *addr = (const void *)original_code[i];
const int insn = rb_vm_insn_addr2insn(addr);
iseq->variable_body->iseq[i] = insn;
original_code[i] = insn;
i += insn_len(insn);
}
}
#endif
return iseq->variable_body->iseq;
return original_code;
}
/*********************************************/

4
iseq.c
View file

@ -92,7 +92,7 @@ rb_iseq_free(const rb_iseq_t *iseq)
ruby_xfree((void *)iseq->body->param.keyword);
}
compile_data_free(ISEQ_COMPILE_DATA(iseq));
ruby_xfree(iseq->variable_body->iseq);
ruby_xfree(iseq->variable_body->iseq_);
ruby_xfree(iseq->variable_body);
ruby_xfree(iseq->body);
}
@ -157,7 +157,7 @@ iseq_memsize(const rb_iseq_t *iseq)
if (variable_body) {
size += sizeof(struct rb_iseq_variable_body);
if (variable_body->iseq && body) {
if (variable_body->iseq_ && body) {
size += body->iseq_size * sizeof(VALUE);
}
}

9
iseq.h
View file

@ -23,10 +23,13 @@ rb_call_info_kw_arg_bytes(int keyword_len)
return sizeof(struct rb_call_info_kw_arg) + sizeof(VALUE) * (keyword_len - 1);
}
#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_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
/* compile.c */

View file

@ -392,7 +392,7 @@ struct rb_iseq_variable_body {
/* original iseq, before encoding
* used for debug/dump (TODO: union with compile_data) */
VALUE *iseq;
VALUE *iseq_;
};
/* T_IMEMO/iseq */