1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Allow changing conversion macro in MJIT bindgen

This is necessary for object shapes.
This commit is contained in:
Takashi Kokubun 2022-09-24 00:02:19 +09:00
parent 3ddab3a84e
commit 7588f21851
No known key found for this signature in database
GPG key ID: 6FFC433B12EE23DD

View file

@ -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,13 +130,15 @@ class BindingGenerator
println
end
# Define int macros/enums
@ints.each do |int|
println " def C.#{int}"
println " Primitive.cexpr! %q{ INT2NUM(#{int}) }"
# 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
nodes_index = nodes.group_by(&:spelling).transform_values(&:last)
@ -329,7 +331,8 @@ generator = BindingGenerator.new(
USE_LAZY_LOAD
USE_RVARGC
],
ints: %w[
values: {
INT: %w[
NOT_COMPILED_STACK_SIZE
VM_CALL_KW_SPLAT
VM_CALL_KW_SPLAT_bit
@ -338,6 +341,7 @@ generator = BindingGenerator.new(
VM_METHOD_TYPE_CFUNC
VM_METHOD_TYPE_ISEQ
],
},
types: %w[
CALL_DATA
IC