Skip to content

Commit 956f1c9

Browse files
Expand binary name section to include type, table, memory, global, and label names.
1 parent 910e3ca commit 956f1c9

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

BinaryEncoding.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,11 @@ be skipped over by an engine. The current list of valid `name_type` codes are:
457457
| [Module](#module-name) | `0` | Assigns a name to the module |
458458
| [Function](#function-names) | `1` | Assigns names to functions |
459459
| [Local](#local-names) | `2` | Assigns names to locals in functions |
460+
| [Labels](#label-names) | `3` | Assigns names to labels in functions |
461+
| [Type](#type-names) | `4` | Assigns names to types |
462+
| [Table](#table-names) | `5` | Assigns names to tables |
463+
| [Memory](#memory-names) | `6` | Assigns names to memories |
464+
| [Global](#global-names) | `7` | Assigns names to globals |
460465

461466

462467
When present, subsections must appear in this order and at most once. The
@@ -522,6 +527,58 @@ where a `local_name` is encoded as:
522527
| index | `varuint32` | the index of the function whose locals are being named |
523528
| local_map | `name_map` | assignment of names to local indices |
524529

530+
#### Label names
531+
532+
The label names subsection assigns `name_map`s to a subset of functions in the
533+
[function index space](Modules.md#function-index-space). This may include both
534+
module-defined or imported functions, but is only meaningful for module-defined
535+
functions. The `name_map` for a function assigns names to label indices, with
536+
label indices assigned sequentially to the labels in the order they are introduced
537+
by control structure operators (i.e. `block`, `loop`, or `if`) in the function's
538+
code.
539+
540+
| Field | Type | Description |
541+
| ----- | ---- | ----------- |
542+
| count | `varuint32` | count of `label_names` in funcs |
543+
| funcs | `label_names*` | sequence of `label_names` sorted by index |
544+
545+
where a `label_name` is encoded as:
546+
547+
| Field | Type | Description |
548+
| ----- | ---- | ----------- |
549+
| index | `varuint32` | the index of the function whose labels are being named |
550+
| label_map | `name_map` | assignment of names to labeling operator |
551+
552+
#### Type names
553+
554+
The type names subsection is a `name_map` which assigns names to a subset
555+
of types in the module's [type section](#type-section).
556+
557+
#### Table names
558+
559+
The table names subsection is a `name_map` which assigns names to a subset
560+
of tables in the [table index space](Modules.md#table-index-space).
561+
562+
#### Memory names
563+
564+
The memory names subsection is a `name_map` which assigns names to a subset
565+
of memories in the [linear memory index space](Modules.md#linear-memory-index-space).
566+
567+
#### Global names
568+
569+
The global names subsection is a `name_map` which assigns names to a subset
570+
of globals in the [global index space](Modules.md#global-index-space).
571+
572+
#### Module name
573+
574+
The module name subsection assigns a name to the module itself. It simply
575+
consists of a single string:
576+
577+
| Field | Type | Description |
578+
| ----- | ---- | ----------- |
579+
| name_len | `varuint32` | length of `name_str` in bytes |
580+
| name_str | `bytes` | UTF-8 encoding of the name |
581+
525582
# Function Bodies
526583

527584
Function bodies consist of a sequence of local variable declarations followed by

0 commit comments

Comments
 (0)