This commit is contained in:
Takashi Kokubun 2023-02-15 23:43:53 -08:00
Родитель ecc86f79ca
Коммит 7b78fd0df2
4 изменённых файлов: 114 добавлений и 15 удалений

Просмотреть файл

@ -1799,7 +1799,9 @@ module RubyVM::MJIT
case cme.def.type
when C.VM_METHOD_TYPE_ISEQ
jit_call_iseq_setup(jit, ctx, asm, ci, cme, flags, argc)
# when C.VM_METHOD_TYPE_NOTIMPLEMENTED
when C.VM_METHOD_TYPE_NOTIMPLEMENTED
asm.incr_counter(:send_notimplemented)
return CantCompile
when C.VM_METHOD_TYPE_CFUNC
jit_call_cfunc(jit, ctx, asm, ci, cme, flags, argc)
when C.VM_METHOD_TYPE_ATTRSET
@ -1807,7 +1809,9 @@ module RubyVM::MJIT
return CantCompile
when C.VM_METHOD_TYPE_IVAR
jit_call_ivar(jit, ctx, asm, ci, cme, flags, argc, comptime_recv, recv_opnd)
# when C.VM_METHOD_TYPE_MISSING
when C.VM_METHOD_TYPE_MISSING
asm.incr_counter(:send_missing)
return CantCompile
when C.VM_METHOD_TYPE_BMETHOD
asm.incr_counter(:send_bmethod)
return CantCompile
@ -1815,9 +1819,10 @@ module RubyVM::MJIT
asm.incr_counter(:send_alias)
return CantCompile
when C.VM_METHOD_TYPE_OPTIMIZED
asm.incr_counter(:send_optimized)
jit_call_optimized(jit, ctx, asm, ci, cme, flags, argc)
when C.VM_METHOD_TYPE_UNDEF
asm.incr_counter(:send_undef)
return CantCompile
# when C.VM_METHOD_TYPE_UNDEF
when C.VM_METHOD_TYPE_ZSUPER
asm.incr_counter(:send_zsuper)
return CantCompile
@ -1825,7 +1830,7 @@ module RubyVM::MJIT
asm.incr_counter(:send_refined)
return CantCompile
else
asm.incr_counter(:send_not_implemented_type)
asm.incr_counter(:send_unknown_type)
return CantCompile
end
end
@ -2001,6 +2006,33 @@ module RubyVM::MJIT
jit_getivar(jit, ctx, asm, comptime_recv, ivar_id, recv_opnd)
end
# vm_call_optimized
# @param jit [RubyVM::MJIT::JITState]
# @param ctx [RubyVM::MJIT::Context]
# @param asm [RubyVM::MJIT::Assembler]
def jit_call_optimized(jit, ctx, asm, ci, cme, flags, argc)
case cme.def.body.optimized.type
when C.OPTIMIZED_METHOD_TYPE_SEND
asm.incr_counter(:send_optimized_send)
return CantCompile
when C.OPTIMIZED_METHOD_TYPE_CALL
asm.incr_counter(:send_optimized_call)
return CantCompile
when C.OPTIMIZED_METHOD_TYPE_BLOCK_CALL
asm.incr_counter(:send_optimized_block_call)
return CantCompile
when C.OPTIMIZED_METHOD_TYPE_STRUCT_AREF
asm.incr_counter(:send_optimized_struct_aref)
return CantCompile
when C.OPTIMIZED_METHOD_TYPE_STRUCT_ASET
asm.incr_counter(:send_optimized_struct_aset)
return CantCompile
else
asm.incr_counter(:send_optimized_unknown_type)
return CantCompile
end
end
# vm_push_frame
#
# Frame structure:

Просмотреть файл

@ -118,14 +118,16 @@ MJIT_RUNTIME_COUNTERS(
send_private,
send_protected,
send_tailcall,
send_not_implemented_type,
send_notimplemented,
send_cfunc,
send_attrset,
send_missing,
send_bmethod,
send_alias,
send_optimized,
send_undef,
send_zsuper,
send_refined,
send_unknown_type,
send_stackoverflow,
send_arity,
send_c_tracing,
@ -142,6 +144,13 @@ MJIT_RUNTIME_COUNTERS(
send_ivar_opt_send,
send_ivar_blockarg,
send_optimized_send,
send_optimized_call,
send_optimized_block_call,
send_optimized_struct_aref,
send_optimized_struct_aset,
send_optimized_unknown_type,
send_guard_symbol,
send_guard_float,

Просмотреть файл

@ -409,6 +409,26 @@ module RubyVM::MJIT # :nodoc: all
Primitive.cexpr! %q{ UINT2NUM(METHOD_VISI_PUBLIC) }
end
def C.OPTIMIZED_METHOD_TYPE_BLOCK_CALL
Primitive.cexpr! %q{ UINT2NUM(OPTIMIZED_METHOD_TYPE_BLOCK_CALL) }
end
def C.OPTIMIZED_METHOD_TYPE_CALL
Primitive.cexpr! %q{ UINT2NUM(OPTIMIZED_METHOD_TYPE_CALL) }
end
def C.OPTIMIZED_METHOD_TYPE_SEND
Primitive.cexpr! %q{ UINT2NUM(OPTIMIZED_METHOD_TYPE_SEND) }
end
def C.OPTIMIZED_METHOD_TYPE_STRUCT_AREF
Primitive.cexpr! %q{ UINT2NUM(OPTIMIZED_METHOD_TYPE_STRUCT_AREF) }
end
def C.OPTIMIZED_METHOD_TYPE_STRUCT_ASET
Primitive.cexpr! %q{ UINT2NUM(OPTIMIZED_METHOD_TYPE_STRUCT_ASET) }
end
def C.RARRAY_EMBED_FLAG
Primitive.cexpr! %q{ UINT2NUM(RARRAY_EMBED_FLAG) }
end
@ -561,6 +581,14 @@ module RubyVM::MJIT # :nodoc: all
Primitive.cexpr! %q{ UINT2NUM(VM_METHOD_TYPE_IVAR) }
end
def C.VM_METHOD_TYPE_MISSING
Primitive.cexpr! %q{ UINT2NUM(VM_METHOD_TYPE_MISSING) }
end
def C.VM_METHOD_TYPE_NOTIMPLEMENTED
Primitive.cexpr! %q{ UINT2NUM(VM_METHOD_TYPE_NOTIMPLEMENTED) }
end
def C.VM_METHOD_TYPE_OPTIMIZED
Primitive.cexpr! %q{ UINT2NUM(VM_METHOD_TYPE_OPTIMIZED) }
end
@ -569,6 +597,10 @@ module RubyVM::MJIT # :nodoc: all
Primitive.cexpr! %q{ UINT2NUM(VM_METHOD_TYPE_REFINED) }
end
def C.VM_METHOD_TYPE_UNDEF
Primitive.cexpr! %q{ UINT2NUM(VM_METHOD_TYPE_UNDEF) }
end
def C.VM_METHOD_TYPE_ZSUPER
Primitive.cexpr! %q{ UINT2NUM(VM_METHOD_TYPE_ZSUPER) }
end
@ -775,6 +807,10 @@ module RubyVM::MJIT # :nodoc: all
)
end
def C.method_optimized_type
@method_optimized_type ||= CType::Immediate.parse("int")
end
def C.mjit_options
@mjit_options ||= CType::Struct.new(
"mjit_options", Primitive.cexpr!("SIZEOF(struct mjit_options)"),
@ -1071,6 +1107,14 @@ module RubyVM::MJIT # :nodoc: all
)
end
def C.rb_method_optimized_t
@rb_method_optimized_t ||= CType::Struct.new(
"rb_method_optimized", Primitive.cexpr!("SIZEOF(struct rb_method_optimized)"),
type: [self.method_optimized_type, Primitive.cexpr!("OFFSETOF((*((struct rb_method_optimized *)NULL)), type)")],
index: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_method_optimized *)NULL)), index)")],
)
end
def C.rb_method_type_t
@rb_method_type_t ||= CType::Immediate.parse("int")
end
@ -1099,14 +1143,16 @@ module RubyVM::MJIT # :nodoc: all
send_private: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_private)")],
send_protected: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_protected)")],
send_tailcall: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_tailcall)")],
send_not_implemented_type: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_not_implemented_type)")],
send_notimplemented: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_notimplemented)")],
send_cfunc: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_cfunc)")],
send_attrset: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_attrset)")],
send_missing: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_missing)")],
send_bmethod: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_bmethod)")],
send_alias: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_alias)")],
send_optimized: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized)")],
send_undef: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_undef)")],
send_zsuper: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_zsuper)")],
send_refined: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_refined)")],
send_unknown_type: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_unknown_type)")],
send_stackoverflow: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_stackoverflow)")],
send_arity: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_arity)")],
send_c_tracing: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_c_tracing)")],
@ -1119,6 +1165,12 @@ module RubyVM::MJIT # :nodoc: all
send_ivar_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_ivar_splat)")],
send_ivar_opt_send: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_ivar_opt_send)")],
send_ivar_blockarg: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_ivar_blockarg)")],
send_optimized_send: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_send)")],
send_optimized_call: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_call)")],
send_optimized_block_call: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_block_call)")],
send_optimized_struct_aref: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_struct_aref)")],
send_optimized_struct_aset: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_struct_aset)")],
send_optimized_unknown_type: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_unknown_type)")],
send_guard_symbol: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_guard_symbol)")],
send_guard_float: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_guard_float)")],
getivar_megamorphic: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), getivar_megamorphic)")],
@ -1290,10 +1342,6 @@ module RubyVM::MJIT # :nodoc: all
CType::Stub.new(:rb_method_bmethod_t)
end
def C.rb_method_optimized_t
CType::Stub.new(:rb_method_optimized_t)
end
def C.ccan_list_node
CType::Stub.new(:ccan_list_node)
end

Просмотреть файл

@ -366,6 +366,11 @@ generator = BindingGenerator.new(
METHOD_VISI_PRIVATE
METHOD_VISI_PROTECTED
METHOD_VISI_PUBLIC
OPTIMIZED_METHOD_TYPE_SEND
OPTIMIZED_METHOD_TYPE_CALL
OPTIMIZED_METHOD_TYPE_BLOCK_CALL
OPTIMIZED_METHOD_TYPE_STRUCT_AREF
OPTIMIZED_METHOD_TYPE_STRUCT_ASET
ROBJECT_EMBED
RARRAY_EMBED_FLAG
RUBY_EVENT_CLASS
@ -397,13 +402,16 @@ generator = BindingGenerator.new(
VM_FRAME_MAGIC_CFUNC
VM_FRAME_FLAG_CFRAME
VM_FRAME_FLAG_CFRAME_KW
VM_METHOD_TYPE_CFUNC
VM_METHOD_TYPE_ISEQ
VM_METHOD_TYPE_IVAR
VM_METHOD_TYPE_NOTIMPLEMENTED
VM_METHOD_TYPE_CFUNC
VM_METHOD_TYPE_ATTRSET
VM_METHOD_TYPE_IVAR
VM_METHOD_TYPE_MISSING
VM_METHOD_TYPE_BMETHOD
VM_METHOD_TYPE_ALIAS
VM_METHOD_TYPE_OPTIMIZED
VM_METHOD_TYPE_UNDEF
VM_METHOD_TYPE_ZSUPER
VM_METHOD_TYPE_REFINED
],
@ -469,6 +477,8 @@ generator = BindingGenerator.new(
rb_shape_t
rb_method_attr_t
rb_method_cfunc_t
rb_method_optimized_t
method_optimized_type
],
dynamic_types: %w[
VALUE