[WASM] Fast load string literals from data section

This commit is contained in:
Igor Yakovlev
2022-10-14 00:03:51 +02:00
committed by teamcity
parent 033e2c45f1
commit 0e16889f45
9 changed files with 42 additions and 24 deletions
@@ -130,15 +130,14 @@ public class String internal @WasmPrimitiveConstructor constructor(
internal inline fun WasmCharArray.createString(): String =
String(null, this.len(), this)
internal fun stringLiteral(poolId: Int, startAddress: Int, length: Int, hashCode: Int): String {
internal fun stringLiteral(poolId: Int, startAddress: Int, length: Int): String {
val cached = stringPool[poolId]
if (cached !== null) {
return cached
}
val chars = WasmCharArray(length)
unsafeRawMemoryToWasmCharArray(startAddress, 0, length, chars)
val chars = array_new_data0<WasmCharArray>(startAddress, length)
val newString = String(null, length, chars)
newString._hashCode = hashCode
stringPool[poolId] = newString
return newString
}