From f3c5239b16b983f1cea6c7710aae052f54e94ff8 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 24 Oct 2018 01:57:27 +0000 Subject: introduce new YARV insn newhashfromarray. * insns.def (newhashfromarray): added to replace `core_hash_from_ary` method to eliminate method call overhead. On my environment, I got the following benchmark results: x = {x: 1} modified: 7864988.6 i/s trunk: 6004098.1 i/s - 1.31x slower x = {x: 1, y: 2} trunk: 6127338.4 i/s modified: 5232380.0 i/s - 1.17x slower x = {x: 1, y: 2, z: 3} modified: 6089553.1 i/s trunk: 5249333.5 i/s - 1.16x slower This trivial improvement should be reconsider because of usage of this instruction. * compile.c: ditto. * defs/id.def, vm.c: remove unused functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index b84f117f5d..7a013b893c 100644 --- a/compile.c +++ b/compile.c @@ -3957,9 +3957,7 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_ro ADD_INSN1(ret, line, duparray, ary); } else { /* COMPILE_ARRAY_TYPE_HASH */ - ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE)); - ADD_INSN1(ret, line, putobject, ary); - ADD_SEND(ret, line, id_core_hash_from_ary, INT2FIX(1)); + ADD_INSN2(ret, line, newhashfromarray, INT2FIX(RARRAY_LEN(ary)/2), ary); } } else { @@ -3968,15 +3966,8 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_ro ADD_INSN(ret, line, concatarray); } else { -#if 0 - ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE)); - ADD_INSN1(ret, line, putobject, ary); - ADD_SEND(ret, line, id_core_hash_merge_ary, INT2FIX(1)); - /* wrong number of arguments -----------------------^ */ -#else COMPILE_ERROR(ERROR_ARGS "core#hash_merge_ary"); return -1; -#endif } } } -- cgit v1.2.3