Skip to content

Commit 4de8482

Browse files
authored
Merge pull request WebKit#138 from danleh/kotlin-fix-isD8-access
Kotlin-compose: do not access isD8 global
2 parents 818aefa + 14f3c8e commit 4de8482

File tree

5 files changed

+45
-5
lines changed

5 files changed

+45
-5
lines changed

Kotlin-compose/build.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Built on 2025-08-08 16:11:09+02:00
1+
Built on 2025-08-14 12:27:42+02:00
22
Cloning into 'compose-multiplatform'...
33
84dad4d3f6 Use custom skiko (0.9.4.3) to fix the FinalizationRegistry API usage for web targets
44
Copying generated files into build/

Kotlin-compose/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -eo pipefail
44

55
# Cleanup old files.
66
rm -rf build/
7+
rm -rf compose-multiplatform/
78

89
BUILD_LOG="$(realpath build.log)"
910
echo -e "Built on $(date --rfc-3339=seconds)" | tee "$BUILD_LOG"
@@ -15,6 +16,10 @@ echo -e "Built on $(date --rfc-3339=seconds)" | tee "$BUILD_LOG"
1516
git clone -b ok/jetstream3_hotfix https://github.com/JetBrains/compose-multiplatform.git |& tee -a "$BUILD_LOG"
1617
pushd compose-multiplatform/
1718
git log -1 --oneline | tee -a "$BUILD_LOG"
19+
# Do not read `isD8` in the main function which decides whether to run eagerly.
20+
# Instead, just patch that out statically.
21+
# TODO: Upstream that fix to the compose-multiplatform repo.
22+
git apply ../empty-main-function.patch | tee -a "$BUILD_LOG"
1823
# FIXME: Use stable 2.3 Kotlin/Wasm toolchain, once available around Sep 2025.
1924
git apply ../use-beta-toolchain.patch | tee -a "$BUILD_LOG"
2025
pushd benchmarks/multiplatform

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ export async function instantiate(imports={}, runInitializer=true) {
172172
'org.w3c.dom.matches_$external_prop_getter' : (_this) => _this.matches,
173173
'org.w3c.dom.protocol_$external_prop_getter' : (_this) => _this.protocol,
174174
'org.w3c.dom.hostname_$external_prop_getter' : (_this) => _this.hostname,
175-
'org.w3c.dom.search_$external_prop_getter' : (_this) => _this.search,
176175
'org.w3c.dom.getData_$external_fun' : (_this, p0) => _this.getData(p0),
177176
'org.w3c.dom.setData_$external_fun' : (_this, p0, p1) => _this.setData(p0, p1),
178177
'org.w3c.dom.language_$external_prop_getter' : (_this) => _this.language,
@@ -198,8 +197,6 @@ export async function instantiate(imports={}, runInitializer=true) {
198197
'org.w3c.dom.reason_$external_prop_getter' : (_this) => _this.reason,
199198
'org.w3c.dom.parsing.DOMParser_$external_fun' : () => new DOMParser(),
200199
'org.w3c.dom.parsing.parseFromString_$external_fun' : (_this, p0, p1) => _this.parseFromString(p0, p1),
201-
'org.w3c.dom.url.URLSearchParams_$external_fun' : (p0, isDefault0) => new URLSearchParams(isDefault0 ? undefined : p0, ),
202-
'org.w3c.dom.url.get_$external_fun' : (_this, p0) => _this.get(p0),
203200
'org.w3c.fetch.status_$external_prop_getter' : (_this) => _this.status,
204201
'org.w3c.fetch.ok_$external_prop_getter' : (_this) => _this.ok,
205202
'org.w3c.fetch.statusText_$external_prop_getter' : (_this) => _this.statusText,
@@ -358,7 +355,6 @@ export async function instantiate(imports={}, runInitializer=true) {
358355
'io.ktor.client.utils.makeJsNew' : (ctor) => new ctor(),
359356
'io.ktor.client.utils.setObjectField' : (obj, name, value) => obj[name]=value,
360357
'io.ktor.client.utils.toJsArrayImpl' : (x) => new Uint8Array(x),
361-
'isD8env' : () => typeof isD8 !== 'undefined',
362358
'runGC' : () => { (typeof gc === 'function')? gc() : console.log('Manual GC is not available. Ensure that the browser was started with the appropriate flags.') }
363359
}
364360

-7.44 KB
Binary file not shown.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
diff --git a/benchmarks/multiplatform/benchmarks/src/wasmJsMain/kotlin/main.wasmJs.kt b/benchmarks/multiplatform/benchmarks/src/wasmJsMain/kotlin/main.wasmJs.kt
2+
index d796d88975..f2c9e48eda 100644
3+
--- a/benchmarks/multiplatform/benchmarks/src/wasmJsMain/kotlin/main.wasmJs.kt
4+
+++ b/benchmarks/multiplatform/benchmarks/src/wasmJsMain/kotlin/main.wasmJs.kt
5+
@@ -8,11 +8,6 @@ import kotlin.js.Promise
6+
val jsOne = 1.toJsNumber()
7+
8+
fun main(args: Array<String>) {
9+
- if (isD8env().toBoolean()) {
10+
- mainD8(args)
11+
- } else {
12+
- mainBrowser()
13+
- }
14+
}
15+
16+
fun mainBrowser() {
17+
@@ -37,15 +32,6 @@ fun mainBrowser() {
18+
}
19+
}
20+
21+
-
22+
-// Currently, the initialization can't be adjusted to avoid calling the fun main, but
23+
-// we don't want use the default fun main, because Jetstream3 requires running the workloads separately / independently of each other.
24+
-// Also, they require that a benchmark completes before the function exists, which is not possible with if they just call fun main.
25+
-// Therefore, they'll rely on fun customLaunch, which returns a Promise (can be awaited for).
26+
-fun mainD8(args: Array<String>) {
27+
- println("mainD8 is intentionally doing nothing. Read the comments in main.wasmJs.kt")
28+
-}
29+
-
30+
private val basicConfigForD8 = Config(
31+
// Using only SIMPLE mode, because VSYNC_EMULATION calls delay(...),
32+
// which is implemented via setTimeout on web targets.
33+
@@ -85,6 +71,3 @@ fun d8BenchmarksRunner(args: String): Promise<JsAny?> {
34+
jsOne
35+
}
36+
}
37+
-
38+
-private fun isD8env(): JsBoolean =
39+
- js("typeof isD8 !== 'undefined'")

0 commit comments

Comments
 (0)