Commit Graph

33 Commits

Author SHA1 Message Date
Jesse D. McDonald f3458173c4 Implement simple self-hosting compiler (src/compiler.rls). 2012-07-14 13:47:39 -05:00
Jesse D. McDonald be48535995 Change bytecode from 'frame' vars to 'transient' values.
Each transient identifies the value of the corresponding previous bytecode.
This change (a) frees up many bytecodes formerly used by the conditional
expression (if c t f); (b) regularizes the bytecode by always placing opcodes
before operands; and (c) causes the bytecode to conform to the Single Static
Assignment (SSA) form preferred by e.g. LLVM.

Includes updates to the hand-assembled files (*.rla) and the bytecode compiler.
2012-07-14 13:47:28 -05:00
Jesse D. McDonald 6da373201c Fix printing of fixnums on 64-bit platforms by using %lld and "long long int". 2012-07-14 13:47:26 -05:00
Jesse D. McDonald b6271bf13e Ensure correct types are passed to printf() when size_t != int. 2012-07-14 13:47:22 -05:00
Jesse D. McDonald 42312e394a Add a helper function for creating structure types. 2012-07-14 13:47:13 -05:00
Jesse D. McDonald 892af308ce Add support for immutable vectors, byte-strings, and structures.
The interpreter now requires its input to be immutable.
The reader marks values read after '#@' as immutable, e.g. #@#(...).
2012-07-14 13:47:10 -05:00
Jesse D. McDonald 960d7917c9 Enforce that all structures have types derived from 'structure'.
Take advantage of this invariant to simplify struct type checks elsewhere.
Group (meta)structure definition with basic types.
2012-07-14 13:47:03 -05:00
Jesse D. McDonald fd62415dee Fix pattern-matching for (value-list (#%apply ...)), etc.
Fix assertion in gc_object_left_behind() to work in Gen-0 collection.
Add (weak-box?) and (make-weak-box) primitives. (unbox) now works for both.
Add option to just simplify the input (stops before reduce-function).
Default to writing .rla without indentation, comments, or newlines.
2012-07-14 13:45:58 -05:00
Jesse D. McDonald 061364c75c Remove structure/field names from builtin structure type.
Moves naming policy (strings/symbols) from the VM to the input image.
To restore introspection, derive annotated base types from anonymous builtins.
2012-07-14 13:45:49 -05:00
Jesse D. McDonald 85eed3da7a Fix mismatched parentheses. 2012-07-14 13:45:48 -05:00
Jesse D. McDonald 96b3bded17 Add a primitive operation to calculate a 30-bit hash from any value.
Pairs, boxes, and strings are hashed by values; vectors and structures
are "hashed" by reference. Takes into account the possibility of cycles.
This is a prelude to implementing hash-tables.
2012-07-14 13:45:40 -05:00
Jesse D. McDonald 786258f144 Add the rest of the FP math primitives.
Improve detection of unsimplified primitive forms. Also hides %goto-end-*.
Automatically convert fixnum to FP in get_float(). (But not _get_float()!)
2012-07-14 13:45:01 -05:00
Jesse D. McDonald ffb8e8f86d Separate statistics for Gen-0 vs. Gen-1 garbage collection. 2012-07-14 13:43:17 -05:00
Jesse D. McDonald 632ac19adf Make Gen-0 size semi-independent of Gen-1 minimum size. 2012-07-14 13:43:14 -05:00
Jesse D. McDonald 7f55142d72 Fix several significant bugs in the generational collector.
No known issues remaining at this time.
2012-07-14 13:43:10 -05:00
Jesse D. McDonald 311a4c2d55 Don't include gc_poison_region in non-debug builds. 2012-07-14 13:43:09 -05:00
Jesse D. McDonald 12b5976b66 Fix a bug which was cryptically preventing Gen-1 size from increasing. 2012-07-14 13:43:07 -05:00
Jesse D. McDonald 7fb083a5f9 Generational GC. Initial version, may be buggy. 2012-07-14 13:43:05 -05:00
Jesse D. McDonald e8d1a2fa40 Minor performance-related changes. 2012-07-14 13:43:00 -05:00
Jesse D. McDonald ea9b1734fd Improve trace output, for debugging. 2012-07-14 13:42:12 -05:00
Jesse D. McDonald 8f263daffc Add a reserved input code for 'self', the current lambda.
Correct an error in the documentation for the condition bytecode(s).
Adjust the printer to limit the depth of non-cyclic object output.
2012-07-14 13:42:04 -05:00
Jesse D. McDonald 0e62641919 Check in a second program, this time demonstrating basic I/O.
Also filter cycles and long byte-strings from print_value() output.
Added three new bytecodes to get the sizes of vectors, strings, and structs.
2012-07-14 13:41:37 -05:00
Jesse D. McDonald 6a12d967ef If hard limit is exceeded, try to allocate more memory from the OS.
Reduce initial allocation to 1 MB now that it can by increased at runtime.
Also remove 'noreturn' attribute from the public API.
If out_of_memory() returns, GC will abort() internally.
2012-07-14 13:40:40 -05:00
Jesse D. McDonald 449b0cf478 Implement fixed-function reader for getting data into the interpreter. 2012-07-14 13:38:44 -05:00
Jesse D. McDonald d80e0c1fd3 CLOCK_MONOTONIC and uint64_t aren't entirely portable. 2012-07-14 13:38:32 -05:00
Jesse D. McDonald 26819cafdc Update list of weak boxes *after* processing finalizers.
It's a bit unlikely, but a finalizer could be arranged for a weak box.
Also add more assertions, clear old range in debug builds, and misc. cleanup.
2012-07-14 13:38:23 -05:00
Jesse D. McDonald 0a2f13b523 Added built-in structure types and interpreter core (w/o bytecode).
Improved timing resolution by using clock_gettime() instead of clock().
Also gave project a name: Rosella. Play on 'Parrot' (Perl 6 VM).
2012-07-14 13:38:02 -05:00
Jesse D. McDonald 7bd6e616ff Add support for weak boxes and wills/finalizers.
Also refactored some GC code into smaller functions.

Weak boxes and wills will be useful for implementing weak hash tables,
which in turn will be used to store dynamic parameters efficiently.
2012-07-14 13:37:41 -05:00
Jesse D. McDonald 0867f66767 Add structure type; allow GC to be disabled; unify object-moving code. 2012-07-14 13:37:37 -05:00
Jesse D. McDonald f8e04f1b86 Add full support for remaining data type (box, vector, byte string).
Improve inline accessors for cases where value type is known.
Move GC stats into a single global structure to reduce proliferation of globals.
2012-07-14 13:37:31 -05:00
Jesse D. McDonald 8db40406a0 Refactor into a GC library (gc.c and gc.h) and a test program (gc_test.c).
Also, allocate GC memory ranges dynamically during startup (gc_init()) rather than statically.
2012-07-14 13:37:19 -05:00
Jesse D. McDonald 61b83a1293 Add support for (strong) boxes, value vectors, and byte strings. 2012-07-14 13:37:15 -05:00
Jesse D. McDonald 9fa0a09509 Initial check-in. 2012-07-14 13:36:26 -05:00