зеркало из https://github.com/github/ruby.git
vm_core.h: refactoring of insns_info
This factors rb_iseq_constant_body#insns_info and #insns_info_size to struct iseq_insn_info. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
d4764ef6e4
Коммит
fd950df795
16
compile.c
16
compile.c
|
@ -2116,11 +2116,11 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
|
|||
iseq->body->stack_max = stack_max;
|
||||
|
||||
/* get rid of memory leak when REALLOC failed */
|
||||
iseq->body->insns_info = insns_info;
|
||||
iseq->body->insns_info.body = insns_info;
|
||||
|
||||
REALLOC_N(insns_info, struct iseq_insn_info_entry, insns_info_index);
|
||||
iseq->body->insns_info = insns_info;
|
||||
iseq->body->insns_info_size = insns_info_index;
|
||||
iseq->body->insns_info.body = insns_info;
|
||||
iseq->body->insns_info.size = insns_info_index;
|
||||
|
||||
return COMPILE_OK;
|
||||
}
|
||||
|
@ -8358,13 +8358,13 @@ ibf_load_param_keyword(const struct ibf_load *load, const struct rb_iseq_constan
|
|||
static struct iseq_insn_info_entry *
|
||||
ibf_dump_insns_info(struct ibf_dump *dump, const rb_iseq_t *iseq)
|
||||
{
|
||||
return IBF_W(iseq->body->insns_info, struct iseq_insn_info_entry, iseq->body->insns_info_size);
|
||||
return IBF_W(iseq->body->insns_info.body, struct iseq_insn_info_entry, iseq->body->insns_info.size);
|
||||
}
|
||||
|
||||
static struct iseq_insn_info_entry *
|
||||
ibf_load_insns_info(const struct ibf_load *load, const struct rb_iseq_constant_body *body)
|
||||
{
|
||||
return IBF_R(body->insns_info, struct iseq_insn_info_entry, body->insns_info_size);
|
||||
return IBF_R(body->insns_info.body, struct iseq_insn_info_entry, body->insns_info.size);
|
||||
}
|
||||
|
||||
static ID *
|
||||
|
@ -8518,7 +8518,7 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
|
|||
dump_body.iseq_encoded = ibf_dump_code(dump, iseq);
|
||||
dump_body.param.opt_table = ibf_dump_param_opt_table(dump, iseq);
|
||||
dump_body.param.keyword = ibf_dump_param_keyword(dump, iseq);
|
||||
dump_body.insns_info = ibf_dump_insns_info(dump, iseq);
|
||||
dump_body.insns_info.body = ibf_dump_insns_info(dump, iseq);
|
||||
dump_body.local_table = ibf_dump_local_table(dump, iseq);
|
||||
dump_body.catch_table = ibf_dump_catch_table(dump, iseq);
|
||||
dump_body.parent_iseq = ibf_dump_iseq(dump, iseq->body->parent_iseq);
|
||||
|
@ -8556,7 +8556,7 @@ ibf_load_iseq_each(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t of
|
|||
load_body->is_size = body->is_size;
|
||||
load_body->ci_size = body->ci_size;
|
||||
load_body->ci_kw_size = body->ci_kw_size;
|
||||
load_body->insns_info_size = body->insns_info_size;
|
||||
load_body->insns_info.size = body->insns_info.size;
|
||||
|
||||
RB_OBJ_WRITE(iseq, &load_body->mark_ary, iseq_mark_ary_create((int)body->mark_ary));
|
||||
|
||||
|
@ -8589,7 +8589,7 @@ ibf_load_iseq_each(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t of
|
|||
load_body->cc_entries = ZALLOC_N(struct rb_call_cache, body->ci_size + body->ci_kw_size);
|
||||
load_body->param.opt_table = ibf_load_param_opt_table(load, body);
|
||||
load_body->param.keyword = ibf_load_param_keyword(load, body);
|
||||
load_body->insns_info = ibf_load_insns_info(load, body);
|
||||
load_body->insns_info.body = ibf_load_insns_info(load, body);
|
||||
load_body->local_table = ibf_load_local_table(load, body);
|
||||
load_body->catch_table = ibf_load_catch_table(load, body);
|
||||
load_body->parent_iseq = ibf_load_iseq(load, body->parent_iseq);
|
||||
|
|
18
iseq.c
18
iseq.c
|
@ -74,7 +74,7 @@ rb_iseq_free(const rb_iseq_t *iseq)
|
|||
if (iseq) {
|
||||
if (iseq->body) {
|
||||
ruby_xfree((void *)iseq->body->iseq_encoded);
|
||||
ruby_xfree((void *)iseq->body->insns_info);
|
||||
ruby_xfree((void *)iseq->body->insns_info.body);
|
||||
ruby_xfree((void *)iseq->body->local_table);
|
||||
ruby_xfree((void *)iseq->body->is_entries);
|
||||
|
||||
|
@ -157,7 +157,7 @@ iseq_memsize(const rb_iseq_t *iseq)
|
|||
|
||||
size += sizeof(struct rb_iseq_constant_body);
|
||||
size += body->iseq_size * sizeof(VALUE);
|
||||
size += body->insns_info_size * sizeof(struct iseq_insn_info_entry);
|
||||
size += body->insns_info.size * sizeof(struct iseq_insn_info_entry);
|
||||
size += body->local_table_size * sizeof(ID);
|
||||
if (body->catch_table) {
|
||||
size += iseq_catch_table_bytes(body->catch_table->size);
|
||||
|
@ -1254,8 +1254,8 @@ iseqw_to_a(VALUE self)
|
|||
static const struct iseq_insn_info_entry *
|
||||
get_insn_info_binary_search(const rb_iseq_t *iseq, size_t pos)
|
||||
{
|
||||
size_t size = iseq->body->insns_info_size;
|
||||
const struct iseq_insn_info_entry *insns_info = iseq->body->insns_info;
|
||||
size_t size = iseq->body->insns_info.size;
|
||||
const struct iseq_insn_info_entry *insns_info = iseq->body->insns_info.body;
|
||||
const int debug = 0;
|
||||
|
||||
if (debug) {
|
||||
|
@ -1298,7 +1298,7 @@ get_insn_info_binary_search(const rb_iseq_t *iseq, size_t pos)
|
|||
static const struct iseq_insn_info_entry *
|
||||
get_insn_info_linear_search(const rb_iseq_t *iseq, size_t pos)
|
||||
{
|
||||
size_t i = 0, size = iseq->body->insns_info_size;
|
||||
size_t i = 0, size = iseq->body->insns_info.size;
|
||||
const struct iseq_insn_info_entry *insns_info = iseq->body->insns_info;
|
||||
const int debug = 0;
|
||||
|
||||
|
@ -1902,8 +1902,8 @@ iseqw_trace_points(VALUE self)
|
|||
unsigned int i;
|
||||
VALUE ary = rb_ary_new();
|
||||
|
||||
for (i=0; i<iseq->body->insns_info_size; i++) {
|
||||
const struct iseq_insn_info_entry *entry = &iseq->body->insns_info[i];
|
||||
for (i=0; i<iseq->body->insns_info.size; i++) {
|
||||
const struct iseq_insn_info_entry *entry = &iseq->body->insns_info.body[i];
|
||||
if (entry->events) {
|
||||
push_event_info(iseq, entry->events, entry->line_no, ary);
|
||||
}
|
||||
|
@ -2344,8 +2344,8 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
|
|||
rb_ary_push(body, (VALUE)label);
|
||||
}
|
||||
|
||||
if (ti < iseq->body->insns_info_size) {
|
||||
const struct iseq_insn_info_entry *info = &iseq->body->insns_info[ti];
|
||||
if (ti < iseq->body->insns_info.size) {
|
||||
const struct iseq_insn_info_entry *info = &iseq->body->insns_info.body[ti];
|
||||
if (info->position == pos) {
|
||||
int line = info->line_no;
|
||||
rb_event_flag_t events = info->events;
|
||||
|
|
|
@ -371,7 +371,10 @@ struct rb_iseq_constant_body {
|
|||
rb_iseq_location_t location;
|
||||
|
||||
/* insn info, must be freed */
|
||||
const struct iseq_insn_info_entry *insns_info;
|
||||
struct iseq_insn_info {
|
||||
const struct iseq_insn_info_entry *body;
|
||||
unsigned int size;
|
||||
} insns_info;
|
||||
|
||||
const ID *local_table; /* must free */
|
||||
|
||||
|
@ -396,7 +399,6 @@ struct rb_iseq_constant_body {
|
|||
unsigned int is_size;
|
||||
unsigned int ci_size;
|
||||
unsigned int ci_kw_size;
|
||||
unsigned int insns_info_size;
|
||||
unsigned int stack_max; /* for stack overflow check */
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче