Rewrite module loading in order to be smaller

Open
#1,950 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
c, erlang

Research direction

Start with the module loading and parsing implementation in opcodesswitch.h, where IMPL_CODE_LOADER enables the current code. Investigate how the mega-switch handles opcode definitions and BIF calls, then assess whether a table-driven parsing loop can reduce flash usage and detect missing BIFs. Done means a smaller loader that checks consistency and avoids crashes from missing BIFs.

Written by the indexing model from the issue text.

Description

Module code loading / parsing is implemented in opcodesswitch.h when IMPL_CODE_LOADER is defined, that relies on the mega-switch and a lot on inlined code.
As a consequence the compile code takes a lot of space.
The whole functionality can be replaced with a smaller parsing loop that relies on some kind of opcode definition table, saving quite a lot of space on flash memory.
Last but not least, a good smarter implementation, should verify consistency and avoid some issues, such as calling missing BIFs (it causes a crash).

Dominant language
Erlang
Stars
2.3k
Forks
171
Avg merge
4d 11h
Merged PRs (30d)
20

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from atomvm/AtomVM

All issues in atomvm/AtomVM

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.