From e60bc51be318bc4c43b2ec432a83df06b54a9984 Mon Sep 17 00:00:00 2001 From: rossberg-chromium Date: Wed, 17 Aug 2016 14:45:29 +0200 Subject: [PATCH 1/3] Remove repetition in description of varint types --- BinaryEncoding.md | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/BinaryEncoding.md b/BinaryEncoding.md index 1394624d..a1583789 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -31,26 +31,21 @@ for a proposal for layer 1 structural compression. # Data types -### uint8 -A single-byte unsigned integer. - -### uint32 -A four-byte little endian unsigned integer. - -### varint32 -A [Signed LEB128](https://en.wikipedia.org/wiki/LEB128#Signed_LEB128) variable-length integer, limited to int32 values. `varint32` values may contain leading zero or one bits and must be at most 5 bytes. - -### varuint1 -A [LEB128](https://en.wikipedia.org/wiki/LEB128) variable-length integer, limited to the values 0 or 1. `varuint1` values must be exactly one byte. (This type is mainly used for compatibility with potential future extensions.) - -### varuint7 -A [LEB128](https://en.wikipedia.org/wiki/LEB128) variable-length integer, limited to the values [0, 127]. `varuint7` values must be exactly one byte. (This type is mainly used for compatibility with potential future extensions.) - -### varuint32 -A [LEB128](https://en.wikipedia.org/wiki/LEB128) variable-length integer, limited to uint32 values. `varuint32` values may contain leading zeros and must be at most 5 bytes. - -### varint64 -A [Signed LEB128](https://en.wikipedia.org/wiki/LEB128#Signed_LEB128) variable-length integer, limited to int64 values. `varint64` values may contain leading zero or one bits and must be at most 10 bytes. +### uintN +An unsigned integer of _N_ bits, +represented in _N_/8 bytes in [little endian](https://en.wikipedia.org/wiki/Endianness#Little-endian) order. +_N_ is either 8, 16, or 32. + +### varuintN +A [LEB128](https://en.wikipedia.org/wiki/LEB128) variable-length integer, limited to _N_ bits (i.e., the values [0, 2^_N_-1]), +represented by at most trunc(_N_/7)+1 bytes that may contain padding zero bytes. +Currently, the only sizes _N_ used are 1, 7, and 32, +where the former are used for compatibility with potential future extensions. + +### varintN +A [Signed LEB128](https://en.wikipedia.org/wiki/LEB128#Signed_LEB128) variable-length integer, limited to _N_ bits (i.e., the values [-2^(_N_-1), +2^(_N_-1)-1]), +represented by at most trunc(_N_/7)+1 bytes that may contain padding zero or all-one bytes. +Currently, the only sizes _N_ used are 32 and 64. ### value_type A single-byte unsigned integer indicating a [value type](AstSemantics.md#types). These types are encoded as: From 7e75be235c9df03055928588c1c2eba7f1144bb0 Mon Sep 17 00:00:00 2001 From: rossberg-chromium Date: Wed, 17 Aug 2016 17:59:50 +0200 Subject: [PATCH 2/3] Fix formula --- BinaryEncoding.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BinaryEncoding.md b/BinaryEncoding.md index a1583789..6ffa139d 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -38,13 +38,13 @@ _N_ is either 8, 16, or 32. ### varuintN A [LEB128](https://en.wikipedia.org/wiki/LEB128) variable-length integer, limited to _N_ bits (i.e., the values [0, 2^_N_-1]), -represented by at most trunc(_N_/7)+1 bytes that may contain padding zero bytes. +represented by at most ceil(_N_/7) bytes that may contain padding zero bytes. Currently, the only sizes _N_ used are 1, 7, and 32, where the former are used for compatibility with potential future extensions. ### varintN A [Signed LEB128](https://en.wikipedia.org/wiki/LEB128#Signed_LEB128) variable-length integer, limited to _N_ bits (i.e., the values [-2^(_N_-1), +2^(_N_-1)-1]), -represented by at most trunc(_N_/7)+1 bytes that may contain padding zero or all-one bytes. +represented by at most ceil(_N_/7) bytes that may contain padding zero or all-one bytes. Currently, the only sizes _N_ used are 32 and 64. ### value_type From b0f984f6264f8b34f4e0b1fa777c3dfbbcc084e5 Mon Sep 17 00:00:00 2001 From: rossberg-chromium Date: Thu, 18 Aug 2016 14:33:04 +0200 Subject: [PATCH 3/3] Tweaks --- BinaryEncoding.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/BinaryEncoding.md b/BinaryEncoding.md index 6ffa139d..22cb2d33 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -31,37 +31,39 @@ for a proposal for layer 1 structural compression. # Data types -### uintN +### `uintN` An unsigned integer of _N_ bits, represented in _N_/8 bytes in [little endian](https://en.wikipedia.org/wiki/Endianness#Little-endian) order. _N_ is either 8, 16, or 32. -### varuintN +### `varuintN` A [LEB128](https://en.wikipedia.org/wiki/LEB128) variable-length integer, limited to _N_ bits (i.e., the values [0, 2^_N_-1]), -represented by at most ceil(_N_/7) bytes that may contain padding zero bytes. -Currently, the only sizes _N_ used are 1, 7, and 32, -where the former are used for compatibility with potential future extensions. +represented by _at most_ ceil(_N_/7) bytes that may contain padding `0x80` bytes. -### varintN +Note: Currently, the only sizes used are `varuint1`, `varuint7`, and `varuint32`, +where the former two are used for compatibility with potential future extensions. + +### `varintN` A [Signed LEB128](https://en.wikipedia.org/wiki/LEB128#Signed_LEB128) variable-length integer, limited to _N_ bits (i.e., the values [-2^(_N_-1), +2^(_N_-1)-1]), -represented by at most ceil(_N_/7) bytes that may contain padding zero or all-one bytes. -Currently, the only sizes _N_ used are 32 and 64. +represented by _at most_ ceil(_N_/7) bytes that may contain padding `0x80` or `0xFF` bytes. + +Note: Currently, the only sizes used are `varuint32` and `varuint64`. -### value_type +### `value_type` A single-byte unsigned integer indicating a [value type](AstSemantics.md#types). These types are encoded as: * `1` indicating type `i32` * `2` indicating type `i64` * `3` indicating type `f32` * `4` indicating type `f64` -### external_kind +### `external_kind` A single-byte unsigned integer indicating the kind of definition being imported or defined: * `0` indicating a `Function` [import](Modules.md#imports) or [definition](Modules.md#function-and-code-sections) * `1` indicating a `Table` [import](Modules.md#imports) or [definition](Modules.md#table-section) * `2` indicating a `Memory` [import](Modules.md#imports) or [definition](Modules.md#linear-memory-section) * `3` indicating a `Global` [import](Modules.md#imports) or [definition](Modules.md#global-section) -### resizable_limits +### `resizable_limits` A packed tuple that describes the limits of a [table](AstSemantics.md#table) or [memory](AstSemantics.md#resizing): @@ -74,7 +76,7 @@ A packed tuple that describes the limits of a The "flags" field may later be extended to include a flag for sharing (between threads). -### init_expr +### `init_expr` The encoding of an [initializer expression](Modules.md#initializer-expression) is the normal encoding of the expression followed by the `end` opcode as a delimiter.