JVM_IR: don't reset callSiteMarker to null after generating lambdas

This commit is contained in:
pyos
2019-10-02 10:26:07 +02:00
committed by max-kammerer
parent cea69e0706
commit f6fe273774
@@ -70,23 +70,21 @@ class IrSourceCompilerForInline(
override val lazySourceMapper: DefaultSourceMapper override val lazySourceMapper: DefaultSourceMapper
get() = codegen.classCodegen.getOrCreateSourceMapper() get() = codegen.classCodegen.getOrCreateSourceMapper()
private fun makeInlineNode(function: IrFunction, classCodegen: ClassCodegen, marker: CallSiteMarker?): SMAPAndMethodNode { private fun makeInlineNode(function: IrFunction, classCodegen: ClassCodegen, isLambda: Boolean): SMAPAndMethodNode {
var node: MethodNode? = null var node: MethodNode? = null
val functionCodegen = object : FunctionCodegen(function, classCodegen, isInlineLambda = marker == null) { val functionCodegen = object : FunctionCodegen(function, classCodegen, isLambda) {
override fun createMethod(flags: Int, signature: JvmMethodGenericSignature): MethodVisitor { override fun createMethod(flags: Int, signature: JvmMethodGenericSignature): MethodVisitor {
val asmMethod = signature.asmMethod val asmMethod = signature.asmMethod
node = MethodNode(Opcodes.API_VERSION, flags, asmMethod.name, asmMethod.descriptor, signature.genericsSignature, null) node = MethodNode(Opcodes.API_VERSION, flags, asmMethod.name, asmMethod.descriptor, signature.genericsSignature, null)
return wrapWithMaxLocalCalc(node!!) return wrapWithMaxLocalCalc(node!!)
} }
} }
lazySourceMapper.callSiteMarker = marker
functionCodegen.generate() functionCodegen.generate()
lazySourceMapper.callSiteMarker = null
return SMAPAndMethodNode(node!!, SMAP(classCodegen.getOrCreateSourceMapper().resultMappings)) return SMAPAndMethodNode(node!!, SMAP(classCodegen.getOrCreateSourceMapper().resultMappings))
} }
override fun generateLambdaBody(lambdaInfo: ExpressionLambda): SMAPAndMethodNode = override fun generateLambdaBody(lambdaInfo: ExpressionLambda): SMAPAndMethodNode =
makeInlineNode((lambdaInfo as IrExpressionLambdaImpl).function, codegen.classCodegen, null) makeInlineNode((lambdaInfo as IrExpressionLambdaImpl).function, codegen.classCodegen, true)
override fun doCreateMethodNodeFromSource( override fun doCreateMethodNodeFromSource(
callableDescriptor: FunctionDescriptor, callableDescriptor: FunctionDescriptor,
@@ -98,7 +96,10 @@ class IrSourceCompilerForInline(
assert(codegen.lastLineNumber >= 0) { "lastLineNumber shall be not negative, but is ${codegen.lastLineNumber}" } assert(codegen.lastLineNumber >= 0) { "lastLineNumber shall be not negative, but is ${codegen.lastLineNumber}" }
val irFunction = getFunctionToInline(jvmSignature, callDefault) val irFunction = getFunctionToInline(jvmSignature, callDefault)
return makeInlineNode(irFunction, FakeClassCodegen(irFunction, codegen.classCodegen), CallSiteMarker(codegen.lastLineNumber)) lazySourceMapper.callSiteMarker = CallSiteMarker(codegen.lastLineNumber)
val nodeAndSmap = makeInlineNode(irFunction, FakeClassCodegen(irFunction, codegen.classCodegen), false)
lazySourceMapper.callSiteMarker = null
return nodeAndSmap
} }
private fun getFunctionToInline(jvmSignature: JvmMethodSignature, callDefault: Boolean): IrFunction { private fun getFunctionToInline(jvmSignature: JvmMethodSignature, callDefault: Boolean): IrFunction {