1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

43 commits

Author SHA1 Message Date
Andy Wingo
258c59b4cc Add assembler and disassembler support for new instructions
* module/system/vm/assembler.scm: Export assemblers for the new
  instructions.
* module/system/vm/disassembler.scm (immediate-tag-annotations)
  (heap-tag-annotations, code-annotation): Add support for disassembling
  the new instructions, with good annotations.
  (compute-labels, instruction-has-fallthrough?, define-jump-parser):
  Add support for new branching instructions.
2017-10-25 16:53:14 +02:00
Andy Wingo
808000034e Add support for C16_C16 instruction words
* module/language/bytecode.scm (compute-instruction-arity):
* module/system/vm/assembler.scm (pack-u16-u16, expand):
* module/system/vm/disassembler.scm (disassembler):
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Add C16_C16.
2017-10-24 21:11:20 +02:00
Andy Wingo
64c5cc58fc Add disjoint syntax object type
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
  (DOT_X_FILES, DOT_DOC_FILES, noinst_HEADERS): Add syntax.c and
  syntax.h.
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (class_syntax, scm_class_of, scm_goops_early_init):
* libguile/init.c (scm_init_guile):
* libguile/print.c (iprin1):
* libguile/tags.h (scm_tc7_syntax):
* module/oop/goops.scm (<syntax>):
* module/system/base/types.scm (%tc7-syntax, cell->object):
* module/system/vm/disassembler.scm (code-annotation): Wire up the new
  data type.
* libguile/syntax.c:
* libguile/syntax.h: New files.
* module/ice-9/boot-9.scm: Move new definitions to (system syntax
  internal).
* module/system/syntax.scm (print-syntax): New helper.
* module/system/vm/assembler.scm (statically-allocatable?)
  (intern-constant, link-data): Arrange to be able to write syntax
  objects into images.
* module/language/cps/types.scm (&syntax): New type.  Remove
  &hash-table; it was never detected, an internal binding, and we need
  the bit to avoid going into bignum territory.
2017-03-28 19:23:13 +02:00
David Thompson
35a9059250 Add unboxed floating point comparison instructions.
* libguile/vm-engine.c (BR_F64_ARITHMETIC): New preprocessor macro.
(br_if_f64_ee, br_if_f64_lt, br_if_f64_le, br_if_f64_gt, br_if_f64_ge):
New VM instructions.
* doc/ref/vm.texi ("Unboxed Floating-Point Arithmetic"): Document them.
* module/language/cps/compile-bytecode.scm (compile-function): Emit f64
comparison instructions.
* module/language/cps/effects-analysis.scm: Define effects for f64
primcalls.
* module/language/cps/primitives.scm (*branching-primcall-arities*): Add
arities for f64 primcalls.
* module/language/cps/specialize-numbers.scm (specialize-f64-comparison):
New procedure.
(specialize-operations): Specialize f64 comparisons.
* module/system/vm/assembler.scm (emit-br-if-f64-=, emit-br-if-f64-<)
(emit-br-if-f64-<=, emit-br-if-f64->, emit-br-if-f64->=): Export.
* module/system/vm/disassembler.scm (code-annotation): Add annotations
for f64 comparison instructions.
2017-01-12 09:27:43 -05:00
Andy Wingo
1d4b4ec39c Add support for comparing u64 values with SCM values
* libguile/vm-engine.c (BR_U64_SCM_COMPARISON): New helper.
  (br-if-u64-<=-scm, br-if-u64-<-scm, br-if-u64-=-scm)
  (br-if-u64->-scm, br-if-u64->=-scm): New instructions, to compare an
  untagged u64 with a tagged SCM.  Avoids many u64->scm operations.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm:
* module/language/cps/type-fold.scm:
* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm (code-annotation, compute-labels):
* module/language/cps/primitives.scm (*branching-primcall-arities*): Add
  support for new opcodes.
* module/language/cps/specialize-numbers.scm
  (specialize-u64-scm-comparison): New helper.
* module/language/cps/specialize-numbers.scm (specialize-operations):
  Specialize u64 comparisons.
* module/language/cps/types.scm (true-comparison-restrictions): New helper.
  (define-comparison-inferrer): Use the new helper.  Add support for
  u64-<-scm et al.
2015-12-03 09:01:24 +01:00
Andy Wingo
a08b3d40f8 Untag values and indexes for all bytevector instructions
* libguile/vm-engine.c (bv-s8-ref, bv-s16-ref, bv-s32-ref, bv-s64-ref):
  Unbox index and return unboxed S32 value.
  (bv-s8-set!, bv-s16-set!, bv-s32-set!, bv-s64-set!): Unbox index and
  take unboxed S32 value.
  (bv-u8-ref, bv-u16-ref, bv-u32-ref, bv-u64-ref)
  (bv-s8-set!, bv-s16-set!, bv-s32-set!, bv-s64-set!): Likewise, but
  with unsigned values.
  (bv-f32-ref, bv-f32-set!, bv-f64-ref, bv-f64-set!): Use memcpy to
  access the value so we don't have to think about alignment.  GCC will
  inline this to a single instruction on architectures that support
  unaligned access.
* libguile/vm.c (vm_error_out_of_range_uint64)
  (vm_error_out_of_range_int64): New helpers.

* module/language/cps/slot-allocation.scm (compute-var-representations):
  All bytevector ref operations produce untagged values.

* module/language/cps/types.scm (define-bytevector-accessors): Update
  for bytevector untagged indices and values.

* module/language/cps/utils.scm (compute-constant-values): Fix s64
  case.

* module/language/tree-il/compile-cps.scm (convert): Box results of all
  bytevector accesses, and unbox incoming indices and values.
2015-12-01 15:42:24 +01:00
Andy Wingo
f34688ad25 New instructions load-f64, load-u64
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Add word
  types for immediate f64 and u64 values.
  (TYPE_WIDTH): Bump up by a bit, now that we have 32 word types.
  (NOP, parse_instruction): Use 64-bit meta type.

* libguile/vm-engine.c (load-f64, load-u64): New instructions.

* module/language/bytecode.scm (compute-instruction-arity): Add parser
  for new instruction word types.

* module/language/cps/compile-bytecode.scm (compile-function): Add
  special-cased assemblers for new instructions, and also for scm->u64
  and u64->scm which I missed before.

* module/language/cps/effects-analysis.scm (load-f64, load-u64): New
  instructions.

* module/language/cps/slot-allocation.scm (compute-needs-slot): load-f64
  and load-u64 don't need slots.
  (compute-var-representations): Update for new instructions.

* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
  Specialize scm->f64 and scm->u64 to make-f64 and make-u64.

* module/language/cps/types.scm (load-f64, load-u64): Wire up to type
  inference, though currently type inference only runs before
  specialization.

* module/language/cps/utils.scm (compute-defining-expressions): For some
  reason I don't understand, it's possible to see two definitions that
  are equal but not equal? here.  Allow for now.
  (compute-constant-values): Punch through type conversions to get
  constant u64/f64 values.

* module/system/vm/assembler.scm (assembler): Support for new word
  types.  Export the new assemblers.
2015-12-01 11:30:55 +01:00
Andy Wingo
07607f66b8 Add instructions to branch on u64 comparisons
* libguile/vm-engine.c (BR_U64_ARITHMETIC): New helper.
  (br-if-u64-=, br-if-u64-<, br-if-u64->=): New instructions.

* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm:
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm (u64-=, infer-u64-comparison-ranges):
  (define-u64-comparison-inferrer, u64-<, u64-<=, u64->=, u64->):
* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm (code-annotation):
  (compute-labels): Compiler and toolchain support for the new
  instructions.
2015-12-01 11:30:54 +01:00
Andy Wingo
3e5d4131d2 Don't compile equal? to br-if-equal
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/language/cps/type-fold.scm (equal?):
* module/language/cps/types.scm (equal?):
* module/language/tree-il/compile-cps.scm (convert): `equal?' is no
  longer a branching primcall, because it isn't inline.  The
  implementation could lead to bad backtraces also, as it didn't save
  the IP, and actually could lead to segfaults as it didn't reload the
  SP after the return.  There is an eqv? fast-path, though.
* module/system/vm/assembler.scm (br-if-equal): Remove interface.
* module/system/vm/disassembler.scm (code-annotation):
  (compute-labels): No need to handle br-if-equal.
2015-11-12 21:22:19 +01:00
Andy Wingo
c984432f60 Remove use of return in disassembler.scm
* module/system/vm/disassembler.scm (instruction-has-fallthrough?):
  Remove return from static opcode set.
2015-10-28 13:11:20 +00:00
Andy Wingo
696339a603 Always emit return-values
* module/language/cps/compile-bytecode.scm (compile-function): Remove
  special cases for nullary and unary returns; instead always use
  return-values and rely on hinting to try to place values in the right
  slot already.

* module/system/vm/assembler.scm (emit-init-constants): Use
  return-values.

* module/system/vm/disassembler.scm (code-annotation): Add annotation
  for return-values.
2015-10-28 11:32:15 +00:00
Andy Wingo
467e587d68 Update VM documentation for new stack layout
* doc/ref/vm.texi: Update for new stack layout.
* module/system/vm/disassembler.scm (code-annotation): Print the frame
  sizes after alloc-frame, reset-frame, etc to make reading the
  disassembly easier.
2015-10-22 11:02:18 +00:00
Andy Wingo
f03960412e Add stack size computation to disassembler
* module/system/vm/disassembler.scm (define-stack-effect-parser)
  (stack-effect-parsers, instruction-stack-size-after): New stack size
  facility.
  (define-clobber-parser, clobber-parsers, instruction-slot-clobbers):
  Take incoming and outgoing stack sizes as arguments to interpret
  SP-relative clobbers.

* module/system/vm/frame.scm (compute-frame-sizes): New helper that
  computes frame sizes for each position in a function.
  (compute-killv): Adapt to compute the clobbered set given the computed
  frame sizes.
2015-10-21 15:02:28 +02:00
Andy Wingo
0da0308b84 Prepare for SP-addressed locals
* libguile/vm-engine.c: Renumber opcodes, and take the opportunity to
  fold recent additions into more logical places.  Be more precise when
  describing the encoding of operands, to shuffle local references only
  and not constants, immediates, or other such values.
  (SP_REF, SP_SET): New helpers.
  (BR_BINARY, BR_ARITHMETIC): Take full 24-bit operands.  Our shuffle
  strategy is to emit push when needed to bring far locals near, then
  pop afterwards, shuffling away far destination values as needed; but
  that doesn't work for conditionals, unless we introduce a trampoline.
  Let's just do the simple thing for now.  Native compilation will use
  condition codes.
  (push, pop, drop): Back from the dead!  We'll only use these for
  temporary shuffling though, when an opcode can't address the full
  24-bit range.
  (long-fmov): New instruction, like long-mov but relative to the frame
  pointer.
  (load-typed-array, make-array): Don't use a compressed encoding so
  that we can avoid the shuffling case.  It would be a pain, given that
  they have so many operands already.

* module/language/bytecode.scm (compute-instruction-arity): Update for
  new instrution word encodings.

* module/system/vm/assembler.scm: Update to expose some opcodes
  directly, without the need for shuffling wrappers.  Adapt to
  instruction word encodings change.

* module/system/vm/disassembler.scm (disassembler): Adapt to instruction
  coding change.
2015-10-21 11:49:20 +02:00
Andy Wingo
e2fafeb901 Keywords have a tc7
* libguile/tags.h (scm_tc7_keyword): Allocate a tc7, so that the VM can
  have cheap keyword? tests.

* libguile/keywords.c:
* libguile/keywords.h: Adapt.

* libguile/goops.c (scm_class_of, scm_sys_goops_early_init): Capture
  <keyword>.

* libguile/print.c (iprin1): Inline keyword printer.

* libguile/evalext.c (scm_self_evaluating_p): Add keywords here.

* libguile/deprecated.h:
* libguile/deprecated.c (scm_tc16_keyword): Deprecate.

* module/language/cps/compile-bytecode.scm (compile-fun): Add keyword?
  case, and bitvector? case while we're at it.
* module/language/cps/effects-analysis.scm (define-primitive-effects):
  Add bytevector?, keyword?, and bitvector? cases.

* module/language/cps/primitives.scm (*branching-primcall-arities*): Add
  keyword?.

* module/language/cps/types.scm (bitvector?, keyword?, bytevector?): Add
  branch inferrers.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*effect-free-primitives*):
  (*effect+exception-free-primitives*): Add bytevector?, keyword?, and
  bitvector?.

* module/oop/goops.scm (<keyword>): New class.

* module/system/base/types.scm (%tc7-keyword, cell->object): Add cases.

* module/system/vm/assembler.scm (br-if-keyword): New definition.
* module/system/vm/disassembler.scm (code-annotation): Add br-if-tc7
  case for keywords.

* test-suite/tests/types.test ("clonable objects"): Update now that
  keywords are cloneable.
2015-01-22 13:03:11 +01:00
Andy Wingo
d613ccaaa0 Compiler emits br-if-logtest
* module/language/cps/compile-bytecode.scm (compile-fun):
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/language/cps/type-fold.scm (logtest):
* module/language/cps/types.scm (logtest):
* module/system/vm/assembler.scm (system):
* module/system/vm/disassembler.scm (compute-labels): Add backend
  support for the logtest instruction.
2014-07-03 15:03:40 +02:00
Andy Wingo
8c6206f319 Add br-if-logtest opcode
* libguile/vm-engine.c (br-if-logtest): New opcode.
* module/system/vm/disassembler.scm (code-annotation): Add branch
  annotation support.
2014-07-03 14:50:50 +02:00
Andy Wingo
c09708f985 VM opcodes only have <24-bit slot operands in the first word
* libguile/vm-engine.c (make-array): Change to only have
  restricted-width operands in the first word.  This instruction is
  currently unused, however.

* module/system/vm/assembler.scm (assembler):
* module/system/vm/disassembler.scm (disassembler): Disallow
  restricted-width operands in tail words.
2014-04-20 11:52:14 +02:00
Andy Wingo
20d7d68284 Add parsing interfaces to the disassembler
* module/system/vm/disassembler.scm (instruction-length):
  (instruction-has-fallthrough?, instruction-relative-jump-targets):
  (instruction-slot-clobbers): New interfaces; to be used when
  determining the bindings available at a given point of a procedure.
2014-04-16 12:58:20 +02:00
Andy Wingo
560bfa9241 Improve disassembly for optimized closures
* module/system/vm/disassembler.scm (code-annotation): Add call-label
  and tail-call-label cases.
  (disassemble-addr): With call-label we can see sets of mutually
  recursive functions, so keep a global "visited?" set.
2014-04-13 14:40:22 +02:00
Andy Wingo
691697de09 Rename "RTL" to "bytecode"
"RTL" didn't make any sense, and now that there's no other bytecode to
disambiguate against, just call it bytecode.

* module/Makefile.am:
* module/ice-9/eval-string.scm:
* module/language/bytecode.scm:
* module/language/bytecode/spec.scm:
* module/language/cps/arities.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/compile-rtl.scm:
* module/language/cps/contification.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/primitives.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/spec.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/rtl.scm:
* module/language/rtl/spec.scm:
* module/scripts/compile.scm:
* module/system/base/compile.scm:
* module/system/repl/common.scm:
* module/system/vm/assembler.scm:
* module/system/vm/debug.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/dwarf.scm:
* test-suite/tests/cross-compilation.test:
* test-suite/tests/dwarf.test:
* test-suite/tests/rtl-compilation.test:
* test-suite/tests/rtl.test:
* test-suite/vm/run-vm-tests.scm: Fixups.
2013-12-02 21:31:47 +01:00
Andy Wingo
1b1c912544 Unknown files print as (unknown file) in disassembler
* module/system/vm/disassembler.scm (disassemble-buffer): Print unknown
  files as "(unknown file)".
2013-11-30 18:46:14 +01:00
Andy Wingo
321c32dc9d ,x disassembles nested programs too
* module/system/vm/disassembler.scm (code-annotation):
  (disassemble-buffer, disassemble-addr, disassemble-program): Arrange
  to disassemble nested procedures.
  (disassemble-image): Adapt.
2013-11-30 18:46:14 +01:00
Andy Wingo
4cbc95f150 Rename objcodes?.{scm,c,h} to loader.{scm,c,h}
* 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 21:45:07 +01:00
Andy Wingo
1b780c134b (system vm instruction) rtl-instruction-list -> (language rtl) instruction-list
* 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-19 20:45:57 +01:00
Andy Wingo
d1100525ff rtl-program-code -> program-code
* 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-19 19:36:27 +01:00
Andy Wingo
0bd1e9c6a0 rtl-program? -> program?
* 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-19 19:11:40 +01:00
Andy Wingo
850e80dacc Add fold-program-code to (system vm disassembler)
* module/system/vm/disassembler.scm (fold-code-range): New helper.
  (fold-program-code): New interface.
2013-11-08 15:58:27 +01:00
Andy Wingo
d65514a2de RTL compiler supports static bitvectors
* 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-03 21:48:48 +01:00
Andy Wingo
becce37b58 Better compiler support for bytevector ops
* 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-31 12:55:24 +01:00
Andy Wingo
2ab2a10d50 static-patch! replaces link-procedure!
* 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-31 09:47:48 +01:00
Andy Wingo
486013d67c VM has "builtins": primitives addressable by emitted RTL code
* 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-27 20:09:01 +01:00
Andy Wingo
be8b62ca7f RTL compiler: Compile TC7 branches.
* 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-26 15:16:09 +02:00
Andy Wingo
8d59d55e86 RTL: Compile prompts
* 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-14 16:13:57 +02:00
Andy Wingo
e9588e7032 Disassembling RTL prints source information.
* module/system/vm/disassembler.scm (disassemble-buffer): Print source
  information.
2013-10-04 15:28:40 +02:00
Andy Wingo
93009a7aca ,xx for RTL images
* 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-29 20:50:19 +02:00
Andy Wingo
610295ec9d add ability to disassemble ELF images
* 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-29 20:44:55 +02:00
Andy Wingo
70a2043143 RA == MVRA in disassembler
* module/system/vm/disassembler.scm: Modify call disassembler to assume
  RA == MVRA.
2013-08-24 15:38:27 +02:00
Andy Wingo
af95414f1d Various RTL VM and calling convention tweaks
* 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-08-11 16:45:31 +02:00
Andy Wingo
78ff784784 RTL instructions have no rest args
* 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-21 17:12:23 +02:00
Andy Wingo
7396d21670 RTL: Local 0 is the procedure
* 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-21 17:12:22 +02:00
Andy Wingo
2a294c7cd3 rtl: propagate OP_DST to scheme
* 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-07-21 17:12:22 +02:00
Andy Wingo
82e299f386 Add RTL disassembler
* module/Makefile.am:
* module/system/vm/disassembler.scm: New module.

* module/system/repl/command.scm (disassemble): Work with RTL programs.
2013-06-09 20:07:57 +02:00