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

2705 commits

Author SHA1 Message Date
Andy Wingo
4dfae1bf50 Move assemble-program to test cases.
* module/system/vm/assembler.scm (assemble-program): Remove.
* test-suite/tests/rtl.test (assemble-program): Move here.
2013-11-08 17:36:45 +01:00
Andy Wingo
b77a5215c7 Per-instruction tracing doesn't try to disassemble stack VM code
* module/system/vm/trace.scm (trace-instructions-in-procedure): Don't
  try to disassemble the procedure, for now.
2013-11-08 17:32:41 +01:00
Andy Wingo
e391f179e4 (system vm traps) support for rtl programs
* 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-08 17:31:51 +01:00
Andy Wingo
0d4bcc71d2 Remove objcode language.
* module/language/objcode/elf.scm:
* module/language/objcode/spec.scm: Remove objcode language.

* module/Makefile.am: Adapt.
2013-11-08 16:51:44 +01:00
Andy Wingo
ad9b491fa7 Remove bytecode language.
* module/language/bytecode/spec.scm: Remove.

* module/Makefile.am: Adapt.
2013-11-08 16:49:04 +01:00
Andy Wingo
f3c0b53346 Remove assembly language.
* 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-08 16:45:10 +01:00
Andy Wingo
f7f5f49a6b Decompile goes from tree-il to scheme by default.
* module/system/base/compile.scm (decompile): By default, go from
  tree-il to Scheme, now that the assembly language is going away.
2013-11-08 16:40:27 +01:00
Andy Wingo
147f9978ba Rewrite (system xref) to work with RTL programs
* 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-08 16:31:29 +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
5af36584d8 Remove GLIL language
* module/Makefile.am:
* module/language/glil.scm:
* module/language/glil/compile-assembly.scm:
* module/language/glil/spec.scm: Remove.
2013-11-08 14:58:40 +01:00
Andy Wingo
ac023564b2 Remove tree-il->glil compiler
* module/Makefile.am:
* module/language/tree-il/compile-glil.scm: Remove.

* module/language/tree-il/spec.scm: Remove tree-il->glil link.
2013-11-08 14:57:43 +01:00
Andy Wingo
8734229528 Fix program-minimum-arity to work better with case-lambda.
* module/system/vm/debug.scm (program-minimum-arity): Be more precise
  with case-lambdas.
2013-11-08 14:19:41 +01:00
Andy Wingo
f41accb9c2 Fix procedure-arguments on RTL programs, and tweak session.test
* 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-08 13:29:03 +01:00
Andy Wingo
b0ed216b6f Fix case-lambda* dispatching to agree with manual.
* module/system/vm/assembler.scm (kw-prelude): Emit br-if-npos-gt as
  appropriate.
2013-11-08 11:41:28 +01:00
Andy Wingo
be564260be Fix arity selection in compute-contification
* 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-08 10:59:52 +01:00
Andy Wingo
6a59420a9d Fix error message in lambda* eval closures with keywords
* 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-08 10:37:09 +01:00
Andy Wingo
0e3a59f750 Fix reading and writing arities into DWARF.
* 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-08 10:11:48 +01:00
Andy Wingo
581a4eb82b frame-instruction-pointer is absolute; rewrite (system vm coverage)
* 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-07 23:03:45 +01:00
Andy Wingo
e15aa02284 Program sources are always pre-retire now
* 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-07 18:00:40 +01:00
Andy Wingo
0128bb9c38 add fold-all-debug-contexts, fold-source-locations
* 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-07 17:53:04 +01:00
Andy Wingo
31602aa04a Fix line advance DWARF opcodes when line advance is exactly 128
* module/system/vm/assembler.scm (link-debug): Fix off-by-one error in
  which forward jumps of 128 were mis-rendered.
2013-11-07 11:10:36 +01:00
Andy Wingo
32ca15d7d7 Write DWARF files list in correct order.
* module/system/vm/assembler.scm (link-debug): Fix order of writing the
  source files list; it was being written backwards.
2013-11-07 10:52:47 +01:00
Andy Wingo
6e422a3599 Source information goes on the $continue, not the $cont.
* 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-07 10:32:21 +01:00
Andy Wingo
963d95f1d9 Fix first find-program-sources result
* module/system/vm/debug.scm (find-program-sources): Manually set the pc
  of the first result in a function.
2013-11-06 17:33:43 +01:00
Andy Wingo
0a1d52ac77 fix docstring assembly and fetching
* 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-05 21:29:46 +01:00
Andy Wingo
3659ef543e asm-labels is a hash table
* module/system/vm/assembler.scm (make-assembler, label):
  (link-data, process-relocs, process-labels): Change labels to be a
  hash table.
2013-11-05 20:18:23 +01:00
Andy Wingo
0d0465135d Re-add the list hack to compile-cps
* module/language/tree-il/compile-cps.scm (convert): Re-add the list
  hack.  Ideally these go into some tree-il pass.
2013-11-05 18:16:13 +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
9ae9debbd3 struct-set! returns a value, yuck
* 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-03 21:48:42 +01:00
Andy Wingo
92afe25d5c Correctness fix for vector constructor inlining.
* module/language/tree-il/compile-cps.scm (convert): Don't inline the
  vector constructor if any arg could capture the current continuation.
2013-11-03 12:28:47 +01:00
Andy Wingo
be6e40a1df Eval evaluates initializers before creating environment ribs.
* 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 12:16:49 +01:00
Andy Wingo
91fc226e24 "length" is an interesting primitive
* module/language/tree-il/primitives.scm (*effect-free-primitives*):
  (*interesting-primitive-names*): Add "length", so that we can
  constant-fold it.
2013-11-03 12:15:09 +01:00
Andy Wingo
1d15832ffc Revert "Compile-time debugging"
This reverts commit 6a37b7faaf.
2013-11-01 19:43:45 +01:00
Andy Wingo
14b9aa95e6 Fix order of evaluation in elisp lexer
* module/language/elisp/lexer.scm (lex): Use let*, to ensure that the
  port position is read before reading the next char.
2013-11-01 18:23:51 +01:00
Andy Wingo
b681671ede Fix contification of non-recursive closures
* 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-01 18:22:58 +01:00
Andy Wingo
d258fcccee RTL compilation sorts continuations topologically before visiting them
* 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-01 14:37:57 +01:00
Andy Wingo
4a565538bd Failed match errors generate less code
* 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-01 13:37:27 +01:00
Andy Wingo
58dee5b9e4 Add compile-cps hack for vectors
* module/language/tree-il/compile-cps.scm (convert): Add a special case
  for "vector" primcalls.  Boo!
2013-11-01 08:51:52 +01:00
Andy Wingo
cb8054c7ac Better range checks in the assembler
* 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-31 22:57:06 +01:00
Andy Wingo
ef47c4229c Be smarter about capturing the environment for memoized code
* 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-31 22:16:10 +01:00
Andy Wingo
3e248c70e3 define! is an interesting primitive
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  Add define!.
2013-10-31 20:39:22 +01:00
Andy Wingo
5bff312598 fix compilation of (let lp () (lp))
* 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-31 20:24:38 +01:00
Andy Wingo
dda5fd94de DFG: Export analyze-control-flow.
* 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-31 19:49:19 +01:00
Andy Wingo
c7cb2bc200 static-patch! for pair and vector fields
* module/system/vm/assembler.scm (intern-constant): Use static-patch!
  for fields.
2013-10-31 19:21:31 +01:00
Andy Wingo
57a5cc9760 Better REPL support for disassembling RTL images
* module/system/repl/command.scm (load-image): New helper.
  (compile, disassemble): Handle bytevectors.
2013-10-31 14:18:25 +01:00
Andy Wingo
b73a2ee017 Default to compiling to RTL
* 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-31 14:17:30 +01:00
Andy Wingo
6165d8120d Better aliased primcall compilation
* 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-31 12:55:24 +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
7bfbc7b1c5 Support serialization of uniform vector literals
* 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-31 12:55:23 +01:00
Andy Wingo
6a37b7faaf Compile-time debugging
* module/language/cps/compile-rtl.scm:
* module/language/cps/contification.scm: Add some compile-time
  printouts.  Will be removed later.
2013-10-31 12:55:17 +01:00