[Wasm] Use Wasm GC arrays instead of JS arrays

JS arrays was a workaround for lack of arrays in Firefox Wasm GC prototype
Now with V8 as a test runner we can use proper arrays
This commit is contained in:
Svyatoslav Kuzmich
2020-12-07 15:42:55 +03:00
parent d15af70a3e
commit d4233f3f0e
15 changed files with 400 additions and 276 deletions
@@ -0,0 +1,196 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package kotlin.wasm.internal
//
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
@WasmArrayOf(Any::class, isNullable = true)
internal class WasmAnyArray(size: Int) {
@WasmOp(WasmOp.ARRAY_GET)
fun get(index: Int): Any? =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_SET)
fun set(index: Int, value: Any?): Unit =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_LEN)
fun len(): Int =
implementedAsIntrinsic
}
internal inline fun WasmAnyArray.fill(size: Int, init: (Int) -> Any?) {
var i = 0
while (i < size) {
set(i, init(i))
i++
}
}
@WasmArrayOf(Boolean::class, isNullable = false)
internal class WasmBooleanArray(size: Int) {
@WasmOp(WasmOp.ARRAY_GET)
fun get(index: Int): Boolean =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_SET)
fun set(index: Int, value: Boolean): Unit =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_LEN)
fun len(): Int =
implementedAsIntrinsic
}
internal inline fun WasmBooleanArray.fill(size: Int, init: (Int) -> Boolean) {
var i = 0
while (i < size) {
set(i, init(i))
i++
}
}
@WasmArrayOf(Byte::class, isNullable = false)
internal class WasmByteArray(size: Int) {
@WasmOp(WasmOp.ARRAY_GET)
fun get(index: Int): Byte =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_SET)
fun set(index: Int, value: Byte): Unit =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_LEN)
fun len(): Int =
implementedAsIntrinsic
}
internal inline fun WasmByteArray.fill(size: Int, init: (Int) -> Byte) {
var i = 0
while (i < size) {
set(i, init(i))
i++
}
}
@WasmArrayOf(Short::class, isNullable = false)
internal class WasmShortArray(size: Int) {
@WasmOp(WasmOp.ARRAY_GET)
fun get(index: Int): Short =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_SET)
fun set(index: Int, value: Short): Unit =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_LEN)
fun len(): Int =
implementedAsIntrinsic
}
internal inline fun WasmShortArray.fill(size: Int, init: (Int) -> Short) {
var i = 0
while (i < size) {
set(i, init(i))
i++
}
}
@WasmArrayOf(Int::class, isNullable = false)
internal class WasmIntArray(size: Int) {
@WasmOp(WasmOp.ARRAY_GET)
fun get(index: Int): Int =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_SET)
fun set(index: Int, value: Int): Unit =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_LEN)
fun len(): Int =
implementedAsIntrinsic
}
internal inline fun WasmIntArray.fill(size: Int, init: (Int) -> Int) {
var i = 0
while (i < size) {
set(i, init(i))
i++
}
}
@WasmArrayOf(Long::class, isNullable = false)
internal class WasmLongArray(size: Int) {
@WasmOp(WasmOp.ARRAY_GET)
fun get(index: Int): Long =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_SET)
fun set(index: Int, value: Long): Unit =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_LEN)
fun len(): Int =
implementedAsIntrinsic
}
internal inline fun WasmLongArray.fill(size: Int, init: (Int) -> Long) {
var i = 0
while (i < size) {
set(i, init(i))
i++
}
}
@WasmArrayOf(Float::class, isNullable = false)
internal class WasmFloatArray(size: Int) {
@WasmOp(WasmOp.ARRAY_GET)
fun get(index: Int): Float =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_SET)
fun set(index: Int, value: Float): Unit =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_LEN)
fun len(): Int =
implementedAsIntrinsic
}
internal inline fun WasmFloatArray.fill(size: Int, init: (Int) -> Float) {
var i = 0
while (i < size) {
set(i, init(i))
i++
}
}
@WasmArrayOf(Double::class, isNullable = false)
internal class WasmDoubleArray(size: Int) {
@WasmOp(WasmOp.ARRAY_GET)
fun get(index: Int): Double =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_SET)
fun set(index: Int, value: Double): Unit =
implementedAsIntrinsic
@WasmOp(WasmOp.ARRAY_LEN)
fun len(): Int =
implementedAsIntrinsic
}
internal inline fun WasmDoubleArray.fill(size: Int, init: (Int) -> Double) {
var i = 0
while (i < size) {
set(i, init(i))
i++
}
}