From f3c5239b16b983f1cea6c7710aae052f54e94ff8 Mon Sep 17 00:00:00 2001
From: ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
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
---
 insns.def | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'insns.def')

diff --git a/insns.def b/insns.def
index 5d04e5066a..c6b5064794 100644
--- a/insns.def
+++ b/insns.def
@@ -512,6 +512,18 @@ newhash
     }
 }
 
+/* make new Hash object from (frozen) Array object */
+DEFINE_INSN
+newhashfromarray
+(rb_num_t num, VALUE ary)
+()
+(VALUE hash)
+{
+    VM_ASSERT(num * 2 == RARRAY_LEN(ary));
+    hash = rb_hash_new_with_size(num);
+    rb_hash_bulk_insert(num * 2, RARRAY_CONST_PTR(ary), hash);
+}
+
 /* put new Range object.(Range.new(low, high, flag)) */
 DEFINE_INSN
 newrange
-- 
cgit v1.2.3

