Lazy evaluation of an error prefix in MethodInliner (performance optimization)

This commit is contained in:
strangepleasures
2023-08-30 09:51:54 +00:00
committed by Space Team
parent 5aa0000b3e
commit ece40ca775
3 changed files with 6 additions and 6 deletions
@@ -334,7 +334,7 @@ class AnonymousObjectTransformer(
inliningContext.subInline(transformationInfo.nameGenerator),
remapper,
isSameModule,
"Transformer for " + transformationInfo.oldClassName,
{ "Transformer for " + transformationInfo.oldClassName },
SourceMapCopier(sourceMapper, sourceMap),
InlineCallSiteInfo(
transformationInfo.oldClassName,
@@ -108,7 +108,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
val callSite = SourcePosition(codegen.lastLineNumber, sourceInfo.sourceFileName!!, sourceInfo.pathOrCleanFQN)
val inliner = MethodInliner(
node, parameters, info, FieldRemapper(null, null, parameters), sourceCompiler.isCallInsideSameModuleAsCallee,
"Method inlining " + sourceCompiler.callElementText,
{ "Method inlining " + sourceCompiler.callElementText },
SourceMapCopier(sourceMapper, nodeAndSmap.classSMAP, callSite),
info.callSiteInfo,
isInlineOnlyMethod = isInlineOnly,
@@ -44,7 +44,7 @@ class MethodInliner(
private val inliningContext: InliningContext,
private val nodeRemapper: FieldRemapper,
private val isSameModule: Boolean,
private val errorPrefix: String,
private val errorPrefixSupplier: () -> String,
private val sourceMapper: SourceMapCopier,
private val inlineCallSiteInfo: InlineCallSiteInfo,
private val isInlineOnlyMethod: Boolean = false,
@@ -297,7 +297,7 @@ class MethodInliner(
info.node.node, lambdaParameters, inliningContext.subInlineLambda(info),
newCapturedRemapper,
if (info is DefaultLambda) isSameModule else true /*cause all nested objects in same module as lambda*/,
"Lambda inlining " + info.lambdaClassType.internalName,
{ "Lambda inlining " + info.lambdaClassType.internalName },
SourceMapCopier(sourceMapper.parent, info.node.classSMAP, callSite), inlineCallSiteInfo,
isInlineOnlyMethod = false
)
@@ -1014,9 +1014,9 @@ class MethodInliner(
@Suppress("SameParameterValue")
private fun wrapException(originalException: Throwable, node: MethodNode, errorSuffix: String): RuntimeException {
return if (originalException is InlineException) {
InlineException("$errorPrefix: $errorSuffix", originalException)
InlineException("${errorPrefixSupplier()}: $errorSuffix", originalException)
} else {
InlineException("$errorPrefix: $errorSuffix\nCause: ${node.nodeText}", originalException)
InlineException("${errorPrefixSupplier()}: $errorSuffix\nCause: ${node.nodeText}", originalException)
}
}