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

ruby-changes:73709

From: Takashi <ko1@a...>
Date: Sat, 24 Sep 2022 00:02:43 +0900 (JST)
Subject: [ruby-changes:73709] 7588f21851 (master): Allow changing conversion macro in MJIT bindgen

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

From 7588f21851ae7fd93103130e565b97c8249f904f Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Sat, 24 Sep 2022 00:02:19 +0900
Subject: Allow changing conversion macro in MJIT bindgen

This is necessary for object shapes.
---
 tool/mjit/bindgen.rb | 40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/tool/mjit/bindgen.rb b/tool/mjit/bindgen.rb
index 56369c2d98..d0f9bf527b 100755
--- a/tool/mjit/bindgen.rb
+++ b/tool/mjit/bindgen.rb
@@ -102,16 +102,16 @@ class BindingGenerator https://github.com/ruby/ruby/blob/trunk/tool/mjit/bindgen.rb#L102
 
   # @param src_path [String]
   # @param uses [Array<String>]
-  # @param ints [Array<String>]
+  # @param values [Hash{ Symbol => Array<String> }]
   # @param types [Array<String>]
   # @param dynamic_types [Array<String>] #ifdef-dependent immediate types, which need Primitive.cexpr! for type detection
   # @param skip_fields [Hash{ Symbol => Array<String> }] Struct fields that are skipped from bindgen
   # @param ruby_fields [Hash{ Symbol => Array<String> }] Struct VALUE fields that are considered Ruby objects
-  def initialize(src_path:, uses:, ints:, types:, dynamic_types:, skip_fields:, ruby_fields:)
+  def initialize(src_path:, uses:, values:, types:, dynamic_types:, skip_fields:, ruby_fields:)
     @preamble, @postamble = split_ambles(src_path)
     @src = String.new
     @uses = uses.sort
-    @ints = ints.sort
+    @values = values.transform_values(&:sort)
     @types = types.sort
     @dynamic_types = dynamic_types.sort
     @skip_fields = skip_fields.transform_keys(&:to_s)
@@ -130,12 +130,14 @@ class BindingGenerator https://github.com/ruby/ruby/blob/trunk/tool/mjit/bindgen.rb#L130
       println
     end
 
-    # Define int macros/enums
-    @ints.each do |int|
-      println "  def C.#{int}"
-      println "    Primitive.cexpr! %q{ INT2NUM(#{int}) }"
-      println "  end"
-      println
+    # Define macros/enums
+    @values.each do |type, values|
+      values.each do |value|
+        println "  def C.#{value}"
+        println "    Primitive.cexpr! %q{ #{type}2NUM(#{value}) }"
+        println "  end"
+        println
+      end
     end
 
     # TODO: Support nested declarations
@@ -329,15 +331,17 @@ generator = BindingGenerator.new( https://github.com/ruby/ruby/blob/trunk/tool/mjit/bindgen.rb#L331
     USE_LAZY_LOAD
     USE_RVARGC
   ],
-  ints: %w[
-    NOT_COMPILED_STACK_SIZE
-    VM_CALL_KW_SPLAT
-    VM_CALL_KW_SPLAT_bit
-    VM_CALL_TAILCALL
-    VM_CALL_TAILCALL_bit
-    VM_METHOD_TYPE_CFUNC
-    VM_METHOD_TYPE_ISEQ
-  ],
+  values: {
+    INT: %w[
+      NOT_COMPILED_STACK_SIZE
+      VM_CALL_KW_SPLAT
+      VM_CALL_KW_SPLAT_bit
+      VM_CALL_TAILCALL
+      VM_CALL_TAILCALL_bit
+      VM_METHOD_TYPE_CFUNC
+      VM_METHOD_TYPE_ISEQ
+    ],
+  },
   types: %w[
     CALL_DATA
     IC
-- 
cgit v1.2.1


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

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