MJIT: Check if self is T_OBJECT before opt_pc jump

This commit is contained in:
Takashi Kokubun 2023-04-30 00:38:10 -07:00 committed by nagachika
parent ae70d2d786
commit 60d75a5665

View file

@ -75,6 +75,13 @@ class RubyVM::MJIT::Compiler # :nodoc: all
src << "#undef GET_SELF\n" src << "#undef GET_SELF\n"
src << "#define GET_SELF() cfp_self\n" src << "#define GET_SELF() cfp_self\n"
# Generate merged ivar guards first if needed
if !status.compile_info.disable_ivar_cache && using_ivar?(iseq.body)
src << " if (UNLIKELY(!RB_TYPE_P(GET_SELF(), T_OBJECT))) {"
src << " goto ivar_cancel;\n"
src << " }\n"
end
# Simulate `opt_pc` in setup_parameters_complex. Other PCs which may be passed by catch tables # Simulate `opt_pc` in setup_parameters_complex. Other PCs which may be passed by catch tables
# are not considered since vm_exec doesn't call jit_exec for catch tables. # are not considered since vm_exec doesn't call jit_exec for catch tables.
if iseq.body.param.flags.has_opt if iseq.body.param.flags.has_opt
@ -88,13 +95,6 @@ class RubyVM::MJIT::Compiler # :nodoc: all
src << " }\n" src << " }\n"
end end
# Generate merged ivar guards first if needed
if !status.compile_info.disable_ivar_cache && using_ivar?(iseq.body)
src << " if (UNLIKELY(!RB_TYPE_P(GET_SELF(), T_OBJECT))) {"
src << " goto ivar_cancel;\n"
src << " }\n"
end
compile_insns(0, 0, status, iseq.body, src) compile_insns(0, 0, status, iseq.body, src)
compile_cancel_handler(src, iseq.body, status) compile_cancel_handler(src, iseq.body, status)
src << "#undef GET_SELF\n" src << "#undef GET_SELF\n"