File tree Expand file tree Collapse file tree 5 files changed +19
-6
lines changed
compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm
internal/kotlin/wasm/internal Expand file tree Collapse file tree 5 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -225,7 +225,7 @@ class WasmSymbols(
225225 val unboxIntrinsic: IrSimpleFunctionSymbol = getInternalFunction(" unboxIntrinsic" )
226226
227227 val stringGetLiteralUTF16 = getFunction(" stringLiteralUTF16" , StandardNames .BUILT_INS_PACKAGE_FQ_NAME )
228- val stringGetLiteralLatin = getFunction(" stringLiteralLatin " , StandardNames .BUILT_INS_PACKAGE_FQ_NAME )
228+ val stringGetLiteralRawByte = getFunction(" stringLiteralRawByte " , StandardNames .BUILT_INS_PACKAGE_FQ_NAME )
229229 val stringGetPoolSize = getInternalFunction(" stringGetPoolSize" )
230230
231231 val testFun = maybeGetFunction(" test" , kotlinTestPackageFqName)
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ internal class WasmUsefulDeclarationProcessor(
3434 is IrConstKind .Null -> expression.type.enqueueType(data, " expression type" )
3535 is IrConstKind .String -> {
3636 if ((expression.value as String ).all { it.code in 0 .. 255 }) {
37- context.wasmSymbols.stringGetLiteralLatin .owner
37+ context.wasmSymbols.stringGetLiteralRawByte .owner
3838 .enqueue(data, " String literal intrinsic getter stringGetLiteral" )
3939 } else {
4040 context.wasmSymbols.stringGetLiteralUTF16.owner
Original file line number Diff line number Diff line change @@ -626,7 +626,7 @@ fun generateConstExpression(
626626 body.commentGroupStart { " const string: \" $stringValue \" " }
627627 body.buildConstI32Symbol(literalPoolId, location)
628628 if (isLatin) {
629- body.buildCall(context.referenceFunction(backendContext.wasmSymbols.stringGetLiteralLatin ), location)
629+ body.buildCall(context.referenceFunction(backendContext.wasmSymbols.stringGetLiteralRawByte ), location)
630630 } else {
631631 body.buildCall(context.referenceFunction(backendContext.wasmSymbols.stringGetLiteralUTF16), location)
632632 }
Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ internal fun stringLiteralUTF16(poolId: Int): String {
173173 return newString
174174}
175175
176- internal fun stringLiteralLatin (poolId : Int ): String {
176+ internal fun stringLiteralRawByte (poolId : Int ): String {
177177 val cached = stringPool[poolId]
178178 if (cached != = null ) {
179179 return cached
@@ -190,6 +190,19 @@ internal fun stringLiteralLatin(poolId: Int): String {
190190 chars.set(i, chr)
191191 }
192192
193+ val newString = String (null , length, chars)
194+ stringPool[poolId] = newString
195+ return newString
196+ }
197+
198+ // TODO: remove after bootstrap
199+ internal fun stringLiteral (poolId : Int , start : Int , length : Int ): String {
200+ val cached = stringPool[poolId]
201+ if (cached != = null ) {
202+ return cached
203+ }
204+
205+ val chars = array_new_data0<WasmCharArray >(start, length)
193206 val newString = String (null , length, chars)
194207 stringPool[poolId] = newString
195208 return newString
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ internal fun getQualifiedName(rtti: kotlin.wasm.internal.reftypes.structref): St
6060
6161internal fun getPackageName (rtti : kotlin.wasm.internal.reftypes.structref): String =
6262 if ((wasmGetRttiIntField(5 , rtti) and TYPE_INFO_FLAG_FITS_ONE_BIT_QUALIFIER ) != 0 )
63- stringLiteralLatin (
63+ stringLiteralRawByte (
6464 poolId = wasmGetRttiIntField(2 , rtti),
6565 )
6666 else
@@ -70,7 +70,7 @@ internal fun getPackageName(rtti: kotlin.wasm.internal.reftypes.structref): Stri
7070
7171internal fun getSimpleName (rtti : kotlin.wasm.internal.reftypes.structref): String =
7272 if ((wasmGetRttiIntField(5 , rtti) and TYPE_INFO_FLAG_FITS_ONE_BIT_SIMPLE_NAME ) != 0 )
73- stringLiteralLatin (
73+ stringLiteralRawByte (
7474 poolId = wasmGetRttiIntField(3 , rtti),
7575 )
7676 else
You can’t perform that action at this time.
0 commit comments