diff options
author | Alan Wu <[email protected]> | 2025-06-06 21:51:05 +0900 |
---|---|---|
committer | Alan Wu <[email protected]> | 2025-06-09 22:36:53 +0900 |
commit | 9865aa94f7de65cd8c4964c13960ca9299cbdd48 (patch) | |
tree | 1c847ac0bf5b84acd53ba82c797970ce96ff60b8 /zjit/src | |
parent | 96fdaf2e393933fdd128cd1a41fa9b2062792a15 (diff) |
ZJIT: Parse opt_empty_p into HIR
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13549
Diffstat (limited to 'zjit/src')
-rw-r--r-- | zjit/src/hir.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs index 86e87d72ac..9ce1b94ec9 100644 --- a/zjit/src/hir.rs +++ b/zjit/src/hir.rs @@ -2355,6 +2355,10 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> { break; // Don't enqueue the next block as a successor } + // These are opt_send_without_block and all the opt_* instructions + // specialized to a certain method that could also be serviced + // using the general send implementation. The optimizer start from + // a general send for all of these later in the pipeline. YARVINSN_opt_nil_p | YARVINSN_opt_plus | YARVINSN_opt_minus | @@ -2371,6 +2375,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> { YARVINSN_opt_length | YARVINSN_opt_size | YARVINSN_opt_aref | + YARVINSN_opt_empty_p | YARVINSN_opt_send_without_block => { let cd: *const rb_call_data = get_arg(pc, 0).as_ptr(); let call_info = unsafe { rb_get_call_data_ci(cd) }; @@ -3807,6 +3812,19 @@ mod tests { } #[test] + fn opt_empty_p() { + eval(" + def test(x) = x.empty? + "); + assert_method_hir_with_opcode("test", YARVINSN_opt_empty_p, expect![[r#" + fn test: + bb0(v0:BasicObject, v1:BasicObject): + v4:BasicObject = SendWithoutBlock v1, :empty? + Return v4 + "#]]); + } + + #[test] fn test_branchnil() { eval(" def test(x) = x&.itself |