Remove a redundant field

This commit is contained in:
pyos
2019-04-09 12:50:55 +02:00
committed by max-kammerer
parent 73bd683af1
commit b24690b35b
2 changed files with 13 additions and 16 deletions
@@ -102,7 +102,7 @@ class VariableInfo(val declaration: IrVariable, val index: Int, val type: Type,
class ExpressionCodegen( class ExpressionCodegen(
val irFunction: IrFunction, val irFunction: IrFunction,
val frame: IrFrameMap, override val frameMap: IrFrameMap,
val mv: InstructionAdapter, val mv: InstructionAdapter,
val classCodegen: ClassCodegen, val classCodegen: ClassCodegen,
val isInlineLambda: Boolean = false val isInlineLambda: Boolean = false
@@ -118,9 +118,6 @@ class ExpressionCodegen(
private val fileEntry = classCodegen.context.psiSourceManager.getFileEntry(irFunction.fileParent) private val fileEntry = classCodegen.context.psiSourceManager.getFileEntry(irFunction.fileParent)
override val frameMap: IrFrameMap
get() = frame
override val visitor: InstructionAdapter override val visitor: InstructionAdapter
get() = mv get() = mv
@@ -246,7 +243,7 @@ class ExpressionCodegen(
} }
info.variables.reversed().forEach { info.variables.reversed().forEach {
frame.leave(it.declaration.symbol) frameMap.leave(it.declaration.symbol)
} }
} }
@@ -399,7 +396,7 @@ class ExpressionCodegen(
override fun visitVariable(declaration: IrVariable, data: BlockInfo): PromisedValue { override fun visitVariable(declaration: IrVariable, data: BlockInfo): PromisedValue {
val varType = typeMapper.mapType(declaration.descriptor) val varType = typeMapper.mapType(declaration.descriptor)
val index = frame.enter(declaration.symbol, varType) val index = frameMap.enter(declaration.symbol, varType)
declaration.markLineNumber(startOffset = true) declaration.markLineNumber(startOffset = true)
@@ -473,7 +470,7 @@ class ExpressionCodegen(
} }
private fun findLocalIndex(irSymbol: IrSymbol): Int { private fun findLocalIndex(irSymbol: IrSymbol): Int {
val index = frame.getIndex(irSymbol) val index = frameMap.getIndex(irSymbol)
if (index >= 0) { if (index >= 0) {
return index return index
} }
@@ -853,7 +850,7 @@ class ExpressionCodegen(
var savedValue: Int? = null var savedValue: Int? = null
if (isExpression) { if (isExpression) {
tryResult.coerce(tryAsmType).materialize() tryResult.coerce(tryAsmType).materialize()
savedValue = frame.enterTemp(tryAsmType) savedValue = frameMap.enterTemp(tryAsmType)
mv.store(savedValue, tryAsmType) mv.store(savedValue, tryAsmType)
} else { } else {
tryResult.discard() tryResult.discard()
@@ -873,7 +870,7 @@ class ExpressionCodegen(
val clauseStart = markNewLabel() val clauseStart = markNewLabel()
val descriptor = clause.parameter val descriptor = clause.parameter
val descriptorType = descriptor.asmType val descriptorType = descriptor.asmType
val index = frame.enter(clause.catchParameter, descriptorType) val index = frameMap.enter(clause.catchParameter, descriptorType)
mv.store(index, descriptorType) mv.store(index, descriptorType)
val catchBody = clause.result val catchBody = clause.result
@@ -886,7 +883,7 @@ class ExpressionCodegen(
catchResult.discard() catchResult.discard()
} }
frame.leave(clause.catchParameter) frameMap.leave(clause.catchParameter)
val clauseEnd = markNewLabel() val clauseEnd = markNewLabel()
@@ -910,14 +907,14 @@ class ExpressionCodegen(
val defaultCatchStart = markNewLabel() val defaultCatchStart = markNewLabel()
// While keeping this value on the stack should be enough, the bytecode validator will // While keeping this value on the stack should be enough, the bytecode validator will
// complain if a catch block does not start with ASTORE. // complain if a catch block does not start with ASTORE.
val savedException = frame.enterTemp(AsmTypes.JAVA_THROWABLE_TYPE) val savedException = frameMap.enterTemp(AsmTypes.JAVA_THROWABLE_TYPE)
mv.store(savedException, AsmTypes.JAVA_THROWABLE_TYPE) mv.store(savedException, AsmTypes.JAVA_THROWABLE_TYPE)
val finallyStart = markNewLabel() val finallyStart = markNewLabel()
val finallyGaps = tryInfo.gaps.toList() val finallyGaps = tryInfo.gaps.toList()
data.handleBlock { genFinallyBlock(tryInfo, null, null, data) } data.handleBlock { genFinallyBlock(tryInfo, null, null, data) }
mv.load(savedException, AsmTypes.JAVA_THROWABLE_TYPE) mv.load(savedException, AsmTypes.JAVA_THROWABLE_TYPE)
frame.leaveTemp(AsmTypes.JAVA_THROWABLE_TYPE) frameMap.leaveTemp(AsmTypes.JAVA_THROWABLE_TYPE)
mv.athrow() mv.athrow()
// Include the ASTORE into the covered region. This is used by the inliner to detect try-finally. // Include the ASTORE into the covered region. This is used by the inliner to detect try-finally.
@@ -929,7 +926,7 @@ class ExpressionCodegen(
// TODO: generate a common `finally` for try & catch blocks here? Right now this breaks the inliner. // TODO: generate a common `finally` for try & catch blocks here? Right now this breaks the inliner.
if (savedValue != null) { if (savedValue != null) {
mv.load(savedValue, tryAsmType) mv.load(savedValue, tryAsmType)
frame.leaveTemp(tryAsmType) frameMap.leaveTemp(tryAsmType)
return aTry.onStack return aTry.onStack
} }
return voidValue return voidValue
@@ -964,11 +961,11 @@ class ExpressionCodegen(
fun generateFinallyBlocksIfNeeded(returnType: Type, afterReturnLabel: Label, data: BlockInfo) { fun generateFinallyBlocksIfNeeded(returnType: Type, afterReturnLabel: Label, data: BlockInfo) {
if (data.hasFinallyBlocks()) { if (data.hasFinallyBlocks()) {
if (Type.VOID_TYPE != returnType) { if (Type.VOID_TYPE != returnType) {
val returnValIndex = frame.enterTemp(returnType) val returnValIndex = frameMap.enterTemp(returnType)
mv.store(returnValIndex, returnType) mv.store(returnValIndex, returnType)
unwindBlockStack(afterReturnLabel, data, null) unwindBlockStack(afterReturnLabel, data, null)
mv.load(returnValIndex, returnType) mv.load(returnValIndex, returnType)
frame.leaveTemp(returnType) frameMap.leaveTemp(returnType)
} else { } else {
unwindBlockStack(afterReturnLabel, data, null) unwindBlockStack(afterReturnLabel, data, null)
} }
@@ -147,7 +147,7 @@ class IrSourceCompilerForInline(
override fun createCodegenForExternalFinallyBlockGenerationOnNonLocalReturn(finallyNode: MethodNode, curFinallyDepth: Int) = override fun createCodegenForExternalFinallyBlockGenerationOnNonLocalReturn(finallyNode: MethodNode, curFinallyDepth: Int) =
ExpressionCodegen( ExpressionCodegen(
codegen.irFunction, codegen.frame, InstructionAdapter(finallyNode), codegen.classCodegen, codegen.isInlineLambda codegen.irFunction, codegen.frameMap, InstructionAdapter(finallyNode), codegen.classCodegen, codegen.isInlineLambda
).also { ).also {
it.finallyDepth = curFinallyDepth it.finallyDepth = curFinallyDepth
} }