コンテンツにスキップ

「WebAssembly」の版間の差分

出典: フリー百科事典『ウィキペディア(Wikipedia)』
削除された内容 追加された内容
m 外部リンクの修正 http:// -> https:// (pc.watch.impress.co.jp) (Botによる編集)
m →‎Webブラウザ: 仮リンクへの変更
 
(12人の利用者による、間の24版が非表示)
1行目: 1行目:
{{Infobox プログラミング言語
{{Infobox プログラミング言語
| name = WebAssembly
| name = WebAssembly
| title =
| title =WebAssembly
| logo = [[ファイル:WebAssembly Logo.svg|180px]]
| logo = [[ファイル:WebAssembly Logo.svg|180px]]
| logo caption =
| logo caption =
31行目: 31行目:
}}
}}


'''WebAssembly'''(ウェブアセンブリ、公式の略称は'''Wasm'''<ref>"abbreviated '''Wasm''' ... A contraction of “WebAssembly”, not an acronym, hence not using all-caps." [https://webassembly.github.io/spec/core/intro/introduction.html#introduction WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021)] 2021-03-26閲覧</ref>)は、[[実行可能ファイル]]を表現するための[[可搬性|可搬]]なバイナリコード形式(およびそれに対応するテキスト形式<ref>{{cite web |author1=Mozilla |title=Understanding WebAssembly text format |url=https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format |access-date=9 December 2019 |website=MDN Web Docs |language=en-US}}</ref>)を定め、同時にそのような実行可能プログラムとホスト環境との間のやりとりを容易にするための[[ソフトウェアインタフェース]]を提供するものである<ref>{{Cite web |url=https://webassembly.github.io/spec/core/intro/introduction.html |title=Introduction — WebAssembly 1.0 |website=webassembly.github.io |access-date=18 June 2019 |quote=WebAssembly is an open standard...}}</ref><ref>{{Cite web |url=https://webassembly.github.io/spec/core/intro/introduction.html |title=Introduction — WebAssembly 1.0 |website=webassembly.github.io |access-date=18 June 2019 |quote=WebAssembly is a ... code format}}</ref><ref name=":0">{{Cite web |url=https://webassembly.github.io/spec/core/syntax/conventions.html |title=Conventions — WebAssembly 1.0 |website=webassembly.github.io |access-date=17 May 2019 |quote=WebAssembly is a programming language that has multiple concrete representations (its binary format and the text format). Both map to a common structure.}}</ref><ref>{{Cite web |url=https://webassembly.github.io/spec/core/intro/introduction.html |title=Introduction — WebAssembly 1.0 |website=webassembly.github.io |access-date=18 June 2019 |quote=... this specification is complemented by additional documents defining interfaces to specific embedding environments such as the Web. These will each define a WebAssembly application programming interface (API) suitable for a given environment.}}</ref>。
'''WebAssembly'''は仮想[[命令セット]]アーキテクチャあるいは[[プログラミング言語]]の一種である<ref>"At its core, WebAssembly is a ''virtual instruction set architecture (virtual ISA)''." [https://webassembly.github.io/spec/core/intro/introduction.html#scope WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021)] 2021-03-26閲覧</ref>。略称は'''Wasm'''<ref>"abbreviated '''Wasm''' ... A contraction of “WebAssembly”, not an acronym, hence not using all-caps." [https://webassembly.github.io/spec/core/intro/introduction.html#introduction WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021)] 2021-03-26閲覧</ref>。[[C言語|C]]・[[Rust (プログラミング言語)|Rust]]など様々なプログラミング言語のコンパイルターゲットとしてWasmバイナリは生成され、[[ウェブブラウザ]]を含む様々な環境内の[[スタックマシン|スタックベース]]仮想マシンにより実行される。


Wasmの当初の目的は、ウェブページ上で高パフォーマンスなアプリケーションを実現することであった。しかし「ウェブ特有の仮定は一切しておらず、ウェブ特有の機能を提供するわけでもないので、他の環境で同様に採用できる」<ref>{{Cite web |title=Introduction — WebAssembly 1.1 |url=https://webassembly.github.io/spec/core/intro/introduction.html |access-date=2021-02-19 |quote=Its main goal is to enable high performance applications on the Web, but it does not make any Web-specific assumptions or provide Web-specific features, so it can be employed in other environments as well. |website=webassembly.github.io}}</ref>としている。Wasmは[[オープン標準]]であり<ref>{{Cite journal|last1=Haas|first1=Andreas|last2=Rossberg|first2=Andreas|last3=Schuff|first3=Derek L.|last4=Titzer|first4=Ben L.|last5=Holman|first5=Michael|last6=Gohman|first6=Dan|last7=Wagner|first7=Luke|last8=Zakai|first8=Alon|last9=Bastien|first9=JF|date=14 June 2017|title=Bringing the Web Up to Speed with WebAssembly|journal=SIGPLAN Notices|volume=52|issue=6|pages=185–200|doi=10.1145/3140587.3062363|issn=0362-1340|quote=While the Web is the primary motivation for WebAssembly, nothing in its design depends on the Web or a JavaScript environment. It is an open standard specifically designed for embedding in multiple contexts, and we expect that stand-alone implementations will become available in the future.|doi-access=free}}</ref><ref name=":14">{{Cite web |title=Outside the web: standalone WebAssembly binaries using Emscripten · V8 |url=https://v8.dev/blog/emscripten-standalone-wasm#running-in-wasm-runtimes |access-date=2020-07-28 |website=v8.dev}}</ref>、あらゆるオペレーティングシステム上であらゆる言語をサポートすることを目指している<ref name="Wasmer3">{{Cite web |title=Wasmer - The Universal WebAssembly Runtime |url=https://wasmer.io/ |quote=Compile everything to WebAssembly. Run it on any OS or embed it into other languages. |access-date=2021-02-19 |website=wasmer.io}}</ref>。実際に、最も有名な言語のすべてが、少なくともいくらかのレベルでWasmに対応している。
ネイティブコード相当の<u>高速性</u>・隔離環境でのメモリ安全な実行による<u>安全性</u>・仮想マシンによるハードウェア/プラットフォーム<u>可搬性</u>・ソースプログラミング言語<u>中立性</u>などを特徴とする<ref>"The design goals of WebAssembly are the following ... '''Fast''': executes with near native code performance ... '''Safe''': code is validated and executes in a memory-safe, sandboxed environment ... '''Hardware-independent''' ... '''Language-independent''' ... '''Platform-independent''': can be embedded in browsers, run as a stand-alone VM, or integrated in other environments" [https://webassembly.github.io/spec/core/intro/introduction.html#design-goals WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021)] 2021-03-26閲覧</ref>。この命令セットはバイナリ形式で定義されており、また[[アセンブリ言語]]ライクなテキスト形式も定義されている(その意味で[[低水準言語|低水準プログラミング言語]]といえる)。


Wasm自体は命令セットアーキテクチャり、Linuxカーネルが提供すようなシステムコール(例: ファイルI/O)、Webブウザが提供するようなDOMアクセスなどを提供していない<ref>"This document is concerned with the core ISA layer of WebAssembly. ... It does '''not''', however, define how WebAssembly programs can interact with a specific environment they execute in" [https://webassembly.github.io/spec/core/intro/introduction.html#scope WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021)] 2021-03-26閲覧</ref>。上記の安全性や可搬性はこの特徴に由来している。それと同時にWasmエコシステムしてはシステムやDOMアクセスがAPIとして個別に定義されておりWasmイムが装すことそれら機能を提供してい(例: ステムコ提供する'''WASI''')<ref>"Instead, this specification is complemented by additional documents defining interfaces to specific embedding environments such as the Web. These will each define a WebAssembly ''application programming interface (API)'' suitable for a given environment." [https://webassembly.github.io/spec/core/intro/introduction.html#scope WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021)] 2021-03-26閲覧</ref>。シンプルでオープンなISAとランタイムごとのAPIを組み合わせることでWasmエコシステムは高い拡張性を有している。例えばWasmをHTTPプロキシでのフィルタスクリプトとして利用するプロジェクトが存在する
Wasmは、仮想の[[命令セット]]アーキテクチャあるいは[[プログミング言語]]の一種<ref>"At its core, WebAssembly is a ''virtual instruction set architecture (virtual ISA)''." [https://webassembly.github.io/spec/core/intro/introduction.html#scope WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021)] 2021-03-26閲覧</ref>とも捉えられる。多くの場合[[C言語|C]]/[[C++]], [[Rust (プログラミング言語)|Rust]]いったプログラミング言語のンパイとしてWasmバイナリが生成され、[[ウェブブウザ]]やその他のソフトウェア環境内で、[[スックマシン]]によって行され。ネイティブコードに近い高速さ、隔離環境でのメモリ安全な実行によ安全性、仮想マンによる可搬性やソスプログラミング言語中立性など特徴とする<ref>"The design goals of WebAssembly are the following ... '''Fast''': executes with near native code performance ... '''Safe''': code is validated and executes in a memory-safe, sandboxed environment ... '''Hardware-independent''' ... '''Language-independent''' ... '''Platform-independent''': can be embedded in browsers, run as a stand-alone VM, or integrated in other environments" [https://webassembly.github.io/spec/core/intro/introduction.html#design-goals WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021)] 2021-03-26閲覧</ref>。


Wasmは2015年に発表され、2017年3月に初めてリリースされたWebAssemblyは、2019年12月5日に[[W3C勧告]]となり、2021年の [[Association for Computing Machinery|ACM]] SIGPLAN のプログラミング言語ソフトウェア賞を受賞した<ref>{{Cite web |url=http://www.sigplan.org/Awards/Software/ |title=Programming Languages Software Award |website=www.sigplan.org |access-date=2024-03-17}}</ref>。[[World Wide Web Consortium]] (W3C) が技術標準を管理しており、有名な大企業なども加盟する非営利団体「Bytecode Alliance」が貢献している<ref name="bytecode3">{{Cite news |url=https://blog.mozilla.org/press/2019/11/new-bytecode-alliance-brings-the-security-ubiquity-and-interoperability-of-the-web-to-the-world-of-pervasive-computing/ |title=New Bytecode Alliance Brings the Security, Ubiquity, and Interoperability of the Web to the World of Pervasive Computing |date=12 November 2019 |work=Mozilla |access-date=27 May 2019 |language=en}}</ref><ref name="ars">{{Cite web |first=Peter |last=Bright |url=http://arstechnica.com/information-technology/2015/06/the-web-is-getting-its-bytecode-webassembly/ |title=The Web is getting its bytecode: WebAssembly |work=Ars Technica |publisher=[[コンデナスト・パブリケーションズ|Condé Nast]] |date=18 June 2015 |accessdate=2017-03-11}}</ref>。
== 設計 ==
WebAssemblyはポータブルな[[スタックマシン]]<ref>{{Cite web|url=https://github.com/WebAssembly/design/blob/master/Rationale.md#why-a-stack-machine|title=Design Rationale|date=1 October 2016|work=[[GitHub]] / WebAssembly / design|accessdate=2017-03-11}}</ref>であり、既存のウェブブラウザで広く用いられている[[JavaScript]]と比べ、構文解析と実行が高速になるよう設計されている<ref name="github.com">{{Cite web|url=https://github.com/WebAssembly/design/blob/master/HighLevelGoals.md|title=WebAssembly High-Level Goals|date=11 December 2015|work=[[GitHub]] / WebAssembly / design|accessdate=2017-03-11}}</ref>。


== 歴史 ==
== 歴史 ==
WebAssembly という命名は、1950年代にまで遡る「[[アセンブリ言語]]」の概念を想起させるためのものであり、アセンブリのようなプログラミングを、Webのクライアントサイド(つまりユーザのWebブラウザを介したユーザのコンピュータ上)で実行される世界に持ち込むことを示唆している。これを実現するために、WebAssemblyは、真のアセンブリ言語に比べて圧倒的にハードウェア非依存でなければならない。
WebAssemblyの最初のアナウンスは[[2015年]]6月17日に行われ<ref>{{Cite web|url=https://github.com/WebAssembly/design/issues/150|title=Launch bug|date=11 June 2015|website=[[GitHub]] / WebAssembly / design|accessdate=2017-03-11}}</ref>、[[2016年]]3月15日には主要ブラウザ ([[Mozilla Firefox|Firefox]], [[Chromium]], [[Google Chrome]], [[Microsoft Edge]]) 上で[[Unity (ゲームエンジン)|Unity]]によるAngry Botsというデモが行われた<ref>{{Cite web|url=https://hacks.mozilla.org/2016/03/a-webassembly-milestone/|title=A WebAssembly Milestone: Experimental Support in Multiple Browsers|last=Wagner|first=Luke|date=14 March 2016|website=Mozilla Hacks|accessdate=2017-03-11}}</ref><ref>{{Cite web|url=http://v8project.blogspot.com/2016/03/experimental-support-for-webassembly.html|title=Experimental support for WebAssembly in V8|last=Thompson|first=Seth|date=15 March 2016|website=V8 Blog|accessdate=2017-03-11}}</ref><ref>{{Cite web|url=https://blogs.windows.com/msedgedev/2016/03/15/previewing-webassembly-experiments/|title=Previewing WebAssembly experiments in Microsoft Edge|last=Zhu|first=Limin|date=15 March 2016|website=Microsoft Edge dev blog|accessdate=2017-03-11}}</ref>。


WebAssemblyの最初のアナウンスは[[2015年]]6月17日に行われ<ref>{{Cite web |url=https://github.com/WebAssembly/design/issues/150 |title=Launch bug |date=11 June 2015 |website=[[GitHub]] / WebAssembly / design |accessdate=2017-03-11}}</ref>、[[2016年]]3月15日に公開された初のデモ主要ブラウザ ([[Mozilla Firefox|Firefox]], [[Chromium]], [[Google Chrome]], [[Microsoft Edge]]) 上で[[Unity (ゲームエンジン)|Unity]]Angry Botsを動かすものだった<ref>{{Cite web |url=https://hacks.mozilla.org/2016/03/a-webassembly-milestone/ |title=A WebAssembly Milestone: Experimental Support in Multiple Browsers |last=Wagner |first=Luke |date=14 March 2016 |website=Mozilla Hacks |accessdate=2017-03-11}}</ref><ref>{{Cite web |url=http://v8project.blogspot.com/2016/03/experimental-support-for-webassembly.html |title=Experimental support for WebAssembly in V8 |last=Thompson |first=Seth |date=15 March 2016 |website=V8 Blog |accessdate=2017-03-11}}</ref><ref>{{Cite web |url=https://blogs.windows.com/msedgedev/2016/03/15/previewing-webassembly-experiments/ |title=Previewing WebAssembly experiments in Microsoft Edge |last=Zhu |first=Limin |date=15 March 2016 |website=Microsoft Edge dev blog |accessdate=2017-03-11}}</ref>。前身となった技術は、[[Mozilla]]による {{仮リンク|asm.js|en|asm.js}}と [[Google Native Client]] であり、最初の実装は asm.js の機能セットに基づいて行われた。asm.jsはすでにネイティブに近いコード実行速度を提供しており<ref>{{Cite web |url=https://blog.mozilla.org/javascript/2013/08/01/staring-at-the-sun-dalvik-vs-spidermonkey/ |title=Staring at the Sun: Dalvik vs. ASM.js vs. Native |website=blog.mozilla.org |date=August 2013 |access-date=7 December 2019 |quote=Even discarding the one score where asm.js did better, it executes at around 70% of the speed of native C++ code.}}</ref><ref>{{Cite book |last=Arjun |first=Jangda, Abhinav Powers, Bobby Berger, Emery Guha |url=http://worldcat.org/oclc/1106328738 |title=Not So Fast: Analyzing the Performance of WebAssembly vs. Native Code |date=2019-01-25 |oclc=1106328738}}</ref>、WebAssembly非対応の環境やセキュリティ上の理由で無効化している環境での実用可能な代替とみなすことができた
最初の目標として[[C言語|C]]と[[C++]]からのコンパイルをサポートすることを目指し<ref name="github.com" />、[[Rust (プログラミング言語)|Rust]]がバージョン1.14以降で<ref name="Rust">{{Cite web|url=https://blog.rust-lang.org/2016/12/22/Rust-1.14.html|title=Announcing Rust 1.14|date=22 December 2016|website=The Rust Programming Language Blog|accessdate=2017-03-11}}</ref>、[[Go (プログラミング言語)|Go]]がバージョン1.11以降で<ref name="Golang">{{Cite web|url=https://blog.golang.org/go1.11|title=Go 1.11 is released|date=24 August 2018|website=The Go Blog|accessdate=2018-10-04}}</ref>、[[Kotlin|Kotlin/Native]]がバージョン0.4以降で<ref name="Kotlin/Native">{{Cite web|url=https://blog.jetbrains.com/kotlin/2017/11/kotlinnative-v0-4-released-objective-c-interop-webassembly-and-more/|title=Kotlin/Native v0.4 released: Objective-C interop, WebAssembly and more|date=16 November 2017|website=KOTLIN BLOG|accessdate=2019-01-12}}</ref>で対応するなど、他のプログラミング言語のサポートも進められた。


最初の目標として[[C言語|C]]と[[C++]]からのコンパイルをサポートすることを目指し<ref name="github.com" />、[[Rust (プログラミング言語)|Rust]]がバージョン1.14以降で<ref name="Rust">{{Cite web |url=https://blog.rust-lang.org/2016/12/22/Rust-1.14.html |title=Announcing Rust 1.14 |date=22 December 2016 |website=The Rust Programming Language Blog |accessdate=2017-03-11}}</ref>、[[Go (プログラミング言語)|Go]]がバージョン1.11以降で<ref name="Golang">{{Cite web |url=https://blog.golang.org/go1.11 |title=Go 1.11 is released |date=24 August 2018 |website=The Go Blog |accessdate=2018-10-04}}</ref>、[[Kotlin|Kotlin/Native]]がバージョン0.4以降で<ref name="Kotlin/Native">{{Cite web |url=https://blog.jetbrains.com/kotlin/2017/11/kotlinnative-v0-4-released-objective-c-interop-webassembly-and-more/ |title=Kotlin/Native v0.4 released: Objective-C interop, WebAssembly and more |date=16 November 2017 |website=KOTLIN BLOG |accessdate=2019-01-12}}</ref>で対応するなど、他のプログラミング言語のサポートも進められた。
[[2017年]]3月7日、WebAssemblyに標準対応した初のブラウザとなるFirefox 52.0がリリースされた<ref name="impress20170308">{{Cite web|url=https://pc.watch.impress.co.jp/docs/news/1048382.html|title=Firefox、ゲームなどをネイティブ並に高速実行する「WebAssembly」を採用|publisher=[[Impress Watch]]|date=2017-03-08|accessdate=2017-03-11}}</ref>。2017年11月、Mozillaは[[Safari]]とEdgeがWebAssemblyに対応したと発表し、すでに対応しているChromeとFirefoxを含め、主要なブラウザすべてでサポートされことになった<ref>{{Cite web |author=長岡弥太郎 |date=2017-11-14 |url=https://news.mynavi.jp/article/20171114-a088/ |title=WebAssemblyが主要ブラウザでサポート - Mozilla official blog |publisher=[[マイナビニュース]] |accessdate=2017-11-14}}</ref>。


[[2017年]]3月に[[実用最小限の製品|MVP]]の設計が完了したことが宣言され、WebAssemblyに標準対応した初のブラウザとなるFirefox 52.0がリリースされた<ref name="impress20170308">{{Cite web|和書|url=https://pc.watch.impress.co.jp/docs/news/1048382.html |title=Firefox、ゲームなどをネイティブ並に高速実行する「WebAssembly」を採用 |publisher=[[Impress Watch]] |date=2017-03-08 |accessdate=2017-03-11}}</ref>。2017年11月、MozillaはMicrosoft EdgeがWebAssemblyに対応し、すでに対応しているChromeとFirefoxを含め、主要なブラウザすべてでサポートされことを発表した<ref>{{Cite web|和書|author=長岡弥太郎 |date=2017-11-14 |url=https://news.mynavi.jp/techplus/article/20171114-a088/ |title=WebAssemblyが主要ブラウザでサポート - Mozilla official blog |publisher=[[マイナビニュース]] |accessdate=2017-11-14}}</ref>。2018年2月には、WebAssembly Working Groupが、3つのワーキングドラフト「Core Specification」「JavaScript Interface」「Web API」を公開した
2019-12-05[[W3C勧告]]「[https://www.w3.org/TR/wasm-core-1/ WebAssembly Core Specification]」が策定され、WebAssemblyは正式なウェブ標準に認定された<ref>5 December 2019 — The World Wide Web Consortium (W3C) announced today that the WebAssembly Core Specification is now an official web standard, launching a powerful new language for the Web. [https://www.w3.org/2019/12/pressrelease-wasm-rec.html.en W3C (2019). World Wide Web Consortium (W3C) brings a new language to the Web as WebAssembly becomes a W3C Recommendation.]</ref>。


2019年6月に、Chrome 75は、WebAssembly[[スレッド (コンピュータ)|スレッド]]が有効にされた状態でリリースされた。
== 開発 ==
WebAssemblyサポートの初期実装は、既存の{{仮リンク|asm.js|en|asm.js}}と[[Google Native Client|PNaCl]]をベースとしている<ref>{{Cite web|url=http://www.2ality.com/2015/06/web-assembly.html|title=WebAssembly: a binary format for the web|work=②ality&nbsp;– JavaScript and more|date=18 June 2015|accessdate=2017-03-11}}</ref><ref name="ars">{{Cite web |first=Peter |last=Bright |url=http://arstechnica.com/information-technology/2015/06/the-web-is-getting-its-bytecode-webassembly/|title=The Web is getting its bytecode: WebAssembly|work=Ars Technica |publisher=[[コンデナスト・パブリケーションズ|Condé Nast]] |date=18 June 2015|accessdate=2017-03-11}}</ref>。必要最低限の機能のみを持つ製品 (MVP) がリリースされた後、次いで[[ガベージコレクション]] (GC) の対応を行い、[[Java]]や[[C Sharp|C#]]といったGCを持つ言語をサポート対象に加えることが計画されている<ref>{{Cite web|title = WebAssembly/design|url = https://github.com/WebAssembly/design/blob/master/GC.md|website = GitHub|accessdate = 28 December 2015}}</ref>。WebAssemblyの開発は[[Mozilla]]、[[マイクロソフト]]、[[Google]]、[[Apple]]といった主要ブラウザの開発者により行われている<ref name="ars" />。


201912月5月[[W3C勧告]]「[https://www.w3.org/TR/wasm-core-1/ WebAssembly Core Specification]」が策定され、WebAssemblyは正式なウェブ標準に認定された<ref>5 December 2019 — The World Wide Web Consortium (W3C) announced today that the WebAssembly Core Specification is now an official web standard, launching a powerful new language for the Web. [https://www.w3.org/2019/12/pressrelease-wasm-rec.html.en W3C (2019). World Wide Web Consortium (W3C) brings a new language to the Web as WebAssembly becomes a W3C Recommendation.]</ref>。
== フォーマット ==
WebAssemblyコミュニティグループは、複数のブラウザにおいて最初 (MVP) のバイナリフォーマットのリリース候補とJavaScript APIを実装している<ref>{{Cite web|url=http://webassembly.org/roadmap/|title=Roadmap - WebAssembly|website=webassembly.org|access-date=2017-01-27}}</ref>。


2022年8月から、WebAssembly 2.0がドラフトの状態になり<ref>{{Cite web |title=WebAssembly Specification — WebAssembly 2.0 (Draft 2022-09-01) |url=https://webassembly.github.io/spec/core/ |access-date=2022-09-09 |website=webassembly.github.io}}</ref><ref>{{Cite web |title=WebAssembly 2.0 First Public Working Drafts {{!}} W3C News |date=19 April 2022 |url=https://www.w3.org/blog/news/archives/9509 |access-date=2022-09-09 |language=en-US}}</ref>、[[SIMD]]関連の多数の命令やv128データ型、関数が多値を返せる機能、大量のメモリの初期化・コピー、などが追加されている。
WebAssemblyのバイナリフォーマットはそのまま人間が読めるようには設計されていない。その代り、人間が読めるリニアアセンブリバイトコード ({{Lang|en|Linear Assembly Bytecode}}) と呼ばれる既存の[[アセンブリ言語]]に相当するようなフォーマットが用意されている。

2023年10月から12月にかけて、Wasmランタイム側で[[ガベージコレクション]] (GC) に対応する WebAssembly Garbage Collection (WasmGC) が、Chrome, Firefox, Edge の最新版でデフォルトで有効になった。

== 実装 ==
WebAssembly (Wasm) は当初、Webブラウザでネイティブに近いコード実行速度を実現するために設計されたものの、今ではWebブラウザの枠を出た、より一般的な文脈や用途でも価値があるとみなされている<ref name="nonweb">{{cite web |title=Non-Web Embeddings |url=https://webassembly. org/docs/non-web/ |access-date=15 May 2019 |work=WebAssembly}}</ref><ref name="nonwebsrc">{{cite web |title=Non-Web Embeddings |url=https://github.com/WebAssembly/design/blob/master/NonWeb.md |access-date=15 May 2019 |work=[[GitHub]]. / WebAssembly}}</ref>。

Wasm自体は命令セットなどの面を定めるだけであり、Linuxカーネルが提供するようなシステムコール(例: ファイルI/O)やWebブラウザが提供するようなDOMアクセスなどを提供しない<ref>"This document is concerned with the core ISA layer of WebAssembly. ... It does '''not''', however, define how WebAssembly programs can interact with a specific environment they execute in" [https://webassembly.github.io/spec/core/intro/introduction.html#scope WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021)] 2021-03-26閲覧</ref>。安全性や可搬性はこの特徴に由来する。応用に必要なAPIは別途に定義され、Wasmランタイムがそれを実装することでそれらの機能を提供する<ref>"Instead, this specification is complemented by additional documents defining interfaces to specific embedding environments such as the Web. These will each define a WebAssembly ''application programming interface (API)'' suitable for a given environment." [https://webassembly.github.io/spec/core/intro/introduction.html#scope WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021)] 2021-03-26閲覧</ref>。これによってWasmエコシステムは高い拡張性を有する。

=== Webブラウザ ===
2017年11月にMozillaは、[[Microsoft Edge]] 16でWebAssemblyがデフォルトで有効になった後<ref name="in browsers" />、「すべての主要なブラウザでの」Wasm対応を宣言した<ref name="Edge16" />。この対応にはiOSとAndroidのモバイルWebブラウザも含まれる。<!-- Android 4.4.4 KitKatとそれ以前のバージョンではWebViewがサポートされていないが、Android 5ではサポートされている。--> {{Asof|2024|3|post=,}}。99%のブラウザがWebAssembly(バージョン1.0)をサポートしており<ref name="canIuse.com" />、その前身である[[asm.js]](Safariなどで使えなかった)を上回っている。<!-- 古いブラウザの場合、WasmはJavaScriptのポリフィル (プログラミング) polyfillによって{{仮リンク|asm.js|en|asm.js}}にコンパイルすることができる。<ref name="ars2015"/> --> バージョン2.0ドラフト標準に由来するいくつかの拡張については対応度は下がりうるが、それでも9割以上のブラウザが既にサポートしていると推測される<ref>{{Cite web |title=WebAssembly Reference Types {{!}} Can I use... Support tables for HTML5, CSS3, etc |url=https://caniuse.com/wasm-reference-types |access-date=2024-03-03 |website=caniuse.com}}</ref>。

=== スタンドアローン環境およびWASI ===
Wasmのランタイム環境 (RE) は、([[Java仮想マシン|JVM]]や[[Adobe Flash|Flash VM]]と同様の)低レベルの[[スタックマシン|仮想スタックマシン]]であり、ホストアプリケーションに埋め込むことができるため、Webブラウザにとらわれない活用の道があり、WasmtimeやWasmerといったスタンドアローンのランタイムが作られた<ref name=":1">{{Cite web |title=Outside the web: Standalone WebAssembly binaries using Emscripten - V8 |url=https://v8.dev/blog/emscripten-standalone-wasm#running-in-wasm-runtimes |access-date=2020-07-28 |website=v8.dev}}</ref><ref name="Wasmer">{{Cite web |title=Wasmer - The Universal WebAssembly Runtime |url=https://wasmer.io/ |quote= |access-date=2021-02-19 |website=wasmer.io}}</ref>。

'''WebAssembly System Interface''' ('''WASI''') は、[[Mozilla]]によって設計された、どのプラットフォームにも移植できるように意図されたシンプルなインタフェース([[アプリケーションバイナリインタフェース|ABI]]および[[アプリケーションプログラミングインタフェース|API]])である<ref name="WASI2">{{cite web |url=https://github.com/WebAssembly/WASI |title=WebAssembly System Interface |work=[[GitHub]] / WebAssembly |date= |access-date=17 Mar 2024}}</ref>。これは、[[POSIX]]ライクの機能を提供するもので、例えば「[[Capability-based security|ケーパビリティベースのセキュリティ]]によって制約されたファイルI/O」のようなものを提供する<ref>{{cite web |title=Additional background on Capabilities |url=https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-capabilities.md |website=GitHub |date= |publisher=bytecodealliance |language=en |access-date=2024-03-17}}</ref><ref>{{cite web |title=Standardizing WASI: A system interface to run WebAssembly outside the web – Mozilla Hacks - the Web developer blog |url=https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/ |website=Mozilla Hacks – the Web developer blog |access-date=2024-03-17}}</ref>。他にもいくつかのABI/APIが提案されている<ref name="wasm-c-api2">{{cite web |url=https://github.com/WebAssembly/wasm-c-api |title=WebAssembly C and C++ API |work=[[GitHub]] / WebAssembly |date= |access-date=2024-03-17}}</ref>。WASIは、[[:en:Capsicum (Unix)#CloudABI|CapsicumのCloudABI]]の影響を受けている。

[[Docker]] の共同創業者であるソロモン・ハイクスは2019年に、「もし2008年にWASM+WASIが存在していたらDockerを作る必要はなかっただろう、というくらい重要なものだ。サーバ上でのWebAssemblyはコンピューティングの未来だ」と書いた<ref name="Wasmer-Docker2">{{Cite web |title=The "Wasmer" WebAssembly Runtime is Generally Available |url=https://www.infoq.com/news/2021/01/wasmer-generally-available/ |access-date=2021-02-19 |website=InfoQ |language=en}}</ref>。

== 仕様 ==
WebAssemblyはポータブルな[[スタックマシン]]<ref>{{Cite web |url=https://github.com/WebAssembly/design/blob/master/Rationale.md#why-a-stack-machine |title=Design Rationale |date=1 October 2016 |work=[[GitHub]] / WebAssembly / design |accessdate=2017-03-11}}</ref>であり、既存のウェブブラウザで広く用いられている[[JavaScript]]と比べ、構文解析と実行が高速になるよう設計されている<ref name="github.com">{{Cite web |url=https://github.com/WebAssembly/design/blob/master/HighLevelGoals.md |title=WebAssembly High-Level Goals |date=11 December 2015 |work=[[GitHub]] / WebAssembly / design |accessdate=2017-03-11}}</ref>。WASM specification はWASMの言語仕様および[[実行ファイル#実行ファイル形式|実行ファイル形式]]を定義する

=== 言語 ===
Wasmは高水準の[[アセンブリ言語]]として設計されている。x64等のアセンブリ言語にみられない特徴として以下がある。

* 制御命令: <code>if</code> や <code>loop</code>。直接のJUMP命令が無い、安全かつ高水準の制御フローを実現([[構造化プログラミング]])<ref name=":13">"Control instructions alter control flow. Control flow is structured ... well-nested constructs ... Branches can only target such constructs." WASM specification 1.0</ref>
* 関数: 型・ローカル変数・ボディで定義され<ref>"''func'' ::= {type ''typeidx'', locals ''vec(valtype)'', body ''expr''}" WASM specification 1.0</ref>、<code>call</code> される関数。コードの組織化を実現<ref>"Code is organized into separate functions. Each function takes a sequence of values as parameters and returns a sequence of values as results." WASM specification 1.0</ref>
** ローカル変数: 関数スコープの自動変数。<code>get</code>/<code>set</code> /<code>tee</code> 命令でアクセスでき疑似レジスタとして利用可能<ref>"Functions may also declare mutable local variables that are usable as virtual registers." WASM specification 1.0</ref>

==== 値型 ====
値に定義される型は <code>i32</code> / <code>i64</code> / <code>f32</code> / <code>f64</code> の4種類である<ref>"''valtype'' ::= i32 | i64 | f32 | f64" WASM specification 1.0</ref>。char/stringは型としてサポートされない。また、[[高水準言語|高級言語]]のように関数が[[構造体]]型を取り回すようなコードが直接的には記述できない。

==== 入出力 ====
デフォルトでは外部と隔離されている([[サンドボックス (セキュリティ)|サンドボックス]])。計算結果を渡したり外部関数を呼び出したりするために、WASMは ''imports''/''exports'' 機能を提供する。対象となるオブジェクトは関数・テーブル・メモリ・グローバル変数の4種類。''exports''要素に対象のインデックスを登録することで、WASM外からそのオブジェクトへアクセスできる(関数呼び出しやメモリ読み書き)。またimports要素に対象の名前と型を登録することで、WASM外に存在する対象へのアクセスをWASMランタイムが提供する。

=== フォーマット ===
Wasmは'''バイナリフォーマット'''({{lang-en-short|binary format}})および'''テキストフォーマット'''({{lang-en-short|text format}})を定義している。フォーマットの設計方針として ''Compact'' / ''Modular'' / ''Efficient'' / ''Streamable'' / ''Parallelizable'' / ''Portable'' を掲げている。

言語のバイナリ/テキスト表現(例: [[オペコード]])に加え、[[実行ファイル#実行ファイル形式|実行ファイル形式]]([[コンテナフォーマット]])を定義する。''module'' が1つの実行ファイルに相当し、マジックナンバー等のメタ情報が冒頭に記述され、関数やexportsなど11種類のセクションが続く。セクションはサイズ情報を持っており、並行処理可能に設計されている。


以下に、C言語のソースコードが、wasmのリニアアセンブリバイトコードとバイナリにそれぞれ変換された例を示す。
以下に、C言語のソースコードが、wasmのリニアアセンブリバイトコードとバイナリにそれぞれ変換された例を示す。
128行目: 163行目:
</syntaxhighlight>
</syntaxhighlight>


== 機能 ==
=== SIMD ===
Wasmのバージョン 2.0(ドラフト)には128ビット幅のベクトル型(<code>v128</code>)、[[SIMD]]命令が追加されている<ref>"2.4.2. Vector Instructions Vector instructions (also known as ''SIMD'' instructions, single data multiple value) provide basic operations over values of vector type."


W3C. (2022). ''[https://webassembly.github.io/spec/core/bikeshed/ WebAssembly Core Specification Editor’s Draft, 2 March 2022]''.</ref>。
=== ベクトル演算 ===
WASMは128ビット幅のベクトル型(<code>v128</code>)をもちベクトル命令({{lang-en-short|Vector instructions}})すなわち[[SIMD]]命令を定義している<ref>"2.4.2. Vector Instructions Vector instructions (also known as ''SIMD'' instructions, single data multiple value) provide basic operations over values of vector type."


== 連携 ==
W3C. (2022). ''[https://webassembly.github.io/spec/core/bikeshed/ WebAssembly Core Specification Editor’s Draft, 2 March 2022]''.</ref>。WASM SIMDは[[Chromium]]でサポートされている<ref>"Feature: WebAssembly SIMD ... Status in Chromium ... Enabled by default" ''[https://chromestatus.com/feature/6533147810332672 Feature: WebAssembly SIMD]''. Chrome Platform Status. 2022-03-06閲覧.</ref>。
Wasmはホスト環境に埋め込まれるサンドボックスであり、import/exportを介したホストとの連携によって意味ある結果が得られる。WasmがシンプルなVMである反面として、Wasm-ホスト間の連携にはいくつかのテクニックが必要となる。また各moduleが1つのサンドボックスとして働くため、Wasmモジュール間の連携にも同様のことが言える。

基本的な問題として、Wasm-ホスト間の型システム不一致解消(マーシャリング)を取り扱うことになる。

=== 文字列 ===
char/stringは型としてサポートされない。Wasm上で扱うためにはcharをintとして操作し、線形メモリ上にchar配列を構築する形になる。export関数も数値型しか返せないため、stringの表現として線形メモリのオフセットと長さを返し(intなので返せる)これに基づきランタイム側で該当メモリ区間を文字列型として読む、といった工夫が必要となる。あるいはmalloc等の外部アロケータをimportした上で線形メモリの内容を外部メモリへ割り当て、そのアドレス・参照をintでランタイムへ返す必要がある。


== ツール ==
== ツール ==
* [[Emscripten]] - 元々asm.js向けであったが、その後、WebAssemblyにも対応した。C言語/C++からWebAssemblyへのコンパイルでは、フロントエンドにclangもしくはそのforkであるfastcomp-clangを、中間層にLLVMもしくはそのforkであるfastcompを、バックエンドにbinaryen (後述)を使用する<ref name="binaryen">[https://github.com/WebAssembly/binaryen https://github.com/WebAssembly/binaryen]</ref>。なお、LLVMのWebAssembly実装とFastcompのWebAssembly実装は別物である。
* [[Emscripten]] - 元々asm.js向けであったが、その後、WebAssemblyにも対応した。C言語/C++からWebAssemblyへのコンパイルでは、フロントエンドにclangもしくはそのforkであるfastcomp-clangを、中間層にLLVMもしくはそのforkであるfastcompを、バックエンドにbinaryen (後述)を使用する<ref name="binaryen">https://github.com/WebAssembly/binaryen</ref>。なお、LLVMのWebAssembly実装とFastcompのWebAssembly実装は別物である。
* GCC asm.js backend - asm.js及びWebAssemblyに対応している<ref>[https://github.com/pipcet/asmjs/blob/everything/asmjs.org https://github.com/pipcet/asmjs/blob/everything/asmjs.org]</ref>。
* GCC asm.js backend - asm.js及びWebAssemblyに対応している<ref>https://github.com/pipcet/asmjs/blob/everything/asmjs.org</ref>。
* [[LLVM]] - WebAssemblyバックエンドを持ち、WebAssemblyバイナリを直接出力できる。また、LLDによるWebAssemblyバイナリのリンクも可能。LLVM 8.0で正式に対応した<ref>[https://mag.osdn.jp/19/03/22/170000 「LLVM 8.0」登場、WebAssemblyを正式サポート] OSDN 2019年3月22日</ref>。
* [[LLVM]] - WebAssemblyバックエンドを持ち、WebAssemblyバイナリを直接出力できる。また、LLDによるWebAssemblyバイナリのリンクも可能。LLVM 8.0で正式に対応した<ref>[https://mag.osdn.jp/19/03/22/170000 「LLVM 8.0」登場、WebAssemblyを正式サポート] OSDN 2019年3月22日</ref>。


=== バックエンド ===
=== バックエンド ===
* Binaryen
* Binaryen
** asm2wasm - asm.jsからWebAssemblyテキストへのコンバータ<ref name="binaryen"/>。
** asm2wasm - asm.jsからWebAssemblyテキストへのコンバータ<ref name="binaryen" />。
** s2wasm - LLVMのWebAssembly用テキストアセンブリ<!--textual assembly--> (*.s)からWebAssemblyテキストへのコンバータ<ref name="binaryen"/>。
** s2wasm - LLVMのWebAssembly用テキストアセンブリ<!--textual assembly--> (*.s)からWebAssemblyテキストへのコンバータ<ref name="binaryen" />。
** mir2wasm - Rust言語の中間レベルIR (MIR)からWebAssemblyテキストへのコンバータ<ref name="binaryen"/>。
** mir2wasm - Rust言語の中間レベルIR (MIR)からWebAssemblyテキストへのコンバータ<ref name="binaryen" />。
** wasm-as - WebAssemblyテキストからWebAssemblyバイナリへのコンバータ。
** wasm-as - WebAssemblyテキストからWebAssemblyバイナリへのコンバータ。
* WABT
* WABT
151行目: 192行目:


=== ランタイム ===
=== ランタイム ===
[[仮想マシン]]の[[命令セット]]であるWASMはコンピュータの[[実行ファイル]]ではないそのまま機械語として実行はできない。そのためWASMファイルはランタイムを介し解釈・実行される。ランタイムには[[インタプリタ]]/[[実行時コンパイラ|JITコンパイラ]]/[[事前コンパイラ|AOTコンパイラ]]があり用途に合わせて選択される。
[[仮想マシン]]の[[命令セット]]であるWASMはコンピュータの[[実行ファイル]]ではないため、そのまま機械語として実行はできない。そのためWASMファイルはランタイムを介し解釈・実行される。ランタイムには[[インタプリタ]]/[[実行時コンパイラ|JITコンパイラ]]/[[事前コンパイラ|AOTコンパイラ]]があり用途に合わせて選択される。
{| class="wikitable"
{| class="wikitable"
|+表. WASMランタイム
|+表. WASMランタイム
169行目: 210行目:
| -
| -
|Cranelift<ref>"Wasmtime is built on the optimizing Cranelift code generator to quickly generate high-quality machine code at runtime." bytecodealliance/wasmtime. [https://github.com/bytecodealliance/wasmtime RAEDME.md].</ref>
|Cranelift<ref>"Wasmtime is built on the optimizing Cranelift code generator to quickly generate high-quality machine code at runtime." bytecodealliance/wasmtime. [https://github.com/bytecodealliance/wasmtime RAEDME.md].</ref>
|-
|Lucet<ref>"Lucet is a native WebAssembly compiler and runtime." bytecodealliance/lucet. [https://github.com/bytecodealliance/lucet README.md].</ref>
| -
|Cranelift<ref>"Lucet uses, and is developed in collaboration with, the Bytecode Alliance's Cranelift code generator." bytecodealliance/lucet. [https://github.com/bytecodealliance/lucet README.md].</ref>
|-
|-
|Wasmer<ref>"The leading WebAssembly Runtime supporting WASI and Emscripten" wasmerio/wasmer. [https://github.com/wasmerio/wasmer About].</ref>
|Wasmer<ref>"The leading WebAssembly Runtime supporting WASI and Emscripten" wasmerio/wasmer. [https://github.com/wasmerio/wasmer About].</ref>
178行目: 215行目:
|pluggable (LLVM, Cranelift)<ref>"Wasmer supports different compilation frameworks to best suit your needs (LLVM, Cranelift...)." wasmerio/wasmer. [https://github.com/wasmerio/wasmer About].</ref>
|pluggable (LLVM, Cranelift)<ref>"Wasmer supports different compilation frameworks to best suit your needs (LLVM, Cranelift...)." wasmerio/wasmer. [https://github.com/wasmerio/wasmer About].</ref>
|}
|}
ランタイムは当初[[JavaScript]]実行環境からの呼び出しにより機能するよう作られていが、Lucet等のWASMネイティブランタイム登場により様々な環境から実行できるようになった (例: [[キャラクタユーザインタフェース|CLI]]における <code>$ wasmtime foo.wasm</code><ref>" you can execute a WebAssembly file" wastime. [https://docs.wasmtime.dev/cli.html Using the <code>wasmtime</code> CLI].</ref>) 。
ランタイムは[[ウェブブラウザ]]への組み込み([[JavaScript]]実行環境からの呼び出し)や独立したWASMネイティブランタイム (例: [[キャラクタユーザインタフェース|CLI]]における <code>$ wasmtime foo.wasm</code><ref>" you can execute a WebAssembly file" wastime. [https://docs.wasmtime.dev/cli.html Using the <code>wasmtime</code> CLI].</ref>) として存在する

かつて存在したランタイムにはCraneliftコンパイラベース<ref>"Lucet uses, and is developed in collaboration with, the Bytecode Alliance's Cranelift code generator." bytecodealliance/lucet. [https://github.com/bytecodealliance/lucet README.md].</ref>のLucetがある<ref>"Lucet is a native WebAssembly compiler and runtime." bytecodealliance/lucet. [https://github.com/bytecodealliance/lucet README.md].</ref>。

=== 開発環境 ===


== 統合開発環境 ==
* WebAssembly Studio - WebベースのWebAssembly向け開発環境。C言語及びRustに対応している。オープンソース<ref>[https://www.theregister.co.uk/2018/04/11/mozilla_webassembly_tools/ Aw, all grown up: Mozilla moves WebAssembly into sparsely furnished Studio apartment] The Register 2018年4月11日</ref>。
* WebAssembly Studio - WebベースのWebAssembly向け開発環境。C言語及びRustに対応している。オープンソース<ref>[https://www.theregister.co.uk/2018/04/11/mozilla_webassembly_tools/ Aw, all grown up: Mozilla moves WebAssembly into sparsely furnished Studio apartment] The Register 2018年4月11日</ref>。


=== ライブラリ ===
== アプリケーションフレームワーク ==

* [[Qt]] for WebAssembly - アプリケーションフレームワークのQtをWebAssemblyに移植したもの。2018年4月現在、テクノロジープレビュー。
* [[Qt]] for WebAssembly - アプリケーションフレームワークのQtをWebAssemblyに移植したもの。2018年4月現在、テクノロジープレビュー。


== 参考文献 ==
== 参考文献 ==
* V8.dev. [https://v8.dev/docs/wasm-compilation-pipeline WebAssembly compilation pipeline].
* V8.dev. [https://v8.dev/docs/wasm-compilation-pipeline WebAssembly compilation pipeline].
* <ref name="bytecode">{{Cite news |url=https://blog.mozilla.org/press/2019/11/new-bytecode-alliance-brings-the-security-ubiquity-and-interoperability-of-the-web-to-the-world-of-pervasive-computing/ |title=New Bytecode Alliance Brings the Security, Ubiquity, and Interoperability of the Web to the World of Pervasive Computing |date=12 November 2019 |work=Mozilla |access-date=27 May 2019 |language=en}}</ref>


== 脚注 ==
== 脚注 ==
{{脚注ヘルプ}}
{{脚注ヘルプ}}
{{Reflist|30em}}
{{Reflist|30em|refs=
* <ref name="in browsers">{{Cite web|url=https://blog.mozilla.org/blog/2017/11/13/webassembly-in-browsers/|title=WebAssembly support now shipping in all major browsers|website=The Mozilla Blog|language=en-US|access-date=21 November 2017}}</ref>
* <ref name="Edge16">{{Cite web|url=https://blogs.windows.com/msedgedev/2017/10/31/optimizations-webassembly-sharedarraybuffer-atomics-edgehtml-16/|title=Introducing new JavaScript optimizations, WebAssembly, SharedArrayBuffer, and Atomics in EdgeHTML 16|website=Microsoft Edge Dev Blog|language=en-US|access-date=21 November 2017|date=31 October 2017}}</ref>
* <ref name="canIuse.com">{{Cite web |title=WebAssembly {{!}} Can I use... Support tables for HTML5, CSS3, etc |url=https://caniuse.com/wasm |access-date=2024-03-01 |website=canIuse.com}}</ref>
}}


== 関連項目 ==
== 関連項目 ==
198行目: 244行目:


==外部リンク==
==外部リンク==
* {{Official website|http://webassembly.org/}} {{Ref-en}}
* {{Official website|http://webassembly.org/}} {{En icon}}
* [https://www.w3.org/community/webassembly/ WebAssembly Community Group] {{Ref-en}}
* [https://www.w3.org/community/webassembly/ WebAssembly Community Group] {{En icon}}
* [https://github.com/WebAssembly/design WebAssembly Design] {{Ref-en}}
* [https://github.com/WebAssembly/design WebAssembly Design] {{En icon}}


{{Web interfaces}}
{{Web interfaces}}

2024年5月13日 (月) 12:35時点における最新版

WebAssembly
パラダイム 式指向英語版
最新リリース 2.0 / 2022年6月1日[1]
型付け 静的
影響を受けた言語 asm.js英語版, PNaCl
ライセンス Apache License
ウェブサイト webassembly.org
拡張子 .wast, .wasm
テンプレートを表示

WebAssembly(ウェブアセンブリ、公式の略称はWasm[2])は、実行可能ファイルを表現するための可搬なバイナリコード形式(およびそれに対応するテキスト形式[3])を定め、同時にそのような実行可能プログラムとホスト環境との間のやりとりを容易にするためのソフトウェアインタフェースを提供するものである[4][5][6][7]

Wasmの当初の目的は、ウェブページ上で高パフォーマンスなアプリケーションを実現することであった。しかし「ウェブ特有の仮定は一切しておらず、ウェブ特有の機能を提供するわけでもないので、他の環境で同様に採用できる」[8]としている。Wasmはオープン標準であり[9][10]、あらゆるオペレーティングシステム上であらゆる言語をサポートすることを目指している[11]。実際に、最も有名な言語のすべてが、少なくともいくらかのレベルでWasmに対応している。

Wasmは、仮想の命令セットアーキテクチャあるいはプログラミング言語の一種[12]とも捉えられる。多くの場合、C/C++, Rustといったプログラミング言語のコンパイル先としてWasmバイナリが生成され、ウェブブラウザやその他のソフトウェア環境内で、スタックマシンによって実行される。ネイティブコードに近い高速さ、隔離環境でのメモリ安全な実行による安全性、仮想マシンによる可搬性やソースプログラミング言語中立性などを特徴とする[13]

Wasmは2015年に発表され、2017年3月に初めてリリースされたWebAssemblyは、2019年12月5日にW3C勧告となり、2021年の ACM SIGPLAN のプログラミング言語ソフトウェア賞を受賞した[14]World Wide Web Consortium (W3C) が技術標準を管理しており、有名な大企業なども加盟する非営利団体「Bytecode Alliance」が貢献している[15][16]

歴史

[編集]

WebAssembly という命名は、1950年代にまで遡る「アセンブリ言語」の概念を想起させるためのものであり、アセンブリのようなプログラミングを、Webのクライアントサイド(つまりユーザのWebブラウザを介したユーザのコンピュータ上)で実行される世界に持ち込むことを示唆している。これを実現するために、WebAssemblyは、真のアセンブリ言語に比べて圧倒的にハードウェア非依存でなければならない。

WebAssemblyの最初のアナウンスは2015年6月17日に行われ[17]2016年3月15日に公開された初のデモは、主要ブラウザ (Firefox, Chromium, Google Chrome, Microsoft Edge) 上でUnityのAngry Botsを動かすものだった[18][19][20]。前身となった技術は、Mozillaによる asm.js英語版Google Native Client であり、最初の実装は asm.js の機能セットに基づいて行われた。asm.jsはすでにネイティブに近いコード実行速度を提供しており[21][22]、WebAssembly非対応の環境やセキュリティ上の理由で無効化している環境での実用可能な代替とみなすことができた。

最初の目標としてCC++からのコンパイルをサポートすることを目指し[23]Rustがバージョン1.14以降で[24]Goがバージョン1.11以降で[25]Kotlin/Nativeがバージョン0.4以降で[26]で対応するなど、他のプログラミング言語のサポートも進められた。

2017年3月にMVPの設計が完了したことが宣言され、WebAssemblyに標準対応した初のブラウザとなるFirefox 52.0がリリースされた[27]。2017年11月、MozillaはMicrosoft EdgeがWebAssemblyに対応し、すでに対応しているChromeとFirefoxを含め、主要なブラウザすべてでサポートされたことを発表した[28]。2018年2月には、WebAssembly Working Groupが、3つのワーキングドラフト「Core Specification」「JavaScript Interface」「Web API」を公開した。

2019年6月に、Chrome 75は、WebAssemblyスレッドが有効にされた状態でリリースされた。

2019年12月5月に、W3C勧告WebAssembly Core Specification」が策定され、WebAssemblyは正式なウェブ標準に認定された[29]

2022年8月から、WebAssembly 2.0がドラフトの状態になり[30][31]SIMD関連の多数の命令やv128データ型、関数が多値を返せる機能、大量のメモリの初期化・コピー、などが追加されている。

2023年10月から12月にかけて、Wasmランタイム側でガベージコレクション (GC) に対応する WebAssembly Garbage Collection (WasmGC) が、Chrome, Firefox, Edge の最新版でデフォルトで有効になった。

実装

[編集]

WebAssembly (Wasm) は当初、Webブラウザでネイティブに近いコード実行速度を実現するために設計されたものの、今ではWebブラウザの枠を出た、より一般的な文脈や用途でも価値があるとみなされている[32][33]

Wasm自体は命令セットなどの面を定めるだけであり、Linuxカーネルが提供するようなシステムコール(例: ファイルI/O)やWebブラウザが提供するようなDOMアクセスなどを提供しない[34]。安全性や可搬性はこの特徴に由来する。応用に必要なAPIは別途に定義され、Wasmランタイムがそれを実装することでそれらの機能を提供する[35]。これによってWasmエコシステムは高い拡張性を有する。

Webブラウザ

[編集]

2017年11月にMozillaは、Microsoft Edge 16でWebAssemblyがデフォルトで有効になった後[36]、「すべての主要なブラウザでの」Wasm対応を宣言した[37]。この対応にはiOSとAndroidのモバイルWebブラウザも含まれる。 2024年3月 (2024-03)現在。99%のブラウザがWebAssembly(バージョン1.0)をサポートしており[38]、その前身であるasm.js(Safariなどで使えなかった)を上回っている。 バージョン2.0ドラフト標準に由来するいくつかの拡張については対応度は下がりうるが、それでも9割以上のブラウザが既にサポートしていると推測される[39]

スタンドアローン環境およびWASI

[編集]

Wasmのランタイム環境 (RE) は、(JVMFlash VMと同様の)低レベルの仮想スタックマシンであり、ホストアプリケーションに埋め込むことができるため、Webブラウザにとらわれない活用の道があり、WasmtimeやWasmerといったスタンドアローンのランタイムが作られた[40][41]

WebAssembly System Interface (WASI) は、Mozillaによって設計された、どのプラットフォームにも移植できるように意図されたシンプルなインタフェース(ABIおよびAPI)である[42]。これは、POSIXライクの機能を提供するもので、例えば「ケーパビリティベースのセキュリティによって制約されたファイルI/O」のようなものを提供する[43][44]。他にもいくつかのABI/APIが提案されている[45]。WASIは、CapsicumのCloudABIの影響を受けている。

Docker の共同創業者であるソロモン・ハイクスは2019年に、「もし2008年にWASM+WASIが存在していたらDockerを作る必要はなかっただろう、というくらい重要なものだ。サーバ上でのWebAssemblyはコンピューティングの未来だ」と書いた[46]

仕様

[編集]

WebAssemblyはポータブルなスタックマシン[47]であり、既存のウェブブラウザで広く用いられているJavaScriptと比べ、構文解析と実行が高速になるよう設計されている[23]。WASM specification はWASMの言語仕様および実行ファイル形式を定義する。

言語

[編集]

Wasmは高水準のアセンブリ言語として設計されている。x64等のアセンブリ言語にみられない特徴として以下がある。

  • 制御命令: ifloop。直接のJUMP命令が無い、安全かつ高水準の制御フローを実現(構造化プログラミング[48]
  • 関数: 型・ローカル変数・ボディで定義され[49]call される関数。コードの組織化を実現[50]
    • ローカル変数: 関数スコープの自動変数。get/set /tee 命令でアクセスでき疑似レジスタとして利用可能[51]

値型

[編集]

値に定義される型は i32 / i64 / f32 / f64 の4種類である[52]。char/stringは型としてサポートされない。また、高級言語のように関数が構造体型を取り回すようなコードが直接的には記述できない。

入出力

[編集]

デフォルトでは外部と隔離されている(サンドボックス)。計算結果を渡したり外部関数を呼び出したりするために、WASMは imports/exports 機能を提供する。対象となるオブジェクトは関数・テーブル・メモリ・グローバル変数の4種類。exports要素に対象のインデックスを登録することで、WASM外からそのオブジェクトへアクセスできる(関数呼び出しやメモリ読み書き)。またimports要素に対象の名前と型を登録することで、WASM外に存在する対象へのアクセスをWASMランタイムが提供する。

フォーマット

[編集]

Wasmはバイナリフォーマット: binary format)およびテキストフォーマット: text format)を定義している。フォーマットの設計方針として Compact / Modular / Efficient / Streamable / Parallelizable / Portable を掲げている。

言語のバイナリ/テキスト表現(例: オペコード)に加え、実行ファイル形式コンテナフォーマット)を定義する。module が1つの実行ファイルに相当し、マジックナンバー等のメタ情報が冒頭に記述され、関数やexportsなど11種類のセクションが続く。セクションはサイズ情報を持っており、並行処理可能に設計されている。

以下に、C言語のソースコードが、wasmのリニアアセンブリバイトコードとバイナリにそれぞれ変換された例を示す。

C(変換元) リニアアセンブリバイトコード
(中間表現)
WASMバイナリフォーマット
(16進数で表記)
int factorial(int n) {
  if (n == 0)
    return 1;
  else
    return n * factorial(n-1);
}
get_local 0
i64.const 0
i64.eq
if i64
    i64.const 1
else
    get_local 0
    get_local 0
    i64.const 1
    i64.sub
    call 0
    i64.mul
end
20 00
42 00
51
04 7e
42 01
05
20 00
20 00
42 01
7d
10 00
7e
0b

[53]

内部的には、wasmコンパイラシステムは中間コードを扱うためにS式を使用している。サンプルを以下に示す。[54]

(module
  (memory 256 256)
  (export "memory" memory)
  (type $FUNCSIG$dd (func (param f64) (result f64)))
  (import $exp "global.Math" "exp" (param f64) (result f64))
  (export "doubleExp" $doubleExp)
  (func $doubleExp (param $0 f64) (result f64)
    (f64.mul
      (call_import $exp
        (get_local $0)
      )
      (f64.const 2)
    )
  )
)

SIMD

[編集]

Wasmのバージョン 2.0(ドラフト)には128ビット幅のベクトル型(v128)と、SIMD命令が追加されている[55]

連携

[編集]

Wasmはホスト環境に埋め込まれるサンドボックスであり、import/exportを介したホストとの連携によって意味ある結果が得られる。WasmがシンプルなVMである反面として、Wasm-ホスト間の連携にはいくつかのテクニックが必要となる。また各moduleが1つのサンドボックスとして働くため、Wasmモジュール間の連携にも同様のことが言える。

基本的な問題として、Wasm-ホスト間の型システム不一致解消(マーシャリング)を取り扱うことになる。

文字列

[編集]

char/stringは型としてサポートされない。Wasm上で扱うためにはcharをintとして操作し、線形メモリ上にchar配列を構築する形になる。export関数も数値型しか返せないため、stringの表現として線形メモリのオフセットと長さを返し(intなので返せる)これに基づきランタイム側で該当メモリ区間を文字列型として読む、といった工夫が必要となる。あるいはmalloc等の外部アロケータをimportした上で線形メモリの内容を外部メモリへ割り当て、そのアドレス・参照をintでランタイムへ返す必要がある。

ツール

[編集]
  • Emscripten - 元々asm.js向けであったが、その後、WebAssemblyにも対応した。C言語/C++からWebAssemblyへのコンパイルでは、フロントエンドにclangもしくはそのforkであるfastcomp-clangを、中間層にLLVMもしくはそのforkであるfastcompを、バックエンドにbinaryen (後述)を使用する[56]。なお、LLVMのWebAssembly実装とFastcompのWebAssembly実装は別物である。
  • GCC asm.js backend - asm.js及びWebAssemblyに対応している[57]
  • LLVM - WebAssemblyバックエンドを持ち、WebAssemblyバイナリを直接出力できる。また、LLDによるWebAssemblyバイナリのリンクも可能。LLVM 8.0で正式に対応した[58]

バックエンド

[編集]
  • Binaryen
    • asm2wasm - asm.jsからWebAssemblyテキストへのコンバータ[56]
    • s2wasm - LLVMのWebAssembly用テキストアセンブリ (*.s)からWebAssemblyテキストへのコンバータ[56]
    • mir2wasm - Rust言語の中間レベルIR (MIR)からWebAssemblyテキストへのコンバータ[56]
    • wasm-as - WebAssemblyテキストからWebAssemblyバイナリへのコンバータ。
  • WABT
    • wat2wasm - WebAssemblyテキストからWebAssemblyバイナリへのコンバータ。
    • wasm-link - WebAssemblyバイナリのリンカー

ランタイム

[編集]

仮想マシン命令セットであるWASMはコンピュータの実行ファイルではないため、そのまま機械語として実行はできない。そのためWASMファイルはランタイムを介し解釈・実行される。ランタイムにはインタプリタ/JITコンパイラ/AOTコンパイラがあり用途に合わせて選択される。

表. WASMランタイム
実行環境 エンジン/ランタイム コンパイラ
Google Chrome & Node.js V8 Liftoff (baseline)[59] + TurboFan (optimizing)[60]
Mozilla Firefox SpiderMonkey[61] rabaldr (baseline) + BaldrMonkey (optimizing, backed by IonMonkey)
wasmtime[62] - Cranelift[63]
Wasmer[64] - pluggable (LLVM, Cranelift)[65]

ランタイムはウェブブラウザへの組み込み(JavaScript実行環境からの呼び出し)や独立したWASMネイティブランタイム (例: CLIにおける $ wasmtime foo.wasm[66]) として存在する。

かつて存在したランタイムにはCraneliftコンパイラベース[67]のLucetがある[68]

開発環境

[編集]
  • WebAssembly Studio - WebベースのWebAssembly向け開発環境。C言語及びRustに対応している。オープンソース[69]

ライブラリ

[編集]
  • Qt for WebAssembly - アプリケーションフレームワークのQtをWebAssemblyに移植したもの。2018年4月現在、テクノロジープレビュー。

参考文献

[編集]

脚注

[編集]
  1. ^ 出典URL: https://github.com/WebAssembly/spec/releases/tag/opam-2.0.0, 閲覧日: 2023年2月11日, 題名: Release 2.0, 出版日: 2022年6月1日
  2. ^ "abbreviated Wasm ... A contraction of “WebAssembly”, not an acronym, hence not using all-caps." WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021) 2021-03-26閲覧
  3. ^ Understanding WebAssembly text format” (英語). MDN Web Docs. 9 December 2019閲覧。
  4. ^ Introduction — WebAssembly 1.0”. webassembly.github.io. 18 June 2019閲覧。 “WebAssembly is an open standard...”
  5. ^ Introduction — WebAssembly 1.0”. webassembly.github.io. 18 June 2019閲覧。 “WebAssembly is a ... code format”
  6. ^ Conventions — WebAssembly 1.0”. webassembly.github.io. 17 May 2019閲覧。 “WebAssembly is a programming language that has multiple concrete representations (its binary format and the text format). Both map to a common structure.”
  7. ^ Introduction — WebAssembly 1.0”. webassembly.github.io. 18 June 2019閲覧。 “... this specification is complemented by additional documents defining interfaces to specific embedding environments such as the Web. These will each define a WebAssembly application programming interface (API) suitable for a given environment.”
  8. ^ Introduction — WebAssembly 1.1”. webassembly.github.io. 2021年2月19日閲覧。 “Its main goal is to enable high performance applications on the Web, but it does not make any Web-specific assumptions or provide Web-specific features, so it can be employed in other environments as well.”
  9. ^ Haas, Andreas; Rossberg, Andreas; Schuff, Derek L.; Titzer, Ben L.; Holman, Michael; Gohman, Dan; Wagner, Luke; Zakai, Alon et al. (14 June 2017). “Bringing the Web Up to Speed with WebAssembly”. SIGPLAN Notices 52 (6): 185–200. doi:10.1145/3140587.3062363. ISSN 0362-1340. "While the Web is the primary motivation for WebAssembly, nothing in its design depends on the Web or a JavaScript environment. It is an open standard specifically designed for embedding in multiple contexts, and we expect that stand-alone implementations will become available in the future." 
  10. ^ Outside the web: standalone WebAssembly binaries using Emscripten · V8”. v8.dev. 2020年7月28日閲覧。
  11. ^ Wasmer - The Universal WebAssembly Runtime”. wasmer.io. 2021年2月19日閲覧。 “Compile everything to WebAssembly. Run it on any OS or embed it into other languages.”
  12. ^ "At its core, WebAssembly is a virtual instruction set architecture (virtual ISA)." WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021) 2021-03-26閲覧
  13. ^ "The design goals of WebAssembly are the following ... Fast: executes with near native code performance ... Safe: code is validated and executes in a memory-safe, sandboxed environment ... Hardware-independent ... Language-independent ... Platform-independent: can be embedded in browsers, run as a stand-alone VM, or integrated in other environments" WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021) 2021-03-26閲覧
  14. ^ Programming Languages Software Award”. www.sigplan.org. 2024年3月17日閲覧。
  15. ^ “New Bytecode Alliance Brings the Security, Ubiquity, and Interoperability of the Web to the World of Pervasive Computing” (英語). Mozilla. (12 November 2019). https://blog.mozilla.org/press/2019/11/new-bytecode-alliance-brings-the-security-ubiquity-and-interoperability-of-the-web-to-the-world-of-pervasive-computing/ 27 May 2019閲覧。 
  16. ^ Bright, Peter (18 June 2015). “The Web is getting its bytecode: WebAssembly”. Ars Technica. Condé Nast. 2017年3月11日閲覧。
  17. ^ Launch bug”. GitHub / WebAssembly / design (11 June 2015). 2017年3月11日閲覧。
  18. ^ Wagner, Luke (14 March 2016). “A WebAssembly Milestone: Experimental Support in Multiple Browsers”. Mozilla Hacks. 2017年3月11日閲覧。
  19. ^ Thompson, Seth (15 March 2016). “Experimental support for WebAssembly in V8”. V8 Blog. 2017年3月11日閲覧。
  20. ^ Zhu, Limin (15 March 2016). “Previewing WebAssembly experiments in Microsoft Edge”. Microsoft Edge dev blog. 2017年3月11日閲覧。
  21. ^ Staring at the Sun: Dalvik vs. ASM.js vs. Native”. blog.mozilla.org (August 2013). 7 December 2019閲覧。 “Even discarding the one score where asm.js did better, it executes at around 70% of the speed of native C++ code.”
  22. ^ Arjun, Jangda, Abhinav Powers, Bobby Berger, Emery Guha (2019-01-25). Not So Fast: Analyzing the Performance of WebAssembly vs. Native Code. OCLC 1106328738. http://worldcat.org/oclc/1106328738 
  23. ^ a b WebAssembly High-Level Goals”. GitHub / WebAssembly / design (11 December 2015). 2017年3月11日閲覧。
  24. ^ Announcing Rust 1.14”. The Rust Programming Language Blog (22 December 2016). 2017年3月11日閲覧。
  25. ^ Go 1.11 is released”. The Go Blog (24 August 2018). 2018年10月4日閲覧。
  26. ^ Kotlin/Native v0.4 released: Objective-C interop, WebAssembly and more”. KOTLIN BLOG (16 November 2017). 2019年1月12日閲覧。
  27. ^ Firefox、ゲームなどをネイティブ並に高速実行する「WebAssembly」を採用”. Impress Watch (2017年3月8日). 2017年3月11日閲覧。
  28. ^ 長岡弥太郎 (2017年11月14日). “WebAssemblyが主要ブラウザでサポート - Mozilla official blog”. マイナビニュース. 2017年11月14日閲覧。
  29. ^ 5 December 2019 — The World Wide Web Consortium (W3C) announced today that the WebAssembly Core Specification is now an official web standard, launching a powerful new language for the Web. W3C (2019). World Wide Web Consortium (W3C) brings a new language to the Web as WebAssembly becomes a W3C Recommendation.
  30. ^ WebAssembly Specification — WebAssembly 2.0 (Draft 2022-09-01)”. webassembly.github.io. 2022年9月9日閲覧。
  31. ^ WebAssembly 2.0 First Public Working Drafts | W3C News” (英語) (19 April 2022). 2022年9月9日閲覧。
  32. ^ org/docs/non-web/ Non-Web Embeddings”. WebAssembly. 15 May 2019閲覧。
  33. ^ Non-Web Embeddings”. GitHub. / WebAssembly. 15 May 2019閲覧。
  34. ^ "This document is concerned with the core ISA layer of WebAssembly. ... It does not, however, define how WebAssembly programs can interact with a specific environment they execute in" WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021) 2021-03-26閲覧
  35. ^ "Instead, this specification is complemented by additional documents defining interfaces to specific embedding environments such as the Web. These will each define a WebAssembly application programming interface (API) suitable for a given environment." WebAssembly Specification Release 1.1 (Draft, Mar 12, 2021) 2021-03-26閲覧
  36. ^ WebAssembly support now shipping in all major browsers” (英語). The Mozilla Blog. 21 November 2017閲覧。
  37. ^ Introducing new JavaScript optimizations, WebAssembly, SharedArrayBuffer, and Atomics in EdgeHTML 16” (英語). Microsoft Edge Dev Blog (31 October 2017). 21 November 2017閲覧。
  38. ^ WebAssembly | Can I use... Support tables for HTML5, CSS3, etc”. canIuse.com. 2024年3月1日閲覧。
  39. ^ WebAssembly Reference Types | Can I use... Support tables for HTML5, CSS3, etc”. caniuse.com. 2024年3月3日閲覧。
  40. ^ Outside the web: Standalone WebAssembly binaries using Emscripten - V8”. v8.dev. 2020年7月28日閲覧。
  41. ^ Wasmer - The Universal WebAssembly Runtime”. wasmer.io. 2021年2月19日閲覧。
  42. ^ WebAssembly System Interface”. GitHub / WebAssembly. 17 Mar 2024閲覧。
  43. ^ Additional background on Capabilities” (英語). GitHub. bytecodealliance. 2024年3月17日閲覧。
  44. ^ Standardizing WASI: A system interface to run WebAssembly outside the web – Mozilla Hacks - the Web developer blog”. Mozilla Hacks – the Web developer blog. 2024年3月17日閲覧。
  45. ^ WebAssembly C and C++ API”. GitHub / WebAssembly. 2024年3月17日閲覧。
  46. ^ The "Wasmer" WebAssembly Runtime is Generally Available” (英語). InfoQ. 2021年2月19日閲覧。
  47. ^ Design Rationale”. GitHub / WebAssembly / design (1 October 2016). 2017年3月11日閲覧。
  48. ^ "Control instructions alter control flow. Control flow is structured ... well-nested constructs ... Branches can only target such constructs." WASM specification 1.0
  49. ^ "func ::= {type typeidx, locals vec(valtype), body expr}" WASM specification 1.0
  50. ^ "Code is organized into separate functions. Each function takes a sequence of values as parameters and returns a sequence of values as results." WASM specification 1.0
  51. ^ "Functions may also declare mutable local variables that are usable as virtual registers." WASM specification 1.0
  52. ^ "valtype ::= i32 | i64 | f32 | f64" WASM specification 1.0
  53. ^ サンプルのソースコードはGitHubのWebAssemblyプロジェクトより https://github.com/WebAssembly/design/blob/master/TextFormat.md
  54. ^ http://cultureofdevelopment.com/blog/build-your-first-thing-with-web-assembly/
  55. ^ "2.4.2. Vector Instructions Vector instructions (also known as SIMD instructions, single data multiple value) provide basic operations over values of vector type." W3C. (2022). WebAssembly Core Specification Editor’s Draft, 2 March 2022.
  56. ^ a b c d https://github.com/WebAssembly/binaryen
  57. ^ https://github.com/pipcet/asmjs/blob/everything/asmjs.org
  58. ^ 「LLVM 8.0」登場、WebAssemblyを正式サポート OSDN 2019年3月22日
  59. ^ "V8 first compiles a WebAssembly module with its baseline compiler, Liftoff." V8.dev. WebAssembly compilation pipeline.
  60. ^ "This is why, as soon as Liftoff compilation is finished, V8 immediately starts to "tier up" the module by recompiling all functions with TurboFan, the optimizing compiler in V8 for both WebAssembly and JavaScript." V8.dev. WebAssembly compilation pipeline.
  61. ^ "SpiderMonkey is the JavaScript and WebAssembly engine in Firefox." wasmtime (2018). Cranelift in SpiderMonkey.
  62. ^ "A standalone runtime for WebAssembly" bytecodealliance/wasmtime. RAEDME.md.
  63. ^ "Wasmtime is built on the optimizing Cranelift code generator to quickly generate high-quality machine code at runtime." bytecodealliance/wasmtime. RAEDME.md.
  64. ^ "The leading WebAssembly Runtime supporting WASI and Emscripten" wasmerio/wasmer. About.
  65. ^ "Wasmer supports different compilation frameworks to best suit your needs (LLVM, Cranelift...)." wasmerio/wasmer. About.
  66. ^ " you can execute a WebAssembly file" wastime. Using the wasmtime CLI.
  67. ^ "Lucet uses, and is developed in collaboration with, the Bytecode Alliance's Cranelift code generator." bytecodealliance/lucet. README.md.
  68. ^ "Lucet is a native WebAssembly compiler and runtime." bytecodealliance/lucet. README.md.
  69. ^ Aw, all grown up: Mozilla moves WebAssembly into sparsely furnished Studio apartment The Register 2018年4月11日
  70. ^ “New Bytecode Alliance Brings the Security, Ubiquity, and Interoperability of the Web to the World of Pervasive Computing” (英語). Mozilla. (12 November 2019). https://blog.mozilla.org/press/2019/11/new-bytecode-alliance-brings-the-security-ubiquity-and-interoperability-of-the-web-to-the-world-of-pervasive-computing/ 27 May 2019閲覧。 

関連項目

[編集]

外部リンク

[編集]