summaryrefslogtreecommitdiff
path: root/src/lisp
Commit message (Collapse)AuthorAge
* altos/lisp: binary search for chunk in collectKeith Packard2016-11-17
| | | | | | Speeds up collect a bit Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Allow empty defun bodiesKeith Packard2016-11-17
| | | | | | This allows for (defun foo()) Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Optimize chunk searching in collectKeith Packard2016-11-17
| | | | | | | 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 Packard2016-11-17
| | | | | | | | | | | | 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: Take advantage of multi-arg macros. Add more ROM funcsKeith Packard2016-11-17
| | | | | | Added nth, or and and. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Allow macro/nlambda/lexpr to have multiple argsKeith Packard2016-11-17
| | | | | | | | Entries from the params are bound to the formals with whatever remaining formals there are bound to the last argument as a list. This makes writing functions a bit easier. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Do better checking for un-evaluated macros in ROMKeith Packard2016-11-17
| | | | | | | | 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: re-use small framesKeith Packard2016-11-17
| | | | | | | | | This saves a pile more use of the allocator by noting when frames have not been referenced from another frame and freeing them when they go out of scope. Frames with references are left to the allocator to deal with. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Get lambdakey and nucleo-32 building againKeith Packard2016-11-17
| | | | | | Remove exti from the build list to make things fit. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Evaluate macros once, then smash them into placeKeith Packard2016-11-17
| | | | | | | 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 Packard2016-11-17
| | | | | | | | | 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: Simplify GC a bit by only marking the head of each objectKeith Packard2016-11-17
| | | | | | | | | We don't need to mark the whole object now as we're getting information about where objects are by walking the tree each time around the loop; ao_lisp_busy is only useful for terminating the walk now. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Change GC to do moves in batches of 32Keith Packard2016-11-17
| | | | | | This should make it quite a bit faster than doing one at a time. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Append a CRC to the saved image to validate on restoreKeith Packard2016-11-17
| | | | | | | 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 Packard2016-11-17
| | | | | | | | 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: Make sure memmove only happens once per object. Other GC fixesKeith Packard2016-11-17
| | | | | | | | | | | | The memmove may be overlapping, so make sure it happens only once by just checking whether move_size has been set, rather than looking at ao_lisp_moving; that doesn't get set when moving a noted cons as that still needs to be walked at a later time. Fix up the various looping move functions to all use the same pattern. Atom was busted. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Make ao_lisp_ref and ao_lisp_poly non-inlineKeith Packard2016-11-17
| | | | | | | These functions are pretty large and end up consuming quite a bit of space if inlined everywhere they are used. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Share mark function for mark and moveKeith Packard2016-11-17
| | | | | | | These two operations both wanted to walk the referenced objects; sharing is caring. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: add length, pack, unpack and flushKeith Packard2016-11-17
| | | | | | lots more builtins Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Deal with memory compation in the middle of operationsKeith Packard2016-11-17
| | | | | | | | Handle memory compaction in places where we've got pointers into the heap across an allocation operation. Either re-compute the values from managed global references or add new roots across the allocation. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Make read() return eof atom on end of fileKeith Packard2016-11-17
| | | | | | Also make it an exception to hit eof in the middle of an sexpr. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: use regular read-eval-print loop for make constKeith Packard2016-11-17
| | | | | | 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 Packard2016-11-17
| | | | | | | | 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 Packard2016-11-17
| | | | | | | 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: macros appear to work nowKeith Packard2016-11-17
| | | | | | | | Needed an extra stack frame to stash the pre-macro state. This simplified macro processing quite a bit; a macro now just evaluates the function and then sends that result to be evaluated again. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: working on lexical scopingKeith Packard2016-11-17
| | | | | | Not working yet Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: convert GC to non-recursiveKeith Packard2016-11-17
| | | | | | | Use a boolean array to note cons cells which would otherwise recurse, then loop until that array is empty. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: more GC issues. add patomKeith Packard2016-11-17
| | | | | | | 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: make sure stack->formals_last gets moved during GCKeith Packard2016-11-17
| | | | | | Failing this leads to broken formals chains Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Change GC move APIKeith Packard2016-11-17
| | | | | | | | 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/lisp: get builtin macros working againKeith Packard2016-11-17
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Start rewriting eval as state machineKeith Packard2016-11-17
| | | | | | | Ad-hoc code was incomprehensible and I couldn't make 'cond' work, so I'm starting over. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Add lambda support to lispKeith Packard2016-11-17
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Separate out values from atomsKeith Packard2016-11-17
| | | | | | | | | | | 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 Packard2016-11-17
| | | | | | 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 Packard2016-11-17
| | | | | | | | | | | 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>
* altos: Add lisp readerKeith Packard2016-11-17
|
* Add first lisp bitsKeith Packard2016-11-17
Signed-off-by: Keith Packard <keithp@keithp.com>