summaryrefslogtreecommitdiff
path: root/module/system/vm/disassembler.scm
AgeCommit message (Collapse)AuthorFilesLines
2013-11-19Rename objcodes?.{scm,c,h} to loader.{scm,c,h}Andy Wingo1-1/+1
* libguile/loader.c: * libguile/loader.h: Rename from objcodes.[ch]. * module/system/vm/loader.scm: Rename from objcode.scm. * libguile/Makefile.am: * libguile/gsubr.c: * libguile/init.c: * libguile/procs.c: * libguile/vm.c: * module/Makefile.am: * module/ice-9/eval-string.scm: * module/language/rtl/spec.scm: * module/system/base/target.scm: * module/system/repl/command.scm: * module/system/repl/common.scm: * module/system/vm/debug.scm: * module/system/vm/disassembler.scm: * module/system/vm/objcode.scm: * test-suite/tests/compiler.test: * test-suite/tests/dwarf.test: * test-suite/tests/rtl-compilation.test: * test-suite/tests/rtl.test: Adapt.
2013-11-19(system vm instruction) rtl-instruction-list -> (language rtl) instruction-listAndy Wingo1-1/+1
* libguile/instructions.c (struct scm_instruction, fetch_instruction_table) (scm_instruction_list): Remove rtl_ infix. * libguile/instructions.h: Adapt. * module/system/vm/instruction.scm: Remove. * module/language/rtl.scm: Export instruction-list from here. * module/Makefile.am: * module/language/cps/primitives.scm: * module/system/vm/assembler.scm: * module/system/vm/disassembler.scm: * module/system/vm/frame.scm: * module/system/vm/program.scm: * module/system/vm/trace.scm: * module/system/vm/traps.scm: Adapt.
2013-11-19rtl-program-code -> program-codeAndy Wingo1-3/+3
* libguile/programs.h: * libguile/programs.c (scm_program_code): Rename from scm_rtl_program_code. Also renames rtl-program-code to program-code. * module/statprof.scm: * module/system/repl/command.scm: * module/system/repl/debug.scm: * module/system/vm/coverage.scm: * module/system/vm/disassembler.scm: * module/system/vm/program.scm: * module/system/vm/traps.scm: * test-suite/tests/dwarf.test: * test-suite/tests/rtl.test: Adapt callers.
2013-11-19rtl-program? -> program?Andy Wingo1-1/+1
* libguile/programs.c (scm_program_p): Rename from scm_rtl_program_p. Changes name also from rtl-program? to program?. * libguile/programs.h: * module/ice-9/session.scm: * module/language/tree-il/analyze.scm: * module/statprof.scm: * module/system/repl/command.scm: * module/system/repl/debug.scm: * module/system/vm/coverage.scm: * module/system/vm/disassembler.scm: * module/system/vm/frame.scm: * module/system/vm/program.scm: * module/system/vm/traps.scm: * module/system/xref.scm: Adapt.
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-03RTL compiler supports static bitvectorsAndy Wingo1-0/+1
* 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-10-31Better compiler support for bytevector opsAndy Wingo1-0/+1
* 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-31static-patch! replaces link-procedure!Andy Wingo1-7/+0
* libguile/vm-engine.c (static-patch!): Replace link-procedure! with this more versatile primitive. * module/system/vm/assembler.scm (intern-constant): Emit static-patch! for static procedures and for strings. * module/system/vm/disassembler.scm (code-annotation): Remove annotation for link-procedure!. There can be no annotation for static-patch!, as neither operand is guaranteed to be a SCM value.
2013-10-27VM has "builtins": primitives addressable by emitted RTL codeAndy Wingo1-1/+3
* libguile/Makefile.am: * libguile/vm-builtins.h: New header, declaring stubs needed by the compiler like values, apply, and abort-to-prompt. * libguile/vm.c: Adapt the apply and values stubs to conform to a standard interface. Add an abort-to-prompt stub. Add call/cc and call-with-values stubs. (scm_vm_builtin_ref): New helper, for the builtin-ref opcode. (scm_vm_builtin_name_to_index) (scm_vm_builtin_index_to_name): New helpers, for the compiler and disassembler, respectively. (scm_init_vm_builtins, scm_bootstrap_vm): Allow the compiler helpers to be loaded later into a module. * module/language/rtl.scm: Export builtin-index->name and builtin-name->index. * libguile/vm-engine.c (RETURN_VALUE_LIST): Update to use new names of "apply" and "values". (tail-call/shuffle): New opcode. (abort): Update to be a tail VM op, and reorder and renumber other ops. (builtin-ref): New opcode. * libguile/continuations.h: * libguile/continuations.c (scm_i_call_with_current_continuation): Move this to vm.[ch], implemented as a builtin. * module/language/tree-il/compile-cps.scm (convert): Convert to 'abort-to-prompt calls, possibly with 'apply, effectively undoing the tree-il transformation. * module/language/cps/reify-primitives.scm (builtin-ref): New helper. (reify-primitives): Convert builtin primitives to builtin-ref. * module/language/cps/dfg.scm (constant-needs-allocation?): * module/language/cps/compile-rtl.scm (emit-rtl-sequence): Add support for compiling builtin-ref. * module/system/vm/disassembler.scm (code-annotation): Add annotation for builtin-ref.
2013-10-26RTL compiler: Compile TC7 branches.Andy Wingo1-1/+11
* module/system/vm/assembler.scm: * module/system/vm/disassembler.scm (code-annotation): * module/language/cps/primitives.scm (*branching-primcall-arities*): * module/language/cps/compile-rtl.scm (emit-rtl-sequence): Add support for compiling symbol?, variable?, vector?, and string? branches.
2013-10-14RTL: Compile promptsAndy Wingo1-1/+1
* libguile/vm-engine.c (prompt): Adapt to explicitly set the saved SP so we know how many incoming values the handler will receive, and to make escape-only? a flag. * module/language/cps/compile-rtl.scm (emit-rtl-sequence): $prompt should only be found in a "seq" context, as it just pushes on a prompt and doesn't bind any values. On the other hand it should emit appropriate code for the handler to bind its values, so do that. * module/language/cps/slot-allocation.scm ($cont-allocation): Add a note that proc-slot is used by prompts as well. (allocate-slots): Compute the allocation of a prompt handler's args. * module/language/tree-il/compile-cps.scm (convert): Use "unwind" instead of the nonexistent "pop-prompt". * module/system/vm/disassembler.scm (code-annotation): Adapt to change in prompt VM op.
2013-10-04Disassembling RTL prints source information.Andy Wingo1-2/+20
* module/system/vm/disassembler.scm (disassemble-buffer): Print source information.
2013-08-29,xx for RTL imagesAndy Wingo1-1/+7
* module/scripts/disassemble.scm (disassemble): * module/system/vm/disassembler.scm (disassemble-file): Factor disassemble-file out. * module/system/repl/command.scm (disassemble-file): Map ,xx to disassemble RTL images.
2013-08-29add ability to disassemble ELF imagesAndy Wingo1-1/+24
* module/scripts/disassemble.scm (disassemble): Update to work with RTl (and only RTL, as that's the future). * module/system/vm/debug.scm (for-each-elf-symbol): New public interface. (debug-context-from-image): New helper. (find-debug-context): Use the helper. * module/system/vm/disassembler.scm (disassemble-image): New public interface.
2013-08-24RA == MVRA in disassemblerAndy Wingo1-6/+1
* module/system/vm/disassembler.scm: Modify call disassembler to assume RA == MVRA.
2013-08-11Various RTL VM and calling convention tweaksAndy Wingo1-5/+12
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Allow for five-word instructions, and for new instruction word types. * libguile/vm-engine.c (RETURN_ONE_VALUE): Instead of returning the value in the fixed part of the call frame, return it in the same place multiple-value returns go: from slot 1. (BR_ARITHMETIC): Allow arithmetic tests to be negated. (rtl_vm_engine): Change calling convention to use the same location for single and multiple-value returns. Renumber all instructions. (halt, halt/values): Fold into a single instruction (halt). (call): Take the location of the procedure instead of the location of the call frame. Also take the number of args, and reset the sp before jumping to the procedure, so as to indicate the number of arguments. (call/values): Remove, as the new calling convention has RA == MVRA. (tail-call): Require the procedure to be shuffled down already, and take "nlocals" as an arg instead of "nargs". (receive, receive-values): New instructions, for receiving returned values from calls. (return-values): Rename from return/values. Remove "values". (alloc-frame): Rename from reserve-locals. (reset-frame): New instruction. (drop-locals): Remove. (br-if-=, br-if-<, br-if-<=): Allow these instructions to be negatable. (br-if->, br-if->=): Remove. Probably a bad idea, given NaN. (box-ref): Don't bother trying to do a reverse lookup -- the toplevel-box, module-box, and resolve instructions should handle that. (resolve): Add arg to check that the variable is bound. (toplevel-box, module-box): New instructions, replacing toplevel-ref, toplevel-set, module-ref, and module-set. * libguile/vm.c (rtl_boot_continuation_code, rtl_values_code): Adapt to instruction set changes. * module/Makefile.am: Make the assembler and disassembler dependent on vm-operations.h. * module/system/vm/assembler.scm: * module/system/vm/disassembler.scm: Adapt to instruction changes and new instruction word kinds. * test-suite/tests/rtl.test: Adapt to instruction set changes.
2013-07-21RTL instructions have no rest argsAndy Wingo1-19/+1
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): * module/system/vm/assembler.scm (assembler): * module/system/vm/disassembler.scm (disassembler): Remove support for RTL instructions with rest args.
2013-07-21RTL: Local 0 is the procedureAndy Wingo1-4/+6
* libguile/vm-engine.c: Change the RTL VM to number the procedure as local 0, and other locals from 1. In the future we will want the FP to point to local 0 instead of local 1. In the future also we can elide the procedure for well-known closures (closures in which all references are known call sites). (make_closure, free_set): Instead of taking rest arguments, we add a new free-set! op that initializes closures. (free_ref): Take the closure as an argument. * libguile/vm.c (rtl_boot_continuation_code): Remove comments, which were out of date. (rtl_apply_code, rtl_values_code): Update comments. * module/system/vm/assembler.scm (intern-constant, emit-init-constants): Adapt to locals numbering change. (begin-kw-arity): For assert-nargs-ee purposes, nreq includes the procedure. * module/system/vm/disassembler.scm (code-annotation): Adapt annotation for assert-nargs-ee/locals. * test-suite/tests/rtl.test: Adapt tests.
2013-07-21rtl: propagate OP_DST to schemeAndy Wingo1-1/+1
* libguile/instructions.c (scm_rtl_instruction_list): Add an element to the list to indicate that an instruction outputs to its first argument. * module/system/vm/assembler.scm: * module/system/vm/disassembler.scm: Adapt.
2013-06-09Add RTL disassemblerAndy Wingo1-0/+350
* module/Makefile.am: * module/system/vm/disassembler.scm: New module. * module/system/repl/command.scm (disassemble): Work with RTL programs.