Skip to content

Commit

Permalink
Use a pointer for PC instead of an instruction counter
Browse files Browse the repository at this point in the history
Also mark code in modules as const.
This optimization brings an additional 20% speed upgrade to the Sudoku
benchmark.

Signed-off-by: Paul Guyot <[email protected]>
  • Loading branch information
pguyot committed Sep 2, 2023
1 parent b8873b2 commit 7b2678e
Show file tree
Hide file tree
Showing 4 changed files with 822 additions and 1,384 deletions.
4 changes: 2 additions & 2 deletions src/libAtomVM/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
static void *module_uncompress_literals(const uint8_t *litT, int size);
#endif
static struct LiteralEntry *module_build_literals_table(const void *literalsBuf);
static void module_add_label(Module *mod, int index, void *ptr);
static void module_add_label(Module *mod, int index, const uint8_t *ptr);
static enum ModuleLoadResult module_build_imported_functions_table(Module *this_module, uint8_t *table_data, GlobalContext *glb);
static void parse_line_table(uint16_t **line_refs, struct ModuleFilename **filenames, uint8_t *data, size_t len);

Expand Down Expand Up @@ -235,7 +235,7 @@ term module_get_exported_functions(Module *this_module, Heap *heap, GlobalContex
return result_list;
}

static void module_add_label(Module *mod, int index, void *ptr)
static void module_add_label(Module *mod, int index, const uint8_t *ptr)
{
mod->labels[index] = ptr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libAtomVM/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct Module

const struct ExportedFunction **imported_funcs;

void **labels;
const uint8_t **labels;

void *literals_data;

Expand Down
Loading

0 comments on commit 7b2678e

Please sign in to comment.