Commit Graph

148 Commits

Author SHA1 Message Date
Jesse D. McDonald cc8dc5d9b6 Add many additional primitives, and centralize definitions.
Also:
- assume top-level free variables are constants, not boxes;
- bind variable 'argv' to top-level argument list, rather than assuming no arguments;
- make %values a first-class form, just like %apply and %call/cc (was: pseudo-primitive);
- fix case where 'rest' argument is sole item in argument list: (lambda argv ...); and
- perform misc. cleanup in output code.
2012-07-14 13:44:52 -05:00
Jesse D. McDonald 03fc616b7a Add basic support for outputting values suitable for the Rosella reader. 2012-07-14 13:44:51 -05:00
Jesse D. McDonald c5cf95b867 Implement basic value-propogation and support for multiple return values.
Also performed misc. cleanup, corrected use of temp variables in (let ...),
changed make-bindings-unique to preserve original names as prefixes, improved
detection of unused %set! forms in reduce-set!, and fixed map-variables to
extract the real value from (quote ...) literal forms.
2012-07-14 13:44:48 -05:00
Jesse D. McDonald 4ab23f6877 Thread context register (%ctx) through %apply and %call/cc forms.
Also remove top-level forms without side-effects during CPS transformation.
2012-07-14 13:44:46 -05:00
Jesse D. McDonald 35059dfebf Implement register allocation.
All that remains is to convert the result to bytecode & format as rosella source code.
2012-07-14 13:44:43 -05:00
Jesse D. McDonald c3e46525db Implement conversion of shared variables to boxes.
Also, narrow bindings to their minimal necessary scope. This reduces
the number of variables which must be considered 'shared'.
2012-07-14 13:44:39 -05:00
Jesse D. McDonald b899f0c3b0 Implement support for (call/cc), and shorthand form (let/cc).
Adds support for non-local returns, among other control-flow structures.
2012-07-14 13:44:35 -05:00
Jesse D. McDonald 14b2a1570a Add support for (quote) literal forms in compiler.ss. 2012-07-14 13:44:33 -05:00
Jesse D. McDonald 0b0b352dd6 Clean up handling of (let) and (%bind), plus misc. cleanup.
With this change, any (%bind) returned from (simplify-let) or (simplify-form)
can be assumed to be flat, with unique bound symbols. Before, this was only
true of (%lambda) forms and the output of (compile).
2012-07-14 13:44:30 -05:00
Jesse D. McDonald 6b51229c48 Raise an error if (set! ...) is applied to a form without a value.
Exception is (%tail-call ...) form, which is permitted simply because
(%tail-call ...) transfers control unidirectionally; the enclosing
(%set! ...) form wouldn't be run anyway.
2012-07-14 13:44:17 -05:00
Jesse D. McDonald 8e147f7989 Don't create extra lambdas when both results of (if ...) are trivial.
Also map () directly to %nil, and allow (%if ...) to provide a value to a set! form.
2012-07-14 13:44:05 -05:00
Jesse D. McDonald 46b18c07d6 Implement conversion to tail-call form (CPS).
Also add some basic optimizations concerning binding and setting
variables which will never be used.
2012-07-14 13:43:58 -05:00
Jesse D. McDonald a98ecda079 Commit other half of doc/compiler.txt -> compiler.ss move. 2012-07-14 13:43:50 -05:00
Jesse D. McDonald 988d4264b2 Improve representation of tail-calls, and normalize primitive operations. 2012-07-14 13:43:45 -05:00
Jesse D. McDonald fd17fcd99c Update compiler description (now a working Scheme program).
Maps lexical variables, decodes argument lists, and flattens procedures
to simple lists of primitive operations, but does not yet convert to
CPS or perform register (gN, iN, fN) allocation, much less optimization.
2012-07-14 13:43:40 -05:00
Jesse D. McDonald 885a1ebdbb Fix a missing-root error in interp.c:perform_tail_call(). 2012-07-14 13:43:39 -05:00
Jesse D. McDonald 9f351abd86 Commit simple script to run regression tests: src/examples/test-*.rla. 2012-07-14 13:43:38 -05:00
Jesse D. McDonald 314e167e6e Commit initial notes on compilation from Scheme-like source code. 2012-07-14 13:43:37 -05:00
Jesse D. McDonald f542fa2bd5 Add bytecodes to skip the rest of a block based on a condition.
Should simplify error-handling and sequences of primitive tests.
Also, automatically instantiate templates used in the tail-call lambda & cont'n fields.
2012-07-14 13:43:33 -05:00
Jesse D. McDonald 6dd02a5d6e Stop reading at EOF, and signal an error when EOF occurs inside a string. 2012-07-14 13:43:32 -05:00
Jesse D. McDonald 7e5014ab07 Correct oversight - 0xfe was not changed to 0xff in lambda args. 2012-07-14 13:43:30 -05:00
Jesse D. McDonald bc3df6dd17 Swap continuation & context in the lambda and template structures.
This is to separate the three 'call' parameters (target, argv, ctx) from
the 'return to' parameter (k). The old order made it look as if the dynamic
context was in some way related to the continuation, which is not the case.
2012-07-14 13:43:26 -05:00
Jesse D. McDonald 9af29f28da Commit basic (and ...) & (or ...) *functions*, with lambda args. 2012-07-14 13:43:25 -05:00
Jesse D. McDonald 893b7e122e Commit (append ...) function, implemented as nested (foldr ...) calls. 2012-07-14 13:43:24 -05:00
Jesse D. McDonald a6715b0922 More primitive functions: map, reverse, acons. 2012-07-14 13:43:23 -05:00
Jesse D. McDonald 2d7b079dd8 Make (foldl ...) state the second argument, as with (foldr ...). 2012-07-14 13:43:22 -05:00
Jesse D. McDonald c6500a53b3 Commit implementation of (foldl ...) function. 2012-07-14 13:43:21 -05:00
Jesse D. McDonald 3a418484c8 Commit (foldr ...) function, and refactor (list ...) to use it. 2012-07-14 13:43:20 -05:00
Jesse D. McDonald a1db12d1e2 Commit implementation of (list ...) primitive function. 2012-07-14 13:43:18 -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 0a6d2f3f73 Control printing of GC stats with GC_STATS env. var rather than #if 0/1. 2012-07-14 13:43:16 -05:00
Jesse D. McDonald 7a651dc9d1 Update main app to use new gc_init() prototype w/ separate Gen-0 size. 2012-07-14 13:43:15 -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 075cbac672 Remove some unnecessary write barriers for better performance. 2012-07-14 13:43:04 -05:00
Jesse D. McDonald 32952e9aa4 Add (empty) write barriers in preparation for more advanced GC. 2012-07-14 13:43:03 -05:00
Jesse D. McDonald da93d60cfd Adjust build script to capitalize HAVE_MOD_* macros. 2012-07-14 13:43:01 -05:00
Jesse D. McDonald e8d1a2fa40 Minor performance-related changes. 2012-07-14 13:43:00 -05:00
Jesse D. McDonald 8ca34f40ec Add a bytecode which returns the type of a given structure. 2012-07-14 13:42:59 -05:00
Jesse D. McDonald 62e2095f31 Add standard build targets (distclean, realclean, install, uninstall). 2012-07-14 13:42:54 -05:00
Jesse D. McDonald 06679a2790 Ignore dependency (*.d) files. 2012-07-14 13:42:51 -05:00
Jesse D. McDonald ca8d68c023 Add automatic dependency tracking to the build rules.
Move optional extension modules (e.g. mod_io.c) into mods/ subdir.
Fix missing #include in reader.c.
2012-07-14 13:42:30 -05:00
Jesse D. McDonald baa2dae345 Rearrange example programs based on new modularity feature. 2012-07-14 13:42:18 -05:00
Jesse D. McDonald ec306ef31f Adjust indirect form (#i"path") to be relative to the current file. 2012-07-14 13:42:16 -05:00
Jesse D. McDonald 6254044280 Add #i"pathname" syntax for reading values from modular input files. 2012-07-14 13:42:14 -05:00
Jesse D. McDonald ea9b1734fd Improve trace output, for debugging. 2012-07-14 13:42:12 -05:00
Jesse D. McDonald 601aa9db67 Re-write factorial.rla to be closer to what a compiler should generate. 2012-07-14 13:42:10 -05:00