summaryrefslogtreecommitdiff
path: root/src/lisp/ao_lisp_make_const.c
Commit message (Collapse)AuthorAge
* altos/lisp: Add builtin 'collect'Keith Packard2017-02-20
| | | | | | Collect memory, return amount free. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add continuationsKeith Packard2017-02-20
| | | | | | This provides call/cc and makes 'stacks' visible to the application. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Fix uninitialized values in ao_lisp_make_constKeith Packard2017-02-20
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Optimize chunk searching in collectKeith Packard2017-02-20
| | | | | | | Note range of existing chunks to exclude objects outside. Only look at chunks which have been set to reduce loop cost. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add incremental collectionKeith Packard2017-02-20
| | | | | | | | | | | | Realizing that long-lived objects will eventually float to the bottom of the heap, I added a simple hack to the collector that 'remembers' the top of the heap the last time a full collect was run and then runs incremental collects looking to shift only objects above that boundary. That doesn't perfectly capture the bounds of transient objects, but does manage to reduce the amount of time spent not moving persistent objects each time through the collector. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Do better checking for un-evaluated macros in ROMKeith Packard2017-02-20
| | | | | | | | Need to look at immediate lambdas as well, and also deal with recursive functions by checking for recursion at each atom dereference. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Evaluate macros once, then smash them into placeKeith Packard2017-02-20
| | | | | | | This assumes that macros are all pure functions, which should be true for syntactic macros. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Cache freed cons and stack itemsKeith Packard2017-02-20
| | | | | | | | | Track freed cons cells and stack items from the eval process where possible so that they can be re-used without needing to collect. This dramatically reduces the number of collect calls. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Append a CRC to the saved image to validate on restoreKeith Packard2017-02-20
| | | | | | | The CRC is actually of the ROM bits, so we can tell if the restored image relates to the currently running code. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add save/restore infrastructure. Needs OS support to work.Keith Packard2017-02-20
| | | | | | | | This sticks a few globals past the end of the heap and then asks the OS to save the heap. On restore, the heap is re-populated by the OS and then various global variables reset. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: add length, pack, unpack and flushKeith Packard2017-02-20
| | | | | | lots more builtins Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: use regular read-eval-print loop for make constKeith Packard2017-02-20
| | | | | | No need to open code this sequence of operations. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: add progn, while, read and evalKeith Packard2017-02-20
| | | | | | | | Progn as a builtin will help with tail-recursion. while provides for loops until tail-recursion works :-) read and eval are kinda useful. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Clean up OS integration bits, add defunKeith Packard2017-02-20
| | | | | | | Provide an abstraction for the OS interface so that it can build more cleanly on Linux and AltOS. Add defun macro. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: working on lexical scopingKeith Packard2017-02-20
| | | | | | Not working yet Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: more GC issues. add patomKeith Packard2017-02-20
| | | | | | | Use global ao_lisp_stack instead of local stack so that gc moves of that item work. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Change GC move APIKeith Packard2017-02-20
| | | | | | | | Pass reference to move API so it can change the values in-place, then let it return '1' when the underlying object has already been moved to shorten GC times. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Add lambda support to lispKeith Packard2017-02-20
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Separate out values from atomsKeith Packard2017-02-20
| | | | | | | | | | | This enables changing values of atoms declared as constants, should enable lets, and with some work, even lexical scoping. this required changing the constant computation to run ao_lisp_collect() before dumping the block of constant data, and that uncovered some minor memory manager bugs. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: add set/setq and ' in readerKeith Packard2017-02-20
| | | | | | Along with other small fixes Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Change lisp objects to use ao_poly everywhere. Add constKeith Packard2017-02-20
This makes all lisp objects use 16-bit ints for references so we can hold more stuff in small amounts of memory. Also adds a separate constant pool of lisp objects for builtins, initial atoms and constant lisp code. Now builds (and runs!) on the nucleo-32 boards. Signed-off-by: Keith Packard <keithp@keithp.com>