Project

General

Profile

Feature #10030 » iseq_catch_table_flex_v2.patch

normalperson (Eric Wong), 07/14/2014 01:20 AM

View differences:

compile.c
tlen = (int)RARRAY_LEN(iseq->compile_data->catch_table_ary);
tptr = RARRAY_CONST_PTR(iseq->compile_data->catch_table_ary);
iseq->catch_table = tlen ? ALLOC_N(struct iseq_catch_table_entry, tlen) : 0;
iseq->catch_table_size = tlen;
iseq->catch_table = 0;
if (tlen > 0) {
iseq->catch_table = xmalloc(iseq_catch_table_bytes(tlen));
iseq->catch_table->size = tlen;
}
for (i = 0; i < tlen; i++) {
for (i = 0; i < iseq_catch_table_size(iseq); i++) {
ptr = RARRAY_CONST_PTR(tptr[i]);
entry = &iseq->catch_table[i];
entry = &iseq->catch_table->entries[i];
entry->type = (enum catch_type)(ptr[0] & 0xffff);
entry->start = label_get_position((LABEL *)(ptr[1] & ~1));
entry->end = label_get_position((LABEL *)(ptr[2] & ~1));
iseq.c
size += iseq->iseq_size * sizeof(VALUE);
size += iseq->line_info_size * sizeof(struct iseq_line_info_entry);
size += iseq->local_table_size * sizeof(ID);
size += iseq->catch_table_size * sizeof(struct iseq_catch_table_entry);
if (iseq->catch_table) {
size += iseq_catch_table_bytes(iseq->catch_table->size);
}
size += iseq->arg_opts * sizeof(VALUE);
size += iseq->is_size * sizeof(union iseq_inline_storage_entry);
size += iseq->callinfo_size * sizeof(rb_call_info_t);
......
rb_str_cat2(str, "\n");
/* show catch table information */
if (iseqdat->catch_table_size != 0) {
if (iseqdat->catch_table) {
rb_str_cat2(str, "== catch table\n");
}
for (i = 0; i < iseqdat->catch_table_size; i++) {
struct iseq_catch_table_entry *entry = &iseqdat->catch_table[i];
for (i = 0; i < iseq_catch_table_size(iseqdat); i++) {
struct iseq_catch_table_entry *entry = &iseqdat->catch_table->entries[i];
rb_str_catf(str,
"| catch type: %-6s st: %04d ed: %04d sp: %04d cont: %04d\n",
catch_type((int)entry->type), (int)entry->start,
......
rb_str_concat(str, rb_iseq_disasm(entry->iseq));
}
}
if (iseqdat->catch_table_size != 0) {
if (iseqdat->catch_table) {
rb_str_cat2(str, "|-------------------------------------"
"-----------------------------------\n");
}
......
nbody = body;
/* exception */
for (i=0; i<iseq->catch_table_size; i++) {
for (i=0; i<iseq_catch_table_size(iseq); i++) {
VALUE ary = rb_ary_new();
struct iseq_catch_table_entry *entry = &iseq->catch_table[i];
struct iseq_catch_table_entry *entry = &iseq->catch_table->entries[i];
rb_ary_push(ary, exception_type2symbol(entry->type));
if (entry->iseq) {
rb_iseq_t *eiseq;
......
ALLOC_AND_COPY(iseq->line_info_table, line_info_table,
struct iseq_line_info_entry, iseq->line_info_size);
ALLOC_AND_COPY(iseq->catch_table, catch_table,
struct iseq_catch_table_entry, iseq->catch_table_size);
/*
* FIXME: probably broken, but this function is probably unused
* and should be removed
*/
if (iseq->catch_table) {
MEMCPY(&iseq->catch_table->entries, catch_table,
struct iseq_catch_table_entry, iseq->catch_table->size);
}
ALLOC_AND_COPY(iseq->arg_opt_table, arg_opt_table,
VALUE, iseq->arg_opts);
iseq.h
unsigned long sp;
};
PACKED_STRUCT_UNALIGNED(struct iseq_catch_table {
int size;
struct iseq_catch_table_entry entries[1]; /* flexible array */
});
static inline int
iseq_catch_table_bytes(int n)
{
return sizeof(struct iseq_catch_table) +
(n - 1) * sizeof(struct iseq_catch_table_entry);
}
static inline int
iseq_catch_table_size(const rb_iseq_t *iseq)
{
return iseq->catch_table ? iseq->catch_table->size : 0;
}
#define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
struct iseq_compile_data_storage {
vm.c
SET_THROWOBJ_STATE(err, state = TAG_BREAK);
}
else {
for (i = 0; i < cfp->iseq->catch_table_size; i++) {
entry = &cfp->iseq->catch_table[i];
for (i = 0; i < iseq_catch_table_size(cfp->iseq); i++) {
entry = &cfp->iseq->catch_table->entries[i];
if (entry->start < epc && entry->end >= epc) {
if (entry->type == CATCH_TYPE_ENSURE) {
catch_iseqval = entry->iseq;
......
}
if (state == TAG_RAISE) {
for (i = 0; i < cfp->iseq->catch_table_size; i++) {
entry = &cfp->iseq->catch_table[i];
for (i = 0; i < iseq_catch_table_size(cfp->iseq); i++) {
entry = &cfp->iseq->catch_table->entries[i];
if (entry->start < epc && entry->end >= epc) {
if (entry->type == CATCH_TYPE_RESCUE ||
......
}
}
else if (state == TAG_RETRY) {
for (i = 0; i < cfp->iseq->catch_table_size; i++) {
entry = &cfp->iseq->catch_table[i];
for (i = 0; i < iseq_catch_table_size(cfp->iseq); i++) {
entry = &cfp->iseq->catch_table->entries[i];
if (entry->start < epc && entry->end >= epc) {
if (entry->type == CATCH_TYPE_ENSURE) {
......
type = CATCH_TYPE_BREAK;
search_restart_point:
for (i = 0; i < cfp->iseq->catch_table_size; i++) {
entry = &cfp->iseq->catch_table[i];
for (i = 0; i < iseq_catch_table_size(cfp->iseq); i++) {
entry = &cfp->iseq->catch_table->entries[i];
if (entry->start < epc && entry->end >= epc) {
if (entry->type == CATCH_TYPE_ENSURE) {
......
goto search_restart_point;
}
else {
for (i = 0; i < cfp->iseq->catch_table_size; i++) {
entry = &cfp->iseq->catch_table[i];
for (i = 0; i < iseq_catch_table_size(cfp->iseq); i++) {
entry = &cfp->iseq->catch_table->entries[i];
if (entry->start < epc && entry->end >= epc) {
if (entry->type == CATCH_TYPE_ENSURE) {
vm_core.h
ID *arg_keyword_table;
/* catch table */
struct iseq_catch_table_entry *catch_table;
int catch_table_size;
struct iseq_catch_table *catch_table;
/* for child iseq */
struct rb_iseq_struct *parent_iseq;
vm_insnhelper.c
rb_iseq_t *iseq = cfp->iseq;
int i;
for (i=0; i<iseq->catch_table_size; i++) {
struct iseq_catch_table_entry *entry = &iseq->catch_table[i];
for (i=0; i<iseq_catch_table_size(iseq); i++) {
struct iseq_catch_table_entry *entry =
&iseq->catch_table->entries[i];
if (entry->type == CATCH_TYPE_BREAK &&
entry->start < epc && entry->end >= epc) {
(2-2/3)