From 802efd49c6c08ee19b702675b5df57b62711dc61 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Wed, 2 Oct 2024 20:04:18 +0200 Subject: [PATCH] wasm gc: fix String.intern support --- .../org/teavm/backend/wasm/wasm-gc-runtime.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/main/resources/org/teavm/backend/wasm/wasm-gc-runtime.js b/core/src/main/resources/org/teavm/backend/wasm/wasm-gc-runtime.js index 368e74d21..5434dcd23 100644 --- a/core/src/main/resources/org/teavm/backend/wasm/wasm-gc-runtime.js +++ b/core/src/main/resources/org/teavm/backend/wasm/wasm-gc-runtime.js @@ -83,6 +83,14 @@ TeaVM.wasm = function() { } function coreImports(imports) { + let finalizationRegistry = new FinalizationRegistry(heldValue => { + if (typeof exports.reportGarbageCollectedValue === "function") { + exports.reportGarbageCollectedValue(heldValue) + } + }); + let stringFinalizationRegistry = new FinalizationRegistry(heldValue => { + exports.reportGarbageCollectedString(heldValue); + }); imports.teavm = { createWeakRef(value, heldValue) { let weakRef = new WeakRef(value); @@ -102,14 +110,6 @@ TeaVM.wasm = function() { } function jsoImports(imports) { - new FinalizationRegistry(heldValue => { - if (typeof exports.reportGarbageCollectedValue === "function") { - exports.reportGarbageCollectedValue(heldValue) - } - }); - new FinalizationRegistry(heldValue => { - exports.reportGarbageCollectedString(heldValue); - }); let javaObjectSymbol = Symbol("javaObject"); let functionsSymbol = Symbol("functions");