| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
| |
|
|
|
|
| |
Some cleanup as I remind myself of how generic functions work in Mu.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Clean up how we reclaim local scopes.
It used to work like this (commit 3216):
1. Update refcounts of products after every instruction, EXCEPT:
a) when instruction is a non-primitive and the callee starts with
'local-scope' (because it's already not decremented in 'return')
OR:
b) when instruction is primitive 'next-ingredient' or
'next-ingredient-without-typechecking', and its result is saved to a
variable in the default space (because it's already incremented at
the time of the call)
2. If a function starts with 'local-scope', force it to be reclaimed
before each return. However, since locals may be returned, *very
carefully* don't reclaim those. (See the logic in the old `escaping`
and `should_update_refcount` functions.)
However, this approach had issues. We needed two separate commands for
'local-scope' (reclaim locals on exit) and 'new-default-space'
(programmer takes charge of reclaiming locals). The hard-coded
reclamation duplicated refcounting logic. In addition to adding
complexity, this implementation failed to work if a function overwrites
default-space after setting up a local-scope (the old default-space is
leaked). It also fails in the presence of continuations. Calling a
continuation more than once was guaranteed to corrupt memory (commit
3986).
After this commit, reclaiming local scopes now works like this:
Update refcounts of products for every PRIMITIVE instruction.
For non-primitive instructions, all the work happens in the `return`
instruction:
increment refcount of ingredients to `return`
(unless -- one last bit of ugliness -- they aren't saved in the
caller)
decrement the refcount of the default-space
use existing infrastructure for reclaiming as necessary
if reclaiming default-space, first decrement refcount of each
local
again, use existing infrastructure for reclaiming as necessary
This commit (finally!) completes the bulk[1] of step 2 of the plan in
commit 3991. It was very hard until I gave up trying to tweak the
existing implementation and just test-drove layer 43 from scratch.
[1] There's still potential for memory corruption if we abuse
`default-space`. I should probably try to add warnings about that at
some point (todo in layer 45).
|
|
|
|
|
| |
I no longer remember why we were disabling memory reclamation inside
sandboxes. Everything seems to be working. Just take it out.
|
|
|
|
|
| |
Clean up the narrative of spaces as I struggle to reimplement
`local-scope` by the plan of commit 3992.
|
| |
|
|
|
|
| |
subx: 'call' and 'return' instructions
|
|
|
|
|
| |
subx: extract helpers for 'push' and 'pop'. We will be using them in
'call' and 'ret' as well.
|
|
|
|
| |
subx: 'pop'
|
|
|
|
|
| |
subx: correct a 'copy' ('mov') instruction as well to get its operand
right from the opcode.
|
| |
|
|
|
|
|
|
|
|
| |
subx: correct 'push' register. It gets its operand right from the
opcode, not a new modrm byte.
Have I misinterpreted any other instructions in this manner (`+rd` in
the Intel manual)?
|
|
|
|
| |
subx: 'pop'
|
| |
|
|
|
|
|
| |
Stop hyperlinking every `i` in subx html files to the integer register
union.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
subx: conditional jump instructions
Lots of boilerplate here. This commit really strains my 'copyista'
ethic. But I think it's still clearer to see each instruction
implemented independently than to try to create a macro or something
like that.
|
| |
|
|
|
|
| |
subx: unconditional 'jump'
|
| |
|
|
|
|
| |
subx: 'mov'
|
|
|
|
|
|
| |
I spent a while spelunking into the code generated by C compilers before
realizing that ignoring the order of arguments for 'cmp' instructions
clarifies everything.
|
|
|
|
|
|
| |
subx: 'compare'
Hopefully I've implemented the 'sense' of comparisons right..
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
subx: 'or'
|
|
|
|
| |
subx: Implement 'and' for the addressing modes we've built so far.
|
| |
|
| |
|
| |
|
|
|
|
| |
subx: Move register direct mode before indirect in the exposition.
|
| |
|
|
|
|
| |
Instead of organizing layers by instruction, do so by addressing mode.
|
| |
|
| |
|
| |
|