Revert "Add a key to enable spilling of all variables in a suspending context"

This reverts commit 38d97d0621.
This commit is contained in:
Nikolay Krasko
2022-07-05 11:26:09 +02:00
committed by teamcity
parent d080297c20
commit c6299ee277
5 changed files with 9 additions and 31 deletions
@@ -61,8 +61,7 @@ class CoroutineTransformerMethodVisitor(
// JVM_IR backend generates $completion, while old backend does not
private val putContinuationParameterToLvt: Boolean = true,
// Parameters of suspend lambda are put to the same fields as spilled variables
private val initialVarsCountByType: Map<Type, Int> = emptyMap(),
private val shouldOptimiseUnusedVariables: Boolean = true
private val initialVarsCountByType: Map<Type, Int> = emptyMap()
) : TransformationMethodVisitor(delegate, access, name, desc, signature, exceptions) {
private val classBuilderForCoroutineState: ClassBuilder by lazy(obtainClassBuilderForCoroutineState)
@@ -207,9 +206,7 @@ class CoroutineTransformerMethodVisitor(
dropUnboxInlineClassMarkers(methodNode, suspensionPoints)
methodNode.removeEmptyCatchBlocks()
if (shouldOptimiseUnusedVariables) {
updateLvtAccordingToLiveness(methodNode, isForNamedFunction, stateLabels)
}
updateLvtAccordingToLiveness(methodNode, isForNamedFunction, stateLabels)
writeDebugMetadata(methodNode, suspensionPointLineNumbers, spilledToVariableMapping)
}
@@ -670,7 +667,7 @@ class CoroutineTransformerMethodVisitor(
for (slot in 0 until localsCount) {
if (slot == continuationIndex || slot == dataIndex) continue
val value = frame.getLocal(slot)
if (value.type == null || (shouldOptimiseUnusedVariables && !livenessFrame.isAlive(slot))) continue
if (value.type == null || !livenessFrame.isAlive(slot)) continue
if (value == StrictBasicValue.NULL_VALUE) {
referencesToSpill += slot to null
@@ -878,16 +875,12 @@ class CoroutineTransformerMethodVisitor(
for ((slot, referenceToSpill) in referencesToSpillBySuspensionPointIndex[suspensionPointIndex]) {
generateSpillAndUnspill(suspension, slot, referenceToSpill)
}
if (shouldOptimiseUnusedVariables) {
val (currentSpilledCount, predSpilledCount) = referencesToCleanBySuspensionPointIndex[suspensionPointIndex]
if (predSpilledCount > currentSpilledCount) {
for (fieldIndex in currentSpilledCount until predSpilledCount) {
cleanUpField(suspension, fieldIndex)
}
val (currentSpilledCount, predSpilledCount) = referencesToCleanBySuspensionPointIndex[suspensionPointIndex]
if (predSpilledCount > currentSpilledCount) {
for (fieldIndex in currentSpilledCount until predSpilledCount) {
cleanUpField(suspension, fieldIndex)
}
}
for ((slot, primitiveToSpill) in primitivesToSpillBySuspensionPointIndex[suspensionPointIndex]) {
generateSpillAndUnspill(suspension, slot, primitiveToSpill)
}