This repository has been archived by the owner on Jun 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve implementation of jump tables in bytecode
Previously, we would issue a series of Breq instructions each of which would decode the argument term, compare against an immediate for a match, then conditionally branch to the target. Now, the argument is decoded only once, and the target branch is resolved in a single instruction. The overall code size is reduced as well. Additionally, I've gone through and documented all of the bytecode ops with their semantics, and assumptions about the runtime implementation in each.
- Loading branch information
Showing
8 changed files
with
1,105 additions
and
518 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Firefly Bytecode | ||
|
||
This crate defines the instruction set for our bytecode emulator. It provides the following: | ||
|
||
* A datastructure which is used to represent individual bytecode-compiled modules, as well as the | ||
result of linking together several bytecode-compiled modules as a whole program, called `ByteCode` | ||
* An instruction set optimized for the way our compiler generates code, of ~120 instructions (currently). | ||
Many of these instructions are similar to those of a real ISA, but a number are fused instructions, performing | ||
multiple operations at once, and a few are superinstructions which have quite complex implementations. | ||
* A bytecode "builder" which can be used to iteratively construct a bytecode module without having to manage | ||
any of the gritty details by hand. | ||
* A textual format to allow for easy review of the generated bytecode in a form similar to our other IR formats | ||
* A binary format to which bytecode-compiled programs are encoded/decoded when shipped as an executable | ||
* Support for source-level debug info down to the instruction level | ||
|
||
## Further Reading | ||
|
||
You can find the compiler pass which generates this bytecode [here](`../compiler/driver/src/compiler/passes/bytecode/lower_ssa.rs`). | ||
|
||
The current implementation of each opcode in our bytecode emulator can be found [here](`../runtimes/emulator/src/emulator/scheduler.rs`). | ||
|
||
A detailed explanation of each instruction/opcode and its semantics can be found [here](src/ops.rs). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.