JVM don't optimize temporary vals in old back-end
This commit is contained in:
committed by
TeamCityServer
parent
568958492a
commit
d8f6d82411
+1
-1
@@ -53,7 +53,7 @@ class OptimizationMethodVisitor(
|
||||
RedundantCheckCastEliminationMethodTransformer(),
|
||||
ConstantConditionEliminationMethodTransformer(),
|
||||
RedundantBoxingMethodTransformer(generationState),
|
||||
TemporaryVariablesEliminationTransformer(),
|
||||
TemporaryVariablesEliminationTransformer(generationState),
|
||||
StackPeepholeOptimizationsTransformer(),
|
||||
PopBackwardPropagationTransformer(),
|
||||
DeadCodeEliminationMethodTransformer(),
|
||||
|
||||
+4
-1
@@ -8,16 +8,19 @@ package org.jetbrains.kotlin.codegen.optimization.temporaryVals
|
||||
import org.jetbrains.kotlin.codegen.optimization.common.InsnSequence
|
||||
import org.jetbrains.kotlin.codegen.optimization.common.removeUnusedLocalVariables
|
||||
import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import kotlin.math.max
|
||||
|
||||
class TemporaryVariablesEliminationTransformer : MethodTransformer() {
|
||||
class TemporaryVariablesEliminationTransformer(private val state: GenerationState) : MethodTransformer() {
|
||||
private val temporaryValsAnalyzer = TemporaryValsAnalyzer()
|
||||
|
||||
override fun transform(internalClassName: String, methodNode: MethodNode) {
|
||||
if (!state.isIrBackend) return
|
||||
|
||||
val cfg = ControlFlowGraph(methodNode)
|
||||
processLabels(cfg)
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ fun infiniteLoop() {
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 2 GOTO L6
|
||||
// 2 GOTO L7
|
||||
// 1 GOTO L1
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ suspend fun SequenceScope<Int>.awaitSeq(): Int = 42
|
||||
// 1 LOCALVARIABLE a I L[0-9]+ L4
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 LINENUMBER 9 L14
|
||||
// 1 LOCALVARIABLE a I L[0-9]+ L14
|
||||
// 1 LINENUMBER 9 L18
|
||||
// 1 LOCALVARIABLE a I L[0-9]+ L18
|
||||
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
+1
-1
@@ -12,4 +12,4 @@ suspend fun suspendThere(param: Int, param2: String, param3: Long): String {
|
||||
return a + b
|
||||
}
|
||||
|
||||
// 0 ASTORE 4
|
||||
// 1 ASTORE 4
|
||||
|
||||
@@ -5,7 +5,7 @@ object A {
|
||||
// JVM_TEMPLATES
|
||||
// Field initialized in constant pool
|
||||
// A super constructor call and INSTANCE put
|
||||
// 1 ALOAD 0
|
||||
// 2 ALOAD 0
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// JVM_IR generates 'dup' instead of 'astore 0; aload 0' in <clinit> method of object class
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
fun test(): Int = "123".indexOfAny(CharArray(1000) { '1' })
|
||||
|
||||
// JVM_TEMPLATES:
|
||||
// 4 ALOAD
|
||||
// 4 ASTORE
|
||||
// 5 ALOAD
|
||||
// 5 ASTORE
|
||||
// 7 ILOAD
|
||||
// 6 ISTORE
|
||||
|
||||
|
||||
+2
-2
@@ -21,6 +21,6 @@ fun foo() : String {
|
||||
)
|
||||
}
|
||||
|
||||
// 11 ALOAD
|
||||
// 1 ASTORE
|
||||
// 12 ALOAD
|
||||
// 2 ASTORE
|
||||
// 0 InlineMarker
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ fun foo() : String {
|
||||
return foobar("abc", bar("ghi") { x -> x + "jkl" }, "mno")
|
||||
}
|
||||
|
||||
// 4 ASTORE
|
||||
// 16 ALOAD
|
||||
// 6 ASTORE
|
||||
// 18 ALOAD
|
||||
// 1 MAXLOCALS = 7
|
||||
// 0 InlineMarker
|
||||
|
||||
Reference in New Issue
Block a user