summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-14 16:59:05 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-14 16:59:05 +0000
commitcbd597e9bc05eac7249e91dcdb4f1c1c75a53cf5 (patch)
tree8f570f2e813466ef8fa0ac3f564a638b69164773 /iseq.c
parente8c234577fa7061a22f0dc515aefdc8dbc61f3b5 (diff)
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using parameters such as `op_id', 'op_argc', `blockiseq' and flag. These information are stored in rb_call_info_t at the compile time. This technique simplifies parameter passings at related function calls (~10% speedups for simple mehtod invocation at my machine). `rb_call_info_t' also has new function pointer variable `call'. This `call' variable enables to customize method (block) invocation process for each place. However, it always call `vm_call_general()' at this changes. `rb_call_info_t' also has temporary variables for method (block) invocation. * vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP VM_CALL macro. This flag indicates that this call can skip caller_setup (block arg and splat arg). * compile.c: catch up above changes. * iseq.c: catch up above changes (especially for TS_CALLINFO). * tool/instruction.rb: catch up above chagnes. * vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions parameters are changed. * vm_eval.c (vm_call0): ditto (it will be rewriten soon). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/iseq.c b/iseq.c
index 792f401bde..3244e44ab8 100644
--- a/iseq.c
+++ b/iseq.c
@@ -149,6 +149,7 @@ iseq_memsize(const void *ptr)
size += iseq->catch_table_size * sizeof(struct iseq_catch_table_entry);
size += iseq->arg_opts * sizeof(VALUE);
size += iseq->ic_size * sizeof(struct iseq_inline_cache_entry);
+ size += iseq->callinfo_size * sizeof(rb_call_info_t);
if (iseq->compile_data) {
struct iseq_compile_data_storage *cur;
@@ -1041,7 +1042,37 @@ insn_operand_intern(rb_iseq_t *iseq,
break;
case TS_CALLINFO:
- ret = rb_sprintf("<ci:%"PRIdPTRDIFF">", (rb_call_info_t *)op - iseq->callinfo_entries);
+ {
+ rb_call_info_t *ci = (rb_call_info_t *)op;
+ VALUE ary = rb_ary_new();
+
+ if (ci->mid) {
+ rb_ary_push(ary, rb_sprintf("mid:%s", rb_id2name(ci->mid)));
+ }
+
+ rb_ary_push(ary, rb_sprintf("argc:%d", ci->orig_argc));
+
+ if (ci->blockiseq) {
+ if (child) {
+ rb_ary_push(child, ci->blockiseq->self);
+ }
+ rb_ary_push(ary, rb_sprintf("block:%"PRIsVALUE, ci->blockiseq->location.label));
+ }
+
+ if (ci->flag) {
+ VALUE flags = rb_ary_new();
+ if (ci->flag & VM_CALL_ARGS_SPLAT_BIT) rb_ary_push(flags, rb_str_new2("ARGS_SPLAT"));
+ if (ci->flag & VM_CALL_ARGS_BLOCKARG_BIT) rb_ary_push(flags, rb_str_new2("ARGS_BLOCKARG"));
+ if (ci->flag & VM_CALL_FCALL_BIT) rb_ary_push(flags, rb_str_new2("FCALL"));
+ if (ci->flag & VM_CALL_VCALL_BIT) rb_ary_push(flags, rb_str_new2("VCALL"));
+ if (ci->flag & VM_CALL_TAILCALL_BIT) rb_ary_push(flags, rb_str_new2("TAILCALL"));
+ if (ci->flag & VM_CALL_SUPER_BIT) rb_ary_push(flags, rb_str_new2("SUPER"));
+ if (ci->flag & VM_CALL_OPT_SEND_BIT) rb_ary_push(flags, rb_str_new2("SNED")); /* maybe not reachable */
+ if (ci->flag & VM_CALL_ARGS_SKIP_SETUP) rb_ary_push(flags, rb_str_new2("ARGS_SKIP"));
+ rb_ary_push(ary, rb_ary_join(flags, rb_str_new2("|")));
+ }
+ ret = rb_sprintf("<callinfo!%"PRIsVALUE">", rb_ary_join(ary, rb_str_new2(", ")));
+ }
break;
case TS_CDHASH:
@@ -1542,6 +1573,17 @@ iseq_data_to_ary(rb_iseq_t *iseq)
rb_ary_push(ary, INT2FIX(ic - iseq->ic_entries));
}
break;
+ case TS_CALLINFO:
+ {
+ rb_call_info_t *ci = (rb_call_info_t *)*seq;
+ VALUE e = rb_hash_new();
+ rb_hash_aset(e, ID2SYM(rb_intern("mid")), ci->mid ? ID2SYM(ci->mid) : Qnil);
+ rb_hash_aset(e, ID2SYM(rb_intern("flag")), ULONG2NUM(ci->flag));
+ rb_hash_aset(e, ID2SYM(rb_intern("orig_argc")), INT2FIX(ci->orig_argc));
+ rb_hash_aset(e, ID2SYM(rb_intern("blockptr")), ci->blockiseq ? iseq_data_to_ary(ci->blockiseq) : Qnil);
+ rb_ary_push(ary, e);
+ }
+ break;
case TS_ID:
rb_ary_push(ary, ID2SYM(*seq));
break;