Skip to content

Commit 57b9942

Browse files
committed
update upstream source and toolchain
...to fix eager stack trace creation and wrong FinalizationRegistry.register usage.
1 parent c9bea5d commit 57b9942

File tree

8 files changed

+1105
-1058
lines changed

8 files changed

+1105
-1058
lines changed

Kotlin-compose/build.log

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Built on 2025-07-08 16:39:05+02:00
1+
Built on 2025-08-06 12:54:47+02:00
22
Cloning into 'compose-multiplatform'...
3-
158e4462e8 Use new exception handling proposal for k/wasm targets (#5359)
3+
84dad4d3f6 Use custom skiko (0.9.4.3) to fix the FinalizationRegistry API usage for web targets
44
Copying generated files into build/
55
Build success

Kotlin-compose/build.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ BUILD_LOG="$(realpath build.log)"
99
echo -e "Built on $(date --rfc-3339=seconds)" | tee "$BUILD_LOG"
1010

1111
# Build the benchmark from source.
12-
git clone https://github.com/JetBrains/compose-multiplatform.git |& tee -a "$BUILD_LOG"
12+
# FIXME: Use main branch and remove hotfix patch below, once
13+
# https://youtrack.jetbrains.com/issue/SKIKO-1040 is resolved upstream.
14+
# See https://github.com/WebKit/JetStream/pull/84#discussion_r2252418900.
15+
git clone -b ok/jetstream3_hotfix https://github.com/JetBrains/compose-multiplatform.git |& tee -a "$BUILD_LOG"
1316
pushd compose-multiplatform/
1417
git log -1 --oneline | tee -a "$BUILD_LOG"
18+
# FIXME: Use stable 2.3 Kotlin/Wasm toolchain, once available.
19+
git apply ../register-hotfix.patch | tee -a "$BUILD_LOG"
1520
pushd benchmarks/multiplatform
1621
./gradlew :benchmarks:wasmJsProductionExecutableCompileSync
1722
# For building polyfills and JavaScript launcher to run in d8 (which inspires the benchmark.js launcher here):

Kotlin-compose/build/compose-benchmarks-benchmarks.uninstantiated.mjs

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@ export async function instantiate(imports={}, runInitializer=true) {
1414
const _ref_QGpzLWpvZGEvY29yZQ_ = imports['@js-joda/core'];
1515

1616
const js_code = {
17-
'kotlin.captureStackTrace' : () => new Error().stack,
18-
'kotlin.wasm.internal.throwJsError' : (message, wasmTypeName, stack) => {
19-
const error = new Error();
20-
error.message = message;
21-
error.name = wasmTypeName;
22-
error.stack = stack;
23-
throw error;
24-
},
17+
'kotlin.createJsError' : (message, cause) => new Error(message, { cause }),
2518
'kotlin.wasm.internal.stringLength' : (x) => x.length,
2619
'kotlin.wasm.internal.jsExportStringToWasm' : (src, srcOffset, srcLength, dstAddr) => {
2720
const mem16 = new Uint16Array(wasmExports.memory.buffer, dstAddr, srcLength);
@@ -38,8 +31,8 @@ export async function instantiate(imports={}, runInitializer=true) {
3831
const str = String.fromCharCode.apply(null, mem16);
3932
return (prefix == null) ? str : prefix + str;
4033
},
41-
'kotlin.wasm.internal.intToExternref' : (x) => x,
4234
'kotlin.wasm.internal.externrefToBoolean' : (ref) => Boolean(ref),
35+
'kotlin.wasm.internal.intToExternref' : (x) => x,
4336
'kotlin.wasm.internal.getJsEmptyString' : () => '',
4437
'kotlin.wasm.internal.externrefToString' : (ref) => String(ref),
4538
'kotlin.wasm.internal.externrefEquals' : (lhs, rhs) => lhs === rhs,
@@ -111,17 +104,23 @@ export async function instantiate(imports={}, runInitializer=true) {
111104
},
112105
'kotlin.js.__convertKotlinClosureToJsClosure_(()->Unit)' : (f) => getCachedJsObject(f, () => wasmExports['__callFunction_(()->Unit)'](f, )),
113106
'kotlin.js.jsThrow' : (e) => { throw e; },
114-
'kotlin.io.printError' : (error) => printErr(error),
115107
'kotlin.io.printlnImpl' : (message) => print(message),
108+
'kotlin.io.printError' : (error) => printErr(error),
116109
'kotlin.js.jsArrayGet' : (array, index) => array[index],
117110
'kotlin.js.jsArraySet' : (array, index, value) => { array[index] = value },
118111
'kotlin.js.JsArray_$external_fun' : () => new Array(),
119112
'kotlin.js.length_$external_prop_getter' : (_this) => _this.length,
120113
'kotlin.js.JsArray_$external_class_instanceof' : (x) => x instanceof Array,
114+
'kotlin.js.JsArray_$external_class_get' : () => Array,
121115
'kotlin.js.stackPlaceHolder_js_code' : () => (''),
122116
'kotlin.js.message_$external_prop_getter' : (_this) => _this.message,
117+
'kotlin.js.name_$external_prop_setter' : (_this, v) => _this.name = v,
123118
'kotlin.js.stack_$external_prop_getter' : (_this) => _this.stack,
119+
'kotlin.js.kotlinException_$external_prop_getter' : (_this) => _this.kotlinException,
120+
'kotlin.js.kotlinException_$external_prop_setter' : (_this, v) => _this.kotlinException = v,
124121
'kotlin.js.JsError_$external_class_instanceof' : (x) => x instanceof Error,
122+
'kotlin.js.JsString_$external_class_instanceof' : (x) => typeof x === 'string',
123+
'kotlin.js.JsString_$external_class_get' : () => JsString,
125124
'kotlin.js.Promise_$external_fun' : (p0) => new Promise(p0),
126125
'kotlin.js.__callJsClosure_((Js?)->Unit)' : (f, p0) => f(p0),
127126
'kotlin.js.__callJsClosure_((Js)->Unit)' : (f, p0) => f(p0),
@@ -131,34 +130,15 @@ export async function instantiate(imports={}, runInitializer=true) {
131130
'kotlin.js.then_$external_fun_1' : (_this, p0, p1) => _this.then(p0, p1),
132131
'kotlin.js.__convertKotlinClosureToJsClosure_((Js)->Js?)' : (f) => getCachedJsObject(f, (p0) => wasmExports['__callFunction_((Js)->Js?)'](f, p0)),
133132
'kotlin.js.catch_$external_fun' : (_this, p0) => _this.catch(p0),
133+
'kotlin.js.Promise_$external_class_instanceof' : (x) => x instanceof Promise,
134+
'kotlin.js.Promise_$external_class_get' : () => Promise,
134135
'kotlin.random.initialSeed' : () => ((Math.random() * Math.pow(2, 32)) | 0),
135136
'kotlin.wasm.internal.getJsClassName' : (jsKlass) => jsKlass.name,
136137
'kotlin.wasm.internal.instanceOf' : (ref, jsKlass) => ref instanceof jsKlass,
137138
'kotlin.wasm.internal.getConstructor' : (obj) => obj.constructor,
138139
'kotlin.time.tryGetPerformance' : () => typeof globalThis !== 'undefined' && typeof globalThis.performance !== 'undefined' ? globalThis.performance : null,
139140
'kotlin.time.getPerformanceNow' : (performance) => performance.now(),
140141
'kotlin.time.dateNow' : () => Date.now(),
141-
'kotlinx.coroutines.tryGetProcess' : () => (typeof(process) !== 'undefined' && typeof(process.nextTick) === 'function') ? process : null,
142-
'kotlinx.coroutines.tryGetWindow' : () => (typeof(window) !== 'undefined' && window != null && typeof(window.addEventListener) === 'function') ? window : null,
143-
'kotlinx.coroutines.nextTick_$external_fun' : (_this, p0) => _this.nextTick(p0),
144-
'kotlinx.coroutines.error_$external_fun' : (_this, p0) => _this.error(p0),
145-
'kotlinx.coroutines.console_$external_prop_getter' : () => console,
146-
'kotlinx.coroutines.createScheduleMessagePoster' : (process) => () => Promise.resolve(0).then(process),
147-
'kotlinx.coroutines.__callJsClosure_(()->Unit)' : (f, ) => f(),
148-
'kotlinx.coroutines.createRescheduleMessagePoster' : (window) => () => window.postMessage('dispatchCoroutine', '*'),
149-
'kotlinx.coroutines.subscribeToWindowMessages' : (window, process) => {
150-
const handler = (event) => {
151-
if (event.source == window && event.data == 'dispatchCoroutine') {
152-
event.stopPropagation();
153-
process();
154-
}
155-
}
156-
window.addEventListener('message', handler, true);
157-
},
158-
'kotlinx.coroutines.setTimeout' : (window, handler, timeout) => window.setTimeout(handler, timeout),
159-
'kotlinx.coroutines.clearTimeout' : (handle) => { if (typeof clearTimeout !== 'undefined') clearTimeout(handle); },
160-
'kotlinx.coroutines.setTimeout_$external_fun' : (p0, p1) => setTimeout(p0, p1),
161-
'kotlinx.coroutines.promiseSetDeferred' : (promise, deferred) => promise.deferred = deferred,
162142
'kotlinx.browser.window_$external_prop_getter' : () => window,
163143
'kotlinx.browser.document_$external_prop_getter' : () => document,
164144
'org.w3c.dom.length_$external_prop_getter' : (_this) => _this.length,
@@ -182,32 +162,33 @@ export async function instantiate(imports={}, runInitializer=true) {
182162
'org.w3c.dom.events.type_$external_prop_getter' : (_this) => _this.type,
183163
'org.w3c.dom.events.preventDefault_$external_fun' : (_this, ) => _this.preventDefault(),
184164
'org.w3c.dom.events.Event_$external_class_instanceof' : (x) => x instanceof Event,
165+
'org.w3c.dom.events.Event_$external_class_get' : () => Event,
185166
'org.w3c.dom.events.key_$external_prop_getter' : (_this) => _this.key,
186167
'org.w3c.dom.events.KeyboardEvent_$external_class_instanceof' : (x) => x instanceof KeyboardEvent,
187168
'org.w3c.dom.location_$external_prop_getter' : (_this) => _this.location,
188169
'org.w3c.dom.navigator_$external_prop_getter' : (_this) => _this.navigator,
189170
'org.w3c.dom.devicePixelRatio_$external_prop_getter' : (_this) => _this.devicePixelRatio,
190171
'org.w3c.dom.matchMedia_$external_fun' : (_this, p0) => _this.matchMedia(p0),
191-
'org.w3c.dom.clearTimeout_$external_fun' : (_this, p0, isDefault0) => _this.clearTimeout(isDefault0 ? undefined : p0, ),
192-
'org.w3c.dom.fetch_$external_fun' : (_this, p0, p1, isDefault0) => _this.fetch(p0, isDefault0 ? undefined : p1, ),
193-
'org.w3c.dom.documentElement_$external_prop_getter' : (_this) => _this.documentElement,
172+
'org.w3c.dom.matches_$external_prop_getter' : (_this) => _this.matches,
194173
'org.w3c.dom.protocol_$external_prop_getter' : (_this) => _this.protocol,
195174
'org.w3c.dom.hostname_$external_prop_getter' : (_this) => _this.hostname,
196175
'org.w3c.dom.search_$external_prop_getter' : (_this) => _this.search,
176+
'org.w3c.dom.getData_$external_fun' : (_this, p0) => _this.getData(p0),
177+
'org.w3c.dom.setData_$external_fun' : (_this, p0, p1) => _this.setData(p0, p1),
178+
'org.w3c.dom.language_$external_prop_getter' : (_this) => _this.language,
179+
'org.w3c.dom.clearTimeout_$external_fun' : (_this, p0, isDefault0) => _this.clearTimeout(isDefault0 ? undefined : p0, ),
180+
'org.w3c.dom.fetch_$external_fun' : (_this, p0, p1, isDefault0) => _this.fetch(p0, isDefault0 ? undefined : p1, ),
181+
'org.w3c.dom.documentElement_$external_prop_getter' : (_this) => _this.documentElement,
197182
'org.w3c.dom.namespaceURI_$external_prop_getter' : (_this) => _this.namespaceURI,
198183
'org.w3c.dom.localName_$external_prop_getter' : (_this) => _this.localName,
199184
'org.w3c.dom.getAttribute_$external_fun' : (_this, p0) => _this.getAttribute(p0),
200185
'org.w3c.dom.getAttributeNS_$external_fun' : (_this, p0, p1) => _this.getAttributeNS(p0, p1),
201186
'org.w3c.dom.Element_$external_class_instanceof' : (x) => x instanceof Element,
202-
'org.w3c.dom.matches_$external_prop_getter' : (_this) => _this.matches,
203187
'org.w3c.dom.data_$external_prop_getter' : (_this) => _this.data,
204188
'org.w3c.dom.nodeName_$external_prop_getter' : (_this) => _this.nodeName,
205189
'org.w3c.dom.childNodes_$external_prop_getter' : (_this) => _this.childNodes,
206190
'org.w3c.dom.lookupPrefix_$external_fun' : (_this, p0) => _this.lookupPrefix(p0),
207191
'org.w3c.dom.item_$external_fun' : (_this, p0) => _this.item(p0),
208-
'org.w3c.dom.language_$external_prop_getter' : (_this) => _this.language,
209-
'org.w3c.dom.getData_$external_fun' : (_this, p0) => _this.getData(p0),
210-
'org.w3c.dom.setData_$external_fun' : (_this, p0, p1) => _this.setData(p0, p1),
211192
'org.w3c.dom.binaryType_$external_prop_setter' : (_this, v) => _this.binaryType = v,
212193
'org.w3c.dom.close_$external_fun' : (_this, p0, p1, isDefault0, isDefault1) => _this.close(isDefault0 ? undefined : p0, isDefault1 ? undefined : p1, ),
213194
'org.w3c.dom.send_$external_fun' : (_this, p0) => _this.send(p0),
@@ -226,13 +207,34 @@ export async function instantiate(imports={}, runInitializer=true) {
226207
'org.w3c.fetch.body_$external_prop_getter' : (_this) => _this.body,
227208
'org.w3c.fetch.blob_$external_fun' : (_this, ) => _this.blob(),
228209
'org.w3c.fetch.get_$external_fun' : (_this, p0) => _this.get(p0),
229-
'org.w3c.performance.performance_$external_prop_getter' : (_this) => _this.performance,
230210
'org.w3c.performance.now_$external_fun' : (_this, ) => _this.now(),
211+
'org.w3c.performance.performance_$external_prop_getter' : (_this) => _this.performance,
231212
'org.w3c.xhr.XMLHttpRequest_$external_fun' : () => new XMLHttpRequest(),
232213
'org.w3c.xhr.status_$external_prop_getter' : (_this) => _this.status,
233214
'org.w3c.xhr.open_$external_fun' : (_this, p0, p1, p2, p3, p4, isDefault0, isDefault1) => _this.open(p0, p1, p2, isDefault0 ? undefined : p3, isDefault1 ? undefined : p4, ),
234215
'org.w3c.xhr.send_$external_fun' : (_this, ) => _this.send(),
235216
'org.w3c.xhr.overrideMimeType_$external_fun' : (_this, p0) => _this.overrideMimeType(p0),
217+
'kotlinx.coroutines.tryGetProcess' : () => (typeof(process) !== 'undefined' && typeof(process.nextTick) === 'function') ? process : null,
218+
'kotlinx.coroutines.tryGetWindow' : () => (typeof(window) !== 'undefined' && window != null && typeof(window.addEventListener) === 'function') ? window : null,
219+
'kotlinx.coroutines.nextTick_$external_fun' : (_this, p0) => _this.nextTick(p0),
220+
'kotlinx.coroutines.error_$external_fun' : (_this, p0) => _this.error(p0),
221+
'kotlinx.coroutines.console_$external_prop_getter' : () => console,
222+
'kotlinx.coroutines.createScheduleMessagePoster' : (process) => () => Promise.resolve(0).then(process),
223+
'kotlinx.coroutines.__callJsClosure_(()->Unit)' : (f, ) => f(),
224+
'kotlinx.coroutines.createRescheduleMessagePoster' : (window) => () => window.postMessage('dispatchCoroutine', '*'),
225+
'kotlinx.coroutines.subscribeToWindowMessages' : (window, process) => {
226+
const handler = (event) => {
227+
if (event.source == window && event.data == 'dispatchCoroutine') {
228+
event.stopPropagation();
229+
process();
230+
}
231+
}
232+
window.addEventListener('message', handler, true);
233+
},
234+
'kotlinx.coroutines.setTimeout' : (window, handler, timeout) => window.setTimeout(handler, timeout),
235+
'kotlinx.coroutines.clearTimeout' : (handle) => { if (typeof clearTimeout !== 'undefined') clearTimeout(handle); },
236+
'kotlinx.coroutines.setTimeout_$external_fun' : (p0, p1) => setTimeout(p0, p1),
237+
'kotlinx.coroutines.promiseSetDeferred' : (promise, deferred) => promise.deferred = deferred,
236238
'androidx.compose.runtime.internal.weakMap_js_code' : () => (new WeakMap()),
237239
'androidx.compose.runtime.internal.set_$external_fun' : (_this, p0, p1) => _this.set(p0, p1),
238240
'androidx.compose.runtime.internal.get_$external_fun' : (_this, p0) => _this.get(p0),
@@ -244,7 +246,7 @@ export async function instantiate(imports={}, runInitializer=true) {
244246
'org.jetbrains.skiko.w3c.window_$external_object_getInstance' : () => window,
245247
'org.jetbrains.skiko.w3c.now_$external_fun' : (_this, ) => _this.now(),
246248
'org.jetbrains.skia.impl.FinalizationRegistry_$external_fun' : (p0) => new FinalizationRegistry(p0),
247-
'org.jetbrains.skia.impl.register_$external_fun' : (_this, p0, p1) => _this.register(p0, p1),
249+
'org.jetbrains.skia.impl.register_$external_fun' : (_this, p0, p1, p2) => _this.register(p0, p1, p2),
248250
'org.jetbrains.skia.impl.unregister_$external_fun' : (_this, p0) => _this.unregister(p0),
249251
'org.jetbrains.skia.impl._releaseLocalCallbackScope_$external_fun' : () => _ref_Li9za2lrby5tanM_._releaseLocalCallbackScope(),
250252
'org.jetbrains.skiko.getNavigatorInfo' : () => navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform,
@@ -263,6 +265,8 @@ export async function instantiate(imports={}, runInitializer=true) {
263265
'androidx.compose.ui.platform.emptyClipboardItems' : () => [new ClipboardItem({'text/plain': new Blob([''], { type: 'text/plain' })})],
264266
'androidx.compose.ui.platform.read_$external_fun' : (_this, ) => _this.read(),
265267
'androidx.compose.ui.platform.write_$external_fun' : (_this, p0) => _this.write(p0),
268+
'androidx.compose.ui.platform.W3CTemporaryClipboard_$external_class_instanceof' : (x) => x instanceof Clipboard,
269+
'androidx.compose.ui.platform.W3CTemporaryClipboard_$external_class_get' : () => Clipboard,
266270
'androidx.compose.ui.platform.types_$external_prop_getter' : (_this) => _this.types,
267271
'androidx.compose.ui.platform.getType_$external_fun' : (_this, p0) => _this.getType(p0),
268272
'androidx.compose.foundation.internal.doesJsArrayContainValue' : (jsArray, value) => jsArray.includes(value),
@@ -376,12 +380,15 @@ export async function instantiate(imports={}, runInitializer=true) {
376380
if (!isNodeJs && !isDeno && !isStandaloneJsVM && !isBrowser) {
377381
throw "Supported JS engine not detected";
378382
}
379-
383+
380384
const wasmFilePath = './compose-benchmarks-benchmarks.wasm';
385+
386+
const wasmTag = WebAssembly.JSTag ?? new WebAssembly.Tag({ parameters: ['externref'] });
387+
381388
const importObject = {
382389
js_code,
383390
intrinsics: {
384-
js_error_tag: WebAssembly.JSTag
391+
tag: wasmTag
385392
},
386393
'./skiko.mjs': imports['./skiko.mjs'],
387394

Binary file not shown.

0 commit comments

Comments
 (0)