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