WebAssembly

현재 번역은 완벽하지 않습니다. 한국어로 문서 번역에 동참해주세요.

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

WebAssembly 자바스크립트 객체는 모든 웹어셈블리에 관계된 기능의 네임스페이스로서 역할합니다.

대부분의 전역객체와 다르게, WebAssembly는 생성자가 아닙니다 (함수 객체가 아닙니다). 비슷한 예로 수학적인 상수나 함수들을 담고있는 Math 객체나, 국제화 관련 생성자나 언어에 민감한 다른 함수들을 담고있는 Intl 등이 있습니다.

설명

WebAssembly 객체의 기본적인 사용례는 다음과 같습니다:

메서드

WebAssembly.instantiate()
The primary API for compiling and instantiating WebAssembly code, returning both a Module and its first Instance.
WebAssembly.compile()
Compiles a WebAssembly.Module from WebAssembly binary code, leaving instantiation as a separate step.
WebAssembly.validate()
Validates a given typed array of WebAssembly binary code, returning whether the bytes are valid WebAssembly code (true) or not (false).

생성자

WebAssembly.Module()
Creates a new WebAssembly Module object.
WebAssembly.Instance()
Creates a new WebAssembly Instance object.
WebAssembly.Memory()
Creates a new WebAssembly Memory object.
WebAssembly.Table()
Creates a new WebAssembly Table object.
WebAssembly.CompileError()
Creates a new WebAssembly CompileError object.
WebAssembly.LinkError()
Creates a new WebAssembly LinkError object.
WebAssembly.RuntimeError()
Creates a new WebAssembly RuntimeError object.

예제

After fetching some WebAssembly bytecode using fetch, we compile and instantiate the module using the WebAssembly.instantiate() function, importing a JavaScript function into the WebAssembly Module in the process. This promise resolves to an object (result) containing the compiled Module and Instance objects. We then call an Exported WebAssembly function that is exported by the Instance.

var importObject = {
  imports: {
    imported_func: function(arg) {
      console.log(arg);
    }
  }
};

fetch('simple.wasm').then(response =>
  response.arrayBuffer()
).then(bytes =>
  WebAssembly.instantiate(bytes, importObject)
).then(result =>
  result.instance.exports.exported_func()
);

Note: See index.html on GitHub (view it live also) for an example that makes use of our fetchAndInstantiate() library function.

스펙

스펙 상태 설명
Web Assembly JavaScript API
The definition of 'WebAssembly' in that specification.
Draft 초안 정의

브라우저 호환성

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 57 No support 52 (52)[1] No support (Yes) No support
Feature Chrome for Android Android Webview Edge Mobile Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 57 57 No support 52.0 (52)[1] No support No support No support

[1] 웹어셈블리는 파이어폭스 52+부터 활성화되었습니다. 다만 파이어폭스 52 확장 지원 릴리즈 (ESR.)에서는 비활성화 돼있습니다.

바깥 고리

문서 태그 및 공헌자

 이 페이지의 공헌자: 0xABCDEF
 최종 변경: 0xABCDEF,