WASM: NFC. Rename WasmPrimitive into WasmAutoboxed and add few comments.

This commit is contained in:
Igor Laevsky
2021-07-16 19:50:48 +03:00
committed by TeamCityServer
parent 59ad7e0e04
commit 9ccdffe8ad
7 changed files with 17 additions and 13 deletions

View File

@@ -29,8 +29,8 @@ fun IrAnnotationContainer.hasWasmReinterpretAnnotation(): Boolean =
fun IrAnnotationContainer.hasWasmForeignAnnotation(): Boolean =
hasAnnotation(FqName("kotlin.wasm.internal.WasmForeign"))
fun IrAnnotationContainer.hasWasmPrimitiveAnnotation(): Boolean =
hasAnnotation(FqName("kotlin.wasm.internal.WasmPrimitive"))
fun IrAnnotationContainer.hasWasmAutoboxedAnnotation(): Boolean =
hasAnnotation(FqName("kotlin.wasm.internal.WasmAutoboxed"))
fun IrAnnotationContainer.getWasmImportAnnotation(): WasmImportPair? =
getAnnotation(FqName("kotlin.wasm.internal.WasmImport"))?.let {

View File

@@ -32,7 +32,9 @@ class WasmInlineClassesUtils(private val wasmSymbols: WasmSymbols) : InlineClass
}
override fun isClassInlineLike(klass: IrClass): Boolean {
return klass.isInline || klass.hasWasmPrimitiveAnnotation()
// TODO: This hook is called from autoboxing lowering so we also handle autoboxing annotation here. In the future it's better
// to separate autoboxing from the inline class handling.
return klass.isInline || klass.hasWasmAutoboxedAnnotation()
}
override val boxIntrinsic: IrSimpleFunctionSymbol

View File

@@ -11,7 +11,7 @@ import kotlin.wasm.internal.*
* Represents a value which is either `true` or `false`. On the JVM, non-nullable values of this type are
* represented as values of the primitive type `boolean`.
*/
@WasmPrimitive
@WasmAutoboxed
public class Boolean private constructor(private val value: Boolean) : Comparable<Boolean> {
/**
* Returns the inverse of this boolean.

View File

@@ -13,7 +13,7 @@ import kotlin.wasm.internal.*
*
* On the JVM, non-nullable values of this type are represented as values of the primitive type `char`.
*/
@WasmPrimitive
@WasmAutoboxed
@Suppress("NOTHING_TO_INLINE")
public class Char private constructor(public val value: Char) : Comparable<Char> {
/**

View File

@@ -15,7 +15,7 @@ import kotlin.wasm.internal.*
/**
* Represents a 8-bit signed integer.
*/
@WasmPrimitive
@WasmAutoboxed
public class Byte private constructor(public val value: Byte) : Number(), Comparable<Byte> {
public companion object {
/**
@@ -359,7 +359,7 @@ private fun byteToStringImpl(byte: Byte): String =
/**
* Represents a 16-bit signed integer.
*/
@WasmPrimitive
@WasmAutoboxed
public class Short private constructor(public val value: Short) : Number(), Comparable<Short> {
public companion object {
/**
@@ -701,7 +701,7 @@ private fun shortToStringImpl(x: Short): String = implementedAsIntrinsic
/**
* Represents a 32-bit signed integer.
*/
@WasmPrimitive
@WasmAutoboxed
public class Int private constructor(val value: Int) : Number(), Comparable<Int> {
public companion object {
@@ -1099,7 +1099,7 @@ private fun intToStringImpl(x: Int): String =
/**
* Represents a 64-bit signed integer.
*/
@WasmPrimitive
@WasmAutoboxed
public class Long private constructor(val value: Long) : Number(), Comparable<Long> {
public companion object {
@@ -1473,7 +1473,7 @@ public class Long private constructor(val value: Long) : Number(), Comparable<Lo
/**
* Represents a single-precision 32-bit IEEE 754 floating point number.
*/
@WasmPrimitive
@WasmAutoboxed
public class Float private constructor(public val value: Float) : Number(), Comparable<Float> {
public companion object {
@@ -1786,7 +1786,7 @@ private fun floatToStringImpl(x: Float): String =
/**
* Represents a double-precision 64-bit IEEE 754 floating point number.
*/
@WasmPrimitive
@WasmAutoboxed
public class Double private constructor(public val value: Double) : Number(), Comparable<Double> {
public companion object {

View File

@@ -11,7 +11,7 @@ import kotlin.wasm.internal.*
* The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are
* implemented as instances of this class.
*/
@WasmPrimitive
@WasmAutoboxed
public class String constructor(public val string: String) : Comparable<String>, CharSequence {
public companion object;

View File

@@ -32,9 +32,11 @@ internal annotation class WasmArrayOf(
@Retention(AnnotationRetention.BINARY)
internal annotation class WasmReinterpret
// 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).
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.BINARY)
internal annotation class WasmPrimitive
internal annotation class WasmAutoboxed
/**
* Replace calls to this functions with specified Wasm instruction.