Commit Graph

6 Commits

Author SHA1 Message Date
Kartik Agaram 2eb174d697 4908
Fix CI.

a) Update canonical binaries.
b) Fix an out-of-bounds access in `clear-stream`. This also required supporting
   a new instruction in `subx run` to load an imm8 into rm8.
2019-01-05 01:07:37 -08:00
Kartik Agaram 7b548ff5c5 4905 - safe ptr lookup is now 6 instructions
The lines within '{}' can now be turned into a macro like `E_X = deref(E_X)`,
parameterizing the register being modified.

Assumes the input is in a register but also saved elsewhere, so it's safe
to clobber and replace with the result.

Compare commit 4894. Used to take 9 instructions, 8 of them making loads/stores.
Now it's 6 instructions, 4 of them loads/stores (the one non-local load
is unchanged, of course). Key is to not consume more registers so we don't
have to push/pop them.
2019-01-04 11:29:12 -08:00
Kartik Agaram 1ffb27a045 4900
Finally really fix the CI failure of commit 4894.

This is a remainder to forget my knowledge of stack addresses in the SubX
VM when writing SubX programs. Otherwise my programs will work in the VM
but not natively. The only assumptions a SubX program should make about
its segment addresses are what's encoded in the ELF binary. Thanks to
https://en.wikipedia.org/wiki/Address_space_layout_randomization, it can't
know anything else.
2018-12-30 21:01:35 -08:00
Kartik Agaram cde1bf97b6 4896
Fix CI.
2018-12-30 12:08:09 -08:00
Kartik Agaram 395b3ffbeb 4894
Done with kinda-safe pointers.

In a real compiler the fast path of 'lookup' would ideally get inlined.
Excluding procedure-call overhead, the current implementation consumes 2
registers besides the input, and requires 9 instructions (2 push, 2 load,
compare, jump, increment, 2 pop). That's large enough that inlining may
become a trade-off. Even if we somehow magically had the registers already
loaded and available, we'd still need 4 instructions (1 pointer dereference,
compare, jump and increment). The price of safety.
2018-12-30 01:30:56 -08:00
Kartik Agaram c164f4fb6b 4889 - playing with kinda-safe pointers 2018-12-29 14:32:27 -08:00