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

ruby-changes:61613

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Tue, 9 Jun 2020 09:53:12 +0900 (JST)
Subject: [ruby-changes:61613] 77293cef91 (master): vm_ci_markable: added

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

From 77293cef91a9aa424c086ae05f03211d9a8a87d3 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: Fri, 29 May 2020 15:20:57 +0900
Subject: vm_ci_markable: added

CIs are created on-the-fly, which increases GC pressure.  However they
include no references to other objects, and those on-the-fly CIs tend to
be short lived.  Why not skip allocation of them.  In doing so we need
to add a flag denotes the CI object does not reside inside of objspace.

diff --git a/iseq.c b/iseq.c
index fe33afc..90fb670 100644
--- a/iseq.c
+++ b/iseq.c
@@ -325,9 +325,13 @@ rb_iseq_mark(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L325
         if (body->call_data) {
             struct rb_call_data *cds = (struct rb_call_data *)body->call_data;
             for (unsigned int i=0; i<body->ci_size; i++) {
-                rb_gc_mark_movable((VALUE)cds[i].ci);
+                const struct rb_callinfo *ci = cds[i].ci;
                 const struct rb_callcache *cc = cds[i].cc;
-                if (cc && vm_cc_markable(cds[i].cc)) {
+
+                if (vm_ci_markable(ci)) {
+                    rb_gc_mark_movable((VALUE)ci);
+                }
+                if (cc && vm_cc_markable(cc)) {
                     rb_gc_mark_movable((VALUE)cc);
                     // TODO: check enable
                 }
diff --git a/vm_callinfo.h b/vm_callinfo.h
index e938092..14027fc 100644
--- a/vm_callinfo.h
+++ b/vm_callinfo.h
@@ -229,6 +229,23 @@ vm_ci_new_runtime_(ID mid, unsigned int flag, unsigned int argc, const struct rb https://github.com/ruby/ruby/blob/trunk/vm_callinfo.h#L229
     return vm_ci_new_(mid, flag, argc, kwarg, file, line);
 }
 
+#define VM_CALLINFO_NOT_UNDER_GC IMEMO_FL_USER0
+
+static inline bool
+vm_ci_markable(const struct rb_callinfo *ci)
+{
+    if (! ci) {
+        return false; /* or true? This is Qfalse... */
+    }
+    else if (vm_ci_packed_p(ci)) {
+        return true;
+    }
+    else {
+        VM_ASSERT(IMEMO_TYPE_P(ci, imemo_callinfo));
+        return ! FL_ANY_RAW((VALUE)ci, VM_CALLINFO_NOT_UNDER_GC);
+    }
+}
+
 typedef VALUE (*vm_call_handler)(
     struct rb_execution_context_struct *ec,
     struct rb_control_frame_struct *cfp,
-- 
cgit v0.10.2


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

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