WASM: NFC. Rename WasmReinterpret into WasmNoOpCast.

This commit is contained in:
Igor Laevsky
2021-07-23 17:27:51 +03:00
committed by TeamCityServer
parent 0f84525bdc
commit d90e3618f9
8 changed files with 17 additions and 14 deletions
@@ -505,7 +505,7 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV
// Return true if function is recognized as intrinsic.
fun tryToGenerateWasmOpIntrinsicCall(call: IrFunctionAccessExpression, function: IrFunction): Boolean {
if (function.hasWasmReinterpretAnnotation()) {
if (function.hasWasmNoOpCastAnnotation()) {
return true
}
@@ -55,7 +55,7 @@ class DeclarationGenerator(val context: WasmModuleCodegenContext) : IrElementVis
declaration.getWasmImportAnnotation()
}
val isIntrinsic = declaration.hasWasmReinterpretAnnotation() || declaration.getWasmOpAnnotation() != null
val isIntrinsic = declaration.hasWasmNoOpCastAnnotation() || declaration.getWasmOpAnnotation() != null
if (isIntrinsic) {
return
}
@@ -23,8 +23,8 @@ fun IrAnnotationContainer.hasExcludedFromCodegenAnnotation(): Boolean =
fun IrAnnotationContainer.getWasmOpAnnotation(): String? =
getAnnotation(FqName("kotlin.wasm.internal.WasmOp"))?.getSingleConstStringArgument()
fun IrAnnotationContainer.hasWasmReinterpretAnnotation(): Boolean =
hasAnnotation(FqName("kotlin.wasm.internal.WasmReinterpret"))
fun IrAnnotationContainer.hasWasmNoOpCastAnnotation(): Boolean =
hasAnnotation(FqName("kotlin.wasm.internal.WasmNoOpCast"))
fun IrAnnotationContainer.hasWasmForeignAnnotation(): Boolean =
hasAnnotation(FqName("kotlin.wasm.internal.WasmForeign"))
@@ -60,7 +60,7 @@ public class Boolean private constructor(private val value: Boolean) : Comparabl
}
}
@WasmReinterpret
@WasmNoOpCast
internal fun toInt(): Int =
implementedAsIntrinsic
@@ -76,7 +76,7 @@ public class Char private constructor(public val value: Char) : Comparable<Char>
this.toInt().toShort()
/** Returns the value of this character as a `Int`. */
@WasmReinterpret
@WasmNoOpCast
public fun toInt(): Int =
implementedAsIntrinsic
@@ -346,7 +346,7 @@ public class Byte private constructor(public val value: Byte) : Number(), Compar
public override inline fun hashCode(): Int =
this.toInt()
@WasmReinterpret
@WasmNoOpCast
@PublishedApi
internal fun reinterpretAsInt(): Int =
implementedAsIntrinsic
@@ -686,7 +686,7 @@ public class Short private constructor(public val value: Short) : Number(), Comp
public override inline fun hashCode(): Int =
this.toInt()
@WasmReinterpret
@WasmNoOpCast
@PublishedApi
internal fun reinterpretAsInt(): Int =
implementedAsIntrinsic
@@ -1065,23 +1065,23 @@ public class Int private constructor(val value: Int) : Number(), Comparable<Int>
public override inline fun hashCode(): Int =
this
@WasmReinterpret
@WasmNoOpCast
@PublishedApi
internal fun reinterpretAsBoolean(): Boolean =
implementedAsIntrinsic
@PublishedApi
@WasmReinterpret
@WasmNoOpCast
internal fun reinterpretAsByte(): Byte =
implementedAsIntrinsic
@PublishedApi
@WasmReinterpret
@WasmNoOpCast
internal fun reinterpretAsShort(): Short =
implementedAsIntrinsic
@PublishedApi
@WasmReinterpret
@WasmNoOpCast
internal fun reinterpretAsChar(): Char =
implementedAsIntrinsic
}
@@ -33,7 +33,7 @@ internal fun unsafeCharArrayToRawMemory(src: CharArray, dstAddr: Int) {
}
}
@WasmReinterpret
@WasmNoOpCast
internal fun unsafeNotNull(x: Any?): Any =
implementedAsIntrinsic
@@ -28,9 +28,12 @@ internal annotation class WasmArrayOf(
val isNullable: Boolean,
)
// When applied to a function it forces codegen to not generate any code for it.
// In other words the annotated function will pass it's arguments unchanged.
// This is used in order to implement type casts when we know that underlying wasm types don't change.
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.BINARY)
internal annotation class WasmReinterpret
internal annotation class WasmNoOpCast
// This tells backend to insert box/unbox intrinsics around the annotated class. It's used to represent built-in types without making them
// explicitly "inline" (or "value" in the newest terminology).