Do not use KotlinTypeMapper when generating JVM assert inline intrinsics
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.codegen.coroutines.createCustomCopy
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.config.JVMAssertionsMode
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.isTopLevelInPackage
|
||||
@@ -48,22 +47,17 @@ fun FunctionDescriptor.isBuiltinAlwaysEnabledAssert() =
|
||||
fun FieldInsnNode.isCheckAssertionsStatus() =
|
||||
opcode == Opcodes.GETSTATIC && name == ASSERTIONS_DISABLED_FIELD_NAME && desc == Type.BOOLEAN_TYPE.descriptor
|
||||
|
||||
fun createMethodNodeForAlwaysEnabledAssert(
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
typeMapper: KotlinTypeMapper
|
||||
): MethodNode {
|
||||
assert(functionDescriptor.isBuiltinAlwaysEnabledAssert()) {
|
||||
"functionDescriptor must be kotlin.alwaysEnabledAssert, but got $functionDescriptor"
|
||||
fun createMethodNodeForAlwaysEnabledAssert(functionDescriptor: FunctionDescriptor): MethodNode {
|
||||
val signature = when {
|
||||
functionDescriptor.isBuiltinAlwaysEnabledAssertWithLambda() ->
|
||||
Type.getMethodDescriptor(Type.VOID_TYPE, Type.BOOLEAN_TYPE, AsmTypes.FUNCTION0)
|
||||
functionDescriptor.isBuiltinAlwaysEnabledAssertWithoutLambda() ->
|
||||
Type.getMethodDescriptor(Type.VOID_TYPE, Type.BOOLEAN_TYPE)
|
||||
else ->
|
||||
error("functionDescriptor must be kotlin.alwaysEnabledAssert, but got $functionDescriptor")
|
||||
}
|
||||
|
||||
val node =
|
||||
org.jetbrains.org.objectweb.asm.tree.MethodNode(
|
||||
Opcodes.API_VERSION,
|
||||
Opcodes.ACC_STATIC,
|
||||
"fake",
|
||||
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
|
||||
)
|
||||
|
||||
val node = MethodNode(Opcodes.API_VERSION, Opcodes.ACC_STATIC, "fake", signature, null, null)
|
||||
val v = InstructionAdapter(node)
|
||||
val returnLabel = Label()
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForCoroutineContext
|
||||
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForIntercepted
|
||||
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForSuspendCoroutineUninterceptedOrReturn
|
||||
import org.jetbrains.kotlin.codegen.coroutines.isBuiltInSuspendCoroutineUninterceptedOrReturnInJvm
|
||||
import org.jetbrains.kotlin.codegen.createMethodNodeForAlwaysEnabledAssert
|
||||
import org.jetbrains.kotlin.codegen.isBuiltinAlwaysEnabledAssert
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
@@ -52,7 +51,7 @@ internal fun generateInlineIntrinsic(
|
||||
descriptor.isBuiltInSuspendCoroutineUninterceptedOrReturn(languageVersionSettings) ->
|
||||
createMethodNodeForSuspendCoroutineUninterceptedOrReturn(descriptor, typeMapper, languageVersionSettings)
|
||||
descriptor.isBuiltinAlwaysEnabledAssert() ->
|
||||
createMethodNodeForAlwaysEnabledAssert(descriptor, typeMapper)
|
||||
createMethodNodeForAlwaysEnabledAssert(descriptor)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public class AsmTypes {
|
||||
|
||||
public static final Type RESULT_FAILURE = Type.getObjectType("kotlin/Result$Failure");
|
||||
|
||||
public static final Type FUNCTION0 = Type.getObjectType("kotlin/jvm/functions/Function0");
|
||||
public static final Type FUNCTION1 = Type.getObjectType("kotlin/jvm/functions/Function1");
|
||||
|
||||
public static final Type[] PROPERTY_REFERENCE_IMPL = {
|
||||
|
||||
Reference in New Issue
Block a user