Extract JVM IR backend module out of compiler/backend

The old backend does not depend on IR modules anymore
This commit is contained in:
Alexander Udalov
2019-01-15 17:19:50 +01:00
parent ad974137b8
commit 4daee6d282
11 changed files with 47 additions and 22 deletions
+1
View File
@@ -218,6 +218,7 @@ extra["compilerModules"] = arrayOf(
":compiler:ir.tree",
":compiler:ir.psi2ir",
":compiler:ir.backend.common",
":compiler:backend.jvm",
":compiler:backend.js",
":compiler:backend-common",
":compiler:backend",
-6
View File
@@ -1,4 +1,3 @@
plugins {
kotlin("jvm")
id("jps-compatible")
@@ -12,9 +11,6 @@ dependencies {
compile(project(":compiler:backend-common"))
compile(project(":compiler:frontend"))
compile(project(":compiler:frontend.java"))
compile(project(":compiler:ir.tree"))
compile(project(":compiler:ir.psi2ir"))
compile(project(":compiler:ir.backend.common"))
compile(project(":compiler:serialization"))
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "annotations", "asm-all", rootProject = rootProject) }
}
@@ -22,8 +18,6 @@ dependencies {
sourceSets {
"main" {
projectDefault()
java.srcDir("../ir/backend.jvm/src")
}
"test" {}
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen
interface IrExpressionLambda {
val isExtensionLambda: Boolean
}
@@ -5,9 +5,9 @@
package org.jetbrains.kotlin.codegen.inline
import org.jetbrains.kotlin.backend.jvm.codegen.IrExpressionLambda
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.ClosureCodegen
import org.jetbrains.kotlin.codegen.IrExpressionLambda
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.codegen.coroutines.continuationAsmType
import org.jetbrains.kotlin.codegen.coroutines.getOrCreateJvmSuspendFunctionView
+2 -2
View File
@@ -1,4 +1,3 @@
plugins {
kotlin("jvm")
id("jps-compatible")
@@ -14,6 +13,7 @@ dependencies {
compile(project(":compiler:frontend.script"))
compile(project(":compiler:backend-common"))
compile(project(":compiler:backend"))
compile(project(":compiler:backend.jvm"))
compile(project(":compiler:light-classes"))
compile(project(":compiler:serialization"))
compile(project(":compiler:plugin-api"))
@@ -54,4 +54,4 @@ testsJar {}
projectTest {
workingDir = rootDir
}
}
+20
View File
@@ -0,0 +1,20 @@
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
compile(project(":kotlin-annotations-jvm"))
compile(project(":compiler:backend"))
compile(project(":compiler:ir.tree"))
compile(project(":compiler:ir.psi2ir"))
compile(project(":compiler:ir.backend.common"))
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "annotations", "asm-all", rootProject = rootProject) }
}
sourceSets {
"main" {
projectDefault()
}
"test" {}
}
@@ -6,10 +6,7 @@
package org.jetbrains.kotlin.backend.jvm.codegen
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
import org.jetbrains.kotlin.codegen.Callable
import org.jetbrains.kotlin.codegen.JvmKotlinType
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.codegen.ValueKind
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.inline.*
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
@@ -32,7 +29,7 @@ class IrInlineCodegen(
) : InlineCodegen<ExpressionCodegen>(codegen, state, function, typeParameterMappings, sourceCompiler), IrCallGenerator {
override fun putClosureParametersOnStack(next: LambdaInfo, functionReferenceReceiver: StackValue?) {
val lambdaInfo = next as IrExpressionLambda
val lambdaInfo = next as IrExpressionLambdaImpl
activeLambda = lambdaInfo
lambdaInfo.reference.getArguments().forEachIndexed { index, (_, ir) ->
@@ -52,7 +49,7 @@ class IrInlineCodegen(
if (valueParameterDescriptor?.let { isInlineParameter(it) } == true && isInlineIrExpression(argumentExpression)) {
val irReference: IrFunctionReference =
(argumentExpression as IrBlock).statements.filterIsInstance<IrFunctionReference>().single()
rememberClosure(irReference, parameterType, valueParameterDescriptor) as IrExpressionLambda
rememberClosure(irReference, parameterType, valueParameterDescriptor) as IrExpressionLambdaImpl
} else {
putValueOnStack(argumentExpression, parameterType, valueParameterDescriptor?.index ?: -1)
}
@@ -94,7 +91,7 @@ class IrInlineCodegen(
private fun rememberClosure(irReference: IrFunctionReference, type: Type, parameter: ValueParameterDescriptor): LambdaInfo {
//assert(InlineUtil.isInlinableParameterExpression(ktLambda)) { "Couldn't find inline expression in ${expression.text}" }
val expression = irReference.symbol.owner as IrFunction
return IrExpressionLambda(
return IrExpressionLambdaImpl(
irReference, expression, typeMapper, parameter.isCrossinline, false/*TODO*/,
parameter.type.isExtensionFunctionType
).also { lambda ->
@@ -105,14 +102,14 @@ class IrInlineCodegen(
}
}
class IrExpressionLambda(
class IrExpressionLambdaImpl(
val reference: IrFunctionReference,
val function: IrFunction,
typeMapper: KotlinTypeMapper,
isCrossInline: Boolean,
override val isBoundCallableReference: Boolean,
val isExtensionLambda: Boolean
) : ExpressionLambda(typeMapper, isCrossInline) {
override val isExtensionLambda: Boolean
) : ExpressionLambda(typeMapper, isCrossInline), IrExpressionLambda {
override fun isMyLabel(name: String): Boolean {
//TODO("not implemented")
@@ -151,4 +148,4 @@ class IrExpressionLambda(
}
fun isInlineIrExpression(argumentExpression: IrExpression) =
argumentExpression is IrBlock && argumentExpression.origin == IrStatementOrigin.LAMBDA
argumentExpression is IrBlock && argumentExpression.origin == IrStatementOrigin.LAMBDA
@@ -69,7 +69,7 @@ class IrSourceCompilerForInline(
get() = codegen.classCodegen.getOrCreateSourceMapper()
override fun generateLambdaBody(adapter: MethodVisitor, jvmMethodSignature: JvmMethodSignature, lambdaInfo: ExpressionLambda): SMAP {
lambdaInfo as? IrExpressionLambda ?: error("Expecting ir lambda, but $lambdaInfo")
lambdaInfo as? IrExpressionLambdaImpl ?: error("Expecting ir lambda, but $lambdaInfo")
val functionCodegen = object : FunctionCodegen(lambdaInfo.function, codegen.classCodegen) {
override fun createMethod(flags: Int, signature: JvmMethodGenericSignature): MethodVisitor {
@@ -1,4 +1,3 @@
description = "Kotlin Serialization Compiler Plugin"
plugins {
@@ -14,6 +13,7 @@ dependencies {
compile(project(":compiler:plugin-api"))
compile(project(":compiler:frontend"))
compile(project(":compiler:backend"))
compile(project(":compiler:ir.backend.common"))
compile(project(":js:js.frontend"))
compile(project(":js:js.translator"))
+1
View File
@@ -16,6 +16,7 @@ val projectsToShadow by extra(listOf(
":plugins:annotation-based-compiler-plugins-ide-support",
":compiler:backend",
":compiler:backend-common",
":compiler:backend.jvm",
":compiler:ir.backend.common",
":kotlin-build-common",
":compiler:cli-common",
+2
View File
@@ -45,6 +45,7 @@ include ":kotlin-build-common",
":compiler:ir.ir2cfg",
":compiler:ir.backend.common",
":compiler:backend.js",
":compiler:backend.jvm",
":compiler:backend-common",
":compiler:backend",
":compiler:plugin-api",
@@ -273,6 +274,7 @@ project(':compiler:ir.psi2ir').projectDir = "$rootDir/compiler/ir/ir.psi2ir" as
project(':compiler:ir.ir2cfg').projectDir = "$rootDir/compiler/ir/ir.ir2cfg" as File
project(':compiler:ir.backend.common').projectDir = "$rootDir/compiler/ir/backend.common" as File
project(':compiler:backend.js').projectDir = "$rootDir/compiler/ir/backend.js" as File
project(':compiler:backend.jvm').projectDir = "$rootDir/compiler/ir/backend.jvm" as File
project(':kotlin-native:kotlin-native-utils').projectDir = "$rootDir/konan/utils" as File
project(':kotlin-native:kotlin-native-library-reader').projectDir = "$rootDir/konan/library-reader" as File
project(':kotlin-jps-plugin').projectDir = "$rootDir/prepare/jps-plugin" as File