WebAssembly
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since â¨2017ë 10ìâ©.
* Some parts of this feature may have varying levels of support.
WebAssembly JavaScript ê°ì²´ë 모ë WebAssemblyì ê´ê³ë 기ë¥ì ë¤ìì¤íì´ì¤ë¡ì ìí í©ëë¤.
ëë¶ë¶ì ì ìê°ì²´ì ë¤ë¥´ê², WebAssemblyë ìì±ìê° ìëëë¤ (í¨ì ê°ì²´ê° ìëëë¤). ë¹ì·í ìë¡ ìíì ì¸ ììë í¨ìë¤ì ë´ê³ ìë Math ê°ì²´ë, êµì í ê´ë ¨ ìì±ìë ì¸ì´ì 민ê°í ë¤ë¥¸ í¨ìë¤ì ë´ê³ ìë Intl ë±ì´ ììµëë¤.
ì¤ëª
WebAssembly ê°ì²´ì 기본ì ì¸ ì¬ì©ë¡ë ë¤ìê³¼ ê°ìµëë¤:
WebAssembly.instantiate()í¨ì를 ì¬ì©í´ì ì¹ì´ì ë¸ë¦¬ ì½ë ë¶ë¬ì¤ê¸°.WebAssembly.Memory()/WebAssembly.Table()ìì±ìë¡ ì ë©ëª¨ë¦¬ì í ì´ë¸ ì¸ì¤í´ì¤ ìì±í기.WebAssembly.CompileError()/WebAssembly.LinkError()/WebAssembly.RuntimeError()ìì±ìë¡ ì¹ì´ì ë¸ë¦¬ìì ë°ìíë ìë¬ì ëí ì²ë¦¬ì¥ì¹ ë§ë¤ê¸°.
ë©ìë
WebAssembly.instantiate()-
WebAssembly ì½ë를 ì»´íì¼íê³ ì¸ì¤í´ì¤ííì¬
Moduleê³¼ 첫 ë²ì§¸Instance를 ë°ííë 기본 APIì ëë¤. WebAssembly.instantiateStreaming()-
ì¤í¸ë¦¬ë° ë ì본 ìì¤ìì ì§ì WebAssembly 모ëì ì»´íì¼íê³ ì¸ì¤í´ì¤ííì¬
Moduleê³¼ 첫 ë²ì§¸Instance를 ë°íí©ëë¤. WebAssembly.compile()-
WebAssembly ë°ì´ë리 ì½ëìì
WebAssembly.Moduleì ì»´íì¼íì¬ ì¸ì¤í´ì¤í를 ë³ëì ë¨ê³ë¡ ë¨ê²¨ ë¡ëë¤. WebAssembly.compileStreaming()-
WebAssembly.Moduleì ì¤í¸ë¦¼ ë ì본 ìì¤ìì ì§ì ì»´íì¼íì¬ ì¸ì¤í´ì¤í를 ë³ëì ë¨ê³ë¡ ë¨ê²¨ ë¡ëë¤. WebAssembly.validate()-
ë°ì´í¸ê° ì í¨í WebAssembly ì½ë (
true)ì¸ì§ ìëì§ (false)를 ë°ííì¬ WebAssembly ë°ì´ë리 ì½ëì ì§ì ë ì ë ¥ ë ë°°ì´ì íì¸í©ëë¤.
ìì±ì
WebAssembly.Global()-
Creates a new WebAssembly
Globalobject. WebAssembly.Module()-
Creates a new WebAssembly
Moduleobject. WebAssembly.Instance()-
Creates a new WebAssembly
Instanceobject. WebAssembly.Memory()-
Creates a new WebAssembly
Memoryobject. WebAssembly.Table()-
Creates a new WebAssembly
Tableobject. WebAssembly.CompileError()-
Creates a new WebAssembly
CompileErrorobject. WebAssembly.LinkError()-
Creates a new WebAssembly
LinkErrorobject. WebAssembly.RuntimeError()-
Creates a new WebAssembly
RuntimeErrorobject.
ìì
ë¤ì ìì (GitHubì instantiate-streaming.html ë°ëª¨ë³´ê¸° ë° ë¼ì´ë¸ë³´ê¸°)ììë 기본 ìì¤ìì .wasm 모ëì ì§ì ì¤í¸ë¦¬ë° í ë¤ì ì»´íì¼íê³ ì¸ì¤í´ì¤íí©ëë¤. íë¡ë¯¸ì¤ë ResultObjectë¡ ì¶©ì¡±ë©ëë¤. instantiateStreaming() í¨ìë Response ê°ì²´ì ëí promise를 ë°ìë¤ì´ë¯ë¡ ì§ì fetch() í¸ì¶ì ì ë¬í ì ììµëë¤.
var importObject = { imports: { imported_func: (arg) => console.log(arg) } };
WebAssembly.instantiateStreaming(fetch("simple.wasm"), importObject).then(
(obj) => obj.instance.exports.exported_func(),
);
ê·¸ë° ë¤ì ResultObjectì ì¸ì¤í´ì¤ 구ì±ì ì¡ì¸ì¤íê³ ê·¸ ìì ìë exported_funcì í¸ì¶í©ëë¤.
ëª ì¸ì
| Specification |
|---|
| WebAssembly JavaScript Interface > # webassembly-namespace > |
ë¸ë¼ì°ì í¸íì±
ë°ê¹¥ ê³ ë¦¬
- ì¹ì´ì ë¸ë¦¬ ê°ì íì´ì§
- ì¹ì´ì ë¸ë¦¬ì 컨ì
- Using the WebAssembly JavaScript API