Redesign code layout
lausek opened this issue · 2 comments
lausek commented
Current
The current Module
looks like this:
- CodeObject
main
globals
locals
consts
code
- CodeObject
add
globals
locals
consts
code
- ...
New Layout
idents
:globals
+locals
consts
entries
:HashMap<Variable, usize>
mapping the function name to the offset insidecode
code
which is the concatenated list of bytecode instructions frommain
andadd
main:
...
ret
add:
...
ret
Pros
- Size of
Module
is expected to decrease by a lot- CodeObject can reuse identifiers and constants
- The new layout is way simpler than the previous one
Steps for redesign
- remove current struct
Module
- redefine
CodeObject
according to new layout- wait until #6 is resolved
- refactor
ModuleProtocol
trait -> removeslot
method - implement
ModuleProtocol
- create new type
CodeObjectFunction
wip name- tuple containing a reference to the
CodeObject
and anoffset
- implement
CallProtocol
- tuple containing a reference to the
lausek commented
If we define the ENTRY_POINT
to be always at offset 0, resolution of a programs starting point will become way simpler. Modules without an entry point will have a ret
as first instruction.