mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
vm: fuse JMPIF and MATCHERR into conditional MATCHERR
Change OP_MATCHERR from Z format (unconditional) to B format (conditional on register). This allows fusing JMPIF + MATCHERR sequence into a single MATCHERR instruction for simple patterns. Before: JMPIF R2 target (4 bytes) + MATCHERR (1 byte) = 5 bytes After: MATCHERR R2 (2 bytes) Saves 3 bytes per pattern match with raise_on_fail. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -57,7 +57,7 @@ OPCODE(JMPUW, S) /* unwind_and_jump_to(a) */
|
||||
OPCODE(EXCEPT, B) /* R[a] = exc */
|
||||
OPCODE(RESCUE, BB) /* R[b] = R[a].isa?(R[b]) */
|
||||
OPCODE(RAISEIF, B) /* raise(R[a]) if R[a] */
|
||||
OPCODE(MATCHERR, Z) /* raise NoMatchingPatternError */
|
||||
OPCODE(MATCHERR, B) /* raise NoMatchingPatternError unless R[a] */
|
||||
OPCODE(SSEND, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
|
||||
OPCODE(SSENDB, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
|
||||
OPCODE(SEND, BBB) /* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
|
||||
|
||||
Reference in New Issue
Block a user