Skip to content

Commit e9e5a16

Browse files
Expand binary name section to include type, table, memory, global, and label names.
1 parent e330cb8 commit e9e5a16

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

BinaryEncoding.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,11 @@ be skipped over by an engine. The current list of valid `name_type` codes are:
452452
| [Module](#module-name) | `0` | Assigns a name to the module |
453453
| [Function](#function-names) | `1` | Assigns names to functions |
454454
| [Local](#local-names) | `2` | Assigns names to locals in functions |
455-
455+
| [Labels](#label-names) | `3` | Assigns names to labels in functions |
456+
| [Type](#type-names) | `4` | Assigns names to types |
457+
| [Table](#table-names) | `5` | Assigns names to tables |
458+
| [Memory](#memory-names) | `6` | Assigns names to memories |
459+
| [Global](#global-names) | `7` | Assigns names to globals |
456460

457461
When present, name subsections must appear in this order and at most once. The
458462
end of the last subsection must coincide with the last byte of the name
@@ -500,6 +504,47 @@ where a `local_name` is encoded as:
500504
| index | `varuint32` | the index of the function whose locals are being named |
501505
| local_map | `name_map` | assignment of names to local indices |
502506

507+
#### Label names
508+
509+
The label names subsection assigns `name_map`s to a subset of functions in the
510+
[function index space](Modules.md#function-index-space). This may include both
511+
module-defined or imported functions, but is only meaningful for module-defined
512+
functions. The `name_map` for a given function assigns names to labels within
513+
the function, with labels identified by the offset from the start of the function's
514+
code to the operator that introduces the label (i.e. control flow operators).
515+
516+
| Field | Type | Description |
517+
| ----- | ---- | ----------- |
518+
| count | `varuint32` | count of `label_names` in funcs |
519+
| funcs | `label_names*` | sequence of `label_names` sorted by index |
520+
521+
where a `label_name` is encoded as:
522+
523+
| Field | Type | Description |
524+
| ----- | ---- | ----------- |
525+
| index | `varuint32` | the index of the function whose labels are being named |
526+
| label_map | `name_map` | assignment of names to labeling operator |
527+
528+
#### Type names
529+
530+
The type names subsection is a `name_map` which assigns names to a subset
531+
of types in the module's [type section](#type-section).
532+
533+
#### Table names
534+
535+
The table names subsection is a `name_map` which assigns names to a subset
536+
of tables in the [table index space](Modules.md#table-index-space).
537+
538+
#### Memory names
539+
540+
The memory names subsection is a `name_map` which assigns names to a subset
541+
of memories in the [linear memory index space](Modules.md#linear-memory-index-space).
542+
543+
#### Global names
544+
545+
The global names subsection is a `name_map` which assigns names to a subset
546+
of globals in the [global index space](Modules.md#global-index-space).
547+
503548
#### Module name
504549

505550
The module name subsection assigns a name to the module itself. It simply

0 commit comments

Comments
 (0)