File tree Expand file tree Collapse file tree 3 files changed +26
-15
lines changed Expand file tree Collapse file tree 3 files changed +26
-15
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright 2025 the V8 project authors. All rights reserved.
2
+ // Copyright 2025 Apple Inc. All rights reserved.
2
3
// Use of this source code is governed by a BSD-style license that can be
3
4
// found in the LICENSE file.
4
5
@@ -34,14 +35,24 @@ function dumpFrame(vec) {
34
35
35
36
class Benchmark {
36
37
isInstantiated = false ;
38
+ romBinary ;
39
+
40
+ async init ( ) {
41
+ if ( isInBrowser ) {
42
+ let response = await fetch ( romBinary ) ;
43
+ this . romBinary = new Int8Array ( await response . arrayBuffer ( ) ) ;
44
+ } else {
45
+ this . romBinary = new Int8Array ( read ( romBinary , "binary" ) ) ;
46
+ }
47
+ }
37
48
38
49
async runIteration ( ) {
39
50
if ( ! this . isInstantiated ) {
40
51
await wasm_bindgen ( Module . wasmBinary ) ;
41
52
this . isInstantiated = true ;
42
53
}
43
54
44
- wasm_bindgen . loadRom ( Module . romBinary ) ;
55
+ wasm_bindgen . loadRom ( this . romBinary ) ;
45
56
46
57
const frameCount = 2 * 60 ;
47
58
for ( let i = 0 ; i < frameCount ; ++ i ) {
Original file line number Diff line number Diff line change @@ -266,19 +266,14 @@ class Benchmark {
266
266
// is a map from module variable name (which will hold the resulting module
267
267
// namespace object) to relative module URL, which is resolved in the
268
268
// `preRunnerCode`, similar to this code here.
269
- if ( isInBrowser ) {
270
- // In browsers, relative imports don't work since we are not in a module.
271
- // (`import.meta.url` is not defined.)
272
- const pathname = location . pathname . match ( / ^ ( .* \/ ) (?: [ ^ . ] + (?: \. (?: [ ^ \/ ] + ) ) + ) ? $ / ) [ 1 ] ;
273
- this . dart2wasmJsModule = await import ( location . origin + pathname + "./Dart/build/flute.dart2wasm.mjs" ) ;
274
- } else {
269
+
270
+ try {
271
+ this . dart2wasmJsModule = await import ( jsModule ) ;
272
+ } catch {
275
273
// In shells, relative imports require different paths, so try with and
276
274
// without the "./" prefix (e.g., JSC requires it).
277
- try {
278
- this . dart2wasmJsModule = await import ( "Dart/build/flute.dart2wasm.mjs" ) ;
279
- } catch {
280
- this . dart2wasmJsModule = await import ( "./Dart/build/flute.dart2wasm.mjs" ) ;
281
- }
275
+ if ( ! isInBrowser )
276
+ this . dart2wasmJsModule = await import ( jsModule . slice ( "./" . length ) )
282
277
}
283
278
}
284
279
Original file line number Diff line number Diff line change @@ -1228,8 +1228,12 @@ class WasmEMCCBenchmark extends AsyncBenchmark {
1228
1228
}
1229
1229
` ;
1230
1230
1231
- for ( let [ preloadKey , blobURLOrPath ] of this . preloads )
1232
- str += `await getBinary("${ preloadKey } ", "${ blobURLOrPath } ");\n`
1231
+ for ( let [ preloadKey , blobURLOrPath ] of this . preloads ) {
1232
+ if ( preloadKey == "wasmBinary" ) {
1233
+ str += `await getBinary("${ preloadKey } ", "${ blobURLOrPath } ");\n`
1234
+ break ;
1235
+ }
1236
+ }
1233
1237
1234
1238
str += super . runnerCode ;
1235
1239
@@ -2078,7 +2082,8 @@ let BENCHMARKS = [
2078
2082
"./Dart/benchmark.js" ,
2079
2083
] ,
2080
2084
preload : {
2081
- wasmBinary : "./Dart/build/flute.dart2wasm.wasm"
2085
+ jsModule : "./Dart/build/flute.dart2wasm.mjs" ,
2086
+ wasmBinary : "./Dart/build/flute.dart2wasm.wasm" ,
2082
2087
} ,
2083
2088
iterations : 15 ,
2084
2089
worstCaseCount : 2 ,
You can’t perform that action at this time.
0 commit comments