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

ruby-changes:57535

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Thu, 5 Sep 2019 12:15:23 +0900 (JST)
Subject: [ruby-changes:57535] b005d7c2e2 (master): use existing vm_search_method()

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

From b005d7c2e208790b89b332d5f8ca56334039d6ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Wed, 4 Sep 2019 15:10:10 +0900
Subject: use existing vm_search_method()

Ko1 plans to implement Guild.  That can interface the caching
mechanism introduced here.  To prevent future breakage we would
better avoid rolling our own code here.  Instead use the existing
vm_search_method() which would be modified by him.

This commit deletes some asserions, but they are in fact checked
inside of vm_search_method().

diff --git a/vm_eval.c b/vm_eval.c
index 437e984..852aacb 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -879,15 +879,8 @@ VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L879
 rb_funcallv_with_cc(void **ptr, VALUE recv, ID mid, int argc, const VALUE *argv)
 {
     VM_ASSERT(ptr);
-    const VALUE klass = CLASS_OF(recv);
-    VM_ASSERT(klass != Qfalse);
-    VM_ASSERT(RBASIC_CLASS(klass) == 0 || rb_obj_is_kind_of(klass, rb_cClass));
-    rb_serial_t now = GET_GLOBAL_METHOD_STATE();
-    rb_serial_t serial = RCLASS_SERIAL(klass);
     struct opaque {
-        const rb_callable_method_entry_t *me;
-        rb_serial_t updated_at;
-        rb_serial_t class_at;
+        struct rb_call_cache cc;
         ID mid;
     } *cc;
     if (UNLIKELY(! *ptr)) {
@@ -895,20 +888,21 @@ rb_funcallv_with_cc(void **ptr, VALUE recv, ID mid, int argc, const VALUE *argv) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L888
     }
     cc = *ptr;
 
-    if (cc->updated_at != now ||
-        cc->class_at != serial ||
-        cc->mid != mid) {
-        *cc = (struct opaque) {
-            rb_callable_method_entry(klass, mid), now, serial, mid,
-        };
+    const struct rb_call_info ci = { mid, VM_CALL_ARGS_SIMPLE, argc, };
+    if (UNLIKELY(cc->mid != mid)) {
+        *cc = (struct opaque) /* reset */ { { 0, }, mid, };
+        return rb_funcallv(recv, mid, argc, argv);
+    }
+    else {
+        vm_search_method(&ci, &cc->cc, recv);
     }
 
-    if (UNLIKELY(UNDEFINED_METHOD_ENTRY_P(cc->me))) {
+    if (UNLIKELY(UNDEFINED_METHOD_ENTRY_P(cc->cc.me))) {
         /* :FIXME: this path can be made faster */
         return rb_funcallv(recv, mid, argc, argv);
     }
     else {
-        return rb_vm_call0(GET_EC(), recv, mid, argc, argv, cc->me);
+        return rb_vm_call0(GET_EC(), recv, mid, argc, argv, cc->cc.me);
     }
 }
 
-- 
cgit v0.10.2


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

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