diff --git a/files/en-us/webassembly/concepts/emscripten-diagram.png b/files/en-us/webassembly/concepts/emscripten-diagram.png new file mode 100644 index 000000000000000..5bb441fd747a3c8 Binary files /dev/null and b/files/en-us/webassembly/concepts/emscripten-diagram.png differ diff --git a/files/en-us/webassembly/concepts/index.html b/files/en-us/webassembly/concepts/index.html index c65c88eb9df966d..c199bcabf81c1c2 100644 --- a/files/en-us/webassembly/concepts/index.html +++ b/files/en-us/webassembly/concepts/index.html @@ -109,7 +109,7 @@

Porting from C/C++

The Emscripten tool is able to take just about any C/C++ source code and compile it into a .wasm module, plus the necessary JavaScript "glue" code for loading and running the module, and an HTML document to display the results of the code.

-

+

In a nutshell, the process works as follows:

diff --git a/files/en-us/webassembly/existing_c_to_wasm/error.png b/files/en-us/webassembly/existing_c_to_wasm/error.png new file mode 100644 index 000000000000000..fbd0425b9d3f132 Binary files /dev/null and b/files/en-us/webassembly/existing_c_to_wasm/error.png differ diff --git a/files/en-us/webassembly/existing_c_to_wasm/index.html b/files/en-us/webassembly/existing_c_to_wasm/index.html index e79dca44011c522..c1ddc2b516ce57e 100644 --- a/files/en-us/webassembly/existing_c_to_wasm/index.html +++ b/files/en-us/webassembly/existing_c_to_wasm/index.html @@ -55,7 +55,7 @@

And you will see the correct version number in the output:

-

  Screenshot of the DevTools console showing the correct versionnumber.

+

  Screenshot of the DevTools console showing the correct versionnumber.

Note: libwebp returns the current version a.b.c as a hexadecimal number 0xabc. For example, v0.6.1 is encoded as 0x000601 = 1537.

@@ -158,7 +158,7 @@

Encode the Image

Depending on the size of your image, you might run into an error where wasm can't grow the memory enough to accommodate both the input and the output image:


-  Screenshot of the DevTools console showing an error.

+ Screenshot of the DevTools console showing an error." src="error.png">

Luckily, the solution to this problem is in the error message. You just need to add -s ALLOW_MEMORY_GROWTH=1 to your compilation command.

@@ -175,4 +175,4 @@

Encode the Image

Demo | Original Article

-

DevTools network panel and the generated image.

+

DevTools network panel and the generated image.

diff --git a/files/en-us/webassembly/existing_c_to_wasm/result.jpg b/files/en-us/webassembly/existing_c_to_wasm/result.jpg new file mode 100644 index 000000000000000..bc3a441233d32b8 Binary files /dev/null and b/files/en-us/webassembly/existing_c_to_wasm/result.jpg differ diff --git a/files/en-us/webassembly/existing_c_to_wasm/version.png b/files/en-us/webassembly/existing_c_to_wasm/version.png new file mode 100644 index 000000000000000..2171fc69ed77ed6 Binary files /dev/null and b/files/en-us/webassembly/existing_c_to_wasm/version.png differ diff --git a/files/en-us/webassembly/text_format_to_wasm/assembly-output.png b/files/en-us/webassembly/text_format_to_wasm/assembly-output.png new file mode 100644 index 000000000000000..64e751ba127e14d Binary files /dev/null and b/files/en-us/webassembly/text_format_to_wasm/assembly-output.png differ diff --git a/files/en-us/webassembly/text_format_to_wasm/index.html b/files/en-us/webassembly/text_format_to_wasm/index.html index 4a00f7b2cabb12c..af8bc85afbef1a9 100644 --- a/files/en-us/webassembly/text_format_to_wasm/index.html +++ b/files/en-us/webassembly/text_format_to_wasm/index.html @@ -60,7 +60,7 @@

Viewing the assembly output

This will give you an output in your terminal in the following way:

-

several strings of binary with textual descriptions beside them. For example: 0000008: 01 ; section code

+

several strings of binary with textual descriptions beside them. For example: 0000008: 01 ; section code

See also

diff --git a/files/en-us/webassembly/using_the_javascript_api/index.html b/files/en-us/webassembly/using_the_javascript_api/index.html index cc1f8e335f08b2b..607bc164919c817 100644 --- a/files/en-us/webassembly/using_the_javascript_api/index.html +++ b/files/en-us/webassembly/using_the_javascript_api/index.html @@ -32,7 +32,7 @@

Preparing the example

  1. First we need a wasm module! Grab our simple.wasm file and save a copy in a new directory on your local machine.
  2. Next, let’s create a simple HTML file called index.html in the same directory as your wasm file (can use our simple template if you haven’t got one easily available).
  3. -
  4. Now, to help us understand what is going on here, let’s look at the text representation of our wasm module (which we also meet in Converting WebAssembly format to wasm): +
  5. Now, to help us understand what is going on here, let’s look at the text representation of our wasm module (which we also meet in Converting WebAssembly format to wasm):
    (module
       (func $i (import "imports" "imported_func") (param i32))
       (func (export "exported_func")
    @@ -83,7 +83,7 @@ 

    Viewing wasm in developer tools

    In Firefox 54+, the Developer Tool Debugger Panel has functionality to expose the text representation of any wasm code included in a web page. To view it, you can go to the Debugger Panel and click on the “wasm://” entry.

    -

    +

    In addition to viewing WebAssembly as text, developers are able to debug (place breakpoints, inspect the callstack, single-step, etc.) WebAssembly using the text format. See WebAssembly debugging with Firefox DevTools for a video preview.

    @@ -91,7 +91,7 @@

    Memory

    In the low-level memory model of WebAssembly, memory is represented as a contiguous range of untyped bytes called Linear Memory that are read and written by load and store instructions inside the module.  In this memory model, any load or store can access any byte in the entire linear memory, which is necessary to faithfully represent C/C++ concepts like pointers.

    -

    Unlike a native C/C++ program, however, where the available memory range spans the entire process, the memory accessible by a particular WebAssembly Instance is confined to one specific — potentially very small — range contained by a WebAssembly Memory object.  This allows a single web app to use multiple independent libraries — each of which are using WebAssembly internally — to have separate memories that are fully isolated from each other. In addition, newer implementations can also create shared memories, which can be transferred between Window and Worker contexts using postMessage(), and used in multiple places.

    +

    Unlike a native C/C++ program, however, where the available memory range spans the entire process, the memory accessible by a particular WebAssembly Instance is confined to one specific — potentially very small — range contained by a WebAssembly Memory object.  This allows a single web app to use multiple independent libraries — each of which are using WebAssembly internally — to have separate memories that are fully isolated from each other. In addition, newer implementations can also create shared memories, which can be transferred between Window and Worker contexts using postMessage(), and used in multiple places.

    In JavaScript, a Memory instance can be thought of as a resizable ArrayBuffer (or SharedArrayBuffer, in the case of shared memories) and, just as with ArrayBuffers, a single web app can create many independent Memory objects.  You can create one using the {{jsxref("WebAssembly.Memory()")}} constructor, which takes as arguments an initial size and (optionally) a maximum size and a shared property that states whether it is a shared memory or not.

    @@ -292,7 +292,7 @@

    Multiplicity

  6. One memory or table instance can be used by 0–N module instances — these instances all share the same address space, allowing dynamic linking.
  7. -

    You can see multiplicity in action in our Understanding text format article — see the Mutating tables and dynamic linking section.

    +

    You can see multiplicity in action in our Understanding text format article — see the Mutating tables and dynamic linking section.

    Summary

    diff --git a/files/en-us/webassembly/using_the_javascript_api/wasm-debug.png b/files/en-us/webassembly/using_the_javascript_api/wasm-debug.png new file mode 100644 index 000000000000000..708140889ef34a6 Binary files /dev/null and b/files/en-us/webassembly/using_the_javascript_api/wasm-debug.png differ