@@ -554,14 +554,14 @@ const wasmInstances = new SafeWeakMap();
554554translators . set ( 'wasm' , function ( url , translateContext ) {
555555 const { source } = translateContext ;
556556 // WebAssembly global is not available during snapshot building, so we need to get it lazily.
557- const { WebAssembly } = primordialsStaging ;
557+ const { WebAssemblyInstance , WebAssemblyLinkError , WebAssemblyModule } = primordialsStaging ;
558558 assertBufferSource ( source , false , 'load' ) ;
559559
560560 debug ( `Translating WASMModule ${ url } ` , translateContext ) ;
561561
562562 let compiled ;
563563 try {
564- compiled = new WebAssembly . Module ( source , {
564+ compiled = new WebAssemblyModule ( source , {
565565 builtins : [ 'js-string' ] ,
566566 importedStringConstants : 'wasm:js/string-constants' ,
567567 } ) ;
@@ -572,28 +572,28 @@ translators.set('wasm', function(url, translateContext) {
572572
573573 const importsList = new SafeSet ( ) ;
574574 const wasmGlobalImports = [ ] ;
575- for ( const impt of WebAssembly . Module . imports ( compiled ) ) {
575+ for ( const impt of WebAssemblyModule . imports ( compiled ) ) {
576576 if ( impt . kind === 'global' ) {
577577 ArrayPrototypePush ( wasmGlobalImports , impt ) ;
578578 }
579579 // Prefix reservations per https://webassembly.github.io/esm-integration/js-api/index.html#parse-a-webassembly-module.
580580 if ( impt . module . startsWith ( 'wasm-js:' ) ) {
581- throw new WebAssembly . LinkError ( `Invalid Wasm import "${ impt . module } " in ${ url } ` ) ;
581+ throw new WebAssemblyLinkError ( `Invalid Wasm import "${ impt . module } " in ${ url } ` ) ;
582582 }
583583 if ( impt . name . startsWith ( 'wasm:' ) || impt . name . startsWith ( 'wasm-js:' ) ) {
584- throw new WebAssembly . LinkError ( `Invalid Wasm import name "${ impt . module } " in ${ url } ` ) ;
584+ throw new WebAssemblyLinkError ( `Invalid Wasm import name "${ impt . module } " in ${ url } ` ) ;
585585 }
586586 importsList . add ( impt . module ) ;
587587 }
588588
589589 const exportsList = new SafeSet ( ) ;
590590 const wasmGlobalExports = new SafeSet ( ) ;
591- for ( const expt of WebAssembly . Module . exports ( compiled ) ) {
591+ for ( const expt of WebAssemblyModule . exports ( compiled ) ) {
592592 if ( expt . kind === 'global' ) {
593593 wasmGlobalExports . add ( expt . name ) ;
594594 }
595595 if ( expt . name . startsWith ( 'wasm:' ) || expt . name . startsWith ( 'wasm-js:' ) ) {
596- throw new WebAssembly . LinkError ( `Invalid Wasm export name "${ expt . name } " in ${ url } ` ) ;
596+ throw new WebAssemblyLinkError ( `Invalid Wasm export name "${ expt . name } " in ${ url } ` ) ;
597597 }
598598 exportsList . add ( expt . name ) ;
599599 }
@@ -620,7 +620,7 @@ translators.set('wasm', function(url, translateContext) {
620620 }
621621 // In cycles importing unexecuted Wasm, wasmInstance will be undefined, which will fail during
622622 // instantiation, since all bindings will be in the Temporal Deadzone (TDZ).
623- const { exports } = new WebAssembly . Instance ( compiled , reflect . imports ) ;
623+ const { exports } = new WebAssemblyInstance ( compiled , reflect . imports ) ;
624624 wasmInstances . set ( module . getNamespace ( ) , exports ) ;
625625 for ( const expt of exportsList ) {
626626 let val = exports [ expt ] ;
0 commit comments