Project

General

Profile

Feature #10185 » iseq-tc-diet.patch

normalperson (Eric Wong), 08/29/2014 09:24 PM

View differences:

compile.c
iseq->iseq_encoded[i] = (VALUE)table[insn];
i += len;
}
xfree(iseq->iseq);
iseq->iseq = 0;
#else
iseq->iseq_encoded = iseq->iseq;
#endif
return COMPILE_OK;
}
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
static int
rb_vm_addr2insn(const void *addr) /* cold path */
{
int insn;
const void * const *table = rb_vm_get_insns_address_table();
for (insn = 0; insn < VM_INSTRUCTION_SIZE; insn++) {
if (table[insn] == addr)
return insn;
}
rb_bug("rb_vm_addr2insn: invalid insn address: %p", addr);
}
#endif
VALUE *
rb_iseq_untranslate_threaded_code(rb_iseq_t *iseq) /* cold path */
{
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
unsigned int i;
if (iseq->iseq)
return iseq->iseq;
iseq->iseq = ALLOC_N(VALUE, iseq->iseq_size);
MEMCPY(iseq->iseq, iseq->iseq_encoded, VALUE, iseq->iseq_size);
for (i = 0; i < iseq->iseq_size; /* */ ) {
int insn = (VALUE)rb_vm_addr2insn((const void *)iseq->iseq[i]);
iseq->iseq[i] = insn;
i += insn_len(insn);
}
#else
iseq->iseq = iseq->iseq_encoded;
#endif
return iseq->iseq;
}
/*********************************************/
/* definition of data structure for compiler */
/*********************************************/
iseq.c
if (ptr) {
iseq = ptr;
if (!iseq->orig) {
if (iseq->iseq != iseq->iseq_encoded) {
if (iseq->iseq && iseq->iseq != iseq->iseq_encoded) {
size += iseq->iseq_size * sizeof(VALUE);
}
......
rb_secure(1);
iseq = iseqdat->iseq;
iseq = rb_iseq_untranslate_threaded_code(iseqdat);
size = iseqdat->iseq_size;
rb_str_cat2(str, "== disasm: ");
......
}
/* body */
rb_iseq_untranslate_threaded_code(iseq);
for (seq = iseq->iseq; seq < iseq->iseq + iseq->iseq_size; ) {
VALUE insn = *seq++;
int j, len = insn_len(insn);
......
int cont = 1;
GetISeqPtr(iseqval, iseq);
rb_iseq_untranslate_threaded_code(iseq);
for (pos = 0; cont && pos < iseq->iseq_size; pos += insn_len(insn)) {
insn = iseq->iseq[pos];
iseq.h
/* compile.c */
VALUE rb_iseq_compile_node(VALUE self, NODE *node);
int rb_iseq_translate_threaded_code(rb_iseq_t *iseq);
VALUE *rb_iseq_untranslate_threaded_code(rb_iseq_t *iseq);
VALUE rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
VALUE exception, VALUE body);
vm_dump.c
#include "addr2line.h"
#include "vm_core.h"
#include "internal.h"
#include "iseq.h"
/* see vm_insnhelper.h for the values */
#ifndef VMDEBUG
......
rb_iseq_t *iseq = cfp->iseq;
if (iseq != 0) {
VALUE *seq = iseq->iseq;
VALUE *seq = rb_iseq_untranslate_threaded_code(iseq);
ptrdiff_t pc = _pc - iseq->iseq_encoded;
int i;
-
(1-1/3)