diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-08-05 00:15:30 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-08-05 16:37:41 +0200 |
commit | 304995b88d4e068db43a5edb677c2d525f7b49d3 (patch) | |
tree | d3259491ea9e4b525a09ec171de5faee8bfce3e2 /include | |
parent | 506cc372436f6b03ac79762e66e307bb4c5a28ea (diff) |
compiler: rework export index allocation
The current implementation of the module export offset tracking was
inadequate and failed to properly handle larger module dependency
graphs. In order to properly support nested module imports/exports,
the following changes have been introduced:
- Gather export slots during module compilation and emit corresponding
export opcodes as one contiguous block at the end of the module
function body, right before the final return. This ensures that
interleaved imports of other modules do not place foreign exports
between our module exports.
- Track the number of program wide allocated export slots in order
to derive per-module-source offsets for the global VM export list.
- Derive import opcode source index from the module source export
offset and the index of the requested name within the module source
export name list.
- Improve error reporting for circular module imports.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'include')
-rw-r--r-- | include/ucode/types.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/ucode/types.h b/include/ucode/types.h index 64ae7cb..636d6e4 100644 --- a/include/ucode/types.h +++ b/include/ucode/types.h @@ -65,7 +65,6 @@ typedef struct { /* Source buffer defintions */ uc_declare_vector(uc_lineinfo_t, uint8_t); -uc_declare_vector(uc_exports_t, uc_value_t *); typedef struct { uc_value_t header; @@ -73,7 +72,10 @@ typedef struct { FILE *fp; size_t off; uc_lineinfo_t lineinfo; - uc_exports_t exports; + struct { + size_t count, offset; + uc_value_t **entries; + } exports; } uc_source_t; |