Skip to content

Commit

Permalink
Reduce binary size by avoiding aggressive inlining of term decoding
Browse files Browse the repository at this point in the history
This leaves more room for libs and programs for smaller targets

Signed-off-by: Paul Guyot <[email protected]>
  • Loading branch information
pguyot committed Jan 8, 2023
1 parent 6501b0a commit e03736c
Show file tree
Hide file tree
Showing 5 changed files with 483 additions and 461 deletions.
6 changes: 6 additions & 0 deletions src/libAtomVM/defaultatoms.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ static const char *const get_tail_atom = "\x8" "get_tail";
static const char *const equal_colon_equal_atom = "\x3" "=:=";
static const char *const signed_atom = "\x6" "signed";

static const char *const no_fail_atom = "\x7" "no_fail";
static const char *const resume_atom = "\x6" "resume";

void defaultatoms_init(GlobalContext *glb)
{
int ok = 1;
Expand Down Expand Up @@ -232,6 +235,9 @@ void defaultatoms_init(GlobalContext *glb)
ok &= globalcontext_insert_atom(glb, equal_colon_equal_atom) == EQUAL_COLON_EQUAL_ATOM_INDEX;
ok &= globalcontext_insert_atom(glb, signed_atom) == SIGNED_ATOM_INDEX;

ok &= globalcontext_insert_atom(glb, no_fail_atom) == NO_FAIL_ATOM_INDEX;
ok &= globalcontext_insert_atom(glb, resume_atom) == RESUME_ATOM_INDEX;

if (!ok) {
AVM_ABORT();
}
Expand Down
8 changes: 7 additions & 1 deletion src/libAtomVM/defaultatoms.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ extern "C" {
#define EQUAL_COLON_EQUAL_ATOM_INDEX 84
#define SIGNED_ATOM_INDEX 85

#define PLATFORM_ATOMS_BASE_INDEX 86
#define NO_FAIL_ATOM_INDEX 86
#define RESUME_ATOM_INDEX 87

#define PLATFORM_ATOMS_BASE_INDEX 88

#define FALSE_ATOM TERM_FROM_ATOM_INDEX(FALSE_ATOM_INDEX)
#define TRUE_ATOM TERM_FROM_ATOM_INDEX(TRUE_ATOM_INDEX)
Expand Down Expand Up @@ -241,6 +244,9 @@ extern "C" {
#define EQUAL_COLON_EQUAL_ATOM TERM_FROM_ATOM_INDEX(EQUAL_COLON_EQUAL_ATOM_INDEX)
#define SIGNED_ATOM TERM_FROM_ATOM_INDEX(SIGNED_ATOM_INDEX)

#define NO_FAIL_ATOM TERM_FROM_ATOM_INDEX(NO_FAIL_ATOM_INDEX)
#define RESUME_ATOM TERM_FROM_ATOM_INDEX(RESUME_ATOM_INDEX)

void defaultatoms_init(GlobalContext *glb);

void platform_defaultatoms_init(GlobalContext *glb);
Expand Down
7 changes: 6 additions & 1 deletion src/libAtomVM/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,12 @@ Module *module_new_from_iff_binary(GlobalContext *global, const void *iff_binary
mod->free_literals_data = 0;
}

mod->end_instruction_ii = read_core_chunk(mod);
int r = read_core_chunk(mod);
if (r < 0) {
module_destroy(mod);
return NULL;
}
mod->end_instruction_ii = r;

return mod;
}
Expand Down

0 comments on commit e03736c

Please sign in to comment.