[WASM] Fix interop adapter for long strings

This commit is contained in:
Igor Yakovlev
2022-06-27 21:21:15 +02:00
committed by teamcity
parent 6e75e4a56e
commit 6f88e9b16f
12 changed files with 136 additions and 71 deletions
@@ -185,6 +185,7 @@ class WasmSymbols(
val nullableDoubleIeee754Equals = getInternalFunction("nullableDoubleIeee754Equals")
val unsafeGetScratchRawMemory = getInternalFunction("unsafeGetScratchRawMemory")
val unsafeGetScratchRawMemorySize = getInternalFunction("unsafeGetScratchRawMemorySize")
val startCoroutineUninterceptedOrReturnIntrinsics =
(0..2).map { getInternalFunction("startCoroutineUninterceptedOrReturnIntrinsic$it") }
@@ -465,6 +465,10 @@ class BodyGenerator(
body.buildConstI32Symbol(context.scratchMemAddr)
}
wasmSymbols.unsafeGetScratchRawMemorySize -> {
body.buildConstI32Symbol(WasmSymbol(context.scratchMemSizeInBytes))
}
else -> {
return false
}
@@ -16,6 +16,7 @@ interface WasmBaseCodegenContext {
val backendContext: WasmBackendContext
val scratchMemAddr: WasmSymbol<Int>
val scratchMemSizeInBytes: Int
fun referenceFunction(irFunction: IrFunctionSymbol): WasmSymbol<WasmFunction>
fun referenceGlobalField(irField: IrFieldSymbol): WasmSymbol<WasmGlobal>
@@ -60,7 +60,7 @@ class WasmCompiledModuleFragment(val irBuiltIns: IrBuiltIns) {
val initFunctions = mutableListOf<FunWithPriority>()
val scratchMemAddr = WasmSymbol<Int>()
private val scratchMemSizeInBytes = 65_536
val scratchMemSizeInBytes = 65_536
open class ReferencableElements<Ir, Wasm : Any> {
val unbound = mutableMapOf<Ir, WasmSymbol<Wasm>>()
@@ -25,6 +25,9 @@ class WasmModuleCodegenContextImpl(
override val scratchMemAddr: WasmSymbol<Int>
get() = wasmFragment.scratchMemAddr
override val scratchMemSizeInBytes: Int
get() = wasmFragment.scratchMemSizeInBytes
override fun transformType(irType: IrType): WasmType {
return with(typeTransformer) { irType.toWasmValueType() }
}