@@ -643,6 +643,40 @@ pub enum SendFallbackReason {
643643 Uncategorized ( ruby_vminsn_type ) ,
644644}
645645
646+ impl Display for SendFallbackReason {
647+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
648+ match self {
649+ SendWithoutBlockPolymorphic => write ! ( f, "SendWithoutBlock: polymorphic call site" ) ,
650+ SendWithoutBlockMegamorphic => write ! ( f, "SendWithoutBlock: megamorphic call site" ) ,
651+ SendWithoutBlockNoProfiles => write ! ( f, "SendWithoutBlock: no profile data available" ) ,
652+ SendWithoutBlockCfuncNotVariadic => write ! ( f, "SendWithoutBlock: C function is not variadic" ) ,
653+ SendWithoutBlockCfuncArrayVariadic => write ! ( f, "SendWithoutBlock: C function expects array variadic" ) ,
654+ SendWithoutBlockNotOptimizedMethodType ( method_type) => write ! ( f, "SendWithoutBlock: unsupported method type {:?}" , method_type) ,
655+ SendWithoutBlockNotOptimizedMethodTypeOptimized ( opt_type) => write ! ( f, "SendWithoutBlock: unsupported optimized method type {:?}" , opt_type) ,
656+ SendWithoutBlockBopRedefined => write ! ( f, "SendWithoutBlock: basic operation was redefined" ) ,
657+ SendWithoutBlockOperandsNotFixnum => write ! ( f, "SendWithoutBlock: operands are not fixnums" ) ,
658+ SendWithoutBlockDirectKeywordMismatch => write ! ( f, "SendWithoutBlockDirect: keyword mismatch" ) ,
659+ SendWithoutBlockDirectOptionalKeywords => write ! ( f, "SendWithoutBlockDirect: optional keywords" ) ,
660+ SendWithoutBlockDirectKeywordCountMismatch => write ! ( f, "SendWithoutBlockDirect: keyword count mismatch" ) ,
661+ SendWithoutBlockDirectMissingKeyword => write ! ( f, "SendWithoutBlockDirect: missing keyword" ) ,
662+ SendPolymorphic => write ! ( f, "Send: polymorphic call site" ) ,
663+ SendMegamorphic => write ! ( f, "Send: megamorphic call site" ) ,
664+ SendNoProfiles => write ! ( f, "Send: no profile data available" ) ,
665+ SendCfuncVariadic => write ! ( f, "Send: C function is variadic" ) ,
666+ SendCfuncArrayVariadic => write ! ( f, "Send: C function expects array variadic" ) ,
667+ SendNotOptimizedMethodType ( method_type) => write ! ( f, "Send: unsupported method type {:?}" , method_type) ,
668+ CCallWithFrameTooManyArgs => write ! ( f, "CCallWithFrame: too many arguments" ) ,
669+ ObjToStringNotString => write ! ( f, "ObjToString: result is not a string" ) ,
670+ TooManyArgsForLir => write ! ( f, "Too many arguments for LIR" ) ,
671+ BmethodNonIseqProc => write ! ( f, "Bmethod: Proc object is not defined by an ISEQ" ) ,
672+ ArgcParamMismatch => write ! ( f, "Argument count does not match parameter count" ) ,
673+ ComplexArgPass => write ! ( f, "Complex argument passing" ) ,
674+ UnexpectedKeywordArgs => write ! ( f, "Unexpected Keyword Args" ) ,
675+ Uncategorized ( insn) => write ! ( f, "Uncategorized({})" , insn_name( * insn as usize ) ) ,
676+ }
677+ }
678+ }
679+
646680/// An instruction in the SSA IR. The output of an instruction is referred to by the index of
647681/// the instruction ([`InsnId`]). SSA form enables this, and [`UnionFind`] ([`Function::find`])
648682/// helps with editing.
@@ -1203,11 +1237,12 @@ impl<'a> std::fmt::Display for InsnPrinter<'a> {
12031237 Insn :: Jump ( target) => { write ! ( f, "Jump {target}" ) }
12041238 Insn :: IfTrue { val, target } => { write ! ( f, "IfTrue {val}, {target}" ) }
12051239 Insn :: IfFalse { val, target } => { write ! ( f, "IfFalse {val}, {target}" ) }
1206- Insn :: SendWithoutBlock { recv, cd, args, .. } => {
1240+ Insn :: SendWithoutBlock { recv, cd, args, reason , .. } => {
12071241 write ! ( f, "SendWithoutBlock {recv}, :{}" , ruby_call_method_name( * cd) ) ?;
12081242 for arg in args {
12091243 write ! ( f, ", {arg}" ) ?;
12101244 }
1245+ write ! ( f, " # SendFallbackReason: {reason}" ) ?;
12111246 Ok ( ( ) )
12121247 }
12131248 Insn :: SendWithoutBlockDirect { recv, cd, iseq, args, .. } => {
@@ -1217,35 +1252,39 @@ impl<'a> std::fmt::Display for InsnPrinter<'a> {
12171252 }
12181253 Ok ( ( ) )
12191254 }
1220- Insn :: Send { recv, cd, args, blockiseq, .. } => {
1255+ Insn :: Send { recv, cd, args, blockiseq, reason , .. } => {
12211256 // For tests, we want to check HIR snippets textually. Addresses change
12221257 // between runs, making tests fail. Instead, pick an arbitrary hex value to
12231258 // use as a "pointer" so we can check the rest of the HIR.
12241259 write ! ( f, "Send {recv}, {:p}, :{}" , self . ptr_map. map_ptr( blockiseq) , ruby_call_method_name( * cd) ) ?;
12251260 for arg in args {
12261261 write ! ( f, ", {arg}" ) ?;
12271262 }
1263+ write ! ( f, " # SendFallbackReason: {reason}" ) ?;
12281264 Ok ( ( ) )
12291265 }
1230- Insn :: SendForward { recv, cd, args, blockiseq, .. } => {
1266+ Insn :: SendForward { recv, cd, args, blockiseq, reason , .. } => {
12311267 write ! ( f, "SendForward {recv}, {:p}, :{}" , self . ptr_map. map_ptr( blockiseq) , ruby_call_method_name( * cd) ) ?;
12321268 for arg in args {
12331269 write ! ( f, ", {arg}" ) ?;
12341270 }
1271+ write ! ( f, " # SendFallbackReason: {reason}" ) ?;
12351272 Ok ( ( ) )
12361273 }
1237- Insn :: InvokeSuper { recv, blockiseq, args, .. } => {
1274+ Insn :: InvokeSuper { recv, blockiseq, args, reason , .. } => {
12381275 write ! ( f, "InvokeSuper {recv}, {:p}" , self . ptr_map. map_ptr( blockiseq) ) ?;
12391276 for arg in args {
12401277 write ! ( f, ", {arg}" ) ?;
12411278 }
1279+ write ! ( f, " # SendFallbackReason: {reason}" ) ?;
12421280 Ok ( ( ) )
12431281 }
1244- Insn :: InvokeBlock { args, .. } => {
1282+ Insn :: InvokeBlock { args, reason , .. } => {
12451283 write ! ( f, "InvokeBlock" ) ?;
12461284 for arg in args {
12471285 write ! ( f, ", {arg}" ) ?;
12481286 }
1287+ write ! ( f, " # SendFallbackReason: {reason}" ) ?;
12491288 Ok ( ( ) )
12501289 }
12511290 Insn :: InvokeBuiltin { bf, args, leaf, .. } => {
@@ -2044,7 +2083,7 @@ impl Function {
20442083 /// Update DynamicSendReason for the instruction at insn_id
20452084 fn set_dynamic_send_reason ( & mut self , insn_id : InsnId , dynamic_send_reason : SendFallbackReason ) {
20462085 use Insn :: * ;
2047- if get_option ! ( stats) {
2086+ if get_option ! ( stats) || get_option ! ( dump_hir_opt ) . is_some ( ) || cfg ! ( test ) {
20482087 match self . insns . get_mut ( insn_id. 0 ) . unwrap ( ) {
20492088 Send { reason, .. }
20502089 | SendForward { reason, .. }
0 commit comments