1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 04:10:18 +02:00
Commit graph

2990 commits

Author SHA1 Message Date
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
8006d2d6eb Optimizer support for logtest and logbit?
* module/language/cps/effects-analysis.scm: Add entries for logtest and
  logbit?.
* module/language/cps/types.scm (logtest, logbit?): New checkers and
  inferrers.
* module/language/tree-il/peval.scm (peval): Convert (zero? (logand a
  b)) to (logtest a b), in anticipation of opcode support for logtest.
*
  module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*effect-free-primitives*): Add logtest and logbit?.
2014-07-03 14:45:12 +02:00
Andy Wingo
5ded849813 Convert slot allocation to use intsets
* module/language/cps/dfg.scm (compute-live-variables): Convert to use
  intsets, and fold in compute-maximum-fixed-point.
  (print-dfa): Update.

* module/language/cps/slot-allocation.scm (dead-after-def?)
  (dead-after-use?, allocate-slots): Convert to use intsets.
2014-07-03 11:24:37 +02:00
Andy Wingo
7f6aafa5ae Add bitvector->intset.
* module/language/cps/intset.scm (bitvector->intset): New interface.
2014-07-03 10:37:20 +02:00
Andy Wingo
4296c36ec8 Restrict intsets and maps to non-negative integers
* module/language/cps/intmap.scm (intmap-add):
* module/language/cps/intset.scm (intset-add): Restrict to only hold
  non-negative integers.
2014-07-03 09:37:30 +02:00
Andy Wingo
e9808c14d7 Adapt visit-prompt-control-flow to use intsets.
* module/language/cps/dfg.scm (compute-reachable): Use intsets.
  (compute-interval): Adapt.
  (visit-prompt-control-flow): Adapt.
2014-07-03 09:20:11 +02:00
Andy Wingo
c1a41f96b4 CSE comments
* module/language/cps/cse.scm (compute-available-expressions): Add
  clarifying comment.
2014-07-03 09:03:45 +02:00
Andy Wingo
41296769c7 Add intset-subtract.
* module/language/cps/intset.scm (intset-subtract): New interface.
2014-07-03 09:03:12 +02:00
Andy Wingo
93e838423c Fix intset on 32-bit machines
* module/language/cps/intset.scm (*leaf-bits*): Define to 4 on 32-bit
  machines, to stay in fixnum range.
2014-07-01 11:30:29 +02:00
Andy Wingo
0ad455ca6b Remove size limit in elide-type-checks
* module/language/cps/dce.scm (elide-type-checks!): Remove limit on
  label-count, now that complexity is under control.
2014-06-30 15:30:39 +02:00
Andy Wingo
e21dae43fc Fix intmap-intersect corner case
* module/language/cps/intmap.scm (intmap-intersect): Fix a corner case,
  as was recently fixed for intsets.
2014-06-29 19:49:49 +02:00
Andy Wingo
072b5a277c CSE truth inference pass uses intsets
* module/language/cps/cse.scm (compute-truthy-expressions): Rewrite to
  use intsets instead of bitvectors.
  (apply-cse): Adapt.
2014-06-29 19:47:38 +02:00
Andy Wingo
793ca4c433 Result of intsect-intersect will share structure with A if it can
* module/language/cps/intset.scm (intset-intersect): Ensure that the
  result shares structure with A if possible, as intmaps do.
2014-06-29 19:47:38 +02:00
Andy Wingo
257db78b6b Fix an intset-intersect corner case
* module/language/cps/intset.scm (intset-intersect): Avoid creating
  invalid intsets when lowering an intset with a higher shift.
2014-06-29 19:41:16 +02:00
Andy Wingo
b5cb1c77ff Fix intset pruning for empty intsets
* module/language/cps/intset.scm (make-intset/prune): Fix empty intset
  case.
2014-06-29 19:31:41 +02:00
Andy Wingo
2c02a21023 Remove namesets.
This was a failed experiment.  It had good space complexity but terrible
time complexity.

* module/Makefile.am: Update.
* module/language/cps/nameset.scm: Remove.
2014-06-29 14:30:34 +02:00
Andy Wingo
3a12f2ce0b Rewrite type inference to use intmaps
* module/language/cps/types.scm: Rewrite to use intmaps instead of
  namesets.
2014-06-29 14:30:34 +02:00
Andy Wingo
b352309301 New module (language cps intmap)
* module/language/cps/intmap.scm: New file.
* module/Makefile.am: Add to build.
2014-06-29 14:30:25 +02:00
Andy Wingo
6fe36f220e Rewrite CSE to use intsets.
* module/language/cps/cse.scm: Rewrite using intsets.
2014-06-29 14:26:02 +02:00
Andy Wingo
b1103eb980 New module: (language cps intset)
* module/Makefile.am: Add to build.
* module/language/cps/intset.scm: New file.
2014-06-29 14:19:03 +02:00
Andy Wingo
ec412d7562 Rewrite type inference pass to use namesets
* module/Makefile.am: Build types.scm early, but don't block the rest of
  the build on it.

* module/language/cps/types.scm: Rewrite to use namesets.

* module/language/cps/dce.scm:
* module/language/cps/type-fold.scm: Adapt to interface changes.
2014-06-22 12:19:29 +02:00
Andy Wingo
97ed2e77ab New module: (language cps nameset)
* module/language/cps/nameset.scm: New file.
* module/Makefile.am: Add new file.
2014-06-22 11:28:18 +02:00
Andy Wingo
38c7bd0e77 Refactor dominator computation
* module/language/cps/cse.scm:
* module/language/cps/dfg.scm (compute-idoms, compute-dom-edges): Move
  these procedures from cse.scm to dfg.scm.
  Remove loop-detection code; that can come back later but it is
  bitrotten for now.
2014-06-19 08:48:07 +02:00
Andy Wingo
803a1ee7c7 Constant folding for (list) and (vector) in peval
* module/language/tree-il/peval.scm (peval): Add cases for (list) -> '()
  and (vector) -> #().
2014-06-19 08:47:25 +02:00
Andy Wingo
59258f7cad Remove $kif
* module/language/cps.scm: Remove $kif.

* module/language/cps/compile-bytecode.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/renumber.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm:
* module/language/cps/verify.scm: Adapt.
2014-05-31 21:43:12 -04:00
Andy Wingo
fd61004764 CPS conversion produces $branch nodes, not $kif
* module/language/tree-il/compile-cps.scm (unbound?, convert): Create
  $branch nodes instead of $kif nodes.
2014-05-31 21:15:13 -04:00
Andy Wingo
92805e2197 Add $branch expression type
* module/language/cps.scm ($branch): New expression type; will replace
  $kif.

* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/primitives.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm:
* module/language/cps/verify.scm: Adapt to $branch expression type.
2014-05-31 21:15:06 -04:00
Andy Wingo
c90e2c6087 Fix source-line-for-user for unknown line
* module/system/vm/debug.scm (source-line-for-user): Fix to allow for
  unknown lines.
2014-05-31 21:15:06 -04:00
Andy Wingo
51177f3515 Fix off-by-one in dump-dfg
* module/language/cps/dfg.scm (dump-dfg): Fix bug where the last
  continuation wasn't printed.
2014-05-31 21:15:06 -04:00
Andy Wingo
5062a56df0 Fix compute-predecessors bug in frame.scm
* module/system/vm/frame.scm (compute-predecessors): Fix bug in
  resolving targets of backwards branches.
2014-05-31 21:15:05 -04:00
Andy Wingo
146c8e72a9 Update effects-analysis docstring.
* module/language/cps/effects-analysis.scm: Update docs.
2014-05-16 16:57:58 +02:00
Andy Wingo
e7f2fe1bb7 Redefine memory kind part of effects to be enumeration, not flags
* module/language/cps/effects-analysis.scm (define-enumeration): New
  helper.
  (&memory-kind-mask): Define as an enumeration, not a bitfield.  Add
  &unknown-memory-kinds.
  (&all-effects, effect-clobbers?, make-prompt-tag, expression-effects):
  Adapt.

Note that this change requires dce.go and cse.go to be recompiled.
2014-05-16 16:17:53 +02:00
Andy Wingo
3be43fb782 DCE uses type analysis to elide type checks
* module/language/cps/dce.scm (elide-type-checks!, compute-live-code):
  Replace old ad-hoc type check elision with one driven from type
  analysis.  Type check elision only operates on smallish functions, to
  avoid n**2 explosion in type inference.
2014-05-15 17:39:24 +02:00
Andy Wingo
a7ee377dbe Limit impact of O(n^2) type analysis by imposing limit
* module/language/cps/types.scm (infer-types): Add #:max-label-count
  argument.

* module/language/cps/type-fold.scm (compute-folded, fold-constants*):
  Disable for big functions.  Perhaps we can relax this if we find an
  O(n log n) way to represent types.
2014-05-15 17:39:24 +02:00
Andy Wingo
a77e3a7c8a Compile language/cps/types.scm early
* module/Makefile.am (BOOT_SOURCES, BOOT_GOBJECTS): New variables.
  (CLEANFILES, nobase_mod_DATA, nobase_ccache_DATA, EXTRA_DIST)
  (ETAGS_ARGS): Use the new variables.

  (CPS_LANG_SOURCES): Remove language/cps/types.scm, as it is a boot
  file.
2014-05-15 17:39:24 +02:00
Andy Wingo
6129faa0f5 Enable type folding
* module/language/cps/compile-bytecode.scm (optimize): Enable type
  folding.
2014-05-15 17:39:24 +02:00
Andy Wingo
8bc65d2d64 Type and range inference for CPS
* module/language/cps/types.scm: New file, implementing type and range
  inference over CPS.

* module/language/cps/type-fold.scm: New file, implementing abstract
  constant folding for CPS.

* module/Makefile.am: Add the new files.

* module/language/cps/compile-bytecode.scm: Wire up type-fold, but
  currently disabled.
2014-05-15 17:39:19 +02:00
Andy Wingo
5d25fdae37 Rewrite effects analysis to be precise for fields.
* module/language/cps/effects-analysis.scm: Rewrite so that instead of
  the depends/causes effects, there is just &type-check, &allocation,
  &read, and &write.  The object kind is a separate part of the
  bitfield, and the field in the object (if appropriate) is another
  field.  Effects are still a fixnum.  This enables precise effects for
  vectors and structs on all architectures.

  This kind of effects analysis was not possible in Tree-IL because
  Tree-IL relied on logior-ing effects of subexpressions, whereas with
  CPS we have no sub-expressions and we do flow analysis instead.

  (effect-clobbers?): Replace effects-commute? with this inherently
  directional and precise predicate.

* module/language/cps/cse.scm (compute-always-available-expressions):
  (compute-equivalent-subexpressions): Adapt to effects analysis
  change.
* module/language/cps/dce.scm (compute-live-code): Likewise.
2014-05-08 10:39:49 +02:00
Andy Wingo
466bdf7ee3 CSE effects analysis cleanup
* module/language/cps/cse.scm (compute-always-available-expressions):
  Use constant? instead of zero?, to avoid punching through the effects
  abstraction.
2014-05-07 17:10:15 +02:00
Andy Wingo
fb512cac6e Add dump-dfg pretty-printer
* module/language/cps/dfg.scm (dump-dfg): New pretty-printer.  Under
  construction.
2014-05-07 15:28:50 +02:00
Andy Wingo
c8d87b4745 Synthetic definitions take advantage of CSE'd vars
* module/language/cps/cse.scm (compute-available-expressions):
  Simplify initialization.
  (compute-equivalent-subexpressions): When synthesizing definitions,
  use substed vars.  Add synthetic definitions after processing an
  expression, to take advantage of the substed vars.
2014-05-07 15:28:12 +02:00
Andy Wingo
aa980ce0dc Fix thinko in synthesize-definition-effects!
* module/language/cps/effects-analysis.scm (synthesize-definition-effects!):
  Fix a boneheaded thinko that caused all primcalls to be marked as
  causing car, cdr, vector, struct, and box effects.
2014-05-07 15:25:13 +02:00
Andy Wingo
7af8115675 Fix frame-call-representation for frames from apply-hook
* module/system/vm/frame.scm (frame-call-representation): Fix when
  called on frames that are created from the apply hook.
2014-05-04 22:51:34 +02:00
Andy Wingo
423164efa6 Program printing tweaks
* module/system/vm/program.scm (print-program): New public interface --
  the guts of write-program, but refactored to be able to work when only
  given an addr.
  (write-program): Use print-program.

* module/system/vm/frame.scm (frame-call-representation): Remove attempt
  to abbreviate procedure representations; was confusing because the
  result would write as a string, quotes and all.
2014-05-04 22:41:48 +02:00
Andy Wingo
f5cb70e94a Refactorings to apply-hook and push-continuation-hook
* libguile/vm-engine.c (vm_engine): Always invoke the apply hook after
  the ip has been reset.  Avoids problems in frame-bindings, which
  builds its bindings map based on the IP.  Invoke push-continuation
  before linking the new frame, so that more locals are available to the
  frame inspector.

* module/system/vm/traps.scm (trap-in-procedure): No need for a
  push-cont handler, as the apply handler will exit the frame.
2014-05-04 14:09:42 +02:00
Andy Wingo
7c080187bc frame-address, frame-stack-pointer return offsets
* libguile/frames.c (scm_frame_address, scm_frame_stack_pointer): Return
  offsets instead of absolute pointers.  This is robust in the presence
  of stack relocation.

* module/system/repl/debug.scm (print-registers): Adapt to print sp and
  fp as integers.
2014-05-04 11:46:18 +02:00
Andy Wingo
18f8fd0211 frame-call-representation has #:top-frame? as keyword argument
* module/system/vm/frame.scm (frame-call-representation): Change
  top-frame? argument to be a keyword instead of an optional argument.

* module/system/vm/trace.scm (print-application): Adapt caller.
2014-05-04 11:18:54 +02:00
Andy Wingo
40b36bbf94 Set-car! on a dead pair does not force the pair to be live
* module/language/cps/dce.scm (constant-type, lookup-type)
  (default-type-checker, *primcall-type-checkers*)
  (define-primcall-type-checker, define-simple-primcall-types)
  (check-primcall-arg-types): Define a really lame type analysis that
  can elide some expressions causing &type-check.
  (compute-live-code): Wire up the type checker.
2014-05-03 12:42:12 +02:00
Andy Wingo
41812daa78 Add auxiliary definitions for boxes
* module/language/cps/cse.scm (compute-equivalent-subexpressions): Add
  auxiliary definitions for boxes.
2014-05-03 12:21:43 +02:00