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

ruby-changes:68648

From: Aaron <ko1@a...>
Date: Thu, 21 Oct 2021 08:11:42 +0900 (JST)
Subject: [ruby-changes:68648] be91995a5e (master): Remove T_OBJECT runtime check

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

From be91995a5e91c2ad0136e44f553ffdd80342d090 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Thu, 12 Nov 2020 09:25:14 -0800
Subject: Remove T_OBJECT runtime check

If the cached class uses the default allocator, then all instances
coming from the class should be T_OBJECT instances.  Meaning we can just
check the allocator function at compile time, then skip the runtime
T_OBJECT check
---
 ujit_compile.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/ujit_compile.c b/ujit_compile.c
index 79a5f05bc4..923eb85e19 100644
--- a/ujit_compile.c
+++ b/ujit_compile.c
@@ -635,6 +635,12 @@ gen_getinstancevariable(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_compile.c#L635
         return false;
     }
 
+    // If the class uses the default allocator, instances should all be T_OBJECT
+    if (rb_get_alloc_func(ic->entry->class_value) != rb_class_allocate_instance)
+    {
+        return false;
+    }
+
     uint32_t ivar_index = ic->entry->index;
 
     // Create a size-exit to fall back to the interpreter
@@ -664,12 +670,6 @@ gen_getinstancevariable(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_compile.c#L670
     test(cb, flags_opnd, imm_opnd(ROBJECT_EMBED));
     jnz_ptr(cb, side_exit);
 
-    // Check that this is a Ruby object (not a string, etc)
-    mov(cb, REG1, flags_opnd);
-    and(cb, REG1, imm_opnd(RUBY_T_MASK));
-    cmp(cb, REG1, imm_opnd(T_OBJECT));
-    jne_ptr(cb, side_exit);
-
     // Get a pointer to the extended table
     x86opnd_t tbl_opnd = mem_opnd(64, REG0, offsetof(struct RObject, as.heap.ivptr));
     mov(cb, REG0, tbl_opnd);
-- 
cgit v1.2.1


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

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