[前][次][番号順一覧][スレッド一覧]

ruby-changes:63563

From: Aaron <ko1@a...>
Date: Tue, 10 Nov 2020 07:06:03 +0900 (JST)
Subject: [ruby-changes:63563] f259906eab (master): Avoid slow path ivar setting

https://git.ruby-lang.org/ruby.git/commit/?id=f259906eab

From f259906eabac6038bb7c79e426c17ae850c8e017 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Mon, 9 Nov 2020 11:20:29 -0800
Subject: Avoid slow path ivar setting

If the ivar index table exists, we can avoid the slowest path for
setting ivars.

diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 398bbd7..ea25de6 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1237,6 +1237,17 @@ vm_setivar(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic, const str https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1237
 		else {
 		    vm_cc_attr_index_set(cc, (int)(ent->index + 1));
 		}
+
+                index = ent->index;
+
+                VALUE *ptr = ROBJECT_IVPTR(obj);
+                if (index >= ROBJECT_NUMIV(obj)) {
+                    rb_init_iv_list(obj, ROBJECT_NUMIV(obj), (uint32_t)iv_index_tbl->num_entries, iv_index_tbl);
+                    ptr = ROBJECT_IVPTR(obj);
+                }
+                RB_OBJ_WRITE(obj, &ptr[index], val);
+
+                return val;
 	    }
 	    /* fall through */
 	}
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]