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

459 commits

Author SHA1 Message Date
Andy Wingo
fb2f7b4e5f Better CPS conversion for tests in tests
* module/language/tree-il/compile-cps.scm (convert): Tests in tests have
  their consequents and alternates also converted in test context.
2016-01-03 18:18:51 +01:00
Andy Wingo
166703c5ce Better partial evaluation of tests in tests
* module/language/tree-il/peval.scm (peval): In test context,
  fold (let ((x EXP)) (if x x ALT)) to (if EXP #t ALT).  This reduces
  the number of boolean literals that the compiler has to reify, by
  causing EXP to evaluate in test context instead of value context.
  Also, rotate `let' out of the test part of conditionals, for the same
  reason.
2016-01-03 18:15:20 +01:00
Andy Wingo
82085252ec Add logsub op.
* libguile/vm-engine.c (logsub): New op.
* module/language/cps/effects-analysis.scm (logsub):
* module/language/cps/types.scm (logsub):
* module/system/vm/assembler.scm (system): Add support for the new op.

* module/language/tree-il/compile-cps.scm (canonicalize):
  Rewrite (logand x (lognot y)) to (logsub x y).
2015-12-01 15:42:24 +01:00
Andy Wingo
8c75a5eb1b Add current-thread VM op
* libguile/vm-engine.c (current-thread): New op.
* module/language/cps/effects-analysis.scm (&thread): New memory kind.

* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm (current-thread):
* module/language/cps/types.scm (current-thread):
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
* module/system/vm/assembler.scm (emit-current-thread): Wire up the new
  op.
2015-12-01 15:42:24 +01:00
Andy Wingo
c3240d09b2 Unbox indexes of vectors, strings, and structs
* libguile/vm-engine.c (string-length, string-ref)
  (make-vector, vector-ref, vector-set!)
  (allocate-struct, struct-ref, struct-set!): Take indexes and return
  lengths as untagged u64 values.

* libguile/vm.c (vm_error_not_a_string): New helper.

* module/language/tree-il/compile-cps.scm (convert):
* module/language/cps/constructors.scm (inline-vector):
* module/language/cps/closure-conversion.scm (convert-one): Untag
  arguments to {string,vector,struct}-{ref,set!}, make-vector, and
  allocate-struct.  Tag return values from {string,vector}-length.

* module/language/cps/slot-allocation.scm (compute-var-representations):
  vector-length and string-length define u64 slots.

* module/language/cps/effects-analysis.scm: make-vector no longer causes
  a &type-check effect.

* module/language/cps/types.scm: Update to expect &u64 values for
  lengths and indexes.
2015-12-01 15:42: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
8f18b71b7a Remove add1 and sub1
* libguile/vm-engine.c: Remove add1 and sub1 instructions.  Will replace
  with add/immediate and sub/immediate.
* module/language/tree-il/peval.scm (peval): If we reify a new
  <primcall>, expand it.  Removes 1- and similar primcalls.
* module/language/tree-il/primitives.scm: Don't specialize (+ x 1) to 1+.
  (expand-primcall): New export, does a single primcall expansion.
  (expand-primitives): Use the new helper.
* module/language/cps/effects-analysis.scm:
* module/language/cps/primitives.scm:
* module/language/cps/types.scm:
* module/system/vm/assembler.scm: Remove support for add1 and sub1 CPS
  primitives.
* test-suite/tests/peval.test ("partial evaluation"): Adapt tests that
  expect 1+/1- to expect +/-.
2015-12-01 11:30:55 +01:00
Andy Wingo
87cc8b0f97 bv-f{32,64}-{ref,set!} take unboxed u64 index
* module/language/tree-il/compile-cps.scm (convert): bv-f32-ref,
  bv-f32-set!, bv-f64-ref, and bv-f64-set! take the index as an untagged
  u64 value.
* module/language/cps/types.scm (define-bytevector-uaccessors): New
  helper, used while migrating bytevectors to take unboxed indexes.
  Adapt f32/f64 accessors to use this definition helper.
* libguile/vm-engine.c (BV_FLOAT_REF, BV_FLOAT_SET): The index is
  unboxed.
2015-12-01 11:30:54 +01:00
Andy Wingo
8464cc576c Add bv-length instruction
* libguile/vm-engine.c (bv-length): New instruction.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm (bv-length):
* module/language/cps/primitives.scm (*instruction-aliases*):
* module/language/cps/slot-allocation.scm (compute-var-representations):
* module/language/cps/types.scm (bv-length):
* module/language/tree-il/compile-cps.scm (convert): Add support for
  bv-length.
* module/system/vm/assembler.scm: Export emit-bv-length.
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
b1ac8d68b5 bv-{f32,f64}-{ref,set!} operate on raw f64 values
* module/language/tree-il/compile-cps.scm (convert): Box results of
  bv-f32-ref and bv-f64-ref.  Unbox the argument to bv-f32-set! and
  bv-f64-set!.

* libguile/vm-engine.c (bv-f32-ref, bv-f64-ref): Results are raw.
  (bv-f32-set!, bv-f64-set!): Take unboxed arguments.

* module/system/vm/assembler.scm (emit-scm->f64, emit-f64->scm):
  Export.

* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm: Add support for scm->f64 and
  f64->scm.

* module/language/cps/slot-allocation.scm (compute-var-representations):
  Add cases for primops returning raw values.

* module/language/cps/types.scm (bv-f32-ref, bv-f32-set!)
  (bv-f64-ref, bv-f64-set!): Deal in &f64 values instead of reals.
2015-11-11 10:20:12 +01:00
Andy Wingo
2f08838cd6 Replace return primcalls with $values
* module/language/cps/compile-bytecode.scm:
* module/language/cps/contification.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Never generate a return
  primcall.  Instead use $values.
2015-10-28 11:11:23 +00:00
Andy Wingo
f169be9fc8 Wire up `guild compile -O0 foo.scm'
* module/scripts/compile.scm (%options): Resurrect -O option and make it
  follow GCC, more or less.  The default is equivalent to -O2.

* module/language/cps/compile-bytecode.scm (lower-cps):
* module/language/cps/optimize.scm (optimize-higher-order-cps): Move
  split-rec to run unconditionally for now, as closure conversion fails
  without it.
  (define-optimizer): Only verify the result if we are debugging, to
  save time.
  (cps-default-optimization-options): New exported procedure.

* module/language/tree-il/optimize.scm
  (tree-il-default-optimization-options): New exported procedure.
2015-10-22 17:44:17 +00:00
Mark H Weaver
315adb6347 Fix typo in CPS conversion.
Fixes <http://bugs.gnu.org/21614>.
Reported by tantalum <sph@posteo.eu>.

* module/language/tree-il/compile-cps.scm (convert): Add missing 'cps'
  argument to the continuation passed to 'convert-arg'.
2015-10-06 10:09:12 -04:00
Andy Wingo
78fdc3e673 Remove unused (language tree-il inline) module.
* module/language/tree-il/inline.scm: Remove.
* module/Makefile.am (TREE_IL_LANG_SOURCES): Remove inline.scm.
2015-09-17 12:45:36 +02:00
Andy Wingo
aa7f0e25ac Rename CPS2 to CPS 2015-07-22 17:19:04 +02:00
Andy Wingo
bac96c10f5 Factor with-cps out to separate module
* module/language/cps2/with-cps.scm: New file.
* module/language/tree-il/compile-cps2.scm: Use (language cps2 with-cps).
* module/Makefile.am: Add language/cps2/with-cps.scm.

* .dir-locals.el: Add indentation rules for with-cps.
2015-06-02 11:06:37 +02:00
Andy Wingo
23379467ae Add intmap-replace!.
* module/language/cps/intmap.scm (intmap-replace!): New interface.

* module/language/cps2/dce.scm (elide-type-checks):
* module/language/cps2/simplify.scm (transform-conts):
* module/language/cps2/utils.scm (intmap-map):
* module/language/tree-il/compile-cps2.scm (cps-convert/thunk): Use intmap-replace!.
2015-06-02 10:05:09 +02:00
Andy Wingo
2b06e90ca4 Intmaps do not treat #f specially as a value
* module/language/cps/intmap.scm: Intmaps can now contain any value;
  #f does not indicate the absence of a value.  Instead we use a unique
  private sentinel to mark absent values or branches.
  (*absent*, absent?, present?): New helpers.
  (new-branch): Initialize empty elements to *absent*.
  (clone-branch-with-edit): New helper.
  (clone-branch-and-set): Use clone-branch-with-edit.
  (writable-branch): Use clone-branch-with-edit
  (empty-intmap): Initialize value to *absent*.
  (add-level): clone-branch-and-set doesn't take #f as a branch any
  more; use new-branch.
  (branch-empty?, make-intmap/prune, intmap-add!):
  (intmap-add, intmap-remove, intmap-next, intmap-prev):
  (intmap-fold, intmap-union, intmap-intersect): Use absent? to detect
  absent branches / values.
  (intmap-ref): Likewise.  Instead of returning #f if the value is not
  found, call the optional not-found procedure.  By default this will
  signal an error.

* module/language/cps/types.scm:
* module/language/cps2/renumber.scm:
* module/language/cps2/simplify.scm: Adapt to intmap-ref signalling an
  error by default if the value is not found.

* module/language/tree-il/compile-cps2.scm: Adapt to intmap-add
  signalling an error if #f was in the intmap as a value.
2015-05-20 19:18:45 +02:00
Andy Wingo
4632f3d998 Fix bug compiling fixpoint combinator
* module/language/tree-il/peval.scm (<operand>): Rename "alias-value"
  field to "alias", which is now an operand and not an expression.
  This allows the operand to capture its environment; before, the
  alias was being visited in its use environment instead of its
  definition environment.
  (peval): Adapt to operand change.  Fix construction of rest bindings
  as well.
* test-suite/tests/peval.test ("partial evaluation"): New test.
2015-05-20 19:18:45 +02:00
Andy Wingo
fa7df5ed3a Fix sub/- primcall bug
* module/language/tree-il/compile-cps2.scm (convert): Fix bug
  in (apply - ...), because the instruction for "-" is "sub", and
  "sub" lookup was failing.  Caught by numbers.test.  Really I would
  like to get rid of $prim, somehow.
2015-05-20 19:18:45 +02:00
Andy Wingo
b31af02faf Consolidate CPS2 above CPS in the compiler
This is an intermediate step.  We'll replace CPS bit by bit.  If it
turns out to be a terrible idea we can just revert.

* module/Makefile.am (TREE_IL_LANG_SOURCES): Remove compile-cps.scm.
  (CPS_LANG_SOURCES): Remove arities.scm.

* module/language/cps/arities.scm: Remove.
* module/language/tree-il/compile-cps.scm: Remove.

* module/language/tree-il/spec.scm: Remove use of compile-cps.scm.

* module/language/cps/compile-bytecode.scm: Remove use of arities.scm.
  Instead, incoming terms are expected to call their continuations
  with the correct number of arguments.
2015-05-11 22:43:25 +02:00
Andy Wingo
9833c545cc Adapt return arities in Tree-IL -> CPS2 conversion
* module/language/tree-il/compile-cps2.scm (adapt-arity): New
  procedure.  This is equivalent to (language cps arities), but as it
  is a necessary pass and not an optimization it's more proper to put
  it in the converter itself.  Unlike with the nested CPS
  representation, it's possible to look up continuations without
  making a DFG.
  (convert): Adapt arities as necessary.
2015-05-11 22:43:20 +02:00
Andy Wingo
3ab3cdecda Build CPS2 with transient intmaps
* module/language/tree-il/compile-cps2.scm (with-cps)
  (cps-convert/thunk): Use transient intmaps.
2015-05-11 22:43:19 +02:00
Andy Wingo
5928d16a8e Tree-IL -> CPS2 -> CPS
* module/language/tree-il/spec.scm (tree-il): Compile to CPS2 instead of CPS.
2015-05-09 16:52:09 +02:00
Andy Wingo
d99fedc5fd Fix convert-cps2 for "not" primcalls
* module/language/tree-il/compile-cps2.scm (convert): Fix typo in "not"
  compilation.
2015-05-08 15:44:50 +02:00
Andy Wingo
09869e781b Register up cps2 compiler with language tower
* module/language/tree-il/compile-cps2.scm (compile-cps2): Rename from compile-cps.
* module/language/cps2/spec.scm: New file.
* module/Makefile.am (CPS2_LANG_SOURCES): Add spec.scm.
* module/language/tree-il/spec.scm (tree-il): Declare compiler to cps2.
2015-05-08 13:35:08 +02:00
Andy Wingo
773595f0db Add compiler from tree-il to cps2
* module/language/tree-il/compile-cps2.scm: New file.
* module/Makefile.am: Add the file to the build.
2015-05-08 11:46:46 +02:00
Andy Wingo
50fcdfece3 Remove "free" field of $fun
* module/language/cps.scm ($fun): Remove unused "free" field.
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt all callers.
2015-04-01 10:10:10 +02:00
Andy Wingo
34ff3af9f0 Replace $letrec with $rec
* module/language/cps.scm ($rec): Replace $letrec with $rec, which is an
  expression, not a term.  This means that the names bound by the letrec
  appear twice: once in the $rec term, and once in the continuation.
  This is not very elegant, but the situation is better than it was
  before.  Adapt all callers.

* doc/ref/compiler.texi (CPS in Guile): Incomplete documentation
  updates.  I'll update these later when the IL settles down.
2015-04-01 10:10:10 +02:00
Andy Wingo
a9ec16f9c5 Remove $void CPS expression type
* module/language/cps.scm: Remove the $void expression type, replaced by
  $const of the unspecified value.
* 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/reify-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/specialize-primcalls.scm:
* module/language/cps/types.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Update callers.
2015-03-11 21:51:33 +01: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
Mark H Weaver
856d318a9f Merge branch 'stable-2.0'
Conflicts:
	benchmark-suite/benchmarks/ports.bm
	libguile/async.h
	libguile/bytevectors.c
	libguile/foreign.c
	libguile/gsubr.c
	libguile/srfi-1.c
	libguile/vm-engine.h
	libguile/vm-i-scheme.c
	module/Makefile.am
	module/language/tree-il/analyze.scm
	module/language/tree-il/peval.scm
	module/scripts/compile.scm
	module/scripts/disassemble.scm
	test-suite/tests/asm-to-bytecode.test
	test-suite/tests/peval.test
	test-suite/tests/rdelim.test
2014-09-30 03:50:47 -04:00
Mark H Weaver
7a71a45cfd peval: Handle optional argument inits that refer to previous arguments.
Fixes <http://bugs.gnu.org/17634>.
Reported by Josep Portella Florit <jpf@primfilat.com>.

* module/language/tree-il/peval.scm (inlined-application): When inlining
  an application whose operator is a lambda expression with optional
  arguments that rely on default initializers, expand into a series of
  nested let expressions, to ensure that previous arguments are in scope
  when the default initializers are evaluated.

* test-suite/tests/peval.test ("partial evaluation"): Add tests.
2014-09-28 23:51:20 -04:00
Ludovic Courtès
8ac39b38d1 Handle ~p in 'format' warnings.
Fixes <http://bugs.gnu.org/18299>.
Reported by Frank Terbeck <ft@bewatermyfriend.org>.

* module/language/tree-il/analyze.scm (format-string-argument-count):
  Add case for ~p.
* test-suite/tests/tree-il.test ("warnings")["format"]("~p", "~p, too
  few arguments", "~:p", "~:@p, too many arguments", "~:@p, too few
  arguments"): New tests.
2014-08-26 23:41:33 +02:00
Andy Wingo
ae67b159bb CPS will not see "not" primcalls
* module/language/tree-il/compile-cps.scm (convert): Remove "not"
  primcalls.

* module/language/cps/effects-analysis.scm (values):
* module/language/cps/types.scm: Remove special cases for the "not"
  primcall.
2014-07-22 12:18:07 +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
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
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
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
a0329d0109 Root higher-order CPS term is always $kfun $cont
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/tree-il/compile-cps.scm: Adapt to produce and consume
  raw $kfun $cont instances.

* .dir-locals.el: Update $letrec indentation.
2014-04-11 14:01:27 +02:00
Andy Wingo
8320f50431 Rename $kentry to $kfun
* module/language/cps.scm ($kfun): Rename from $kentry.

* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.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/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/reify-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/specialize-primcalls.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt users.
2014-04-10 12:11:35 +02:00
Andy Wingo
24b611e81c src and meta are fields of $kentry, not $fun
* module/language/cps.scm ($kentry, $fun): Attach "src" and "meta" on
  the $kentry, not the $fun.  This prepares us for $callk to $kentry
  continuations that have no corresponding $fun.

* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/reify-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/specialize-primcalls.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt.
2014-04-10 10:50:17 +02:00
Andy Wingo
85270a8c89 Remove old Tree-IL CSE pass
* module/language/tree-il/cse.scm: Delete.

* module/language/tree-il/optimize.scm: Remove use of Tree-IL CSE.

* module/Makefile.am: Remove language/tree-il/cse.scm.

* module/language/cps/compile-bytecode.scm: Rename CSE keyword to
  #:cse?.
2014-04-06 11:12:29 +02:00
Andy Wingo
84d3ce20cd Disable Tree-IL CSE
* module/language/tree-il/optimize.scm (optimize): Disable Tree-IL CSE
  by default.
2014-04-05 11:40:21 +02:00
Andy Wingo
54c7882a75 Minor CSE optimization
* module/language/tree-il/cse.scm (cse): Use hashq instead of modulo to
  convert a full-width hash value to a vector index.
2014-04-03 09:40:18 +02:00
Andy Wingo
48e65b4468 Refactor toplevel scope name generation in compile-cps
* module/language/tree-il/compile-cps.scm (scope-counter, fresh-scope-id):
  (toplevel-box, capture-toplevel-scope, convert, cps-convert/thunk):
  Refactor to avoid abusing the var counter to generate scope
  identifiers.
2014-04-02 15:58:06 +02:00
Andy Wingo
90dce16db4 Use Tree-IL-like case-lambda clause chaining in CPS
* module/language/cps.scm ($kclause, $kentry): Instead of having an
  entry continuation contain a list of clauses, have the clauses contain
  clauses (as in Tree-IL).  In some ways it's not as convenient but it
  does reflect the continuation tree correctly.

* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/renumber.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt aaaaaaall users.
2014-03-31 18:54:12 +02:00
Andy Wingo
e6cf744ab4 CPS conversion renames incoming gensyms to small integers
* module/language/tree-il/compile-cps.scm (fold-formals)
  (unbound?, init-default-value, convert): Arrange to rename incoming
  gensyms as small integers.
  (canonicalize): Convert vector and abort here too.
2014-03-31 18:20:55 +02:00
Andy Wingo
ef58442a05 Prompt-related refactor in compile-cps
* module/language/tree-il/compile-cps.scm (fix-prompts): New procedure.
  Eta-expand prompts before compiling to ensure that they have inline
  handlers.
2014-03-31 18:20:55 +02:00