From 21de225d71d3eced3fd1c099fc48a03480001a70 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Tue, 27 Oct 2015 14:28:01 -0500 Subject: [PATCH 1/3] Change max to a hint --- AstSemantics.md | 2 +- BinaryEncoding.md | 5 +++-- Modules.md | 22 ++++++++++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/AstSemantics.md b/AstSemantics.md index 47dc81de..8b051b0a 100644 --- a/AstSemantics.md +++ b/AstSemantics.md @@ -71,7 +71,7 @@ be an untyped array of bytes, and it is unspecified how embedders map this array into their process' own [virtual memory][]. The linear memory is sandboxed; it does not alias the execution engine's internal data structures, the execution stack, local variables, or other process memory. The initial state of linear -memory is specified by the [module](Modules.md#initial-state-of-linear-memory). +memory is specified by the [module](Modules.md#linear-memory-section). [virtual memory]: https://en.wikipedia.org/wiki/Virtual_memory diff --git a/BinaryEncoding.md b/BinaryEncoding.md index f9276310..1e80f716 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -103,8 +103,9 @@ Yes: - A sequence of byte ranges within the binary and corresponding addresses in the linear memory -All strings are encoded as null-terminated UTF8. -Data segments represent initialized data that is loaded directly from the binary into the linear memory when the program starts (see [modules](Modules.md#initial-state-of-linear-memory)). +All strings are encoded as null-terminated UTF8. Data segments represent +initialized data that is loaded directly from the binary into the linear memory +when the program starts (see [modules](Modules.md#linear-memory-section)). ## Serialized AST diff --git a/Modules.md b/Modules.md index 1bcbe45c..3f8682e8 100644 --- a/Modules.md +++ b/Modules.md @@ -8,7 +8,7 @@ is determined by the module it was loaded from. A module contains: * a set of [imports and exports](Modules.md#imports-and-exports); -* a section defining the [initial state of linear memory](Modules.md#initial-state-of-linear-memory); +* a section defining [linear memory](Modules.md#linear-memory-section); * a section containing [code](Modules.md#code-section); * after the MVP, sections containing [debugging/symbol information](Tooling.md) or a reference to separate files containing them; and @@ -122,12 +122,22 @@ shared `malloc` and coordinated global address ranges). Instead, the [dynamic linking future feature](DynamicLinking.md) is intended to allow *explicitly* injecting multiple modules into the same instance. -## Initial state of linear memory +## Linear memory section -A module will contain a section declaring the linear memory size (initial and -maximum size allowed by [`grow_memory`](AstSemantics.md#resizing) and the -initial contents of memory, analogous to `.data`, `.rodata`, `.bss` sections in -native executables (see [binary encoding](BinaryEncoding.md#global-structure)). +A module may contain an optional section declaring the use of linear memory +by the module. If the section is absent, the linear memory operators +`load`, `store`, `memory_size`, and `grow_memory` may not be used in the module. + +The linear memory section declares the initial [memory size](AstSemantics.md#linear-memory) +(which may be subsequently increased by [`grow_memory`](AstSemantics.md#resizing)). + +The initial contents of linear memory are zero by default. However, the memory +section contains a possibly-empty array of *segments* (analogous to `.data`) +which can specify the initial contents of fixed ranges of memory. + +The linear memory section may also contain an optional hint declaring the maximum +heap usage. This hint is not semantically visible but can help a WebAssembly engine +to optimize `grow_memory`. ## Code section From c6ce2481c86524650016c6bf0c58a3cdb94e14a5 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Wed, 28 Oct 2015 10:35:45 -0500 Subject: [PATCH 2/3] Include feedback --- Modules.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Modules.md b/Modules.md index 3f8682e8..ead86eb8 100644 --- a/Modules.md +++ b/Modules.md @@ -133,11 +133,12 @@ The linear memory section declares the initial [memory size](AstSemantics.md#lin The initial contents of linear memory are zero by default. However, the memory section contains a possibly-empty array of *segments* (analogous to `.data`) -which can specify the initial contents of fixed ranges of memory. +which can specify the initial contents of fixed `(offset, length)` ranges of +memory. -The linear memory section may also contain an optional hint declaring the maximum -heap usage. This hint is not semantically visible but can help a WebAssembly engine -to optimize `grow_memory`. +The linear memory section may also contain an optional hint declaring the expected +maximum heap usage. This hint is not semantically visible but can help a +WebAssembly engine to optimize `grow_memory`. ## Code section From ac4cd1a5fe2847ef1f7ca70913fd93fb68e113ec Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Wed, 28 Oct 2015 16:21:44 -0500 Subject: [PATCH 3/3] Add rationale --- Rationale.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Rationale.md b/Rationale.md index 7920ebd7..0bb56bad 100644 --- a/Rationale.md +++ b/Rationale.md @@ -112,6 +112,11 @@ to communicate their own implementation details in a useful manner to the developer. +## Linear memory disabled if no linear memory section + +See [#107](https://github.com/WebAssembly/spec/pull/107). + + ## Control Flow See [#299](https://github.com/WebAssembly/design/pull/299).