Use fast compare for stable obj temps

This commit is contained in:
Sergey Chernov 2026-02-16 17:35:08 +03:00
parent 44f9573eec
commit e8f5c9eaf4
2 changed files with 9 additions and 8 deletions

View File

@ -1683,12 +1683,12 @@ class BytecodeCompiler(
val left = ensureObjSlot(a)
val right = ensureObjSlot(b)
val opcode = when {
isExactNonNullSlotClass(left.slot, ObjString.type) &&
isExactNonNullSlotClass(right.slot, ObjString.type) -> stringOp
isExactNonNullSlotClass(left.slot, ObjInt.type) &&
isExactNonNullSlotClass(right.slot, ObjInt.type) -> intOp
isExactNonNullSlotClass(left.slot, ObjReal.type) &&
isExactNonNullSlotClass(right.slot, ObjReal.type) -> realOp
isExactNonNullSlotClassOrTemp(left.slot, ObjString.type) &&
isExactNonNullSlotClassOrTemp(right.slot, ObjString.type) -> stringOp
isExactNonNullSlotClassOrTemp(left.slot, ObjInt.type) &&
isExactNonNullSlotClassOrTemp(right.slot, ObjInt.type) -> intOp
isExactNonNullSlotClassOrTemp(left.slot, ObjReal.type) &&
isExactNonNullSlotClassOrTemp(right.slot, ObjReal.type) -> realOp
else -> objOp
}
builder.emit(opcode, left.slot, right.slot, out)

View File

@ -4,8 +4,9 @@ Baseline
- See `notes/nested_range_baseline.md`
Candidates (not started)
1) Primitive comparisons
- Emit fast CMP variants for known ObjString/ObjInt/ObjReal/ObjBool across all comparison operators.
1) Primitive comparisons (done)
- Emit fast CMP variants for known ObjString/ObjInt/ObjReal using temp/stable slots.
- MixedCompareBenchmarkTest: 374 ms -> 347 ms.
2) Mixed numeric ops
- Ensure INT+REAL arithmetic uses INT_TO_REAL + REAL op with no extra moves/boxing.
3) Boolean conversion