Remove OperationType.PLUGIN_DEFINED type:
instead, plugins should emit the code similar to the TYPE_OF one with a special call to MagicApiIntrinsics.voidMagicApiCall directly afterwards. This is required because old compiler need to correctly inline code rewritten by plugin.
This commit is contained in:
+4
-14
@@ -32,8 +32,8 @@ import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.Type.INT_TYPE
|
||||
import org.jetbrains.org.objectweb.asm.Type.VOID_TYPE
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.InsnList
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodInsnNode
|
||||
|
||||
class IrInlineIntrinsicsSupport(
|
||||
private val classCodegen: ClassCodegen,
|
||||
@@ -127,17 +127,7 @@ class IrInlineIntrinsicsSupport(
|
||||
.report(JvmBackendErrors.TYPEOF_NON_REIFIED_TYPE_PARAMETER_WITH_RECURSIVE_BOUND, typeParameterName.asString())
|
||||
}
|
||||
|
||||
override fun applyPluginDefinedReifiedOperationMarker(
|
||||
insn: MethodInsnNode,
|
||||
instructions: InsnList,
|
||||
type: IrType,
|
||||
asmType: Type
|
||||
): Int = pluginExtensions.maxOfOrNull {
|
||||
it.applyPluginDefinedReifiedOperationMarker(
|
||||
insn,
|
||||
instructions,
|
||||
type,
|
||||
classCodegen.context
|
||||
)
|
||||
} ?: -1
|
||||
override fun rewritePluginDefinedOperationMarker(v: InstructionAdapter, next: AbstractInsnNode, instructions: InsnList, type: IrType): Boolean {
|
||||
return pluginExtensions.any { it.rewritePluginDefinedOperationMarker(v, next, instructions, type, classCodegen.context) }
|
||||
}
|
||||
}
|
||||
|
||||
+11
-5
@@ -10,16 +10,22 @@ import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.intrinsics.IntrinsicMethod
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.InsnList
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodInsnNode
|
||||
|
||||
interface JvmIrIntrinsicExtension : IrIntrinsicExtension {
|
||||
fun getIntrinsic(symbol: IrFunctionSymbol): IntrinsicMethod?
|
||||
|
||||
fun applyPluginDefinedReifiedOperationMarker(
|
||||
insn: MethodInsnNode,
|
||||
/**
|
||||
* Should return `true` if marker was processed.
|
||||
* If this method returns `false`, a regular `TYPE_OF` intrinsic would be inserted.
|
||||
*/
|
||||
fun rewritePluginDefinedOperationMarker(
|
||||
v: InstructionAdapter,
|
||||
next: AbstractInsnNode,
|
||||
instructions: InsnList,
|
||||
type: IrType,
|
||||
jvmBackendContext: JvmBackendContext,
|
||||
): Int = -1
|
||||
jvmBackendContext: JvmBackendContext
|
||||
): Boolean
|
||||
}
|
||||
Reference in New Issue
Block a user