Introduce support for plugin-defined intrinsics in JVM IR backend:

Add intrinsic for kotlinx.serialization.serializer<T>() function.

Plugin intrinsic for old backend is removed because it is too hard
and unjustifiable to unify them.
This commit is contained in:
Leonid Startsev
2022-02-07 18:08:23 +03:00
committed by Space
parent f9edbd825a
commit a59f5f407b
20 changed files with 989 additions and 580 deletions
@@ -10,6 +10,7 @@ dependencies {
api(project(":compiler:ir.tree"))
api(project(":compiler:ir.interpreter"))
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
}
sourceSets {
@@ -5,9 +5,15 @@
package org.jetbrains.kotlin.backend.common.extensions
import org.jetbrains.org.objectweb.asm.tree.InsnList
import org.jetbrains.org.objectweb.asm.tree.MethodInsnNode
import org.jetbrains.kotlin.backend.common.BackendContext
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.linkage.IrDeserializer
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType
interface IrGenerationExtension : IrDeserializer.IrLinkerExtension {
companion object :
@@ -16,4 +22,15 @@ interface IrGenerationExtension : IrDeserializer.IrLinkerExtension {
)
fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext)
// TODO: normal dependency & typing
fun retrieveIntrinsic(symbol: IrFunctionSymbol): Any? = null
fun applyPluginDefinedReifiedOperationMarker(
insn: MethodInsnNode,
instructions: InsnList,
type: IrType,
jvmBackendContext: BackendContext,
): Int = -1
}