Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce binary size by avoiding aggressive inlining of term decoding #463

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading