description::
· WebAssembly-(Wasm) is a low-level, assembly-like programing-language understood by javascript-runtimes, browsers and Node.js.
· it is an intermediate language, between a-high|middle-level and a-machine programing-language.
[hmnSngo.2018-05-20]
===
"The name WebAsssembly is actually a bit of a misnomer because it’s a statically typed instruction format targeting stack based virtual machines which is much higher level representation in constrast with your typical register based assembly."
[https://medium.com/@caspervonb/hello-webassembly-882bba5c9fb7]
name::
* McsEngl.McsTchInf000014.last.html//dirTchInf//dirMcs!⇒lagWasm,
* McsEngl.dirMcs/dirTchInf/McsTchInf000014.last.html!⇒lagWasm,
* McsEngl.language.WebAssembly!⇒lagWasm,
* McsEngl.programing-language.WebAssembly!⇒lagWasm,
* McsEngl.Wasm!⇒lagWasm,
* McsEngl.Wasm-(WebAssembly)!⇒lagWasm,
* McsEngl.WebAssembly!⇒lagWasm,
* McsEngl.WebAssembly-(Wasm)!⇒lagWasm,
* McsEngl.lagWasm, {2019-06-21},
* McsEngl.lagWasm!=McsTchInf000014,
* McsEngl.lagWasm!=WebAssembly-language,
description::
· Wasm is an intermediate language between a-high|middle-level and a-machine languge.
· the-Wasm-archetype is a-high|middle-level-source-document of programing-languages such as C, C++, Rust, ..., which will-be-mapped to a-Wasm-binary-algorithm by a-compiler.
· also, the-Wasm-archetype could-be a human info-processing-document, which will-be-mapped to a-Wasm-text-algorithm by a-human.
[hmnSngo.2018-05-07]
===
Consider WebAssembly for performance-intensive use cases such as games, music streaming, video editing, and CAD applications.
[https://www.technologybreakingnews.com/2018/02/webassembly-tutorial-get-started-with-webassembly/]
name::
* McsEngl.lagWasm'archetype,
* McsEngl.lagWasm'input-document,
description::
· WebAssembly[a] is also a-compile-target, that is other languages like C, C++, Rust are-compiled to it[a].
name::
* McsEngl.lagWasm'compile-target,
* McsEngl.lagWasm'language-that-is-compiled-to-Wasm,
addressWpg::
* https://github.com/appcypher/awesome-wasm-langs,
description::
· Wasm-algorithm[a] is a-document, which is a-translation of a-Wasm-archetype in a-format that the-Wasm-virtual-machine executes.
· it[a] is written in 2 formats, a-text and a-binary.
· a-Wasm-algorithm is-not-understood directly by a-physical-machine.
· it[a] must-be-translated to machine-document.
[hmnSngo.2018-05-07]
name::
* McsEngl.lagWasm'algorithm,
* McsEngl.lagWasm'document,
* McsEngl.lagWasm'output-document,
* McsEngl.Wasm-algo,
* McsEngl.Wasm-doc,
description::
· the-machine[a] that understands a-Wasm-algorithm is not a real machine, it is a virtual machine, intermediate to the real machine that executes the-algorithm.
· it[a] is a-stack-machine, this means that all the-values an-operation needs are-inserted in a-stack before the-operation is-performed.
name::
* McsEngl.lagWasm'computational-model,
* McsEngl.lagWasm'intermediate-virtual-machine,
* McsEngl.lagWasm'machine,
* McsEngl.lagWasm'stack-machine,
* McsEngl.lagWasm'virtual-machine,
addressWpg::
* {2017-04-25} Sven-Sauleau, Imagine the computer is a stack (using Forth), https://medium.com/@svensauleau/,
* {2012-07-15} Stack based vs Register based Virtual Machine Architecture, and the Dalvik VM, https://markfaction.wordpress.com/,
description::
The store represents all global state that can be manipulated by WebAssembly programs. It consists of the runtime representation of all instances of functions, tables, memories, and globals that have been allocated during the life time of the abstract machine.
[https://webassembly.github.io/spec/core/exec/runtime.html#syntax-store]
name::
* McsEngl.lagWasm'store-of-machine,
* McsEngl.Wasm-machine'store,
description::
· stack is a-LIFO-Last-In-First-Out data-structure with push and pop operations.
==
· instructions manipulate values on an-implicit-operand-stack, consuming (popping) argument-values and producing (pushing) result-values.
[https://webassembly.github.io/spec/core/_download/WebAssembly.pdf]
name::
* McsEngl.lagWasm'implicit-operand-stack,
* McsEngl.lagWasm'operand-stack,
* McsEngl.lagWasm'stack,
* McsEngl.lagWasm'value-stack,
* McsEngl.lagWasm'virtual-stack,
description::
· the-units of binary-algo are bits.
· the-units of text-algo are unicode-characters.
[hmnSngo.2018-03-28]
name::
* McsEngl.lagWasm'unit-of-algo,
description::
· while source-text may-contain any Unicode-character in comments or string literals, the-rest of the-grammar is-formed exclusively from the-characters supported by the-7-bit-ASCII-subset-of-Unicode.
[https://webassembly.github.io/spec/core/text/lexical.html#characters {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'text-unit,
* McsEngl.Wasm-text-unit,
* McsEngl.Wasm-unit.text,
description::
· the-text-format assigns meaning to source-text, which consists of a sequence of characters.
· characters are-assumed to be-represented as valid Unicode (Section 2.4) code-points.
- source ::= char∗
- char ::= U+00 | … | U+D7FF | U+E000 | … | U+10FFFF
· note: while source-text may-contain any Unicode-character in comments or string-literals, the-rest of the-grammar is-formed exclusively from the-characters supported by the-7-bit-ASCII-subset-of-Unicode.
[https://webassembly.github.io/spec/core/text/lexical.html#characters {1-0.2018-03-28}]
description::
· white-space is any sequence of literal-space-characters, formatting-characters, or comments.
· the allowed formatting-characters correspond to a subset of the-ASCII-format-effectors, namely, horizontal-tabulation-(U+09), line-feed-(U+0A), and carriage-return-(U+0D).
space ::= (‘ ’ | format | comment)∗
format ::= U+09 | U+0A | U+0D
· the only relevance of white-space is to separate tokens, it is-ignored otherwise.
[https://webassembly.github.io/spec/core/text/lexical.html#white-space]
name::
* McsEngl.lagWasm'white-space,
* McsEngl.Wasm-text-unit.white-space,
description::
· the character stream in the-source-text is-divided, from left to right, into a sequence of tokens, as defined by the following grammar.
- token ::= keyword | uN | sN | fN | string | id | ‘(’ | ‘)’ | reserved
- keyword ::= (‘a’ | … | ‘z’) idchar∗(if occurring as a literal terminal in the grammar)
- reserved ::= idchar+
· tokens are-formed from the input character stream according to the longest match rule.
· that is, the next token always consists of the longest possible sequence of characters that is recognized by the above lexical-grammar.
· tokens can-be-separated by white-space, but except for strings, they cannot themselves contain whitespace.
[https://webassembly.github.io/spec/core/text/lexical.html#tokens {1-0.2018-03-28}]
description::
· a-comment can either be a-line-comment, started with a double semicolon ‘;;’ and extending to the-end of the-line, or a-block-comment, enclosed in delimiters ‘(;’…‘;)’.
· block-comments can-be-nested.
[https://webassembly.github.io/spec/core/text/lexical.html#comments {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'comment,
example::
(global (;0;) (mut i32) (i32.const 100)) ;;mutable-variable
//(;0;) is a-block-comment denoting the-index of the-global
//;;mutable-variable is a-line-comment
description::
· bit is the-unit of a-binary-algo.
name::
* McsEngl.lagWasm'binary-unit,
* McsEngl.Wasm-unit.binary,
name::
* McsEngl.lagWasm'semantic-unit-of-algo,
* McsEngl.Wasm-sem-unit,
specific::
* text--sem-unit,
* binary--sem-unit,
===
* value,
* function,
* variable,
* table,
* memory,
name::
* McsEngl.lagWasm'text-sem-unit,
* McsEngl.Wasm-sem-unit.text,
description::
· strings denote sequences of bytes that can-represent both textual and binary data.
· they are-enclosed in quotation-marks and may-contain any character other than ASCII-control-characters, quotation-marks (‘"’), or backslash (‘∖’), except when expressed with an-escape-sequence.
[https://webassembly.github.io/spec/core/text/values.html#strings {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'string,
* McsEngl.Wasm-sem-unit.string,
name::
* McsEngl.lagWasm'binary-sem-unit,
* McsEngl.Wasm-sem-unit.binary,
description::
'Machine Types
WebAssembly has only four basic value types t, all of which are available in common hardware.
These are integers and IEEE 754 floating point numbers, each in 32 and 64 bit width.
32 bit integers can be used as addresses in the linear memory (Section 2.2), and indexes into function tables (Section 2.4).
Most WebAssembly instructions simply execute operators on values of these basic data types.
The grammar in Figure 1 conveniently distinguishes several categories, such as unary and binary operators, tests and comparisons.
WebAssembly provides conversions between all four types, and the ability to reinterpret the bits of values across equally-sized types.
Like common hardware, WebAssembly has no distinction between signed and unsigned integer types.
Instead, when the signedness of values matters to an instruction, a sign extension suffix u or s selects either unsigned or 2's complement signed behavior.'
[https://github.com/WebAssembly/spec/blob/master/papers/pldi2017.pdf]
name::
* McsEngl.Wasm-sem-unit.value,
* McsEngl.Wasm-value,
name::
* McsEngl.Wasm-value.specific,
specific::
* byte,
* f32,
* f64,
* floating-point,
* i32,
* i64,
* integer,
* result,
* value-type,
name::
* McsEngl.lagWasm'basic-data-type,
* McsEngl.lagWasm'machine-type,
* McsEngl.lagWasm'value-type,
specific::
* i32,
* i64,
* f32,
* f64,
description::
· value-types are-encoded by a single byte.
- valtype ::= 0x7F ⇒ i32
| 0x7E ⇒ i64
| 0x7D ⇒ f32
| 0x7C ⇒ f64
[https://webassembly.github.io/spec/core/binary/types.html#binary-valtype {1-0.2018-03-28}]
description::
· valtype ::= ‘i32’ ⇒ i32
| ‘i64’ ⇒ i64
| ‘f32’ ⇒ f32
| ‘f64’ ⇒ f64
[https://webassembly.github.io/spec/core/text/types.html#value-types {1-0.2018-03-28}]
description::
The types i32 and i64 classify 32 and 64 bit integers, respectively. Integers are not inherently signed or unsigned, their interpretation is determined by individual operations.
[https://webassembly.github.io/spec/core/syntax/types.html#value-types {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'i32-sem-unit,
* McsEngl.Wasm-sem-unit.i32,
* McsEngl.Wasm-value.i32,
name::
* McsEngl.lagWasm'i64-sem-unit,
* McsEngl.Wasm-sem-unit.i64,
* McsEngl.Wasm-value.i64,
description::
The types f32 and f64 classify 32 and 64 bit floating-point data, respectively. They correspond to the respective binary floating-point representations, also known as single and double precision, as defined by the IEEE 754-2008 standard (Section 3.3).
[https://webassembly.github.io/spec/core/syntax/types.html#value-types {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'f32-sem-unit,
* McsEngl.Wasm-sem-unit.f32,
* McsEngl.Wasm-value.f32,
name::
* McsEngl.lagWasm'f64-sem-unit,
* McsEngl.Wasm-sem-unit.f64,
* McsEngl.Wasm-value.f64,
description::
· different classes of integers with different value ranges are distinguished by their bit-width-N and by whether they are unsigned or signed.
· the main integer types occurring in this specification are u32, u64, s32, s64, i8, i16, i32, i64. However, other sizes occur as auxiliary constructions, e.g., in the definition of floating-point numbers.
[https://webassembly.github.io/spec/core/syntax/values.html#integers {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'integer,
* McsEngl.lagWasm'number.integer,
* McsEngl.Wasm-sem-unit.integer,
name::
* McsEngl.lagWasm'floating-point,
* McsEngl.lagWasm'number.floating-point,
* McsEngl.Wasm-sem-unit.floating-point,
description::
· byte is equal to 8 bits, and it is-used to denote different things.
description::
· limit is the-size-range of resizeable storage associated with memory-types and table-types.
· limits ::= {min u32, max u32?}
· if no maximum is given, the respective storage can grow to any size.
name::
* McsEngl.lagWasm'limit-type,
* McsEngl.Wasm-sem-unit.limit,
description::
- limits ::= n:u32 ⇒{min n,max ϵ}
| n:u32 m:u32 ⇒ {min n,max m}
[https://webassembly.github.io/spec/core/text/types.html#limits {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'limit.text,
* McsEngl.Wasm-limit.text,
example::
;; table with min and max limit
(table (;0;) 1 1 anyfunc)
;; table with min limit
(table (;0;) 1 anyfunc)
;; memory with min and max limit
(memory 256 256)
description::
· limits are-encoded with a preceding flag indicating whether a-maximum is present.
limits ::= 0x00 n:u32 ⇒ {min n,max ϵ}
| 0x01 n:u32 m:u32 ⇒ {min n,max m}
[https://webassembly.github.io/spec/core/binary/types.html#limits {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'limit.binary,
* McsEngl.Wasm-limit.binary,
example::
;; limit with max
01 ; limits: max present
01 ; limits: initial
01 ; limits: max
;; limit with NO max
00 ; limits: max absent
01 ; limits: initial
description::
· result is a sequence of values which is the-output of executing instructions or blocks.
· in current version, at most one value is-allowed.
[https://webassembly.github.io/spec/core/syntax/types.html#result-types {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'result-type,
* McsEngl.Wasm-value.result,
description::
· function is a-semantic-unit that denotes a-process.
[hmnSngo.2018-05-17]
name::
* McsEngl.lagWasm'function,
* McsEngl.Wasm-func,
name::
* McsEngl.lagWasm'param-of-function,
* McsEngl.Wasm-function'param,
description::
· the-return-value of a-function is just the final value left on the-stack.
· the-WebAssembly validation-rules ensure the-stack matches exactly: if you declare a (result f32), then the-stack must contain exactly one f32 at the-end.
· If there is no result-type, the-stack must-be-empty.
[https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format]
name::
* McsEngl.lagWasm'result-of-function,
* McsEngl.Wasm-function'result,
description::
· function-types classify the-signature of functions, mapping a-vector of parameters to a-vector of results, written as follows.
- functype ::= [vec(valtype)] → [vec(valtype)]
· note: in the current version of WebAssembly, the-length of the-result-type-vector of a valid function-type may-be at most 1. This restriction may-be-removed in future versions.
[https://webassembly.github.io/spec/core/syntax/types.html#syntax-functype {1-0.2018-04-05}]
===
· function-type is a generic signature that maps a-vector of parmeters to a-vector of results[a] which[a] in the current version is at most 1.
[https://webassembly.github.io/spec/core/syntax/types.html#syntax-functype {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'type-of-function,
* McsEngl.Wasm-function'signature,
* McsEngl.Wasm-function'type,
* McsEngl.Wasm-function-type,
description::
- functype ::=‘(’ ‘func’ t∗1:vec(param) t∗2:vec(result) ‘)’ ⇒ [t∗1]→[t∗2]
- param ::= ‘(’ ‘param’ id? t:valtype ‘)’ ⇒ t
- result ::= ‘(’ ‘result’ t:valtype ‘)’ ⇒ t
[https://webassembly.github.io/spec/core/text/types.html#function-types {1-0.2018-03-28}]
name::
* McsEngl.Wasm-function-type.text,
example::
(type (;0;) (func (param i32 i32) (result i32)))
(func (;0;) (type 0) (param i32 i32) (result i32))
or
(func (param $p1 i32) (param $p2 i32) (result i32))
or
(func (export "f") (param $p1 i32) (param $p2 i32) (result i32))
or
(func (export "f") (param i32 i32) (result i32))
description::
· function-types are-encoded by the-byte 0x60 followed by the respective vectors of parameter and result-types.
- functype ::= 0x60 t∗1:vec(valtype) t∗2:vec(valtype)⇒[t∗1]→[t∗2]
[https://webassembly.github.io/spec/core/binary/types.html#function-types {1-0.2018-03-28}]
name::
* McsEngl.Wasm-function-type.binary,
example::
;; (func (;0;) (param i32 i32) (result i32))
; type 0
60 ; function-type
02 ; num params
7f ; i32 type of first parameter
7f ; i32
01 ; num results
7f ; i32
description::
· the-body-of-a-function is a-sequence of instructions that describe the-process of the-function:
(i32.mul
(i32.add (i32.const 5) (get_local $x))
(i32.const 2)
)
or in the following format:
i32.const 5
get_local $x
i32.add
i32.const 2
i32.mul
· in the-binary-format, the-order of instructions is always sequential.
name::
* McsEngl.Wasm-function'body,
* McsEngl.Wasm-function'code,
description::
· the-index-space for functions, tables, memories and globals includes respective imports declared in the same module.
· the-indices of these imports precede the-indices of other definitions in the same index-space.
[https://webassembly.github.io/spec/core/syntax/modules.html#indices {1-0.2018-03-22}]
description::
· when a-function is-called, it starts with an empty stack which is gradually filled-up and emptied as the body’s instructions are-executed.
===
· Invocation may fail with an error if the arguments do not fit the function type.
[https://webassembly.github.io/spec/core/exec/modules.html#invocation]
name::
* McsEngl.Wasm-function'calling,
* McsEngl.Wasm-function'invocating,
description::
· modules can-define a-start-function that is automatically executed.
[https://webassembly.github.io/spec/core/intro/overview.html#concepts {1-0.2018-03-22}]
===
· the-start-component of a-module optionally declares the-function-index of a-start-function that is automatically invoked when the-module is-instantiated, after tables and memories have-been-initialized.
- start ::= {func funcidx}
[https://webassembly.github.io/spec/core/syntax/modules.html#start-function {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'start-function,
* McsEngl.Wasm-function.start,
* McsEngl.Wasm-start-function,
description::
· the-start-section has the-id 8.
· it decodes into an optional start-function that represents the-start-component of a-module.
- startsec ::= st?:section8(start) ⇒st?
- start ::= x:funcidx ⇒ {func x}
[https://webassembly.github.io/spec/core/binary/modules.html#start-section {1-0.2018-03-28}]
description::
· a-start-function is-defined in terms of its index.
- startI ::= ‘(’ ‘start’ x:funcidxI ‘)’ ⇒ {func x}
· note: at most one start-function may-occur in a-module, which is-ensured by a suitable side condition on the-module-grammar.
[https://webassembly.github.io/spec/core/text/modules.html#start-function {1-0.2018-03-28}]
description::
· input: 2 i32 numbers.
· output: the-sum of input.
(func (export "f") (param $p1 i32) (param $p2 i32) (result i32)
get_local $p1
get_local $p2
i32.add
)
//=== javascript code:
let f = oModule.instance.exports.f;
console.log(f(8,2)); //outputs 10
description::
· make upper-case the-english-letters (as numbers) of wasm-memory.
· input: the-length of memory to work with.
(func (export "fWupper") (param $length i32)
;; var i = 0
(local $i i32) ;; store loop index
(local $sbl i32) ;; store char code
(block $Lbreak
;; while(true)
(loop $Lloop
;; if (i >= length) break
(br_if $Lbreak (i32.ge_u (get_local $i) (get_local $length)))
;; sbl = $memory[i]
(set_local $sbl (i32.load8_u (get_local $i)))
;; if (sbl >= 97 && sbl <= 122)
(if (i32.ge_u (get_local $sbl) (i32.const 97))
(if (i32.le_u (get_local $sbl) (i32.const 122))
;; $memory[i] = sbl - 32, upper-case
(i32.store8 (get_local $i) (i32.sub (get_local $sbl) (i32.const 32)))
)
)
;; ++i
(set_local $i (i32.add (get_local $i) (i32.const 1)))
;; continue
(br $Lloop)
)
)
)
or
(type (;0;) (func (param i32)))
(func (;0;) (type 0) (param i32)
(local i32 i32)
block ;; label = @1
loop ;; label = @2
get_local 1
get_local 0
i32.ge_u
br_if 1 (;@1;)
get_local 1
i32.load8_u
set_local 2
get_local 2
i32.const 97
i32.ge_u
if ;; label = @3
get_local 2
i32.const 122
i32.le_u
if ;; label = @4
get_local 1
get_local 2
i32.const 32
i32.sub
i32.store8
end
end
get_local 1
i32.const 1
i32.add
set_local 1
br 0 (;@2;)
end
end
)
[https://github.com/reklatsmasters/webassembly-examples/blob/master/%235-loop/loop.wat]
description::
· a-variable is a-name-value pair.
name::
* McsEngl.lagWasm'variable,
* McsEngl.Wasm-sem-unit.named-value,
name::
* McsEngl.lagWasm'global-variable,
* McsEngl.Wasm-global,
* McsEngl.Wasm-variable.global,
description::
· type | mutability | initialization
· text: (global (mut i32) (i32.const 100)) ;; mutable
· binary: 7F (;i32;) 01 (;mutable;) e400 (;i32 100;) 0b (;end;)
name::
* McsEngl.Wasm-global'declaration,
* McsEngl.Wasm-global'definition,
* McsEngl.Wasm-global'description,
* McsEngl.Wasm-global-variable'description,
whole-chain::
* global-section,
description::
· Global types are encoded by their value type and a flag for their mutability.
- globaltype ::= t:valtype m:mut ⇒ m t
- mut ::= 0x00 ⇒ const
| 0x01 ⇒ var
[https://webassembly.github.io/spec/core/binary/types.html#global-types {1-0.2018-03-28}]
description::
- globaltype ::= t:valtype ⇒ const t
| ‘(’ ‘mut’ t:valtype ‘)’ ⇒ var t
[https://webassembly.github.io/spec/core/text/types.html#global-types {1-0.2018-03-28}]
name::
* McsEngl.Wasm-global-dfn.text,
example::
(global (;0;) (mut i32) (i32.const 100)) ;;mutable
(global (;1;) i32 (i32.const 200)) ;;immutable
description::
· the-global-index starts with any imported-globals and continues incrementing with any globals defined in the-global-section.
[https://rsms.me/wasm-intro]
name::
* McsEngl.Wasm-global'index-space,
* McsEngl.Wasm-global-variable'index-space,
description::
· every global is mutable or immutable.
· in text-format it is-denoted with the-mut keyword.
· in binary-format this attribute takes 0 or 1 value.
description::
· locals are the-variables of functions, parameters AND body variables.
===
· locals are like variables in many higher-level-programming-languages: we can-name them, store values to them and load values from them.
· locals are-named using function-local integer index.
· when defining a-function-body, we can-declare any number of locals for the function's code.
· parameters to a-function are also locals and the “name” index of locals start at 0 with the first function parameter and continue incrementing with each additional parameter and eventually with each listed local of the-function-body.
· locals are always initialized to zero (all their bits are 0.)
[https://rsms.me/wasm-intro]
name::
* McsEngl.lagWasm'local-variable,
* McsEngl.Wasm-local,
* McsEngl.Wasm-variable.local,
description::
· body-locals are-decleared in function's-body.
· text-format: (local i32 i32 i64)
description::
· the-index-space for locals is only accessible inside a-function and includes the-parameters and local-variables of that function, which precede the other locals.
[https://webassembly.github.io/spec/core/syntax/modules.html#indices {1-0.2018-03-22}]
description::
A table is similar to a linear memory whose elements, instead of being bytes, are opaque values of a particular table element type.
This allows the table to contain values—like GC references, raw OS handles, or native pointers—that are accessed by WebAssembly code indirectly through an integer index.
This feature bridges the gap between low-level, untrusted linear memory and high-level opaque handles/references at the cost of a bounds-checked table indirection.
[https://webassembly.org/docs/semantics/#table]
===
· tables are basically resizable arrays of references that can-be-accessed by index from WebAssembly-code.
[https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format]
===
· tables are mechanisms for mapping opaque values which can-not-be-represented in nor directly accessed by WebAssembly, like for instance a-JavaScript-object or an-operating-system-file-handle.
[https://rsms.me/wasm-intro]
name::
* McsEngl.lagWasm'table,
addressWpg::
* https://webassembly.org/docs/semantics/#table,
description::
Field-Name | Type | Description
element_type | table element type | the element type of the table
resizable | resizable limits | table flags and sizes in units of elements
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#table-description]
name::
* McsEngl.lagWasm'table'declaration,
* McsEngl.Wasm-table'declaration,
* McsEngl.Wasm-table'description,
description::
- tabletype ::=lim:limits et:elemtype ⇒ lim et
- elemtype ::= ‘anyfunc’ ⇒ anyfunc
Note: additional element-types may-be-introduced in future versions of WebAssembly.
[https://webassembly.github.io/spec/core/text/types.html#table-types {1-0.2018-03-28}]
name::
* McsEngl.Wasm-table-dfn.text,
example::
;; table with 1 min and 10 max elements of anyfunc type
(table 1 10 anyfunc)
or
;; table with 1 element, the-function $f42, exported as 'tbl'
(table (export "tbl") anyfunc (elem $f42))
description::
· Table types are encoded with their limits and a constant byte indicating their element type.
- tabletype ::= et:elemtype lim:limits ⇒ lim et
- elemtype ::= 0x70 ⇒ anyfunc
[https://webassembly.github.io/spec/core/binary/types.html#table-types {1-0.2018-03-28}]
name::
* McsEngl.Wasm-table-dfn.binary,
example::
;; (table 1 10 anyfunc)
; section "Table" (4)
04 ; section code
00 ; section size (guess)
01 ; num tables
; table 0
70 ; anyfunc
01 ; limits: flags
01 ; limits: initial
0a ; limits: max
description::
· the-index-space for functions, tables, memories and globals includes respective imports declared in the same module.
· the-indices of these imports precede the-indices of other definitions in the same index-space.
[https://webassembly.github.io/spec/core/syntax/modules.html#indices {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'table'index-space,
* McsEngl.Wasm-table'index-space,
name::
* McsEngl.lagWasm'element-segment,
* McsEngl.lagWasm'table'element-segment,
example::
// defines a-table with elements 2 funtions, and export it
(table (export "tbl") anyfunc (elem $f13 $f42))
===
// imports a-table with 2 elements and initializes the 2 elements.
(import "js" "tbl" (table 2 anyfunc))
(elem (i32.const 0) $f42 $f83)
description::
· a-memory is a-vector of raw uninterpreted bytes.
[https://webassembly.github.io/spec/core/syntax/modules.html#memories {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'memory,
* McsEngl.Wasm-memory,
* McsEngl.Wasm-sem-unit.memory,
usage::
· the-memory is-used to store strings and other data other than numbers.
name::
* McsEngl.Wasm-memory'declaration,
* McsEngl.Wasm-memory'definition,
description::
- memtype ::= lim:limits ⇒ lim
[https://webassembly.github.io/spec/core/text/types.html#memory-types {1-0.2018-03-28}]
name::
· Memory types are encoded with their limits.
* McsEngl.Wasm-memory.text,
example::
;; declares a-memory and exports it as "mem"
;; the ‘1’ indicates that the-memory requires at 1 page.
(memory (export "mem") 1)
or
;; first memory with min 1 and max 10 page.
(memory (;0;) 1 10)
description::
· Memory types are encoded with their limits.
- memtype ::= lim:limits ⇒ lim
[https://webassembly.github.io/spec/core/binary/types.html#memory-types {1-0.2018-03-28}]
name::
* McsEngl.Wasm-memory.binary,
example::
;;(memory (;0;) 1 10)
; section "Memory" (5)
05 ; section code
00 ; section size (guess)
01 ; num memories
; memory 0
01 ; limits: flags
01 ; limits: initial
0a ; limits: max
description::
· pages in WebAssembly are 64-KiB, and are the-units used in linear-memory size-declarations and size-operations.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#pages]
description::
· the-index-space for functions, tables, memories and globals includes respective imports declared in the same module.
· the-indices of these imports precede the-indices of other definitions in the same index-space.
[https://webassembly.github.io/spec/core/syntax/modules.html#indices {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'external-type,
* McsEngl.Wasm-sem-unit.external,
description::
· named-sem-unit is a-sem-unit with a-name.
· the-name is an-index in the-sequence of the-definitions of sem-units or a-symbolic-name in the-text-algo.
[hmnSngo.2018-03-28]
name::
* McsEngl.lagWasm'named-sem-unit,
* McsEngl.Wasm-sem-unit.named,
description::
· definitions are-referenced with zero-based indices.
· each class of definition has its own index-space, as distinguished by the following classes.
- typeidx ::= u32
- funcidx ::= u32
- tableidx ::= u32
- memidx ::= u32
- globalidx ::= u32
- localidx ::= u32
- labelidx ::= u32
[https://webassembly.github.io/spec/core/syntax/modules.html#syntax-index {1-0.2018-03-22}]
description::
· indices can-be-given in both numeric and symbolic form.
· symbolic-identifiers that stand in-lieu-of indices start with ‘$’, followed by any sequence of printable-ASCII-characters that does-not-contain a-space, quotation-mark, comma, semicolon, or bracket.
- id ::= ‘$’ idchar+
- idchar ::= ‘0’ | … | ‘9’
| ‘A’ | … | ‘Z’
| ‘a’ | … | ‘z’
| ‘!’ | ‘#’ | ‘$’ | ‘%’ | ‘&’ | ‘′’ | ‘∗’ | ‘+’ |
| ‘−’ | ‘.’ | ‘/’
| ‘:’ | ‘<’ | ‘=’ | ‘>’ | ‘?’ | ‘@’ | ‘∖’ | ‘ ^’ | ‘_’ | ‘`’ | ‘|’ | ‘~’
[https://webassembly.github.io/spec/core/text/values.html#text-idchar {1-0.2018-03-28}]
description::
· a-WebAssembly-document consist of a-sequence of instructions.
· an-instruction consists of an-opcode followed by its immediate operands.
name::
* McsEngl.lagWasm'command,
* McsEngl.lagWasm'computation,
* McsEngl.lagWasm'instruction,
* McsEngl.lagWasm'sentence,
* McsEngl.Wasm-instruction,
description::
'WebAssembly is not a large language.
Its official specification defines 171 individual opcodes, but each of these can be viewed as different specialisations of the 28 abstract operations specified in the working group’s paper.
All WebAssembly behaviour is specified at the level of abstract operations, not concrete opcodes.'
[https://www.cl.cam.ac.uk/~caw77/papers/mechanising-and-verifying-the-webassembly-specification.pdf]
name::
* McsEngl.lagWasm'opcode-of-instruction,
* McsEngl.Wasm-instruction'opcode,
* McsEngl.Wasm-instruction'operation,
specific::
name::
* McsEngl.lagWasm'operand-of-sentence,
* McsEngl.Wasm-instruction'operand,
description::
· type-of-instruction is the-input (operands) and output (result) of an-instruction.
· it is-denoted as e.g.: [i32 i32]→[i32]
· you can-see them at: https://webassembly.github.io/spec/core/appendix/index-instructions.html,
name::
* McsEngl.lagWasm'type-of-instruction,
* McsEngl.Wasm-instruction'type,
description::
· under some conditions, certain instructions may-produce a-trap, which immediately aborts execution.
· traps cannot-be-handled by WebAssembly-code, but are-reported to the-outside-environment, where they typically can-be-caught.
[https://webassembly.github.io/spec/core/_download/WebAssembly.pdf {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'trap-of-instruction,
* McsEngl.Wasm-instruction'trap,
name::
* McsEngl.Wasm-instruction'Infrsc,
addressWpg::
* https://webassembly.org/docs/semantics/,
* https://webassembly.github.io/spec/core/syntax/instructions.html,
* https://webassembly.github.io/spec/core/appendix/index-instructions.html,
* {2018-04-07} Mauro-Bringolf, Learning the Webassembly type system, https://maurobringolf.ch/,
specific::
* additional-memory-related--instruction,
* basic-instruction,
* control-flow--instruction,
* conversion-instruction,
* floating-point-arithmetic--instruction,
* floating-point-comparison--instruction,
* integer-arithmetic--instruction,
* integer-comparison--instruction,
* load-and-store--instruction,
* signed-instruction,
* unsigned-instruction,
* B-branch--instruction-family,
* C-comparison--instruction-family,
* E-floating-point-bitwise--instruction-family,
* F-floating-point--instruction-family,
* G-generic-integer--instruction-family,
* L-call--instruction-family,
* M-linear-memory-access--instruction-family,
* Q-control-flow-barrier--instruction-family,
* R-remainder--instruction-family,
* S-signed-integer--instruction-family,
* T-shift--instruction-family,
* U-unsigned-integer--instruction-family,
* Z-linear-memory-size--instruction-family,
name::
* McsEngl.lagWasm'control-flow-instruction,
* McsEngl.Wasm-instruction.control-flow,
specific::
* block,
* br (unconditional-branch),
* br_if (conditional-brance),
* br_table (table-branch),
* loop,
* if,
* else,
* end,
* nop,
* return,
* unreachable,
description::
· the block, loop and if instructions are structured-instructions.
· they bracket nested sequences of instructions, called blocks, terminated with, or separated by, end or else pseudo-instructions.
· as the-grammar prescribes, they must-be-well-nested.
· a-structured-instruction can-produce a-value as described by the annotated result-type.
[https://webassembly.github.io/spec/core/syntax/instructions.html#control-instructions {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'structured-control-instruction,
* McsEngl.Wasm-instruction.structured-control,
addressWpg::
* {2018-04-22} Mauro-Bringolf, Structured control flow in WebAssembly by example, https://maurobringolf.ch/,
description::
· each structured-control-instruction introduces an implicit label.
· labels are targets for branch-instructions that reference them with label indices.
· unlike with other index-spaces, indexing of labels is relative by nesting depth, that is, label 0 refers to the innermost structured-control-instruction enclosing the referring branch-instruction, while increasing indices refer to those farther out.
· consequently, labels can only be-referenced from within the associated structured-control-instruction.
· this also implies that branches can only be-directed outwards, “breaking” from the-block of the-control-construct they target.
· the exact effect depends on that control-construct.
· in case of block or if it is a forward jump, resuming execution after the matching end.
· in case of loop it is a backward jump to the-beginning of the-loop.
[https://webassembly.github.io/spec/core/syntax/instructions.html#control-instructions {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'label-of--structured-control-instruction,
description::
· block resulttype instr∗ end
name::
* McsEngl.lagWasm'block-instruction,
* McsEngl.Wasm-instruction.0x02-block,
* McsEngl.Wasm-instruction.block-0x02,
example::
* link,
name::
* McsEngl.lagWasm'br-instruction,
* McsEngl.Wasm-instruction.br,
example::
* link,
name::
* McsEngl.lagWasm'br_if-instruction,
* McsEngl.Wasm-instruction.0x0D-br_if,
* McsEngl.Wasm-instruction.br_if-0x0D,
example::
(func (export "f") (result i32)
(local $v1 i32)
(set_local $v1 (i32.const 1))
loop
;; v1 + 1
(i32.add (get_local $v1) (i32.const 1))
;; if v1 < 10, loop
(br_if 0 (i32.lt_u (tee_local $v1) (i32.const 10)))
end
get_local $v1
)
name::
* McsEngl.lagWasm'br_table-instruction,
* McsEngl.Wasm-instruction.br_table,
description::
· marks the else block of an-if.
name::
* McsEngl.lagWasm'else-instruction,
* McsEngl.Wasm-instruction.0x05-else,
* McsEngl.Wasm-instruction.else-0x05,
example::
(module
(func (export "f") (param i32) (result i32)
(if (result i32) (i32.lt_s (get_local 0) (i32.const 0))
;; if input < 0, then output 1
(then (i32.const 1))
;; else output 2
(else (i32.const 2))
)
)
)
or
(module
(type (;0;) (func (param i32) (result i32)))
(func (;0;) (type 0) (param i32) (result i32)
get_local 0
i32.const 0
i32.lt_s
if (result i32) ;; label = @1
i32.const 1
else
i32.const 2
end
)
(export "f" (func 0))
)
description::
· marks the end of a block, loop, if, or function.
· Blocks are composed of matched pairs of block … end instructions, loops with matched pairs of loop … end instructions, and ifs with either if … end or if … else … end sequences. For each of these constructs the instructions in the ellipsis are said to be enclosed in the construct.
[https://webassembly.org/docs/semantics/]
name::
* McsEngl.lagWasm'end-instruction,
* McsEngl.Wasm-instruction.0x0B-end,
* McsEngl.Wasm-instruction.end-0x0B,
example::
(module
(type (;0;) (func (param i32) (result i32)))
(func (;0;) (type 0) (param i32) (result i32)
get_local 0
i32.const 0
i32.lt_s
if (result i32) ;; label = @1
i32.const 1
else
i32.const 2
end
)
(export "f" (func 0))
)
description::
· if resulttype instr∗ else instr∗ end
name::
* McsEngl.lagWasm'if-instruction,
* McsEngl.Wasm-instruction.0x04-if,
* McsEngl.Wasm-instruction.if-0x04,
example::
(module
(func (export "f") (param i32) (result i32)
(if (result i32) (i32.lt_s (get_local 0) (i32.const 0))
;; if input < 0, then output 1
(then (i32.const 1))
;; else output 2
(else (i32.const 2))
)
)
)
or
(module
(type (;0;) (func (param i32) (result i32)))
(func (;0;) (type 0) (param i32) (result i32)
get_local 0
i32.const 0
i32.lt_s
if (result i32) ;; label = @1
i32.const 1
else
i32.const 2
end
)
(export "f" (func 0))
)
description::
· loop resulttype instr∗ end
name::
* McsEngl.lagWasm'loop-instruction,
* McsEngl.Wasm-instruction.0x03-loop,
* McsEngl.Wasm-instruction.loop-0x03,
example::
(func (export "f") (result i32)
(local $v1 i32)
(set_local $v1 (i32.const 1))
loop
;; v1 + 1
(i32.add (get_local $v1) (i32.const 1))
;; if v1 < 10, loop
(br_if 0 (i32.lt_u (tee_local $v1) (i32.const 10)))
end
get_local $v1
)
or
(func (export "f") (result i32)
(local $v1 i32)
(set_local $v1 (i32.const 1))
loop &L0
get_local $v1
i32.const 1
i32.add
tee_local $v1
i32.const 10
i32.lt_u
br_if $L0
end
get_local $v1
)
description::
· the-nop-instruction does nothing.
name::
* McsEngl.lagWasm'nop-instruction,
* McsEngl.Wasm-instruction.0x01-nop,
* McsEngl.Wasm-instruction.nop-0x01,
description::
· return value from function.
name::
* McsEngl.lagWasm'return-instruction,
* McsEngl.Wasm-instruction.0x0F-return,
* McsEngl.Wasm-instruction.return-0x0F,
example::
(func (export "f") (param $a i32) (param $b i32) (result i32)
;; if (a > b) return 1, return 2
(if (i32.gt_s (get_local $a) (get_local $b))
(return (i32.const 1))
)
(return (i32.const 2))
)
or using wasm2wat
(module
(type (;0;) (func (param i32 i32) (result i32)))
(func (;0;) (type 0) (param i32 i32) (result i32)
get_local 0
get_local 1
i32.gt_s
if ;; label = @1
i32.const 1
return
end
i32.const 2
return
)
(export "f" (func 0))
)
description::
· the-unreachable-instruction causes an unconditional trap.
name::
* McsEngl.lagWasm'unreachable-instruction,
* McsEngl.Wasm-instruction.0x00-unreachable,
* McsEngl.Wasm-instruction.unreachable-0x00,
description::
· instructions manipulate values on an implicit operand-stack and fall into two main categories.
· simple-instructions perform basic operations on data.
· they pop arguments from the-operand-stack and push results back to it.
· control-instructions alter control-flow.
· control-flow is structured, meaning it is-expressed with well-nested constructs such as blocks, loops, and conditionals.
· branches can only target such constructs.
[https://webassembly.github.io/spec/core/_download/WebAssembly.pdf]
name::
* McsEngl.lagWasm'control-flow.no-instruction,
* McsEngl.Wasm-instruction.control-flow.no,
description::
· the-call-instruction calls a single function, given its index or name.
name::
* McsEngl.lagWasm'call-instruction,
* McsEngl.Wasm-instruction.0x10-call,
* McsEngl.Wasm-instruction.call-0x10,
example::
(func $f1 ...)
(func (export "f2") (result i32)
call $f1
)
description::
· the-current_memory instruction returns the current size of a-memory.
name::
* McsEngl.lagWasm'current_memory,
* McsEngl.Wasm-instruction.current_memory,
description::
· the-drop-operator simply throws away a single operand.
[https://webassembly.github.io/spec/core/syntax/instructions.html#parametric-instructions {1-0.2018-03-22}]
===
· binary-format: 0x1A
name::
* McsEngl.lagWasm'drop-instruction,
* McsEngl.Wasm-instruction.0x1A-drop,
* McsEngl.Wasm-instruction.drop-0x1A,
name::
* McsEngl.lagWasm'get_global,
* McsEngl.Wasm-instruction.0x23-get_global,
* McsEngl.Wasm-instruction.get_global-0x23,
description::
· pushes the-value of a-variable onto the-stack,
name::
* McsEngl.lagWasm'get_local,
* McsEngl.Wasm-instruction.0x20-get_local,
* McsEngl.Wasm-instruction.get_local-0x20,
example::
(func (param $p1 i32) (param $p2 f32) (local $loc i32)
get_local $p1 ;; pushes param1 on stack
)
===
(func (param i32) (param f32) (local i32)
get_local 0 ;; pushes first parameter on stack
get_local 1 ;; pushes second parameter on stack
get_local 2 ;; pushes first local on stack
)
description::
· the-grow_memory-instruction grows memory by a given delta and returns the previous size, or −1 if enough memory cannot-be-allocated.
· operate in units of page size.
[https://webassembly.github.io/spec/core/syntax/instructions.html#memory-instructions {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'grow_memory,
* McsEngl.lagWasm'memory.grow,
* McsEngl.Wasm-instruction.0x40-memory.grow,
* McsEngl.Wasm-instruction.memory.grow-0x40,
description::
· i32.add pops two i32 values from the-stack, computes their sum (modulo 2^32) and pushes the resulting i32 value.
name::
* McsEngl.lagWasm'i32.add-instruction,
* McsEngl.Wasm-instruction.0x6A-i32.add,
* McsEngl.Wasm-instruction.i32.add-0x6A,
example::
(func (export "f") (param $a i32) (result i32)
(i32.add (get_local 0) (i32.const 10))
)
or
(func (export "f") (param $a i32) (result i32)
get_local 0
i32.const 10
i32.add
)
description::
· i32.const just defines a 32-bit integer and pushes it onto the-stack.
name::
* McsEngl.lagWasm'i32.const-instruction,
* McsEngl.Wasm-instruction.0x41-i32.const,
* McsEngl.Wasm-instruction.i32.const-0x41,
example::
// returns 10
(func (export "f") (result i32)
(i32.const 10)
)
or
(func (export "f") (result i32)
i32.const 10
)
description::
· pop two values from the-stack, multiply them, and push the-result onto the-stack.
name::
* McsEngl.lagWasm'i32.mul-instruction,
* McsEngl.Wasm-instruction.0x6C-i32.mul,
* McsEngl.Wasm-instruction.i32.mul-0x6C,
example::
//for input 6 and 5, outputs 30
(func (export "f") (param $a i32) (param $b i32) (result i32)
(i32.mul (get_local 0) (get_local 1))
)
or
(func (export "f") (param $a i32) (param $b i32) (result i32)
get_local 0
get_local 1
i32.mul
)
description::
· loads memory's bytes on the-stack.
===
· memory is-accessed with load and store instructions for the different value-types.
· they all take a-memory-immediate-memarg that contains an address-offset and an-alignment-hint (in base 2 logarithmic representation).
· integer loads and stores can optionally specify a storage size that is smaller than the bit width of the respective value-type.
· in the-case of loads, a-sign-extension-mode-sx-(u|s) is then required to select appropriate behavior.
· the-static-address offset is added to the-dynamic-address operand, yielding a 33-bit effective-address that is the zero-based index at which the-memory is-accessed.
· all values are read and written in little-endian-byte-order.
· a-trap results if any of the accessed memory bytes lies outside the address range implied by the memory's current size.
· note: future version of WebAssembly might-provide memory-instructions with 64-bit address ranges.
[https://webassembly.github.io/spec/core/syntax/instructions.html#memory-instructions {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'load-memory-instruction,
* McsEngl.Wasm-instruction.load-memory,
example::
//put var1 on stack
//load on stack 1 byte from memory var1 position and zero-extend i8 to i32
(i32.load8_u (get_local $v1)
or
get_local 1
i32.load8_u
specific::
* f32.load: load 4 bytes as f32,
* f64.load: load 8 bytes as f64
* i32.load8_s: load 1 byte and sign-extend i8 to i32
* i32.load8_u: load 1 byte and zero-extend i8 to i32
* i32.load16_s: load 2 bytes and sign-extend i16 to i32
* i32.load16_u: load 2 bytes and zero-extend i16 to i32
* i32.load: load 4 bytes as i32
* i64.load8_s: load 1 byte and sign-extend i8 to i64
* i64.load8_u: load 1 byte and zero-extend i8 to i64
* i64.load16_s: load 2 bytes and sign-extend i16 to i64
* i64.load16_u: load 2 bytes and zero-extend i16 to i64
* i64.load32_s: load 4 bytes and sign-extend i32 to i64
* i64.load32_u: load 4 bytes and zero-extend i32 to i64
* i64.load: load 8 bytes as i64
description::
f32.load: load 4 bytes as f32
name::
* McsEngl.lagWasm'f32.load,
* McsEngl.Wasm-instruction.f32.load,
description::
f64.load: load 8 bytes as f64
name::
* McsEngl.lagWasm'f64.load,
* McsEngl.Wasm-instruction.f64.load,
description::
i32.load8_s: load 1 byte and sign-extend i8 to i32
name::
* McsEngl.lagWasm'i32.load8_s,
* McsEngl.Wasm-instruction.i32.load8_s,
description::
i32.load8_u: load 1 byte and zero-extend i8 to i32
name::
* McsEngl.lagWasm'i32.load8_u,
* McsEngl.Wasm-instruction.i32.load8_u,
description::
i32.load16_s: load 2 bytes and sign-extend i16 to i32
name::
* McsEngl.lagWasm'i32.load16_s,
* McsEngl.Wasm-instruction.i32.load16_s,
description::
i32.load16_u: load 2 bytes and zero-extend i16 to i32
name::
* McsEngl.lagWasm'i32.load16_u,
* McsEngl.Wasm-instruction.i32.load16_u,
description::
i32.load: load 4 bytes as i32
name::
* McsEngl.lagWasm'i32.load,
* McsEngl.Wasm-instruction.i32.load,
description::
i64.load8_s: load 1 byte and sign-extend i8 to i64
name::
* McsEngl.lagWasm'i64.load8_s,
* McsEngl.Wasm-instruction.i64.load8_s,
description::
i64.load8_u: load 1 byte and zero-extend i8 to i64
name::
* McsEngl.lagWasm'i64.load8_u,
* McsEngl.Wasm-instruction.i64.load8_u,
description::
i64.load16_s: load 2 bytes and sign-extend i16 to i64
name::
* McsEngl.lagWasm'i64.load16_s,
* McsEngl.Wasm-instruction.i64.load16_s,
description::
i64.load16_u: load 2 bytes and zero-extend i16 to i64
name::
* McsEngl.lagWasm'i64.load16_u,
* McsEngl.Wasm-instruction.i64.load16_u,
description::
i64.load32_s: load 4 bytes and sign-extend i32 to i64
name::
* McsEngl.lagWasm'i64.load32_s,
* McsEngl.Wasm-instruction.i64.load32_s,
description::
i64.load32_u: load 4 bytes and zero-extend i32 to i64
name::
* McsEngl.lagWasm'i64.load32_u,
* McsEngl.Wasm-instruction.i64.load32_u,
description::
i64.load: load 8 bytes as i64
name::
* McsEngl.lagWasm'i64.load,
* McsEngl.Wasm-instruction.i64.load,
description::
· a-ternary-operator with two operands, which have the same type as each other, plus a-boolean (i32) condition.
· it returns the first operand if the-condition operand is non-zero, or the-second otherwise.
===
· the-select-operator selects one of its first two operands based on whether its third operand is zero or not.
[https://webassembly.github.io/spec/core/syntax/instructions.html#parametric-instructions {1-0.2018-03-22}]
===
· binary-format: 0x1B
name::
* McsEngl.lagWasm'select-instruction,
* McsEngl.Wasm-instruction.0x1B-select,
* McsEngl.Wasm-instruction.select-0x1B,
example::
(func (export "f") (param $a i32) (param $b i32) (result i32)
;; return a > b ? a : b
(select
(get_local $a)
(get_local $b)
(i32.gt_s (get_local $a) (get_local $b))
)
)
or
(func (export "f") (param $a i32) (param $b i32) (result i32)
get_local 0
get_local 1
get_local 0
get_local 1
i32.gt_s
select
)
name::
* McsEngl.lagWasm'set_global,
* McsEngl.Wasm-instruction.0x24-set_global,
* McsEngl.Wasm-instruction.set_global-0x24,
description::
· set the-value of the-stack on a-local.
name::
* McsEngl.lagWasm'set_local,
* McsEngl.Wasm-instruction.0x20-set_local,
* McsEngl.Wasm-instruction.set_local-0x20,
example::
(func (export "f") (param (;0;) i32) (result i32)
(local (;1;) i32)
i32.const 7
set_local 1
get_local 1 ;;no get_local, compile-error
)
description::
· stores the-stack's last value on memory.
name::
* McsEngl.lagWasm'store-memory-instruction,
* McsEngl.Wasm-instruction.store-memory,
example::
// wrap stack's value to i8 (1 byte), i2 value,
// and store it in memory's i1 position
(i32.store8 (get_local $i1) (get_local $i2))
or
get_local 1
get_local 2
i32.store8
specific::
* f32.store: (no conversion) store 4 bytes
* f64.store: (no conversion) store 8 bytes
* i32.store8: wrap i32 to i8 and store 1 byte
* i32.store16: wrap i32 to i16 and store 2 bytes
* i32.store: (no conversion) store 4 bytes,
* i64.store8: wrap i64 to i8 and store 1 byte
* i64.store16: wrap i64 to i16 and store 2 bytes
* i64.store32: wrap i64 to i32 and store 4 bytes
* i64.store: (no conversion) store 8 bytes
description::
f32.store: (no conversion) store 4 bytes
name::
* McsEngl.lagWasm'f32.store,
* McsEngl.Wasm-instruction.f32.store,
description::
f64.store: (no conversion) store 8 bytes
name::
* McsEngl.lagWasm'f64.store,
* McsEngl.Wasm-instruction.f64.store,
description::
i32.store8: wrap i32 to i8 and store 1 byte
name::
* McsEngl.lagWasm'i32.store8,
* McsEngl.Wasm-instruction.i32.store8,
description::
i32.store16: wrap i32 to i16 and store 2 bytes
name::
* McsEngl.lagWasm'i32.store16,
* McsEngl.Wasm-instruction.i32.store16,
description::
i32.store: (no conversion) store 4 bytes,
name::
* McsEngl.lagWasm'i32.store,
* McsEngl.Wasm-instruction.i32.store,
description::
i64.store8: wrap i64 to i8 and store 1 byte
name::
* McsEngl.lagWasm'i64.store8,
* McsEngl.Wasm-instruction.i64.store8,
description::
i64.store16: wrap i64 to i16 and store 2 bytes
name::
* McsEngl.lagWasm'i64.store16,
* McsEngl.Wasm-instruction.i64.store16,
description::
i64.store32: wrap i64 to i32 and store 4 bytes
name::
* McsEngl.lagWasm'i64.store32,
* McsEngl.Wasm-instruction.i64.store32,
description::
i64.store: (no conversion) store 8 bytes
name::
* McsEngl.lagWasm'i64.store,
* McsEngl.Wasm-instruction.i64.store,
description::
· set the-value of the-stack on a-local AND return it.
name::
* McsEngl.lagWasm'tee_local,
* McsEngl.Wasm-instruction.0x22-tee_local,
* McsEngl.Wasm-instruction.tee_local-0x22,
example::
(func (export "f") (param (;0;) i32) (result i32)
(local (;1;) i32)
i32.const 7
tee_local 1
)
name::
* McsEngl.Wasm-instruction.basic,
specific::
* No-Op
* Drop
* Constant
* Get Local
* Set Local
* Tee Local
* Get Global
* Set Global
* Select
* Call
* Indirect Call,
name::
* McsEngl.Wasm-instruction.numeric,
specific::
* i32.clz (0x67),
* i32.ctz (0x68),
* i32.popcnt (0x69),
* i32.add (0x6a),
* i32.sub (0x6b),
* i32.mul (0x6c),
* i32.div_s (0x6d),
* i32.div_u (0x6e),
* i32.rem_s (0x6f),
* i32.rem_u (0x70),
* i32.and (0x71),
* i32.or (0x72),
* i32.xor (0x73),
* i32.shl (0x74),
* i32.shr_s (0x75),
* i32.shr_u (0x76),
* i32.rotl (0x77),
* i32.rotr (0x78),
* i64.clz (0x79),
* i64.ctz (0x7a),
* i64.popcnt (0x7b),
* i64.add (0x7c),
* i64.sub (0x7d),
* i64.mul (0x7e),
* i64.div_s (0x7f),
* i64.div_u (0x80),
* i64.rem_s (0x81),
* i64.rem_u (0x82),
* i64.and (0x83),
* i64.or (0x84),
* i64.xor (0x85),
* i64.shl (0x86),
* i64.shr_s (0x87),
* i64.shr_u (0x88),
* i64.rotl (0x89),
* i64.rotr (0x8a),
* f32.abs (0x8b),
* f32.neg (0x8c),
* f32.ceil (0x8d),
* f32.floor (0x8e),
* f32.trunc (0x8f),
* f32.nearest (0x90),
* f32.sqrt (0x91),
* f32.add (0x92),
* f32.sub (0x93),
* f32.mul (0x94),
* f32.div (0x95),
* f32.min (0x96),
* f32.max (0x97),
* f32.copysign (0x98),
* f64.abs (0x99),
* f64.neg (0x9a),
* f64.ceil (0x9b),
* f64.floor (0x9c),
* f64.trunc (0x9d),
* f64.nearest (0x9e),
* f64.sqrt (0x9f),
* f64.add (0xa0),
* f64.sub (0xa1),
* f64.mul (0xa2),
* f64.div (0xa3),
* f64.min (0xa4),
* f64.max (0xa5),
* f64.copysign (0xa6),
description::
· instructions in this group can-operate on operands of any value-type.
[https://webassembly.github.io/spec/core/syntax/instructions.html#parametric-instructions {1-0.2018-03-22}]
name::
* McsEngl.Wasm-instruction.parametric,
specific::
* drop,
* select-instruction,
description::
· variable-instructions are-concerned with the-access to local or global variables.
· these instructions get or set the-values of variables, respectively.
· the-tee_local-instruction is like set_local but also returns its argument.
name::
* McsEngl.lagWasm'variable-instruction,
* McsEngl.Wasm-instruction.variable,
specific::
* get_global,
* get_local,
* set_global,
* set_local,
* tee_local,
description::
· instructions related to memory.
name::
* McsEngl.lagWasm'memory-instruction,
* McsEngl.Wasm-instruction.memory,
description::
· memarg ::= {offset u32, align u32}
[https://webassembly.github.io/spec/core/syntax/instructions.html#memory-instructions {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'memarg,
* McsEngl.Wasm-memory-instruction'memarg,
specific::
* current_memory,
* grow_memory,
* load,
* store,
description::
· expression is a sequence of instructions terminated by an-end-marker.
[https://webassembly.github.io/spec/core/syntax/instructions.html#expressions {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'expression-instruction,
* McsEngl.Wasm-instruction.expression,
description::
· expressions are-encoded by their instruction sequence terminated with an explicit 0x0B opcode for end.
- expr ::= (in:instr)∗ 0x0B ⇒ in∗ end
[https://webassembly.github.io/spec/core/binary/instructions.html#expressions {1-0.2018-03-28}]
description::
· expressions are-written as instruction sequences.
· no explicit ‘end’ keyword is-included, since they only occur in bracketed positions.
- expr ::= (in:instr)∗ ⇒ in∗ end
{https://webassembly.github.io/spec/core/text/instructions.html#expressions {1-0.2018-03-28}}
name::
* McsEngl.lagWasm'type-signature,
* McsEngl.Wasm-instruction.type,
whole-chain::
* type-section,
example::
;;text-format
(type (;0;) (func (param i32 i32) (result i32)))
;;binary-format
; type 0
60 ; func
02 ; num params
7f ; i32
7f ; i32
01 ; num results
7f ; i32
description::
· the-exports-component of a-module defines a-set of exports that become accessible to the-host-environment once the-module has-been-instantiated.
- export ::= {name name,desc exportdesc}
- exportdesc ::= func funcidx
| table tableidx
| mem memidx
| global globalidx
· each export is-labeled by a unique name.
· exportable definitions are functions, tables, memories, and globals, which are-referenced through a respective descriptor.
· note: in the current version of WebAssembly, only immutable globals may-be-exported.
[https://webassembly.github.io/spec/core/syntax/modules.html#exports {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'export-instruction,
* McsEngl.Wasm-export,
* McsEngl.Wasm-instruction.export,
whole-chain::
* export-section,
description::
· the-export-section has the-id 7.
· it decodes into a-vector of exports that represent the-exports-component of a-module.
- exportsec ::= ex∗:section7 (vec(export)) ⇒ ex∗
- export ::= nm:name d:exportdesc ⇒ {name nm,desc d}
- exportdesc ::= 0x00 x:funcidx ⇒ func x
| 0x01 x:tableidx ⇒ table x
| 0x02 x:memidx ⇒ mem x
| 0x03 x:globalidx ⇒ global x
name::
* McsEngl.Wasm-export.binary,
example::
02; string length
6632 ; 'f2' export name
00 ; export kind
01 ; export func index
or in text-format
(export "f2" (func 1)))
description::
· the-syntax for exports mirrors their abstract-syntax directly.
- exportI ::= ‘(’ ‘export’ nm:name d:exportdescI ‘)’ ⇒ {name nm,desc d}
- exportdescI ::= ‘(’ ‘func’ x:funcidxI ‘)’ ⇒ func x
| ‘(’ ‘table’ x:tableidxI ‘)’ ⇒ table x
| ‘(’ ‘memory’ x:memidxI ‘)’ ⇒mem x
| ‘(’ ‘global’ x:globalidxI ‘)’ ⇒ global x
· abbreviations: as an-abbreviation, exports may also be-specified inline with function, table, memory, or global definitions; see the respective sections.
name::
* McsEngl.Wasm-export.text,
example::
(func $fAdd … )
(export "fAdd" (func $fAdd))
or
(func (export "fAdd") ...)
===
//export global
(global (;1;) i32 (i32.const 20))
(export "CONSTA" (global 1))
name::
* McsEngl.lagWasm'import-instruction,
* McsEngl.Wasm-import,
* McsEngl.Wasm-instruction.import,
whole-chain::
* import-section,
whole-chain::
* import-section,
example::
//imports the-fImported javascript-function and name it fImp.
//wat file:
(func $fImp (import "oJs" "fImported") (param i32))
//html file:
var oImport = {oJs: {fImported: arg => console.log(arg)} };
WebAssembly.instantiateStreaming(fetch('simple.wasm'), oImport)
===
//the-above with import-sentence
//wat file:
(import "oJs" "fImported" (func $fImp (param i32)))
description::
· section is a-sequence of similar instructions.
name::
* McsEngl.lagWasm'section,
* McsEngl.Wasm-section,
whole-chain::
* module,
name::
* McsEngl.Wasm-section.specific,
specific::
* text-section,
* binary-section,
===
* code-section,
* custom-section,
* data-section,
* element-section,
* export-section,
* function-section,
* global-section,
* import-section,
* known-section,
* linear-memory--section,
* start-section,
* table-section,
* type-section,
name::
* McsEngl.lagWasm'text-section,
* McsEngl.Wasm-section.text,
description::
· a-module consists of a-header and a sequence of sections.
· a-section consists of a varuint7 opcode followed by a byte-array payload.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#module-contents]
name::
* McsEngl.lagWasm'binary-section,
* McsEngl.Wasm-binary-section,
* McsEngl.Wasm-section.binary,
description::
· the-opcode is required to either indicate a-known-section, or be 0x00, indicating a-custom-section.
name::
* McsEngl.lagWasm'opcode-of-section,
* McsEngl.Wasm-section'id,
* McsEngl.Wasm-section'opcode,
description::
· each section consists of
- a one-byte section-id,
- the-u32-size of the-contents, in bytes,
- the actual contents, whose structure is depended on the section-id.
[https://webassembly.github.io/spec/core/binary/modules.html#sections {1-0.2018-03-22}]
description::
· each section consists of
- a one-byte section-id,
- the-u32-size of the-contents, in bytes,
- the actual contents, whose structure is depended on the section-id.
[https://webassembly.github.io/spec/core/binary/modules.html#sections {1-0.2018-03-22}]
name::
* McsEngl.Wasm-section'content,
* McsEngl.Wasm-section'payload,
name::
* McsEngl.Wasm-known-section,
* McsEngl.Wasm-section.known,
specific::
There are several known sections:
01. type-section,
02. import-section,
03. function-section,
04. table-section,
05. linear-memory--section,
06. global-section,
07. export-section,
08. start-section,
09. element-section,
10. code-section,
11. data-section,
description::
· for now, the-type-section contains function-types.
===
· opcode: 0x01.
· it consists of a-list of type-signatures, today of function-signatures.
· it includes signatures of imported-functions.
· the-position in this list, define the unique index of the-type inside the-module.
[https://rsms.me/wasm-intro]
name::
* McsEngl.lagWasm'types-component,
* McsEngl.Wasm-section.01-type,
* McsEngl.Wasm-section.type,
* McsEngl.Wasm-type-section,
example::
;;text-format
(type (;0;) (func (param i32 i32) (result i32)))
(type (;1;) (func (param i32) (result i32)))
;;or binary
; section "Type" (1)
01 ; section code
00 ; section size (guess)
02 ; num types
; type 0
60 ; func
02 ; num params
7f ; i32
7f ; i32
01 ; num results
7f ; i32
; type 1
60 ; func
01 ; num params
7f ; i32
01 ; num results
7f ; i32
name::
* McsEngl.lagWasm'section.type.text,
* McsEngl.lagWasm'text-type-section,
* McsEngl.lagWasm'type-section.text,
* McsEngl.Wasm-section.type.text,
example::
;;text-format
(type (;0;) (func (param i32 i32) (result i32)))
(type (;1;) (func (param i32) (result i32)))
name::
* McsEngl.lagWasm'binary-type-section,
* McsEngl.lagWasm'section.type.binary,
* McsEngl.lagWasm'type-section.binary,
* McsEngl.Wasm-section.type.binary,
example::
; section "Type" (1)
01 ; section code
00 ; section size (guess)
02 ; num types
; type 0
60 ; func
02 ; num params
7f ; i32
7f ; i32
01 ; num results
7f ; i32
; type 1
60 ; func
01 ; num params
7f ; i32
01 ; num results
7f ; i32
description::
· opcode: 0x02.
· it consists of an-array of imports.
· the-import-section declares any external dependencies by listing module name, field name and type for each function, value or data required:
("dumb-math", "quadruple", (func_type 1)) // func #0
("dumb-math", "pi", (global_type i64 immutable))
· it's up to the-host-system (e.g. web browser) to resolve these imports and this is how runtime-dynamic linking is made possible in Wasm, and is also the foreign-function interface for interacting with non-Wasm-functions.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#import-section]
[https://rsms.me/wasm-intro]
name::
* McsEngl.lagWasm'imports-component,
* McsEngl.Wasm-import-section,
* McsEngl.Wasm-section.02-import,
* McsEngl.Wasm-section.import,
example::
;; text-format
(import "oJs" "fImport1" (func (;0;) (type 0)))
(import "oJs" "fImport2" (func (;1;) (type 0)))
;; binary-format
; section "Import" (2)
02 ; section code
00 ; section size (guess)
02 ; num imports
; import header 0
03 ; string length
6f4a 73 ; oJs import module name
08 ; string length
6649 6d70 6f72 7431 ; fImport1 import field name
00 ; import kind
00 ; import signature index
; import header 1
03 ; string length
6f4a 73 ; oJs import module name
08 ; string length
6649 6d70 6f72 7432 ; fImport2 import field name
00 ; import kind
00 ; import signature index
name::
* McsEngl.lagWasm'import-section.text,
* McsEngl.lagWasm'section.import.text,
* McsEngl.lagWasm'text-import-section,
* McsEngl.Wasm-section.import.text,
example::
(import "oJs" "fImport1" (func (;0;) (type 0)))
(import "oJs" "fImport2" (func (;1;) (type 0)))
name::
* McsEngl.lagWasm'binary-import-section,
* McsEngl.lagWasm'import-section.binary,
* McsEngl.lagWasm'section.import.binary,
* McsEngl.Wasm-section.import.binary,
example::
; section "Import" (2)
02 ; section code
00 ; section size (guess)
02 ; num imports
; import header 0
03 ; string length
6f4a 73 ; oJs import module name
08 ; string length
6649 6d70 6f72 7431 ; fImport1 import field name
00 ; import kind
00 ; import signature index
; import header 1
03 ; string length
6f4a 73 ; oJs import module name
08 ; string length
6649 6d70 6f72 7432 ; fImport2 import field name
00 ; import kind
00 ; import signature index
description::
· the-funcs-component of a-module defines a-vector of functions with the following structure:
· func ::= {type typeidx, locals vec(valtype), body expr}
· the-type of a-function declares its signature by reference to a-type defined in the-module.
· the-parameters of the-function are-referenced through 0-based local indices in the-function's-body.
· the-locals declare a-vector of mutable local-variables and their types.
· these variables are-referenced through local indices in the-function's-body.
· the-index of the first local is the smallest index not referencing a parameter.
· the-body is an instruction sequence that upon termination must-produce a-stack matching the-function-type's result-type.
· functions are-referenced through function indices, starting with the smallest index not referencing a-function-import.
[https://webassembly.github.io/spec/core/syntax/modules.html#syntax-func {1-0.2018-04-05}]
===
· opcode: 0x03.
· it consists of an-array of function-declarations.
· a-function-declaration consists of: an-index in the-type-section of the-signature-of-the-function.
· the-function-declarations directly correspond to elements in the-code-section array.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#function-section]
name::
* McsEngl.lagWasm'funcs-component,
* McsEngl.lagWasm'function-section,
* McsEngl.Wasm-function-section,
* McsEngl.Wasm-section.03-function,
* McsEngl.Wasm-section.function,
whole-chain::
* module,
description::
· the-text-function-section contains AND the-body[a] of functions, which[a] in the-binary-format is-included in the-binary-code-section.
name::
* McsEngl.lagWasm'function-section.text,
* McsEngl.lagWasm'section.function.text,
* McsEngl.lagWasm'text-function-section,
* McsEngl.Wasm-section.function.text,
example::
(func $fAddTwo (param i32 i32) (result i32)
get_local 0
get_local 1
i32.add)
name::
* McsEngl.lagWasm'function-section.binary,
* McsEngl.lagWasm'section.function.binary,
* McsEngl.lagWasm'binary-function-section,
* McsEngl.Wasm-section.function.binary,
example::
; section "Function" (3)
03 ; section code
00 ; section size (guess)
01 ; num functions
00 ; function 0 type-index
description::
· opcode: 0x04.
· it consists of an-array of table-descriptions|definitions.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#table-section]
name::
* McsEngl.lagWasm'table-section,
* McsEngl.Wasm-table-section,
* McsEngl.Wasm-section.04-table,
* McsEngl.Wasm-section.table,
description::
· the-text-table-section includes and the-table initializations, which in the-binary-format is-included in the-element-section.
name::
* McsEngl.lagWasm'table-section.text,
* McsEngl.lagWasm'section.table.text,
* McsEngl.lagWasm'text-table-section,
* McsEngl.Wasm-section.table.text,
name::
* McsEngl.lagWasm'table-section.binary,
* McsEngl.lagWasm'section.table.binary,
* McsEngl.lagWasm'binary-table-section,
* McsEngl.Wasm-section.table.binary,
example::
; section "Table" (4)
0000013: 04 ; section code
0000014: 00 ; section size (guess)
0000015: 01 ; num tables
; table 0
0000016: 70 ; anyfunc
0000017: 01 ; limits: flags
0000018: 01 ; limits: initial
0000019: 01 ; limits: max
0000014: 05 ; FIXUP section size
description::
· opcode: 0x05.
· it consists of an-array of linear-memory-descriptions.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#linear-memory-section]
===
· the-memory-section defines the optional memory of the-module by defining its initial size and optionally how large it is-expected to expand.
· the-data-section can-be-used to initialize the-memory.
[https://rsms.me/wasm-intro]
name::
* McsEngl.lagWasm'mems-component,
* McsEngl.Wasm-memory-section,
* McsEngl.Wasm-section.05-linear-memory,
* McsEngl.Wasm-section.linear-memory,
* McsEngl.Wasm-section.memory,
name::
* McsEngl.lagWasm'memory-section.text,
* McsEngl.lagWasm'section.memory.text,
* McsEngl.lagWasm'text-memory-section,
* McsEngl.Wasm-section.memory.text,
name::
* McsEngl.lagWasm'binary-memory-section,
* McsEngl.lagWasm'memory-section.binary,
* McsEngl.lagWasm'section.memory.binary,
* McsEngl.Wasm-section.memory.binary,
example::
; memory-section
05 ; section code
03 ; section size
01 ; num memories
00 ; limits: flags
01 ; limits: initial
description::
· Opcode: 0x06.
· it consists of an-array of global-declarations.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#global-section]
name::
* McsEngl.lagWasm'globals-component,
* McsEngl.Wasm-global-section,
* McsEngl.Wasm-section.06-global,
* McsEngl.Wasm-section.global,
example::
;; text-format
(global (;0;) (mut i32) (i32.const 100))
(global (;1;) i32 (i32.const 200))
;; binary-format
; section "Global" (6)
06 ; section code
00 ; section size (guess)
02 ; num globals
7f ; i32
01 ; global mutability
41 ; i32.const
e400 ; i32 literal
0b ; end
7f ; i32
00 ; global mutability
41 ; i32.const
c801 ; i32 literal
0b ; end
name::
* McsEngl.lagWasm'text-global-section,
* McsEngl.lagWasm'global-section.text,
* McsEngl.lagWasm'section.global.text,
* McsEngl.Wasm-section.global.text,
example::
(global (;0;) (mut i32) (i32.const 100))
(global (;1;) i32 (i32.const 200))
name::
* McsEngl.lagWasm'binary-global-section,
* McsEngl.lagWasm'global-section.binary,
* McsEngl.lagWasm'section.global.binary,
* McsEngl.Wasm-section.global.binary,
example::
; section "Global" (6)
06 ; section code
00 ; section size (guess)
02 ; num globals
7f ; i32
01 ; global mutability
41 ; i32.const
e400 ; i32 literal
0b ; end
7f ; i32
00 ; global mutability
41 ; i32.const
c801 ; i32 literal
0b ; end
description::
· opcode: 0x07.
· it consists of an-array of exports.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#export-section]
===
· the-export-section declares any parts of the-module that can-be-accessed by the-host-environment, not-including the special start-function, which we will get to in a just a few sentences.
("half" (func 1))
· the-above would-export function-1 as “half”.
· if we look at the-function-section above, we can-see that func #1’s type is func_type #1, so the-host-environment will see this as:
function half(arg0 :int64) :int64
· in addition to functions, modules can also export tables, memory-segments and global-variables to the-outside-world.
[https://rsms.me/wasm-intro]
name::
* McsEngl.lagWasm'exports-component,
* McsEngl.Wasm-export-section,
* McsEngl.Wasm-section.07-export,
* McsEngl.Wasm-section.export,
example::
;;text-format
(export "f" (func 0))
(export "f2" (func 1)))
;; binary-format
; section "Export" (7)
07 ; section code
00 ; section size (guess)
02 ; num exports
;; export f
01 ; string length
66 ; 'f' export name
00 ; export kind
00 ; export func index
;; export f2
02; string length
6632 ; 'f2' export name
00 ; export kind
01 ; export func index
name::
* McsEngl.lagWasm'text-export-section,
* McsEngl.lagWasm'export-section.text,
* McsEngl.lagWasm'section.export.text,
* McsEngl.Wasm-section.export.text,
name::
* McsEngl.lagWasm'binary-export-section,
* McsEngl.lagWasm'export-section.binary,
* McsEngl.lagWasm'section.export.binary,
* McsEngl.Wasm-section.export.binary,
example::
; section "Export" (7)
07 ; section code
00 ; section size (guess)
02 ; num exports
;; export f
01 ; string length
66 ; 'f' export name
00 ; export kind
00 ; export func index
;; export f2
02; string length
6632 ; 'f2' export name
00 ; export kind
01 ; export func index
description::
· opcode: 0x08.
· it consists of a-varuint32-index into the-function-index-space. This is-used by Instance-Execution.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#start-section]
===
· the-start-section has the-id 8.
· it decodes into an optional start-function that represents the-start-component of a-module.
- startsec ::= st?:section8(start) ⇒st?
- start ::= x:funcidx ⇒ {func x}
[https://webassembly.github.io/spec/core/binary/modules.html#start-section {1-0.2018-03-28}]
===
· the-start-section designates a-function-index for a-function to be-called when the-module is loading and is the-mechanism that can-be-used to make a-module an-executable-program, or used to dynamically initialize globals or memory of a-module.
[https://rsms.me/wasm-intro]
name::
* McsEngl.lagWasm'start-component,
* McsEngl.Wasm-start-section,
* McsEngl.Wasm-section.08-start,
* McsEngl.Wasm-section.start,
example::
;; text-format
(func (;2;) (type 0) call 0)
(start 2)
;; binary-format
; section "Start" (8)
08 ; section code
00 ; section size (guess)
02 ; start func index
name::
* McsEngl.lagWasm'text-start-section,
* McsEngl.lagWasm'start-section.text,
* McsEngl.lagWasm'section.start.text,
* McsEngl.Wasm-section.start.text,
name::
* McsEngl.lagWasm'binary-start-section,
* McsEngl.lagWasm'start-section.binary,
* McsEngl.lagWasm'section.start.binary,
* McsEngl.Wasm-section.start.binary,
example::
; section "Start" (8)
08 ; section code
00 ; section size (guess)
02 ; start func index
description::
· opcode: 0x09.
· it consists of an-array of table-initializers.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#element-section]
===
· the-element-section allows a-module to initialize the-contents of a-table imported from the-outside or defined in the-table-section.
[https://rsms.me/wasm-intro]
===
· the initial contents of a-table is-uninitialized.
· the-elem-component of a-module defines a-vector of element-segments that initialize a-subrange of a-table at a given offset from a static vector of elements.
- elem::={table tableidx,offset expr,init vec(funcidx)}
· the-offset is-given by a constant expression.
· note: in the current version of WebAssembly, at most one table is-allowed in a-module. Consequently, the only valid tableidx is 0.
[https://webassembly.github.io/spec/core/syntax/modules.html#syntax-elem {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'elem-component,
* McsEngl.Wasm-element-section,
* McsEngl.Wasm-section.09-element,
* McsEngl.Wasm-section.element,
description::
· in text-Wasm, the-element-section is-included in the-table-section.
name::
* McsEngl.lagWasm'text-element-section,
* McsEngl.lagWasm'element-section.text,
* McsEngl.lagWasm'section.element.text,
* McsEngl.Wasm-section.element.text,
name::
* McsEngl.lagWasm'binary-element-section,
* McsEngl.lagWasm'element-section.binary,
* McsEngl.lagWasm'section.element.binary,
* McsEngl.Wasm-section.element.binary,
example::
; section "Elem" (9)
0000023: 09 ; section code
0000024: 00 ; section size (guess)
0000025: 01 ; num elem segments
; elem segment header 0
0000026: 00 ; table index
0000027: 41 ; i32.const
0000028: 00 ; i32 literal
0000029: 0b ; end
000002a: 01 ; num function indices
000002b: 00 ; function index
0000024: 07 ; FIXUP section size
description::
· opcode: 0x0a.
· it consists of an-array of function-bodies.
===
· the-code-section is probably the-bulk of most WebAssembly-modules as it defines all code for all functions in the-module.
· the-function-bodies are-defined in the same order as their respective function-indexes in the-function-section, not including imports of course.
[https://rsms.me/wasm-intro]
name::
* McsEngl.Wasm-code-section,
* McsEngl.Wasm-section.10-code,
* McsEngl.Wasm-section.code,
description::
· in text-Wasm, the-code-section (the-bodies of functions) is-included in the-function-section.
name::
* McsEngl.lagWasm'text-code-section,
* McsEngl.lagWasm'code-section.text,
* McsEngl.lagWasm'section.code.text,
* McsEngl.Wasm-section.code.text,
name::
* McsEngl.lagWasm'binary-code-section,
* McsEngl.lagWasm'code-section.binary,
* McsEngl.lagWasm'section.code.binary,
* McsEngl.Wasm-section.code.binary,
example::
;; (func (result i32) (i32.const 59))
; section "Code" (10)
0a ; section code
06 ; section size (guess)
01 ; num functions
; function body 0
04 ; func body size (guess)
00 ; local decl count
41 ; i32.const
3b ; i32 literal
0b ; end
description::
· opcode: 0x0b.
· it consists of an-array of data-initializers.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#data-section]
===
· the initial contents of a-memory are zero bytes.
· the-data-component of a-module defines a-vector of data-segments that initialize a range of memory at a given offset with a static vector of bytes.
- data ::= {data memidx,offset expr,init vec(byte)}
· the-offset is-given by a constant expression.
· note: in the current version of WebAssembly, at most one memory is-allowed in a-module. Consequently, the only valid memidx is 0.
[https://webassembly.github.io/spec/core/syntax/modules.html#data-segments {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'data-component,
* McsEngl.Wasm-data-section,
* McsEngl.Wasm-section.11-data,
* McsEngl.Wasm-section.data,
name::
* McsEngl.lagWasm'text-data-section,
* McsEngl.lagWasm'text-section.binary,
* McsEngl.lagWasm'section.text.binary,
* McsEngl.Wasm-section.text.binary,
name::
* McsEngl.lagWasm'binary-data-section,
* McsEngl.lagWasm'data-section.binary,
* McsEngl.lagWasm'section.data.binary,
* McsEngl.Wasm-section.data.binary,
example::
; data-section
0B ; section code
11 ; section size
01 ; num data segments
00 ; memory index
41 ; i32.const
00 ; i32 value
0B ; end
0B ; data segment size
48 65 6C 6C 6F 20 57 6F 72 6C 64 ; Hello World
description::
· opcode: 0x00.
· this appendix defines dedicated custom-sections for WebAssembly’s binary format.
· such sections do-not-contribute to, or otherwise affect, the WebAssembly semantics, and like any custom-section they may-be-ignored by an-implementation.
· however, they provide useful meta data that implementations can-make-use of to improve user experience or take compilation hints.
· currently, only one dedicated custom-section is-defined, the-name-section.
[https://webassembly.github.io/spec/core/appendix/custom.html#custom-sections {1-0.2018-03-28}]
name::
* McsEngl.Wasm-custom-section,
* McsEngl.Wasm-section.0-custom,
* McsEngl.Wasm-section.custom,
description::
· module is the outermost construction.
· a-module consists of a sequence of sections.
===
· WebAssembly-programs are-organized into modules, which are the-unit of deployment, loading, and compilation.
· a-module collects definitions for types, functions, tables, memories, and globals.
· in addition, it can-declare imports and exports and provide initialization logic in the-form of data and element segments or a-start-function.
- module ::= {
types vec(functype),
funcs vec(func),
tables vec(table),
mems vec(mem),
globals vec(global),
elem vec(elem),
data vec(data),
start start?,
imports vec(import),
exports vec(export)
}
· each of the-vectors – and thus the entire module – may-be empty.
[https://webassembly.github.io/spec/core/syntax/modules.html {1-0.2018-04-05}]
name::
* McsEngl.lagWasm'module,
* McsEngl.Wasm-module,
description::
· a-binary-module consists of a-header followed by a sequence of binary-sections.
name::
* McsEngl.lagWasm'binary-module,
* McsEngl.Wasm-binary-module,
* McsEngl.Wasm-module.binary,
description::
· the-header is the first part of a-module.
· the-header consists of the-magic_cookie and the-version parts.
name::
* McsEngl.lagWasm'header-of-module,
* McsEngl.Wasm-binary-module'header,
description::
· magic_cookie is-required to be 0x6d736100 (the-string "asm") which identifies a-file as a-WebAssembly-module.
· its size is 4-bytes.
description::
· version is a-32-bit-unsigned-integer which denotes the-WebAssembly-version.
description::
· a-module consists of a sequence of text-sections.
name::
* McsEngl.lagWasm'text-module,
* McsEngl.Wasm-module.text,
* McsEngl.Wasm-text-module,
name::
* McsEngl.Wasm-algo.specific,
specific::
* text-algo,
* binary-algo,
===
* program,
* library,
description::
· a-Wasm-program is one or more modules working together.
[hmnSngo.2018-05-19]
name::
* McsEngl.program.Wasm,
* McsEngl.lagWasm'program,
* McsEngl.Wasm-program,
specific::
* Wasm-binary-program,
* Wasm-text-program,
===
* examples that accompany the-MDN-WebAssembly-documentation: https://github.com/mdn/webassembly-examples
- demo: https://mdn.github.io/webassembly-examples/js-api-examples/,
* Hello World: https://github.com/tgsstdio/Hello-WebAssembly,
description::
· Wasm-binary-program is a-Wasm-program written in binary-format.
name::
* McsEngl.lagWasm'binary-program,
* McsEngl.Wasm-program.binary,
whole-chain::
* browser-javascript-program,
description::
· a-text-program is a-Wasm-program in text-format.
· it must-be-translated into binary-program to be-executed by the-runtime-environment.
[hmnSngo.2018-04-08]
name::
* McsEngl.lagWasm'text-program,
* McsEngl.Wasm-program.text,
* McsEngl.Wasm-program.wat,
description::
· simple-demo-program.
· creates and exports a-Wasm-function that creates and outputs the-value 59.
· from javascript we execute that function.
name::
* McsEngl.Wasm-program.demo.simple,
* McsEngl.Wasm-program.simple-demo,
wat-file::
(module
(func (export "f59") (result i32) (i32.const 59))
)
wasm-file::
// wat2wasm simple2.wat -o simple2.wasm
// a-sequence of bytes, in hex-format here.
00 61 73 6d ; WASM_BINARY_MAGIC
01 00 00 00 ; WASM_BINARY_VERSION
; section "Type" (1)
01 ; section code
05 ; section size
01 ; num types
60 ; func
00 ; num params
01 ; num results
7f ; i32
; section "Function" (3)
03 ; section code
02 ; section size (guess)
01 ; num functions
00 ; function 0 signature index
; section "Export" (7)
07 ; section code
07 ; section size (guess)
01 ; num exports
03 ; string length
66 35 39 ; f59 export name
00 ; export kind
00 ; export func index
; section "Code" (10)
0a ; section code
06 ; section size (guess)
01 ; num functions
; function body 0
04 ; func body size (guess)
00 ; local decl count
41 ; i32.const
3b ; i32 literal
0b ; end
; section "name"
00 ; section code
0a ; section size (guess)
04 ; string length
6e 61 6d 65 ; name custom section name
02 ; local name type
03 ; subsection size (guess)
01 ; num functions
00 ; function index
00 ; num locals
browser-file::
· we can-run the-program in a-browser-environment.
· we open this file in a-browser and hit F12 to see the-console.
<!doctype html>
<html>
<body>
<script>
WebAssembly.instantiateStreaming(fetch('simple2.wasm'))
.then(oModule => console.log(oModule.instance.exports.f59()))
</script>
</body>
</html>
Node.js-file::
//Node.js 8.11.1
· we ALSO can-run the-Wasm-program in a-Node.js-environment.
· we need this Node.js-program (simple2.js) and to run the-command: node simple2.js
.
const { readFileSync } = require("fs");
const fRun = async () => {
const oModule = await WebAssembly.compile(readFileSync("simple2.wasm"));
const oModuleInst = await WebAssembly.instantiate(oModule);
console.log(oModuleInst.exports.f59());
};
fRun();
[http://blog.scottlogic.com/2018/04/26/webassembly-by-hand.html]
demo::
· browser-demo.
description::
· creates a-wasm-function that outputs 42.
· creates and exports a-table with element the previous function.
· then, from javascript get the-table, calls its element and also displays the-length of table's elements.
name::
* McsEngl.Wasm-program.demo.table,
* McsEngl.Wasm-program.table-demo,
wat-program::
(module
(type (;0;) (func (result i32)))
(func (;0;) (type 0) (result i32) i32.const 42)
(table (;0;) 1 1 anyfunc)
(export "tbl" (table 0))
(elem (i32.const 0) 0)
)
wasm-program::
0000000: 0061 736d ; WASM_BINARY_MAGIC
0000004: 0100 0000 ; WASM_BINARY_VERSION
; section "Type" (1)
0000008: 01 ; section code
0000009: 00 ; section size (guess)
000000a: 01 ; num types
; type 0
000000b: 60 ; func
000000c: 00 ; num params
000000d: 01 ; num results
000000e: 7f ; i32
0000009: 05 ; FIXUP section size
; section "Function" (3)
000000f: 03 ; section code
0000010: 00 ; section size (guess)
0000011: 01 ; num functions
0000012: 00 ; function 0 signature index
0000010: 02 ; FIXUP section size
; section "Table" (4)
0000013: 04 ; section code
0000014: 00 ; section size (guess)
0000015: 01 ; num tables
; table 0
0000016: 70 ; anyfunc
0000017: 01 ; limits: flags
0000018: 01 ; limits: initial
0000019: 01 ; limits: max
0000014: 05 ; FIXUP section size
; section "Export" (7)
000001a: 07 ; section code
000001b: 00 ; section size (guess)
000001c: 01 ; num exports
000001d: 03 ; string length
000001e: 7462 6c ; tbl export name
0000021: 01 ; export kind
0000022: 00 ; export table index
000001b: 07 ; FIXUP section size
; section "Elem" (9)
0000023: 09 ; section code
0000024: 00 ; section size (guess)
0000025: 01 ; num elem segments
; elem segment header 0
0000026: 00 ; table index
0000027: 41 ; i32.const
0000028: 00 ; i32 literal
0000029: 0b ; end
000002a: 01 ; num function indices
000002b: 00 ; function index
0000024: 07 ; FIXUP section size
; section "Code" (10)
000002c: 0a ; section code
000002d: 00 ; section size (guess)
000002e: 01 ; num functions
; function body 0
000002f: 00 ; func body size (guess)
0000030: 00 ; local decl count
0000031: 41 ; i32.const
0000032: 2a ; i32 literal
0000033: 0b ; end
000002f: 04 ; FIXUP func body size
000002d: 06 ; FIXUP section size
; section "name"
0000034: 00 ; section code
0000035: 00 ; section size (guess)
0000036: 04 ; string length
0000037: 6e61 6d65 ; name custom section name
000003b: 01 ; function name type
000003c: 00 ; subsection size (guess)
000003d: 01 ; num functions
000003e: 00 ; function index
000003f: 03 ; string length
0000040: 6634 32 ; f42 func name 0
000003c: 06 ; FIXUP subsection size
0000043: 02 ; local name type
0000044: 00 ; subsection size (guess)
0000045: 01 ; num functions
0000046: 00 ; function index
0000047: 00 ; num locals
0000044: 03 ; FIXUP subsection size
0000035: 12 ; FIXUP section size
html-program::
<html>
<body>
<h1>table-demo</h1>
<p>· hit F12 to see console's output.
<script>
WebAssembly.instantiateStreaming(fetch('table3.wasm'))
var oTbl = oModule.instance.exports.tbl;
console.log(oTbl.get(0)()); // 42
console.log(oTbl.length); // 1
})
</script>
</body>
</html>
demo::
· link.
description::
· creates a-wasm-memory and export it.
· at offset 0, of memory puts the-string "Hello World".
· then, from javascript it gets the-memory, creates an-Uint8Array from its buffer, and String.fromCharCode() the-items of the-array.
name::
* McsEngl.Wasm-program.demo.memory,
* McsEngl.Wasm-program.memory-demo,
wat-program::
(module
(memory (export "mem") 1)
(data (i32.const 0) "Hello World")
)
wasm-program::
// a-sequence of bytes, here in hex
00 61 73 6D ; magic
01 00 00 00 ; version
; memory-section
05 ; section code
03 ; section size
01 ; num memories
00 ; limits: flags
01 ; limits: initial
; export-section
07 ; section code
07 ; section size
01 ; num exports
03 ; string length
6D 65 6D ; mem
02 ; export kind
00 ; export memory index
; data-section
0B ; section code
11 ; section size
01 ; num data segments
00 ; memory index
41 ; i32.const
00 ; i32 value
0B ; end
0B ; data segment size
48 65 6C 6C 6F 20 57 6F 72 6C 64 ; Hello World
; custom-section
00 ; section code
08 ; section size
04 ; string length
6E 61 6D 65 ; name
02 ; local name type
01 ; subsection size
00 ; num functions
html-program::
<html>
<body>
<h1>Wasm-memory demo</h1>
<p>· hit F12 to see console's output.
<script>
WebAssembly.instantiateStreaming(fetch('memory2.wasm'))
.then(oModule => {
function fUint8_to_string(aIn) {
let s = "";
for (let i = 0; i < 11; i++) {
s += String.fromCharCode(aIn[i]);
}
return s;
}
let a = new Uint8Array(oModule.instance.exports.mem.buffer);
console.log(fUint8_to_string(a));
})
</script>
</body>
</html>
demo::
· link.
description::
· simple program from Mdn-examples.
· imports a-javascript-function that prints on console its argument.
· creates and exports a-Wasm-function that creates the value 42 and calls the imported function that prints 42 on console.
name::
* McsEngl.Wasm-program.simple,
wat-file::
(module
(func $fImp (import "oJs" "fImported") (param i32))
(func (export "fExported")
i32.const 42
call $fImp
)
)
html-file::
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Wasm compile() test
</head>
<body>
<script>
var oImport = {
oJs: {fImported: arg => console.log(arg)}
};
//case1: with compile()
fetch('simple.wasm')
.then(oResponse => oResponse.arrayBuffer())
.then(bytes => WebAssembly.compile(bytes))
.then(oModule => WebAssembly.instantiate(oModule, oImport))
.then(oModuleInst => oModuleInst.exports.fExported());
//case2: with compileStreaming()
WebAssembly.compileStreaming(fetch('simple.wasm'))
.then(oModule => WebAssembly.instantiate(oModule, oImport))
.then(instance => instance.exports.fExported());
//case3: with instantiate()
fetch('simple.wasm')
.then(oResponse => oResponse.arrayBuffer())
.then(oArrayBuffer => WebAssembly.instantiate(oArrayBuffer, oImport))
.then(oModule => oModule.instance.exports.fExported());
//case4: with instantiateStreaming()
WebAssembly.instantiateStreaming(fetch('simple.wasm'), oImport)
.then(oModule => oModule.instance.exports.fExported());
//case5: with XMLHttpRequest
oXHR = new XMLHttpRequest();
oXHR.open('GET', 'simple.wasm');
oXHR.responseType = 'arraybuffer';
oXHR.send();
oXHR.onload = function() {
WebAssembly.instantiate(oXHR.response, oImport))
.then(oModule => oModule.instance.exports.fExported());
}
</script>
</body>
</html>
demo::
* compile-demo,
* compileStreaming-demo,
* instantiate-demo,
* instantiateStreaming-demo,
description::
· example from spec's WebAssembly JavaScript Interface.
· imports 2 javascript-functions that print on console "hello," the-first and "world!" the-second.
· then, uses the first imported as start-function and exports the second imported.
name::
* McsEngl.Wasm-program.hello-world,
wat-program::
(module
(import "oJs" "fImport1" (func $fImp1))
(import "oJs" "fImport2" (func $fImp2))
(func $fStart (call $fImp1))
(start $fStart)
(func (export "f") (call $fImp2))
)
wasm-program::
· we compile the-wat-program to wasm.
· one method is with an-online-compiler.
html-program::
<html>
<body>
<h1>hello-world example</h1>
<p>· example from spec's <a href="https://webassembly.github.io/spec/js-api/index.html">WebAssembly JavaScript Interface</a>
<p>· hit F12 to see console's output.
<script>
var oImport = {oJs: {
fImport1: () => console.log("hello,"),
fImport2: () => console.log("world!")
}};
WebAssembly.instantiateStreaming(fetch('demo.wasm'), oImport)
.then(oModule => oModule.instance.exports.f());
</script>
</body>
</html>
demo::
· link.
description::
· computes the-factorial of a-number, !4=1*2*3*4=24.
name::
* McsEngl.factorial-Wasm-program,
* McsEngl.Wasm-program.factorial,
wat-file::
(module
(func $factorial (export "f") (param i32) (result i32)
(if (result i32) (i32.lt_s (get_local 0) (i32.const 1))
;; if input < 1, then output 1
(then (i32.const 1))
;; else input * factorial(input-1)
(else (i32.mul (get_local 0) (call $factorial (i32.sub (get_local 0) (i32.const 1)))))
)
)
)
wasm-file::
// wat2wasm factorial.wat -o factorial.wasm
Node.js-file::
//Node.js 8.11.1
//node factorial.js
const { readFileSync } = require("fs");
const fRun = async () => {
const oModule = await WebAssembly.compile(readFileSync("factorial.wasm"));
const oModuleInst = await WebAssembly.instantiate(oModule);
console.log(oModuleInst.exports.f(4)); //24
};
fRun();
description::
with WebAssembly there’s no difference between a “program” and a “library” — there are only “modules”, each which can tie in and communicate with other modules, and each which can have a “main” function.
[https://rsms.me/wasm-intro]
description::
· Wasm-text-algo is a-Wasm-algo written with the-Wasm-text-format using S-expressions.
description::
· Wasm-binary-algo is a-Wasm-algo written with the-Wasm-binary-format.
name::
* McsEngl.lagWasm'binary-algo,
* McsEngl.Wasm-algo.binary,
* McsEngl.Wasm-binary-algo,
* McsEngl.Wasm-bnr-algo,
description::
· the-extention of a-Wasm-binary-file is .wasm
.
name::
* McsEngl.lagWasm'evaluation,
name::
* McsEngl.lagWasm'relation-to-javascript,
description::
An exciting aspect of WebAssembly is that it wasn’t made to be a substitute for JavaScript but to work alongside it.
At the same time, this combination can provide the performance of typed/compiled languages and the flexibility of JavaScript.
Using the WebAssembly API on JavaScript, you can load modules WASM on JS application and share functionalities between them.
[{2018-04-02} Willian-Martins, https://hackernoon.com/webassembly-the-journey-what-is-wasm-caf9871108aa]
===
WebAssembly is faster than JavaScript in many cases because:
* fetching WebAssembly takes less time because it is more compact than JavaScript, even when compressed,
* decoding WebAssembly takes less time than parsing JavaScript,
* compiling and optimizing takes less time because WebAssembly is closer to machine code than JavaScript and already has gone through optimization on the server side,
* reoptimizing doesn’t need to happen because WebAssembly has types and other information built in, so the JS engine doesn’t need to speculate when it optimizes the way it does with JavaScript,
* executing often takes less time because there are fewer compiler tricks and gotchas that the developer needs to know to write consistently performant code, plus WebAssembly’s set of instructions are more ideal for machines,
* garbage collection is not required since the memory is managed manually,
This is why, in many cases, WebAssembly will outperform JavaScript when doing the same task.
There are some cases where WebAssembly doesn’t perform as well as expected, and there are also some changes on the horizon that will make it faster.
[https://hacks.mozilla.org/2017/02/what-makes-webassembly-fast/]
description::
· to support the-embedding of WebAssembly into different environments, its specification is split into layers that are specified in separate documents.
· core-specification: defines the-semantics of WebAssembly-modules and its instruction-set, independent from a concrete embedding.
· API-specifications: define application-programming-interfaces enabling the-use of WebAssembly-modules in concrete embedding environments.
[https://webassembly.github.io/spec/]
name::
* McsEngl.lagWasm'specification,
* McsEngl.Wasm-spec,
addressWpg::
* core-spec.html : https://webassembly.github.io/spec/core/,
* core-spec.pdf: https://webassembly.github.io/spec/core/_download/WebAssembly.pdf,
* JavaScript-API-spec: https://webassembly.github.io/spec/js-api/index.html,
* web-API-spec: https://webassembly.github.io/spec/web-api/index.html,
* WebAssembly-Reference-Manual: a human-readable document written in Markdown, an alternative to the official WebAssembly specification: https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md,
* Conrad-Watt, Mechanising and Verifying the WebAssembly Specification: https://www.cl.cam.ac.uk/~caw77/,
* Bringing the Web up to Speed with WebAssembly: https://github.com/WebAssembly/spec/blob/master/papers/pldi2017.pdf,
name::
* McsEngl.lagWasm'grammar,
* McsEngl.Wasm-grammar,
* McsEngl.Wasm-spec'grammar,
description::
· abstract-grammar is the generic grammar for both formats, binary and text.
[hmnSngo.2018-03-31]
===
· WebAssembly is a-programming-language that has multiple concrete representations (its binary-format and the-text-format).
· both map to a common structure.
· for conciseness, this structure is-described in the-form of an-abstract-syntax.
· all parts of this specification are-defined in terms of this abstract-syntax.
[https://webassembly.github.io/spec/core/syntax/conventions.html#conventions {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'abstract-grammar,
* McsEngl.Wasm-grammar.abstract,
addressWpg::
* https://webassembly.github.io/spec/core/syntax/conventions.html,
description::
· Terminal symbols (atoms) are written in sans-serif font: i32, end.
· Nonterminal symbols are written in italic font: valtype, instr.
· Productions are written sym ::= A1 | … | An.
· Some productions are augmented with side conditions in parentheses, “(if condition)”, that provide a shorthand for a combinatorial expansion of the production into many separate cases.
[https://webassembly.github.io/spec/core/syntax/conventions.html {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'production-of-abstract-syntax,
* McsEngl.Wasm-abstract-syntax'production,
description::
· An is a sequence of n≥0 iterations of A.
· A∗ is a possibly empty sequence of iterations of A. (This is a shorthand for An used where n is not relevant.)
· A+ is a non-empty sequence of iterations of A. (This is a shorthand for An where n≥1.)
· A? is an optional occurrence of A. (This is a shorthand for An where n≤1.)
· ϵ denotes the empty sequence.
· |s| denotes the length of a sequence s.
· s[i] denotes the i-th element of a sequence s, starting from 0.
· s[i:n] denotes the sub-sequence s[i] … s[i+n−1] of a sequence s.
· swith[i]=A denotes the same sequence as s, except that the i-the element is replaced with A.
· swith[i:n]=An denotes the same sequence as s, except that the sub-sequence s[i:n] is replaced with An.
· concat(s∗) denotes the flat sequence formed by concatenating all sequences si in s∗.
[https://webassembly.github.io/spec/core/syntax/conventions.html {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'sequence-of-abstract-syntax,
* McsEngl.Wasm-abstract-syntax'sequence,
name::
* McsEngl.lagWasm'record-of-abstract-syntax,
* McsEngl.Wasm-abstract-syntax'record,
description::
· vectors are bounded sequences of the-form An (or A∗), where the-A can either be values or complex constructions.
· a-vector can-have at most 232−1 elements.
- vec(A) ::= An (if n < 232)
[https://webassembly.github.io/spec/core/syntax/conventions.html#vectors {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'vector-of-abstract-grammar,
* McsEngl.Wasm-abstract-grammar'vector,
description::
· the-binary-format for WebAssembly-modules is a dense linear encoding of their abstract-syntax. [ 1 ]
· the-format is-defined by an-attribute-grammar whose only terminal-symbols are bytes.
· a byte sequence is a-well-formed-encoding-of-a-module if and only if it is-generated by the-grammar.
· each production of this grammar has exactly one synthesized-attribute: the-abstract-syntax that the respective byte sequence encodes.
· thus, the-attribute-grammar implicitly defines a-decoding-function.
· except for a few exceptions, the-binary-grammar closely mirrors the-grammar-of-the-abstract-syntax.
· note: some phrases of abstract-syntax have multiple possible encodings in the-binary-format.
· for example, numbers may-be-encoded as if they had optional leading zeros.
· implementations of decoders must-support all possible alternatives; implementations of encoders can-pick any allowed encoding.
· the recommended extension for files containing WebAssembly-modules in binary-format is “.wasm” and the recommended Media-Type is “application/wasm”.
· [1] additional encoding layers – for example, introducing compression – may-be-defined on top of the basic representation defined here. However, such layers are outside the-scope of the current specification.
[https://webassembly.github.io/spec/core/binary/conventions.html]
name::
* McsEngl.lagWasm'binary-grammar,
* McsEngl.Wasm-grammar.binary,
addressWpg::
* https://webassembly.github.io/spec/core/binary/conventions.html,
description::
· like the-binary-format, the-text-format is defined by an-attribute-grammar.
· a-text-string is a well-formed description of a-module if and only if it is-generated by the-grammar.
[https://webassembly.github.io/spec/core/text/conventions.html {1-0.2018-03-28}]
name::
* McsEngl.lagWasm'text-grammar,
* McsEngl.Wasm-grammar.text,
* McsEngl.Wasm-text-grammar,
addressWpg::
* https://webassembly.github.io/spec/core/text/conventions.html,
* https://github.com/WebAssembly/spec/tree/master/interpreter/#s-expression-syntax,
description::
· the-text-format allows to use symbolic-identifiers in place of indices.
· to resolve these identifiers into concrete indices, some grammar production are-indexed by an-identifier-context-I as a-synthesized-attribute that records the declared identifiers in each index-space.
· in addition, the-context records the-types defined in the-module, so that parameter indices can-be-computed for functions.
· it is convenient to define identifier-contexts as records I with abstract-syntax as follows:
- I ::= {types (id?)∗,
funcs (id?)∗,
tables (id?)∗,
mems (id?)∗,
globals (id?)∗,
locals (id?)∗,
labels (id?)∗,
typedefs functype∗ }
· for each index-space, such a-context contains the list of identifiers assigned to the defined indices.
· unnamed indices are-associated with empty (ϵ) entries in these lists.
· an-identifier-context is well-formed if no index-space contains duplicate identifiers.
[https://webassembly.github.io/spec/core/text/conventions.html#contexts {1-0.2018-03-28}]
description::
'WebAssembly is an open standard developed by a W3C Community Group that includes representatives of all major browser vendors.'
[https://webassembly.github.io/spec/core/_download/WebAssembly.pdf]
===
'The mission of the WebAssembly Working Group is to standardize a size- and load-time-efficient format and execution environment, allowing compilation to the web with consistent behavior across a variety of implementations.'
[https://www.w3.org/wasm/]
name::
* McsEngl.lagWasm'W3C-community-group,
* McsEngl.lagWasm'working-group,
* McsEngl.WebAssembly-working-group,
addressWpg::
* https://www.w3.org/wasm/,
* https://www.w3.org/community/webassembly/,
name::
* McsEngl.lagWasm'tool,
* McsEngl.Wasm-tool,
addressWpg::
* https://github.com/WebAssembly/design/blob/master/Tooling.md,
specific::
* runtime-environment,
* editor,
* compiler,
name::
* McsEngl.lagWasm'compiler,
* McsEngl.Wasm-compiler,
specific::
* https://wasdk.github.io/WasmFiddle/,
* http://mbebenita.github.io/WasmExplorer/,
name::
* McsEngl.lagWasm'to-wat-compiler,
* McsEngl.Wasm-compiler.to-wat,
specific::
* online C-to-wat: https://wasdk.github.io/WasmFiddle/,
name::
* McsEngl.lagWasm'to-wasm-compiler,
* McsEngl.Wasm-compiler.to-wasm,
specific::
* online C-to-wasm: https://wasdk.github.io/WasmFiddle/,
* TypeScript-to-wasm: AssemblyScript https://github.com/AssemblyScript/assemblyscript,
* TypeScript-to-wasm: speedy.js https://github.com/MichaReiser/speedy.js,
name::
* McsEngl.lagWasm'wat-to-wasm,
* McsEngl.Wasm-compiler.wat-to-wasm,
specific::
* wat2wasm cli-tool (WABT),
* online: https://cdn.rawgit.com/WebAssembly/wabt/aae5a4b7/demo/wat2wasm/,
name::
* McsEngl.lagWasm'wasm-to-wat,
* McsEngl.Wasm-compiler.wasm-to-wat,
addressWpg::
* online: https://cdn.rawgit.com/WebAssembly/wabt/aae5a4b7/demo/wasm2wat/,
* wat2wasm: WABT cli tool (wat2wasm test.wat -o test.wasm),
name::
* McsEngl.lagWasm'wasm-to-machine,
* McsEngl.Wasm-compiler.wasm-to-machine,
specific::
* Wasm-runtime-environment,
description::
· view a-wasm-file in hexadecimal-format.
name::
* McsEngl.Wasm-tool.hex-viewer,
addressWpg::
* online: http://tomeko.net/online_tools/file_to_hex.php?lang=en,
description::
· WABT includes tools for development and/or use in tools meant to work with WebAssembly:
- it perfectly supports the format specification
- it can convert from/to the textual format
- it include an interpreter
· In short, it ensures a clean and easy access to the data in the WebAssembly format so that you can work with it.
[https://tomassetti.me/introduction-to-webassembly/]
name::
* McsEngl.WABT,
* McsEngl.lagWasm'WABT, /wabit/
* McsEngl.lagWasm'WebAssembly-Binary-Toolkit,
* McsEngl.Wasm-tool.WABT,
addressWpg::
* https://github.com/WebAssembly/wabt,
* on npm: https://www.npmjs.com/package/wabt,
tool::
* wat2wasm: translate from WebAssembly text format to the WebAssembly binary format
* wasm2wat: the inverse of wat2wasm, translate from the binary format back to the text format (also known as a .wat)
* wasm-objdump: print information about a wasm binary. Similiar to objdump,
* wasm-interp: decode and run a WebAssembly binary file using a stack-based interpreter
* wat-desugar: parse .wat text form as supported by the spec interpreter (s-expressions, flat syntax, or mixed) and print "canonical" flat format
* wasm2c: convert a WebAssembly binary file to a C source and header
[https://github.com/WebAssembly/wabt]
installing::
* clone: $ git clone --recursive https://github.com/WebAssembly/wabt
* build: instructions in https://github.com/WebAssembly/wabt,
* set directory of tools on path,
description::
· Binaryen is an industrial-strength toolkit meant for usage in a compiler infrastructure:
- it can work with WebAssembly code or a control flow graph form meant for compilers
- it optimizes the code with many passes, both standard optimization and specific ones for WebAssembly
- it can compile from/to asm.js (a subset of JavaScript), Rust MIR (an intermediate language for Rust) and LLVM
· So, this toolkit is ready to be integrated in your production backend.
[https://tomassetti.me/introduction-to-webassembly/]
name::
* McsEngl.Binaryen,
* McsEngl.lagWasm'Binaryen,
* McsEngl.Wasm-tool.Binaryen,
addressWpg::
* https://github.com/WebAssembly/binaryen,
description::
· Emscripten is a toolchain for compiling to asm.js and WebAssembly, built using LLVM, that lets you run C and C++ on the web at near-native speed without plugins.
[http://kripken.github.io/emscripten-site/index.html]
name::
* McsEngl.Emscripten,
* McsEngl.lagWasm'Emscripten,
* McsEngl.Wasm-tool.Emscripten,
addressWpg::
* http://kripken.github.io/emscripten-site/index.html,
description::
· the-runtime-environment[a] is the-software-system that provides the necessary libraries and executes a-Wasm-program.
· now, it[a] is a-browser and the-Node.js.
[hmnSngo.2018-04-08]
===
· a WebAssembly runtime-environment will typically provide APIs for interacting with the-outside-world, as-well-as mechanisms for loading and linking wasm-modules.
· this is the-embedding-environment.
[https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#embedding-environment]
name::
* McsEngl.lagWasm'embedder,
* McsEngl.lagWasm'embedding-environment,
* McsEngl.lagWasm'host-environment,
* McsEngl.lagWasm'outside-environment,
* McsEngl.lagWasm'runtime-environment,
description::
· The-WebAssembly-JavaScript-object acts as the-namespace for all WebAssembly-related functionality.
· unlike most other global-objects, WebAssembly is-not a-constructor (it is-not a-function-object).
· you can-compare it to Math, which is also a namespace object for mathematical constants and functions, or to Intl which is the namespace object for internationalization constructors and other language sensitive functions.
· the primary uses for the-WebAssembly-object are:
* loading WebAssembly-code, using the-WebAssembly.instantiate()-function,
* creating new memory and table instances via the-WebAssembly.Memory()/WebAssembly.Table()-constructors,
* providing facilities to handle errors that occur in WebAssembly via the-WebAssembly.CompileError()/WebAssembly.LinkError()/WebAssembly.RuntimeError()-constructors,
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly]
name::
* McsEngl.Jsbr-API'WebAssembly-object,
* McsEngl.Jsnd-API'WebAssembly-object,
* McsEngl.Jsgn-API'WebAssembly-object,
* McsEngl.Jsbr-o.WebAssembly,
* McsEngl.lagWasm'Api.javascript,
* McsEngl.lagWasm'javascript-Api,
* McsEngl.lagWasm'WebAssembly--javascript-object,
* McsEngl.Wasm-WebAssembly-object,
* McsEngl.WebAssembly--javascript-object,
member::
> Object.getOwnPropertyNames(WebAssembly).sort().join(', ')
"CompileError, Instance, LinkError, Memory, Module, RuntimeError, Table, compile, compileStreaming, instantiate, instantiateStreaming, validate"
===
//Node.js 8.11.1
"CompileError, Instance, LinkError, Memory, Module, RuntimeError, Table, compile, instantiate, validate"
description::
· the-WebAssembly.instantiate()-function allows you to compile and instantiate WebAssembly-code.
· this function has two overloads:
* the primary overload takes the-WebAssembly-binary-code, in the-form of a-typed-array or ArrayBuffer, and performs both compilation and instantiation in one step. The returned Promise resolves to both a compiled WebAssembly.Module and its first WebAssembly.Instance,
* the secondary overload takes an already-compiled WebAssembly.Module and returns a-Promise that resolves to an Instance of that Module. This overload is useful if the-Module has already been-compiled or retrieved from cache,
· important: this method is-not the most efficient way of fetching and instantiating wasm-modules. If at all possible, you should-use the newer WebAssembly.instantiateStreaming() method instead, which fetches, compiles, and instantiates a-module all in one step, directly from the raw bytecode, so doesn't require conversation to an-ArrayBuffer.
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate]
name::
* McsEngl.lagWasm'WebAssembly.instantiate-function,
* McsEngl.WebAssembly.instantiate-function,
description::
· the-WebAssembly.instantiateStreaming()-function compiles and instantiates a-WebAssembly-module directly from a streamed underlying source.
· this is the most efficient, optimized way to load wasm-code.
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming]
name::
* McsEngl.lagWasm'WebAssembly.instantiateSteaming-function,
* McsEngl.WebAssembly.instantiateSteaming-function,
description::
· the-WebAssembly.compile()-function compiles a-WebAssembly.Module from WebAssembly-binary-code.
· this function is useful if it is necessary to compile a-module before it can-be-instantiated (otherwise, the-WebAssembly.instantiate()-function should-be-used).
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile]
name::
* McsEngl.lagWasm'WebAssembly.compile-function,
* McsEngl.WebAssembly.compile-function,
description::
· the-WebAssembly.compileStreaming()-function compiles a-WebAssembly.Module directly from a streamed underlying source.
· this function is useful if it is necessary to compile a-module before it can-be-instantiated (otherwise, the-WebAssembly.instantiateStreaming()-function should-be-used).
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming]
name::
* McsEngl.lagWasm'WebAssembly.compileStreaming-function,
* McsEngl.WebAssembly.compileStreaming-function,
description::
· the-WebAssembly.validate()-function validates a given typed-array of WebAssembly-binary-code, returning whether the-bytes form a valid wasm-module (true) or not (false).
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate]
name::
* McsEngl.lagWasm'WebAssembly.validate-function,
* McsEngl.WebAssembly.validate-function,
example::
fetch('simple.wasm')
.then(oResponse => oResponse.arrayBuffer())
.then(function(oArrayBuffer) {
var bValid = WebAssembly.validate(oArrayBuffer);
console.log("The given bytes are " + (bValid ? "" : "not ") + "a valid wasm module");
});
[https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/validate.html]
description::
· a-WebAssembly.Module-object contains stateless WebAssembly-code that has already been-compiled by the-browser and can-be efficiently shared with Workers, cached in IndexedDB and instantiated multiple times.
· the-WebAssembly.Module()-constructor-function can-be-called to synchronously compile given WebAssembly-binary-code.
· however, the primary way to get a-Module is through an asynchronous compilation function like WebAssembly.compile() or by reading a-Module out of IndexedDB.
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module]
name::
* McsEngl.lagWasm'WebAssembly.Module-function,
* McsEngl.WebAssembly.Module-function,
member::
>Object.getOwnPropertyNames(WebAssembly.Module).sort()
(8) ["arguments", "caller", "customSections", "exports", "imports", "length", "name", "prototype"]
example Module.imports::
//display the-imports of the-simple-program
WebAssembly.compileStreaming(fetch('simple.wasm'))
.then(function(mod) {
var aImports = WebAssembly.Module.imports(mod);
console.log(aImports[0]);
});
demo.
[https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/imports.html]
example Module.exports::
//display the-exports of the-simple-program
WebAssembly.compileStreaming(fetch('simple.wasm'))
.then(function(mod) {
var aExports = WebAssembly.Module.exports(mod);
console.log(aExports[0]);
});
demo.
description::
· a-WebAssembly.Instance-object is a stateful, executable instance of a-WebAssembly.Module.
· instance-objects contain all the Exported WebAssembly functions that allow calling into WebAssembly code from JavaScript.
· the-WebAssembly.Instance()-constructor-function can-be-called to synchronously instantiate a given WebAssembly.Module-object.
· however, the primary way to get an Instance is through the asynchronous WebAssembly.instantiateStreaming()-function.
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance]
name::
* McsEngl.lagWasm'WebAssembly.Instance-function,
* McsEngl.WebAssembly.Instance-function,
description::
· the-WebAssembly.Memory()-constructor creates a new Memory-object which is a resizable ArrayBuffer that holds the raw bytes of memory accessed by a-WebAssembly-Instance.
· a-memory created by JavaScript or in WebAssembly-code will-be accessible and mutable from both JavaScript and WebAssembly.
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory]
name::
* McsEngl.lagWasm'WebAssembly.Memory-function,
* McsEngl.WebAssembly.Memory-function,
description::
· the-WebAssembly.Table()-constructor creates a new Table-object of the given size and element type.
· this is a-JavaScript wrapper object — an array-like structure representing a-WebAssembly-Table, which stores function-references.
· a-table created by JavaScript or in WebAssembly-code will-be accessible and mutable from both JavaScript and WebAssembly.
· note: tables can currently only store function-references, but this will likely be-expanded in the-future.
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table]
name::
* McsEngl.lagWasm'WebAssembly.Table-function,
* McsEngl.WebAssembly.Table-function,
description::
· the-WebAssembly.CompileError()-constructor creates a new WebAssembly-CompileError-object, which indicates an-error during WebAssembly decoding or validation.
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError]
name::
* McsEngl.lagWasm'WebAssembly.CompileError-function,
* McsEngl.WebAssembly.CompileError-function,
description::
· the-WebAssembly.LinkError()-constructor creates a new WebAssembly-LinkError-object, which indicates an-error during module-instantiation (besides traps from the-start-function).
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError]
name::
* McsEngl.lagWasm'WebAssembly.LinkError-function,
* McsEngl.WebAssembly.LinkError-function,
description::
· the-WebAssembly.RuntimeError()-constructor creates a new WebAssembly-RuntimeError-object — the-type that is-thrown whenever WebAssembly specifies a-trap.
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError]
name::
* McsEngl.lagWasm'WebAssembly.RuntimeError-function,
* McsEngl.WebAssembly.RuntimeError-function,
description::
· machine-document is the-document that understands and executes a real|concrete machine.
[hmnSngo.2018-03-25]
description::
'Decoding
WebAssembly modules are distributed in a binary format. Decoding processes that format and converts it into an internal representation of a module. In this specification, this representation is modelled by abstract syntax, but a real implementation could compile directly to machine code instead.'
[https://webassembly.github.io/spec/core/intro/overview.html#semantic-phases {1-0.2018-03-22}]
description::
'Validation
A decoded module has to be valid. Validation checks a number of well-formedness conditions to guarantee that the module is meaningful and safe. In particular, it performs type checking of functions and the instruction sequences in their bodies, ensuring for example that the operand stack is used consistently.'
[https://webassembly.github.io/spec/core/intro/overview.html#semantic-phases {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'validating,
addressWpg::
* {2018-04-07} Mauro-Bringolf, Learning the Webassembly type system, https://maurobringolf.ch/,
description::
'Finally, a valid module can be executed. Execution can be further divided into two phases: instantiation, invocation.'
[https://webassembly.github.io/spec/core/intro/overview.html#semantic-phases {1-0.2018-03-22}]
name::
* McsEngl.lagWasm'executing,
description::
Instantiation. A module instance is the dynamic representation of a module, complete with its own state and execution stack. Instantiation executes the module body itself, given definitions for all its imports. It initializes globals, memories and tables and invokes the module’s start function if defined. It returns the instances of the module’s exports.
[https://webassembly.github.io/spec/core/intro/overview.html#semantic-phases {1-0.2018-03-22}]
description::
'Invocation. Once instantiated, further WebAssembly computations can be initiated by invoking an exported function on a module instance. Given the required arguments, that executes the respective function and returns its results.'
[https://webassembly.github.io/spec/core/intro/overview.html#semantic-phases {1-0.2018-03-22}]
Name::
* McsEngl.WebAssembly'Infrsc,
* McsEngl.lagWasm'Infrsc,
* McsEngl.WasmAeResource,
addressWpg::
* webassembly.org,
* https://research.mozilla.org/webassembly/,
* WebAssembly-community-group,
* spec: https://webassembly.github.io/spec/core/_download/WebAssembly.pdf,
* https://github.com/mbasso/awesome-wasm,
* https://wasdk.github.io/WasmFiddle/,
* https://rsms.me/wasm-intro,
* https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md,
* https://tomassetti.me/introduction-to-webassembly/,
* {2019-03-27} Lin-Clark, https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/,
* {2018-10-22} Lin-Clark, Till-Schneidereit, Luke-Wagner, WebAssembly’s post-MVP future: A cartoon skill tree, https://hacks.mozilla.org/2018/10/webassemblys-post-mvp-future/,
* {2018-10-08} Lin-Clark, Calls between JavaScript and WebAssembly are finally fast, https://hacks.mozilla.org/2018/10/calls-between-javascript-and-webassembly-are-finally-fast-%F0%9F%8E%89/,
* {2018-01-01} Mirko-Sertic, Object-Oriented WebAssembly, https://www.mirkosertic.de/blog/2018/01/object-oriented-webassembly/,
* {2017-07} https://hacks.mozilla.org/2017/07/creating-a-webassembly-module-instance-with-javascript,
addressWpg::
* Clark.Lin, A cartoon intro to WebAssembly: https://hacks.mozilla.org/2017/02/,
* code-examples: https://github.com/reklatsmasters/webassembly-examples,
Generic-chain::
* web-programing-language,
...
* entity,
name::
* McsEngl.WebAssembly.specific,
* McsEngl.WasmAsSpecific,
specific::
* binary-format,
* text-format,
* Ethereum flavored WebAssembly (ewasm): https://github.com/ewasm,
description::
· the-Wasm-specification represents a-Wasm-document AND in a generic format of the-two Wasm-formats, the-text and the-binary.
· this generic format it calls it 'abstract-format'.
[hmnSngo.2018-04-06]
name::
* McsEngl.lagWasm'abstract-format,
description::
· WebAssembly has an-S-expression-based textual representation, an intermediate form designed to be-exposed in text-editors, browser-developer-tools, etc.
[https://developer.mozilla.org/en-US/docs/WebAssembly/Text_format_to_wasm]
name::
* McsEngl.text-Wasm,
* McsEngl.Wasm.source-format,
* McsEngl.Wasm.textual-format,
* McsEngl.Wasm.text-format,
description::
· S-expressions are a very old and very simple textual-format for representing trees of nodes.
· each node in the-tree goes inside a-pair of parentheses — ( ... ).
· the first label inside the-parenthesis tells you what type of node it is, and after that there-is a space-separated list of either attributes or child-nodes.
[https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format]
name::
* McsEngl.S-expression.Wasm,
* McsEngl.lagWasm'S-expression,
description::
· the recommended file-extension for WebAssembly code in textual-format is .wat
.
name::
* McsEngl.lagWasm'converting-text-to-binary-format,
* McsEngl.lagWasm'translating-text-to-binary-format,
addressWpg::
* wat2wasm: https://cdn.rawgit.com/WebAssembly/wabt/aae5a4b7/demo/wat2wasm/,
addressWpg::
* https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format,
description::
The .wast format understood by some of the listed tools is a superset of the .wat format that is intended for writing test scripts. Besides the definition of modules such scripts can contain assertions and other commands as defined by a grammar extension. These extensions are not part of the official text format, which may only contain a single module.
[https://webassembly.org/docs/text-format/]
name::
* McsEngl.lagWasm'wast-format,
* McsEngl.wast-format,
description::
· Wasm-binary-format is a-WebAssembly with bits as algo-units.
name::
* McsEngl.binary-Wasm,
* McsEngl.Wasm.binary-format,
name::
* McsEngl.Wasm.evoluting,
{time.2016-03-15}::
=== demonstration:
on 15-March-2016 was-demonstrated executing Unity's-Angry-Bots in Firefox, Chromium, Google Chrome, and Microsoft Edge.
[https://en.wikipedia.org/wiki/WebAssembly]
{time.2015-06-17}::
=== announcement:
It was first announced on 17-June-2015.
[https://en.wikipedia.org/wiki/WebAssembly]
this webpage was-visited times since {2018-03-18}
page-wholepath: synagonism.net / worldviewSngo / dirTchInf / lagWasm
SEARCH::
· this page uses 'locator-names', names that when you find them, you find the-LOCATION of the-concept they denote.
• LOCAL-SEARCH:
· TYPE CTRL+F "cpt.words-of-concept's-name", to go to the-LOCATION of the-concept.
• GLOBAL-SEARCH:
· clicking on the-GREEN-BAR of a-page you have access to the-global--locator-names of my-site.
· a-preview of the-description of a-global-name makes reading fast.
webpage-versions::
• version.last.dynamic: McsTchInf000014.last.html,
• version.1-0-0.2021-04-09: (0-54) ../../dirMiwMcs/dirTchInf/filMcsLagWasm.1-0-0.2021-04-09.html,
• version.0-1-0.2018-03-18.created: ../../dirMiwMcs/dirTchInf/filMcsLagWasm.0-1-0.2018-03-18.html,
specific::
* on Disqus,