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

1586 commits

Author SHA1 Message Date
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
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
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
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
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
Andy Wingo
6119a90595 CSE does scalar replacement of aggregates
* module/language/cps/effects-analysis.scm (effects-clobber): New
  helper.
  (length): Only depend on &cdr.
  (synthesize-definition-effects!): New interface.

* module/language/cps/cse.scm (compute-available-expressions): Don't
  count out constructors here -- we'll do that below.
  (compute-defs): Add a comment.
  (compute-equivalent-subexpressions): Synthesize getter calls at
  constructor/setter sites, so that (set-car! x y) can cause a
  future (car x) to just reference y.  The equiv-labels set now stores
  the defined vars, so there is no need for the defs vector.
  (cse, apply-cse): Adapt to compute-equivalent-subexpressions change.
2014-05-02 17:47:20 +02:00
Andy Wingo
cfb42b4c8a More inlinable effects-analysis procedures
* module/language/cps/effects-analysis.scm (exclude-effects)
  (effect-free?, constant?): Define to be inlinable.
  (allocate-struct/immediate): Add effects.
2014-05-02 17:30:10 +02:00
Andy Wingo
48ad85fb56 Fix foreign slot initialization and access
* libguile/goops.c (scm_sys_initialize_object): Refactor initialization
  so that we don't ref uninitialized slots before initializing them.
  This allows foreign slots, whose initial value is 0, to be initialized
  via #:init-form.

* module/oop/goops.scm (@slot-ref, @slot-set!): Remove definitions.
  Change callers to use struct-ref and struct-set!.  slot-ref and
  slot-set! were only marginally more efficient and were much more
  dangerous.  This change allows the standard accessors to work on
  foreign slots; that was not the case before, as the 'u' fields of the
  struct were read as if they were 'p' slots.
* module/language/tree-il/compile-glil.scm (lambda): Remove support for
  compiling @slot-ref/@slot-set!.  These were private to GOOPS.

* test-suite/tests/goops.test ("active-slot"): Update to not expect a
  ref before initialization.
  ("foreign slots"): Add tests.
2014-04-27 11:02:35 +02:00
Andy Wingo
d38ca16e2c Add make-vector opcode
* libguile/vm-engine.c (make-vector): New opcode.
* module/language/cps/compile-bytecode.scm (compile-fun):
* module/system/vm/assembler.scm (system): Support the new opcode.
  (*bytecode-minor-version*): Bump.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* test-suite/tests/compiler.test ("limits"): Add vector test.
2014-04-21 22:47:33 +02:00
Andy Wingo
d4b3a36d42 Operations on 8-bit and 12-bit operands shuffle args into range
* module/language/cps/slot-allocation.scm (allocate-slots): Avoid
  allocating locals in the range [253,255].

* module/system/vm/assembler.scm: List exports explicitly.  For
  operations with limited-range operands, export wrapper assemblers that
  handle shuffling their operands into and out of their range.
  (define-assembler): Get rid of enclosing begin.
  (shuffling-assembler, define-shuffling-assembler): New helpers to
  define shuffling wrapper assemblers.
  (emit-mov*, emit-receive*): New functions.
  (shuffle-up-args): New helper.
  (standard-prelude, opt-prelude, kw-prelude): Call shuffle-up-args
  after finishing.

* test-suite/tests/compiler.test ("limits"): Add test cases.
2014-04-21 22:47:28 +02:00
Andy Wingo
f5765cc25e Slot allocation can re-use closure and argument slots
* module/language/cps/slot-allocation.scm (allocate-slots): Allow slot
  allocation to re-use the closure and argument slots.
2014-04-16 19:21:50 +02:00
Andy Wingo
78351d1065 Beginnings of local variable information
* module/system/vm/assembler.scm (<arity>, begin-kw-arity, end-arity):
  (definition): Add definition macro-instruction.  Arrange to record
  variable definitions.

* module/language/cps/compile-bytecode.scm (compile-fun): Emit
  definition macro-instructions as appropriate.
2014-04-15 14:14:15 +02:00
Andy Wingo
863034a8ac Remove needless label remapping in slot-allocation
* module/language/cps/slot-allocation.scm (dead-after-def?):
  (dead-after-use?, allocate-slots): Remove some needless remapping
  between label indexes in the CFA, the DFA, and their names.
2014-04-15 12:25:26 +02:00
Andy Wingo
21a528fd82 DFA datums don't rename their labels
* module/language/cps/dfg.scm (analyze-reverse-control-flow): Don't
  compute and return an order vector; it's not needed.
  ($dfa): Remove label renaming.  We can just rename labels before
  returning the DFA.
  (dfa-k-idx, dfa-k-sym, dfa-k-count): Adapt.
  (compute-live-variables): Adapt, and rename labels before returning.
2014-04-15 12:16:41 +02:00
Andy Wingo
2ad91e6b34 Optimize make-global-cont-folder
* module/language/cps.scm (make-global-cont-folder): Inline the
  fold-values, as peval doesn't do so.  Allows closure conversion to
  avoid any closure creation.
2014-04-14 13:53:35 +02:00
Andy Wingo
c4aa51bae8 Remove debugging code in closure-conversion
* module/language/cps/closure-conversion.scm (prune-free-vars): Remove
  pk.
2014-04-13 14:26:03 +02:00
Andy Wingo
fcb31f2953 Closure conversion eliminates self-references introduced by fixpoint
* module/language/cps/closure-conversion.scm (analyze-closures): Build a
  bound-vars set as well, to resolve introduced self-references.
  (prune-free-vars, convert-one): Arrange to eliminate self-references.
2014-04-13 14:21:25 +02:00
Andy Wingo
2920554a1e Refactor to closure-conversion
* module/language/cps/closure-conversion.scm (convert-one): Refactor to
  pull in helpers locally, as they will need more state.
2014-04-13 13:54:17 +02:00
Andy Wingo
32e62c2dae Optimize closures with one free variable
* module/language/cps/closure-conversion.scm (convert-free-var)
  (allocate-closure, init-closure, prune-free-vars, convert-one)
  (convert-closures): Optimize closures with one free variable.
2014-04-13 11:47:17 +02:00
Andy Wingo
cd130361b8 Well-known closures represented using pairs or vectors
* module/language/cps/closure-conversion.scm (convert-free-var):
  (convert-free-vars): Take self-known? param, to do the right thing for
  well-known closures.
  (allocate-closure): New helper.  Well-known closures are represented
  using pairs or vectors.
  (init-closure): Adapt tpo DTRT for well-known closures.
  (prune-free-vars): Move up.
  (convert-one): Adapt to new well-known closure representation.
2014-04-12 23:31:08 +02:00