-
Notifications
You must be signed in to change notification settings - Fork 1
Implementation Decisions
Russell Blickhan edited this page Jul 14, 2018
·
4 revisions
- For comparison operators, we will only use equality, non-equality (to handle NaN appropriately), greater, and greater-equal. Lesser and lesser-equal will be implemented by flipping.
- On call:
- Caller pushes parameters in backwards order, then function object.
- Caller uses CALL instruction.
- Push the frame pointer.
- Push the program counter.
- Set the new frame pointer to be at the stack pointer.
- On return:
- Callee uses RET instruction.
- RET assumes the return value is on top of the stack.
- Read the return value and store temporarily.
- Set stack pointer to frame pointer.
- Reset program counter.
- Reset frame pointer.
- Pop function object.
- Pop parameters.
- Push return value to the top of the stack.
- Callee uses RET instruction.
- Metadata:
- Magic number (consider versioning?)
- Maximum number of global values
- Execution start index
- Length (?)
- Static data:
- Strings
- Function definition:
- Name
- Number of parameters
- Body bytecode
- Instructions