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

ruby-changes:69226

From: Alan <ko1@a...>
Date: Thu, 21 Oct 2021 08:24:16 +0900 (JST)
Subject: [ruby-changes:69226] 5906a5a732 (master): Add comments about special runtime routines YJIT calls

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

From 5906a5a7329e34a43dc46d4fc3cdf1b04cc13d0a Mon Sep 17 00:00:00 2001
From: Alan Wu <XrXr@u...>
Date: Mon, 18 Oct 2021 11:30:18 -0400
Subject: Add comments about special runtime routines YJIT calls

When YJIT make calls to routines without reconstructing interpreter
state through jit_prepare_routine_call(), it relies on the routine to
never allocate, raise, and push/pop control frames. Comment about this
on the routines that YJTI calls.

This is probably something we should dynamically verify on debug builds.
It's hard to statically verify this as it requires verifying all
functions in the call tree. Maybe something to look at in the future.
---
 internal/array.h  | 1 +
 internal/string.h | 1 +
 object.c          | 2 ++
 vm_core.h         | 2 ++
 vm_insnhelper.c   | 1 +
 5 files changed, 7 insertions(+)

diff --git a/internal/array.h b/internal/array.h
index 6fcb4e83f5..60f66f31bf 100644
--- a/internal/array.h
+++ b/internal/array.h
@@ -46,6 +46,7 @@ struct rb_execution_context_struct; https://github.com/ruby/ruby/blob/trunk/internal/array.h#L46
 VALUE rb_ec_ary_new_from_values(struct rb_execution_context_struct *ec, long n, const VALUE *elts);
 MJIT_SYMBOL_EXPORT_END
 
+// YJIT needs this function to never allocate and never raise
 static inline VALUE
 rb_ary_entry_internal(VALUE ary, long offset)
 {
diff --git a/internal/string.h b/internal/string.h
index d010669ca8..18b01862f7 100644
--- a/internal/string.h
+++ b/internal/string.h
@@ -116,6 +116,7 @@ is_broken_string(VALUE str) https://github.com/ruby/ruby/blob/trunk/internal/string.h#L116
 }
 
 /* expect tail call optimization */
+// YJIT needs this function to never allocate and never raise
 static inline VALUE
 rb_str_eql_internal(const VALUE str1, const VALUE str2)
 {
diff --git a/object.c b/object.c
index 6bb3488153..4dfa7a44f8 100644
--- a/object.c
+++ b/object.c
@@ -790,6 +790,8 @@ rb_obj_is_kind_of(VALUE obj, VALUE c) https://github.com/ruby/ruby/blob/trunk/object.c#L790
 {
     VALUE cl = CLASS_OF(obj);
 
+    // Note: YJIT needs this function to never allocate and never raise when
+    // `c` is a class or a module.
     c = class_or_module_required(c);
     return RBOOL(class_search_ancestor(cl, RCLASS_ORIGIN(c)));
 }
diff --git a/vm_core.h b/vm_core.h
index 79aa22d3de..11af8a365d 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -446,6 +446,8 @@ struct rb_iseq_constant_body { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L446
     char catch_except_p; /* If a frame of this ISeq may catch exception, set TRUE */
     // If true, this ISeq is leaf *and* backtraces are not used, for example,
     // by rb_profile_frames. We verify only leafness on VM_CHECK_MODE though.
+    // Note that GC allocations might use backtraces due to
+    // ObjectSpace#trace_object_allocations.
     // For more details, see: https://bugs.ruby-lang.org/issues/16956
     bool builtin_inline_p;
     struct rb_id_table *outer_variables;
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index d068beb8be..3b99f7c350 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -4790,6 +4790,7 @@ vm_ic_hit_p(const struct iseq_inline_constant_cache_entry *ice, const VALUE *reg https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L4790
     return vm_inlined_ic_hit_p(ice->flags, ice->value, ice->ic_cref, ice->ic_serial, reg_ep);
 }
 
+// YJIT needs this function to never allocate and never raise
 bool
 rb_vm_ic_hit_p(IC ic, const VALUE *reg_ep)
 {
-- 
cgit v1.2.1


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

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