From 2ebd97b2676fc036ff869a514f364437aece5a69 Mon Sep 17 00:00:00 2001 From: Michael Holman Date: Mon, 29 Jun 2015 09:07:36 -0700 Subject: add opcode definitions section --- BinaryEncoding.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'BinaryEncoding.md') diff --git a/BinaryEncoding.md b/BinaryEncoding.md index 33d296e..ab77f30 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -72,13 +72,19 @@ Yes: * A section contains: * a header followed by * the section contents (specific to the section type) +* An opcode definitions section contains: + * the generic section header + * a table containing, for each opcode-space, it's type, offset (within the section), sorted by offset, followed by + * a sequence of opcode tables + * An opcode table contains: + * a sequence of standardized string literals, where order determines opcode index * A code section contains: * the generic section header * a table containing, for each function, it's signature, offset (within the section), sorted by offset, followed by * a sequence of functions -* A function contains: - * a table containing, for each type, how many locals are indexed by the function body of that type - * the serialized AST + * A function contains: + * a table containing, for each type, how many locals are indexed by the function body of that type + * the serialized AST ## Serialized AST -- cgit v1.2.3 From adad31c80812a5943605d3ae7aea766a90d4fd53 Mon Sep 17 00:00:00 2001 From: Michael Holman Date: Mon, 29 Jun 2015 09:26:26 -0700 Subject: added type id to section --- BinaryEncoding.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'BinaryEncoding.md') diff --git a/BinaryEncoding.md b/BinaryEncoding.md index ab77f30..ca152a6 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -67,23 +67,30 @@ Yes: * A module contains: * a header followed by - * a table (sorted by offset) containing, for each section, its type and offset (within the module), followed by + * a table (sorted by offset) containing, for each section, its type and + offset (within the module), followed by * a sequence of sections. * A section contains: * a header followed by * the section contents (specific to the section type) -* An opcode definitions section contains: +* A definitions section contains: * the generic section header - * a table containing, for each opcode-space, it's type, offset (within the section), sorted by offset, followed by + * a sequence of standardized string literal types, where order determines + type ID, followed by + * a table containing, for each opcode-space, its type, offset (within the + section), sorted by offset, followed by * a sequence of opcode tables * An opcode table contains: - * a sequence of standardized string literals, where order determines opcode index + * a sequence of standardized string literal opcodes, where order determines + opcode index * A code section contains: * the generic section header - * a table containing, for each function, it's signature, offset (within the section), sorted by offset, followed by + * a table containing, for each function, its signature, offset (within the + section), sorted by offset, followed by * a sequence of functions * A function contains: - * a table containing, for each type, how many locals are indexed by the function body of that type + * a table containing, for each type, how many locals are indexed by the + function body of that type * the serialized AST ## Serialized AST -- cgit v1.2.3 From f6625e1becab6672863034125163984f13a0c86f Mon Sep 17 00:00:00 2001 From: Michael Holman Date: Mon, 29 Jun 2015 09:47:23 -0700 Subject: combined tables --- BinaryEncoding.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'BinaryEncoding.md') diff --git a/BinaryEncoding.md b/BinaryEncoding.md index ca152a6..557664e 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -75,14 +75,13 @@ Yes: * the section contents (specific to the section type) * A definitions section contains: * the generic section header - * a sequence of standardized string literal types, where order determines - type ID, followed by - * a table containing, for each opcode-space, its type, offset (within the - section), sorted by offset, followed by + * a table containing, for each opcode-space, a standardized string literal + type name (where index defines its type), offset (within the section), + sorted by offset, followed by * a sequence of opcode tables * An opcode table contains: - * a sequence of standardized string literal opcodes, where order determines - opcode index + * a sequence of standardized string literal opcode names, where order + determines opcode index * A code section contains: * the generic section header * a table containing, for each function, its signature, offset (within the -- cgit v1.2.3 From f638520afb6c669442caa7d788bbcdbef300edf8 Mon Sep 17 00:00:00 2001 From: Michael Holman Date: Mon, 29 Jun 2015 13:50:38 -0700 Subject: some cleanup --- BinaryEncoding.md | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'BinaryEncoding.md') diff --git a/BinaryEncoding.md b/BinaryEncoding.md index 557664e..61fb019 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -65,32 +65,36 @@ Yes: ## Global structure -* A module contains: - * a header followed by - * a table (sorted by offset) containing, for each section, its type and - offset (within the module), followed by - * a sequence of sections. +* A module contains (in this order): + * A header + * A table (sorted by offset) containing, for each section: + * Section type + * Offset within the module + * A sequence of sections * A section contains: - * a header followed by - * the section contents (specific to the section type) -* A definitions section contains: - * the generic section header - * a table containing, for each opcode-space, a standardized string literal - type name (where index defines its type), offset (within the section), - sorted by offset, followed by - * a sequence of opcode tables + * A header followed by + * The section contents (specific to the section type) +* A definitions section contains (in this order): + * The generic section header + * A table (sorted by offset) containing, for each type which has opcodes: + * A standardized string literal [type name](AstSemantics.md#local-and-memory-types). + The index of a type name in this table is referred to as a type ID + * Offset of its opcode table within the section + * A sequence of opcode tables * An opcode table contains: - * a sequence of standardized string literal opcode names, where order - determines opcode index -* A code section contains: - * the generic section header - * a table containing, for each function, its signature, offset (within the - section), sorted by offset, followed by - * a sequence of functions + * A sequence of standardized string literal [opcode names](AstSemantics.md), + where order determines opcode index +* A code section contains (in this order): + * The generic section header + * A table (sorted by offset) containing, for each function: + * Signature + * Offset within the section + * A sequence of functions * A function contains: - * a table containing, for each type, how many locals are indexed by the - function body of that type - * the serialized AST + * A table containing, for each type ID that has [locals](AstSemantics.md#addressing-local-variables): + * Type ID + * Count of locals + * The serialized AST ## Serialized AST -- cgit v1.2.3 From ad4a73eddd074cec18a94bd6bc843f19504217e0 Mon Sep 17 00:00:00 2001 From: Michael Holman Date: Mon, 29 Jun 2015 15:40:54 -0700 Subject: cleanup and clarifications --- BinaryEncoding.md | 52 ++++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'BinaryEncoding.md') diff --git a/BinaryEncoding.md b/BinaryEncoding.md index 61fb019..1f4f3ed 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -66,35 +66,39 @@ Yes: ## Global structure * A module contains (in this order): - * A header - * A table (sorted by offset) containing, for each section: - * Section type - * Offset within the module - * A sequence of sections + - A header, containing: + + The [magic number](https://en.wikipedia.org/wiki/Magic_number_%28programming%29) + + Other data TBD (possibly entrypoint, memory bitness, source language, etc.) + - A table (sorted by offset) containing, for each section: + + A string literal section type name + + 32-bit offset within the module + - A sequence of sections * A section contains: - * A header followed by - * The section contents (specific to the section type) -* A definitions section contains (in this order): - * The generic section header - * A table (sorted by offset) containing, for each type which has opcodes: - * A standardized string literal [type name](AstSemantics.md#local-and-memory-types). + - A header followed by + - The section contents (specific to the section type) +* A `definitions` section contains (in this order): + - The generic section header + - A table (sorted by offset) containing, for each type which has opcodes: + + A standardized string literal [type name](AstSemantics.md#local-and-memory-types). The index of a type name in this table is referred to as a type ID - * Offset of its opcode table within the section - * A sequence of opcode tables - * An opcode table contains: - * A sequence of standardized string literal [opcode names](AstSemantics.md), + + 32-bit offset of its opcode table within the section + - A sequence of opcode tables + - An opcode table contains: + + A sequence of standardized string literal [opcode names](AstSemantics.md), where order determines opcode index -* A code section contains (in this order): - * The generic section header - * A table (sorted by offset) containing, for each function: - * Signature - * Offset within the section - * A sequence of functions - * A function contains: - * A table containing, for each type ID that has [locals](AstSemantics.md#addressing-local-variables): +* A `code` section contains (in this order): + - The generic section header + - A table (sorted by offset) containing, for each function: + + Signature + + 32-bit offset within the section + - A sequence of functions + - A function contains: + + A table containing, for each type ID that has [locals](AstSemantics.md#addressing-local-variables): * Type ID * Count of locals - * The serialized AST + + The serialized AST + +All strings are encoded as null-terminated UTF8. ## Serialized AST -- cgit v1.2.3 From 1abb70631f16e6a2922f035730d6186db3d889a2 Mon Sep 17 00:00:00 2001 From: Michael Holman Date: Tue, 30 Jun 2015 13:32:02 -0700 Subject: tiny update --- BinaryEncoding.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'BinaryEncoding.md') diff --git a/BinaryEncoding.md b/BinaryEncoding.md index 1f4f3ed..316f345 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -68,10 +68,10 @@ Yes: * A module contains (in this order): - A header, containing: + The [magic number](https://en.wikipedia.org/wiki/Magic_number_%28programming%29) - + Other data TBD (possibly entrypoint, memory bitness, source language, etc.) + + Other data TBD - A table (sorted by offset) containing, for each section: + A string literal section type name - + 32-bit offset within the module + + 64-bit offset within the module - A sequence of sections * A section contains: - A header followed by -- cgit v1.2.3 From 90f8acd4b876ab67a60abfa16cdf3f2342e031be Mon Sep 17 00:00:00 2001 From: Michael Holman Date: Tue, 30 Jun 2015 13:57:45 -0700 Subject: made code sections have 64 bit offsets --- BinaryEncoding.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'BinaryEncoding.md') diff --git a/BinaryEncoding.md b/BinaryEncoding.md index 316f345..3ccc9f9 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -90,7 +90,7 @@ Yes: - The generic section header - A table (sorted by offset) containing, for each function: + Signature - + 32-bit offset within the section + + 64-bit offset within the section - A sequence of functions - A function contains: + A table containing, for each type ID that has [locals](AstSemantics.md#addressing-local-variables): -- cgit v1.2.3