From 7ea3edc409dc6d383df9bc10d0034a6ecddb84dc Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 9 Oct 2012 05:33:54 +0000 Subject: * vm_core.h (rb_call_info_t): add new type `rb_call_inf_t'. This data structure contains information including inline method cache. After that, `struct iseq_inline_cache_entry' does not need to contain inline cache for method invocation. Other information will be added to this data structure. * vm_core.h (rb_iseq_t): add `callinfo_entries' and `callinfo_size' members to `rb_iseq_t'. * insns.def, compile.c: Use CALL_INFO instead of IC. * tool/instruction.rb: support CALL_INFO as operand type. * vm_insnhelper.c, vm_insnhelper.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 1d943ed0bb..e03d0f9ac6 100644 --- a/compile.c +++ b/compile.c @@ -946,7 +946,7 @@ new_insn_send(rb_iseq_t *iseq, int line_no, operands[1] = argc; operands[2] = block; operands[3] = flag; - operands[4] = INT2FIX(iseq->ic_size++); + operands[4] = INT2FIX(iseq->callinfo_size++); iobj = new_insn_core(iseq, line_no, BIN(send), 5, operands); return iobj; } @@ -1398,6 +1398,8 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor) line_info_table = ALLOC_N(struct iseq_line_info_entry, k); iseq->ic_entries = ALLOC_N(struct iseq_inline_cache_entry, iseq->ic_size); MEMZERO(iseq->ic_entries, struct iseq_inline_cache_entry, iseq->ic_size); + iseq->callinfo_entries = ALLOC_N(rb_call_info_t, iseq->callinfo_size); + MEMZERO(iseq->callinfo_entries, rb_call_info_t, iseq->callinfo_size); list = FIRST_ELEMENT(anchor); k = pos = sp = 0; @@ -1495,12 +1497,21 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor) int ic_index = FIX2INT(operands[j]); IC ic = &iseq->ic_entries[ic_index]; if (UNLIKELY(ic_index >= iseq->ic_size)) { - rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", - ic_index, iseq->ic_size); + rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", ic_index, iseq->ic_size); } generated_iseq[pos + 1 + j] = (VALUE)ic; break; } + case TS_CALLINFO: /* call info */ + { + int ci_index = FIX2INT(operands[j]); + CALL_INFO ci = &iseq->callinfo_entries[ci_index]; + if (UNLIKELY(ci_index >= iseq->callinfo_size)) { + rb_bug("iseq_set_sequence: ci_index overflow: index: %d, size: %d", ci_index, iseq->callinfo_size); + } + generated_iseq[pos + 1 + j] = (VALUE)ci; + break; + } case TS_ID: /* ID */ generated_iseq[pos + 1 + j] = SYM2ID(operands[j]); break; @@ -1859,7 +1870,7 @@ insn_set_specialized_instruction(rb_iseq_t *iseq, INSN *iobj, int insn_id) } for (i=0; ioperand_size; i++) { - iobj->operands[i] = INT2FIX(iseq->ic_size++); + iobj->operands[i] = INT2FIX(iseq->callinfo_size++); } return COMPILE_OK; @@ -5234,9 +5245,12 @@ insn_data_to_s_detail(INSN *iobj) (OPERAND_AT(iobj, j) & (~1)); rb_str_cat2(str, rb_id2name(entry->id)); } - case TS_IC: /* method cache */ + case TS_IC: /* inline cache */ rb_str_catf(str, "", FIX2INT(OPERAND_AT(iobj, j))); break; + case TS_CALLINFO: /* call info */ + rb_str_catf(str, "", FIX2INT(OPERAND_AT(iobj, j))); + break; case TS_CDHASH: /* case/when condition cache */ rb_str_cat2(str, ""); break; @@ -5500,9 +5514,15 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor, break; case TS_IC: argv[j] = op; - if (NUM2INT(op) >= iseq->ic_size) + if (NUM2INT(op) >= iseq->ic_size) { iseq->ic_size = NUM2INT(op) + 1; + } break; + case TS_CALLINFO: + argv[j] = op; + if (NUM2INT(op) >= iseq->callinfo_size) { + iseq->callinfo_size = NUM2INT(op) + 1; + } case TS_ID: argv[j] = rb_convert_type(op, T_SYMBOL, "Symbol", "to_sym"); -- cgit v1.2.3