Unbox assign-op operands for fast int/real ops

This commit is contained in:
Sergey Chernov 2026-02-16 18:04:55 +03:00
parent 09b1eb68ae
commit bfa8a59df3
2 changed files with 15 additions and 2 deletions

View File

@ -3604,6 +3604,12 @@ class BytecodeCompiler(
} }
SlotType.OBJ -> { SlotType.OBJ -> {
if (objOp == null) return null if (objOp == null) return null
if (isExactNonNullSlotClassOrTemp(rhs.slot, ObjInt.type)) {
val right = allocSlot()
builder.emit(Opcode.UNBOX_INT_OBJ, rhs.slot, right)
builder.emit(intOp, out, right, out)
return CompiledValue(out, SlotType.INT)
}
val leftObj = allocSlot() val leftObj = allocSlot()
builder.emit(Opcode.BOX_OBJ, out, leftObj) builder.emit(Opcode.BOX_OBJ, out, leftObj)
updateSlotType(leftObj, SlotType.OBJ) updateSlotType(leftObj, SlotType.OBJ)
@ -3629,6 +3635,12 @@ class BytecodeCompiler(
} }
SlotType.OBJ -> { SlotType.OBJ -> {
if (objOp == null) return null if (objOp == null) return null
if (isExactNonNullSlotClassOrTemp(rhs.slot, ObjReal.type)) {
val right = allocSlot()
builder.emit(Opcode.UNBOX_REAL_OBJ, rhs.slot, right)
builder.emit(realOp, out, right, out)
return CompiledValue(out, SlotType.REAL)
}
val leftObj = allocSlot() val leftObj = allocSlot()
builder.emit(Opcode.BOX_OBJ, out, leftObj) builder.emit(Opcode.BOX_OBJ, out, leftObj)
updateSlotType(leftObj, SlotType.OBJ) updateSlotType(leftObj, SlotType.OBJ)

View File

@ -19,5 +19,6 @@ Candidates (not started)
5) String ops (done) 5) String ops (done)
- Mark GET_INDEX results as stable only for closed ObjString elements to enable fast compares. - Mark GET_INDEX results as stable only for closed ObjString elements to enable fast compares.
- MixedCompareBenchmarkTest: 247 ms -> 240 ms. - MixedCompareBenchmarkTest: 247 ms -> 240 ms.
6) Box/unbox audit 6) Box/unbox audit (done)
- Identify remaining BOX_OBJ / OBJ_TO_* in inner loops and eliminate when safe. - Unbox ObjInt/ObjReal in assign-op when target is INT/REAL to avoid boxing + obj ops.
- MixedCompareBenchmarkTest: 240 ms -> 234 ms.