summaryrefslogtreecommitdiff
path: root/module
AgeCommit message (Collapse)AuthorFilesLines
2013-11-08Move assemble-program to test cases.Andy Wingo1-11/+1
* module/system/vm/assembler.scm (assemble-program): Remove. * test-suite/tests/rtl.test (assemble-program): Move here.
2013-11-08Per-instruction tracing doesn't try to disassemble stack VM codeAndy Wingo1-9/+3
* module/system/vm/trace.scm (trace-instructions-in-procedure): Don't try to disassemble the procedure, for now.
2013-11-08(system vm traps) support for rtl programsAndy Wingo2-53/+50
* module/system/vm/debug.scm: Export program-debug-info-size. * module/system/vm/traps.scm (frame-matcher): Remove stack program case. Use absolute frame-instruction-procedure to match if match-code?. (program-last-ip): Use (system vm debug) interfaces. (program-sources-by-line): Use program-sources, as program-sources-pre-retire will go away soon. Return absolute addresses.
2013-11-08Remove objcode language.Andy Wingo3-181/+0
* module/language/objcode/elf.scm: * module/language/objcode/spec.scm: Remove objcode language. * module/Makefile.am: Adapt.
2013-11-08Remove bytecode language.Andy Wingo2-44/+0
* module/language/bytecode/spec.scm: Remove. * module/Makefile.am: Adapt.
2013-11-08Remove assembly language.Andy Wingo8-713/+4
* module/system/repl/command.scm: Remove disassembly cases for stack procedures. * module/system/vm/inspect.scm: Adapt to disassemble RTL programs. * module/language/assembly.scm: * module/language/assembly/compile-bytecode.scm: * module/language/assembly/decompile-bytecode.scm: * module/language/assembly/disassemble.scm: * module/language/assembly/spec.scm: Remove assembly language. * module/Makefile.am: Adapt.
2013-11-08Decompile goes from tree-il to scheme by default.Andy Wingo1-2/+2
* module/system/base/compile.scm (decompile): By default, go from tree-il to Scheme, now that the assembly language is going away.
2013-11-08Rewrite (system xref) to work with RTL programsAndy Wingo1-77/+66
* module/system/xref.scm (nested-procedures): New helper. (program-callee-rev-vars): Rewrite using fold-program-code and nested-procedures. (add-sources, forget-sources): Use match instead of pmatch. Use nested-procedures.
2013-11-08Add fold-program-code to (system vm disassembler)Andy Wingo1-0/+66
* module/system/vm/disassembler.scm (fold-code-range): New helper. (fold-program-code): New interface.
2013-11-08Remove GLIL languageAndy Wingo4-1166/+0
* module/Makefile.am: * module/language/glil.scm: * module/language/glil/compile-assembly.scm: * module/language/glil/spec.scm: Remove.
2013-11-08Remove tree-il->glil compilerAndy Wingo3-1057/+1
* module/Makefile.am: * module/language/tree-il/compile-glil.scm: Remove. * module/language/tree-il/spec.scm: Remove tree-il->glil link.
2013-11-08Fix program-minimum-arity to work better with case-lambda.Andy Wingo1-1/+11
* module/system/vm/debug.scm (program-minimum-arity): Be more precise with case-lambdas.
2013-11-08Fix procedure-arguments on RTL programs, and tweak session.testAndy Wingo2-4/+5
* module/ice-9/session.scm (procedure-arguments): Add an rtl-program? case. * module/system/vm/debug.scm (arity-arguments-alist): Use the order that session.test expects. * test-suite/tests/session.test ("procedure-arguments"): Adapt tests with keywords for the new starting-with-the-procedure numbering of locals.
2013-11-08Fix case-lambda* dispatching to agree with manual.Andy Wingo1-1/+4
* module/system/vm/assembler.scm (kw-prelude): Emit br-if-npos-gt as appropriate.
2013-11-08Fix arity selection in compute-contificationAndy Wingo1-5/+9
* module/language/cps/contification.scm (compute-contification): Fail as soon as we see an arity with rest, optional, or keyword arguments. Fixes ((case-lambda ((a . b) #t) ((a b) #f)) 1 2).
2013-11-08Fix error message in lambda* eval closures with keywordsAndy Wingo1-1/+1
* module/ice-9/eval.scm (primitive-eval): For ((lambda* (#:key foo) foo) 'bar), give an "invalid keyword" error instead of a "wrong number of arguments" error.
2013-11-08Fix reading and writing arities into DWARF.Andy Wingo3-15/+20
* libguile/gsubr.h: * libguile/gsubr.c (scm_i_primitive_call_ip): * libguile/programs.c (scm_primitive_call_ip): Adapt to return an absolute address. * module/system/vm/assembler.scm (write-arity-headers): Adapt to write byte addresses (relative to the text base). * module/system/vm/debug.scm (arity-low-pc, arity-high-pc): Return absolute addresses, instead of word offsets relative to the text base. (find-first-arity): Adapt for absolute addresses. * module/system/vm/program.scm (program-arguments-alist): Adapt for arity-low-pc / arity-high-pc absolute addresses.
2013-11-07frame-instruction-pointer is absolute; rewrite (system vm coverage)Andy Wingo4-198/+186
* libguile/frames.c (scm_frame_source): Instead of assuming that scm_frame_procedure is correct, use the IP to get the source. (scm_frame_instruction_pointer): Return an absolute value instead of assuming that slot 0 is correct. (It isn't, when preparing for a tail call.) * libguile/programs.h: * libguile/programs.c (scm_find_source_for_addr): New internal helper. * module/system/repl/debug.scm (print-registers): Readably print absolute instruction pointers. * module/system/vm/coverage.scm: Complete rewrite to use absolute IP's. We can't assume that frame-procedure is cheap if it is correct, or correct if it is cheap. Anyway using the address is better anyway. (coverage-data->lcov): Disable per-function info temporarily. (loaded-modules, module-procedures, closest-source-line) (closed-over-procedures): Remove these. Instead of going from procedures to source info, now we go from ELF image to source info. * module/system/vm/debug.scm (debug-context-length): New interface. * module/system/vm/program.scm (source-for-addr): New internal helper.
2013-11-07Program sources are always pre-retire nowAndy Wingo5-43/+23
* module/system/repl/debug.scm (<debug>): Remove for-trap?. Backtraces with RTL will always happen pre-retire on the top frame, source info is pre-retire, and continuations will always have a source-marked receive or receive-values or whatever with the right source marking, so we can remove this complication. (print-frame): Use frame-source. (print-frames): Remove for-trap? kw. * module/system/repl/command.scm (define-stack-command, backtrace) (up, down, frame): Remove for-trap? introduced local, and its uses. (repl-pop-continuation-resumer): Adapt to make-debug change. * module/system/repl/error-handling.scm (call-with-error-handling): Adapt to make-debug change. * module/system/vm/frame.scm (frame-next-source): Remove. RTL sources are pre-retire. * module/system/vm/trap-state.scm (add-ephemeral-stepping-trap!): Adapt to use frame-source. Still some work to do here.
2013-11-07add fold-all-debug-contexts, fold-source-locationsAndy Wingo2-2/+45
* module/system/vm/objcode.scm: * libguile/objcodes.c (scm_all_mapped_elf_images): New proc. * module/system/vm/debug.scm (fold-all-debug-contexts): (fold-source-locations): New public interfaces.
2013-11-07Fix line advance DWARF opcodes when line advance is exactly 128Andy Wingo1-1/+1
* module/system/vm/assembler.scm (link-debug): Fix off-by-one error in which forward jumps of 128 were mis-rendered.
2013-11-07Write DWARF files list in correct order.Andy Wingo1-9/+12
* module/system/vm/assembler.scm (link-debug): Fix order of writing the source files list; it was being written backwards.
2013-11-07Source information goes on the $continue, not the $cont.Andy Wingo12-800/+783
* module/language/cps.scm ($continue, $cont): Put source information on the $continue, not on the $cont. Otherwise it is difficult for CPS conversion to preserve source information. ($fun): Add a src member to $fun. Otherwise we might miss the source info for the start of the function. * .dir-locals.el: * module/language/cps/arities.scm: * module/language/cps/closure-conversion.scm: * module/language/cps/compile-rtl.scm: * module/language/cps/constructors.scm: * module/language/cps/contification.scm: * module/language/cps/dfg.scm: * module/language/cps/elide-values.scm: * module/language/cps/reify-primitives.scm: * module/language/cps/slot-allocation.scm: * module/language/cps/verify.scm: * module/language/tree-il/compile-cps.scm: Update the whole CPS world for this change.
2013-11-06Fix first find-program-sources resultAndy Wingo1-2/+10
* module/system/vm/debug.scm (find-program-sources): Manually set the pc of the first result in a function.
2013-11-05fix docstring assembly and fetchingAndy Wingo2-9/+8
* module/system/vm/assembler.scm (link-docstrs): Write pc offsets as byte addresses. Works better with native code. * module/system/vm/debug.scm (find-program-docstring): Fix the linear search. How embarassing!
2013-11-05asm-labels is a hash tableAndy Wingo1-15/+10
* module/system/vm/assembler.scm (make-assembler, label): (link-data, process-relocs, process-labels): Change labels to be a hash table.
2013-11-05Re-add the list hack to compile-cpsAndy Wingo1-0/+25
* module/language/tree-il/compile-cps.scm (convert): Re-add the list hack. Ideally these go into some tree-il pass.
2013-11-03RTL compiler supports static bitvectorsAndy Wingo3-9/+27
* libguile/arrays.c (scm_from_contiguous_typed_array): * libguile/bytevectors.c (scm_uniform_array_to_bytevector): For bitvectors, round up the length to 32-bit units, as they are stored internally. Otherwise I think this probably does the wrong thing for the last word on big-endian systems. * libguile/bitvectors.c (BITVECTOR_LENGTH, BITVECTOR_BITS): (scm_c_make_bitvector): Reorder the length and pointer words to match the layout of bytevectors. * module/language/cps/primitives.scm (*branching-primcall-arities*): * module/system/vm/assembler.scm (br-if-bitvector): * module/system/vm/disassembler.scm (code-annotation): Add bitvector test support. * module/system/vm/assembler.scm (<uniform-vector-backing-store>): Add an element-size field. (intern-constant): Adapt make-uniform-vector-backing-store call. Use uniform-array->bytevector, as the old compiler did. (link-data): Add bitvector cases.
2013-11-03struct-set! returns a value, yuckAndy Wingo1-0/+30
* module/language/cps/arities.scm (fix-clause-arities): Add a hack to ensure that (struct-set! OBJ POS VAL) evaluates to VAL. Yuck.
2013-11-03Correctness fix for vector constructor inlining.Andy Wingo1-4/+15
* module/language/tree-il/compile-cps.scm (convert): Don't inline the vector constructor if any arg could capture the current continuation.
2013-11-03Eval evaluates initializers before creating environment ribs.Andy Wingo1-7/+43
* module/ice-9/eval.scm (let-env-evaluator, primitive-eval): Evaluate initializers of let expressions before creating the environment rib. This prevents call/cc-related shenanigans.
2013-11-03"length" is an interesting primitiveAndy Wingo1-1/+3
* module/language/tree-il/primitives.scm (*effect-free-primitives*): (*interesting-primitive-names*): Add "length", so that we can constant-fold it.
2013-11-01Revert "Compile-time debugging"Andy Wingo2-9/+3
This reverts commit 6a37b7faaf150e9fb7945ef79969cb7671d17367.
2013-11-01Fix order of evaluation in elisp lexerAndy Wingo1-15/+15
* module/language/elisp/lexer.scm (lex): Use let*, to ensure that the port position is read before reading the next char.
2013-11-01Fix contification of non-recursive closuresAndy Wingo1-15/+18
* module/language/cps/contification.scm (compute-contification): When eliding let-bound functions, also record the cont that declares the function. (apply-contification): Instead of reifying ($values ()) gotos instead of the elided function, inline the body that binds the function directly. This ensures that the function gets contified in its own scope.
2013-11-01RTL compilation sorts continuations topologically before visiting themAndy Wingo2-376/+407
* module/language/cps/compile-rtl.scm (compile-fun): Rewrite to visit conts in reverse-post-order, which is a topological sort on the basic blocks. * module/language/cps/slot-allocation.scm (allocate-slots): Expect a DFG as an argument.
2013-11-01Failed match errors generate less codeAndy Wingo1-4/+9
* module/ice-9/match.upstream.scm (match-next): Call out to an external procedure on error, and use a begin instead of double-parens. This results in less generated code.
2013-11-01Add compile-cps hack for vectorsAndy Wingo1-7/+37
* module/language/tree-il/compile-cps.scm (convert): Add a special case for "vector" primcalls. Boo!
2013-10-31Better range checks in the assemblerAndy Wingo1-6/+28
* module/system/vm/assembler.scm (pack-u8-u24, pack-u8-s24): (pack-u1-u7-u24, pack-u8-u12-u12, pack-u8-u8-u16, pack-u8-u8-u8-u8): Prevent adjacent fields from stompling each other.
2013-10-31Be smarter about capturing the environment for memoized codeAndy Wingo1-25/+11
* libguile/memoize.h (SCM_M_CAPTURE_MODULE) * libguile/memoize.c (MAKMEMO_CAPTURE_MODULE, capture_env): (maybe_makmemo_capture_module, memoize): Determine when to capture the module on the environment chain at compile-time, instead of at runtime. Introduces a new memoized expression type, capture-module. (scm_memoized_expression): Start memoizing with #f as the environment. (unmemoize): Add unmemoizer. (scm_memoize_variable_access_x): Cope with #f as module, and treat as the root module (captured before modules were booted). * libguile/eval.c (eval): * module/ice-9/eval.scm (primitive-eval): Adapt.
2013-10-31define! is an interesting primitiveAndy Wingo1-1/+1
* module/language/tree-il/primitives.scm (*interesting-primitive-names*): Add define!.
2013-10-31fix compilation of (let lp () (lp))Andy Wingo2-59/+78
* module/language/cps/dfg.scm (reverse-post-order): Add an optional "fold-all-conts" argument. (compute-live-variables): Take the function as an arg instead of the start continuation, and implement fold-all-conts so that nodes that never reach the tail also get liveness information.
2013-10-31DFG: Export analyze-control-flow.Andy Wingo1-64/+65
* module/language/cps/dfg.scm ($cfa, $dominator-analysis): Remove dominator things from $cfa, to break out to separate structure. (cfa-k-idx, cfa-k-count, cfa-k-sym, cfa-predecessors): New public accessors. (analyze-control-flow): New public function. (analyze-dominators): Adapt.
2013-10-31static-patch! for pair and vector fieldsAndy Wingo1-4/+4
* module/system/vm/assembler.scm (intern-constant): Use static-patch! for fields.
2013-10-31Better REPL support for disassembling RTL imagesAndy Wingo1-7/+10
* module/system/repl/command.scm (load-image): New helper. (compile, disassemble): Handle bytevectors.
2013-10-31Default to compiling to RTLAndy Wingo6-10/+24
* module/ice-9/eval-string.scm (eval-string) * module/language/tree-il/spec.scm (tree-il) * module/scripts/compile.scm (compile) * module/system/base/compile.scm (compile-file, read-and-compile) * module/system/repl/common.scm (repl-compile, repl-prepare-eval-thunk): Default to compiling to RTL. * module/language/rtl/spec.scm (rtl->value): Add value compiler.
2013-10-31Better aliased primcall compilationAndy Wingo3-4/+27
* libguile/vm-engine.c (define!): Rename from define. * module/language/cps/arities.scm (fix-clause-arities): If a prim aliases an RTL instruction with a different name and we reify a primcall, reify the instruction name. * module/language/cps/compile-rtl.scm (emit-rtl-sequence): Update emit-define! for new name. * module/language/cps/primitives.scm (*rtl-instruction-aliases*): Add bytevector native accessors.
2013-10-31Better compiler support for bytevector opsAndy Wingo4-2/+47
* module/language/cps/compile-rtl.scm (emit-rtl-sequence): Add emitters for bytevector ops. Add br-if-bytevector emitter. * module/language/cps/primitives.scm (*branching-primcall-arities*): Mark bytevector? as a branching primitive. * module/system/vm/assembler.scm (br-if-bytevector): New instruction * module/system/vm/disassembler.scm (code-annotation): Add support for bytevector?.
2013-10-31Support serialization of uniform vector literalsAndy Wingo1-5/+55
* libguile/uniform.h: * libguile/uniform.c (scm_uniform_vector_element_type_code): New interface, returns a type code as an integer. * module/system/vm/assembler.scm (<uniform-vector-backing-store>) (simple-vector?, uniform-array?, statically-allocatable?) (intern-constant, link-data, link-constants): Support uniform arrays, and punt on vectors aren't contiguous from 0. Support for general arrays will come later. * test-suite/tests/rtl.test ("load-constant"): Add tests.
2013-10-31Compile-time debuggingAndy Wingo2-3/+9
* module/language/cps/compile-rtl.scm: * module/language/cps/contification.scm: Add some compile-time printouts. Will be removed later.