summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-09-24 00:02:19 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2022-09-24 00:02:21 +0900
commit7588f21851ae7fd93103130e565b97c8249f904f (patch)
treee95182ede100f5414dfa45f90ffe24e9f3be47e1
parent3ddab3a84e1fb44fb851c0edfee204e761cfc4d8 (diff)
downloadruby-7588f21851ae7fd93103130e565b97c8249f904f.tar.gz
Allow changing conversion macro in MJIT bindgen
This is necessary for object shapes.
-rwxr-xr-xtool/mjit/bindgen.rb40
1 files 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
# @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
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(
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