Combine two caches from interpreter environment into single one
This commit is contained in:
committed by
TeamCityServer
parent
3fc5405d57
commit
3cf4b8b108
+2
-2
@@ -114,7 +114,7 @@ private fun unfoldValueParameters(expression: IrFunctionAccessExpression, enviro
|
||||
val hasDefaults = (0 until expression.valueArgumentsCount).any { expression.getValueArgument(it) == null }
|
||||
if (hasDefaults) {
|
||||
val ownerWithDefaults = expression.getFunctionThatContainsDefaults()
|
||||
environment.cachedFunctionsWithDefaults[ownerWithDefaults.symbol]?.let {
|
||||
environment.createdFunctionsCache[ownerWithDefaults.symbol]?.let {
|
||||
val callToDefault = it.owner.createCall().apply { expression.copyArgsInto(this) }
|
||||
callStack.addInstruction(CompoundInstruction(callToDefault))
|
||||
return
|
||||
@@ -159,7 +159,7 @@ private fun unfoldValueParameters(expression: IrFunctionAccessExpression, enviro
|
||||
(0 until expression.valueArgumentsCount).forEach { callWithAllArgs.putValueArgument(it, actualParameters[it]?.createGetValue()) }
|
||||
defaultFun.body = (actualParameters.filterIsInstance<IrVariable>() + defaultFun.createReturn(callWithAllArgs)).wrapWithBlockBody()
|
||||
|
||||
environment.cachedFunctionsWithDefaults[ownerWithDefaults.symbol] = defaultFun.symbol
|
||||
environment.createdFunctionsCache[ownerWithDefaults.symbol] = defaultFun.symbol
|
||||
val callToDefault = defaultFun.createCall().apply { expression.copyArgsInto(this) }
|
||||
callStack.addInstruction(CompoundInstruction(callToDefault))
|
||||
} else {
|
||||
|
||||
+1
-2
@@ -23,8 +23,7 @@ class IrInterpreterEnvironment(
|
||||
internal val irExceptions = mutableListOf<IrClass>()
|
||||
internal var mapOfEnums = mutableMapOf<IrSymbol, Complex>()
|
||||
internal var mapOfObjects = mutableMapOf<IrSymbol, Complex>()
|
||||
internal var cachedFunctionsWithDefaults = mutableMapOf<IrFunctionSymbol, IrFunctionSymbol>()
|
||||
internal var cachedLambdasAndReferences = mutableMapOf<IrFunctionSymbol, IrFunctionSymbol>()
|
||||
internal var createdFunctionsCache = mutableMapOf<IrFunctionSymbol, IrFunctionSymbol>()
|
||||
|
||||
init {
|
||||
mapOfObjects[irBuiltIns.unitClass] = Common(irBuiltIns.unitClass.owner)
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ internal class KFunctionState(
|
||||
private var _returnType: KType? = null
|
||||
private var _typeParameters: List<KTypeParameter>? = null
|
||||
|
||||
val invokeSymbol: IrFunctionSymbol = environment.cachedLambdasAndReferences
|
||||
val invokeSymbol: IrFunctionSymbol = environment.createdFunctionsCache
|
||||
.getOrDefault(
|
||||
irFunction.symbol,
|
||||
createInvokeFunction(
|
||||
|
||||
Reference in New Issue
Block a user