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

3884 commits

Author SHA1 Message Date
Andy Wingo
02e52a4118 Remove box instructions
* libguile/vm-engine.c (box, box-ref, box-set!): Remove these
  instructions.
* module/system/vm/assembler.scm: Remove assemblers for box-ref et al.
* libguile/vm.c (vm_error_not_a_variable): Remove unused function.
2018-01-10 07:59:21 +01:00
Andy Wingo
24f998e4d2 Lower box, box-ref, box-set! primcalls
* module/language/tree-il/compile-cps.scm (box, ensure-box):
  (box-ref, box-set!): Lower box primcalls.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/cse.scm (compute-equivalent-subexpressions):
* module/language/cps/dce.scm (compute-live-code):
* module/language/cps/effects-analysis.scm:
* module/language/cps/types.scm: Remove special support for boxes.  What
  a pleasure!
2018-01-10 07:59:21 +01:00
Andy Wingo
55a8483435 Improve make-vector compilation for known big sizes
* module/language/tree-il/compile-cps.scm
  (emit-initializations-as-loop): New helper.
  (make-vector): Use new helper.
  (make-vector/immediate): Emit a loop if the number of words is greater
  than or equal to 32.  An arbitrary limit that could be adjusted later.
2018-01-07 23:07:12 +01:00
Andy Wingo
5e1109a97f Better compilation of vector constructors and initializers
* module/language/tree-il/cps-primitives.scm (allocate-vector)
  (vector-init!): Declare these primitives which later go away when
  lowering to CPS.
* module/language/tree-il/compile-cps.scm (vector-init!): New
  converter.
  (allocate-vector): New converter.
2018-01-07 22:51:17 +01:00
Andy Wingo
abfe04835b Remove special optimizer and backend support for pairs
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/cse.scm (compute-equivalent-subexpressions):
* module/language/cps/dce.scm (compute-live-code):
* module/language/cps/effects-analysis.scm:
* module/language/cps/types.scm: Remove support for cons, car, etc
  primcalls.
* module/language/cps/effects-analysis.scm (&car, &cdr): Remove
  undefined exports.
* module/system/vm/assembler.scm: Remove emit-cons, etc exports.
2018-01-07 18:44:53 +01:00
Andy Wingo
49fa4980bb Expand pair-related primcalls
* module/language/tree-il/compile-cps.scm (ensure-pair): New helper.
  (cons, car, cdr, set-car!, set-cdr!): New expanders.
* module/language/cps/closure-conversion.scm (convert-one):
* module/language/cps/contification.scm (apply-contification): Emit
  lower-level instructions for making pairs.
2018-01-07 18:44:48 +01:00
Andy Wingo
9a1d2d8ec8 Minor compile-cps refactor for cons
* module/language/tree-il/compile-cps.scm (build-list): Pass cons
  through an expander.
2018-01-07 17:57:45 +01:00
Andy Wingo
ee84af1311 Compiler frontend support for vector mutability checks
* module/language/tree-il/compile-cps.scm (ensure-vector):
  (prepare-vector-access, prepare-vector-access/immediate):
  (vector-length, vector-ref, vector-ref/immediate):
  (vector-set!, vector-set!/immediate): Use mutable-vector? predicate
  for write access.
2018-01-07 17:38:40 +01:00
Andy Wingo
8ed5d9f237 Re-add compiler backend support for immutable vectors
* module/language/cps/compile-bytecode.scm (compile-function): Add cases
  for mutable-vector? and immutable-vector?.
* module/system/vm/assembler.scm: Export emit-mutable-vector? and
  emit-immutable-vector?.
2018-01-07 17:37:16 +01:00
Andy Wingo
9b3c4612bd CPS type analysis support for mutable vs immutable vectors
* module/language/cps/types.scm (&mutable-vector, &vector): Separate
  type bits.
  (&vector): New union type.
  (constant-type): Constant vectors are immutable.
* module/language/cps/type-fold.scm (mutable-vector?)
  (immutable-vector?): New folders.
  (vector?): Add union folder.
2018-01-07 17:37:06 +01:00
Andy Wingo
8009359f6e Fix bug in struct-ref effects analysis
* module/language/cps/effects-analysis.scm (struct-ref): Fix bug in
  struct-ref effects analysis.
2018-01-07 17:15:42 +01:00
Andy Wingo
3cedc108d8 Add CPS compilation support for mutable-vector?
* module/system/base/types/internal.scm (heap-tags): Add
  immutable-vector? and mutable-vector?.
* module/language/tree-il/cps-primitives.scm:
* module/system/vm/disassembler.scm: Bump copyright lines.
2018-01-07 16:41:40 +01:00
Andy Wingo
5dde0e48e7 Remove "ash" instruction.
* libguile/vm-engine.c (ash): Remove instruction, which hasn't been
  emitted for a long time.
* module/system/vm/assembler.scm (emit-ash): Remove export.
2018-01-07 16:25:09 +01:00
Andy Wingo
6e100c9ba6 CPS pass now expects exploded vector primitives
* module/language/cps/closure-conversion.scm (convert-one): Reify
  make-vector inline, without field initialization.
* module/language/cps/cse.scm (compute-equivalent-subexpressions):
* module/language/cps/dce.scm (compute-live-code):
* module/language/cps/effects-analysis.scm:
* module/language/cps/reify-primitives.scm (reify-primitives):
* module/language/cps/slot-allocation.scm (compute-var-representations):
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
* module/language/cps/types.scm:
* module/language/cps/compile-bytecode.scm (compile-function): Remove
  cases for make-vector, vector-ref, etc.
* module/system/vm/assembler.scm: Remove make-vector, vector-ref etc
  exports.
2018-01-07 16:14:09 +01:00
Andy Wingo
06cf66d6cc Mark word-ref and word-ref/immediate as producing U64 values
* module/language/cps/slot-allocation.scm (compute-var-representations):
  Mark word-ref and word-ref/immediate as producing U64 values.
2018-01-07 15:53:59 +01:00
Andy Wingo
f488bc53e7 Instruction explosion for /immediate variants of vector prims
* module/language/tree-il/compile-cps.scm
  (prepare-vector-access/immediate): New helper.
* module/language/tree-il/compile-cps.scm (vector-ref/immediate):
  (vector-set!/immediate, make-vector/immediate): New expanders.
2018-01-07 15:42:39 +01:00
Andy Wingo
c766a883d3 Instruction explosion for make-vector
* module/language/tree-il/compile-cps.scm (untag-fixnum-in-imm-range):
  New helper.
  (make-vector): New custom expander.  Gnarly; to refactor.
2018-01-07 15:42:39 +01:00
Andy Wingo
7ef48c4069 Fix primitive reification for scm-set! / word-set!.
* module/language/cps/reify-primitives.scm (reify-primitives): Fix for
  scm-set! and word-set!.
2018-01-07 15:42:39 +01:00
Andy Wingo
1bb44a1ad6 Minor optimization in loop peeling
* module/language/cps/peel-loops.scm (compute-out-vars): Fold over the
  body of the loop, not the body of the function.  A small
  optimization.
2018-01-07 13:04:20 +01:00
Andy Wingo
ef23e512b5 Make integer devirtualization less eager
* module/language/cps/devirtualize-integers.scm (bailout?): Factor out.
  (peel-trace): Adapt to call external bailout? predicate.
  (peel-traces-in-function): Don't peel traces whose alternate is a
  bailout.
2018-01-07 13:04:20 +01:00
Andy Wingo
d4addf3792 Bug-fix to devirtualize-integers pass
* module/language/cps/devirtualize-integers.scm (peel-trace): Only
  terminate a trace at a branch if the set of live vars is empty.
2018-01-07 13:04:20 +01:00
Andy Wingo
7162c758b3 Fix specialization of the allocate-words family of instructions
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
  Fix specialization of allocate-words and friends.
2018-01-05 19:51:17 +01:00
Andy Wingo
d4502dba07 Fix verify.scm for call-thunk/no-inline
* module/language/cps/verify.scm (check-arities): Allow
  call-thunk/no-inline to continue to $kreceive.
2018-01-05 19:50:12 +01:00
Andy Wingo
7486806ba3 Improve compilation of make-vector without init
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Add
  expansion for one-argument make-vector.
2018-01-05 15:18:16 +01:00
Andy Wingo
a821042480 Allow peval to gnaw on string->symbol, symbol->string
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*effect-free-primitives*): Add string->symbol and symbol->string.
2018-01-05 15:17:46 +01:00
Andy Wingo
6fdbd3b17b Instruction explosion for vector-{length,ref,set!}
* module/language/tree-il/compile-cps.scm (ensure-vector)
  (untag-fixnum-index-in-range, compute-vector-access-pos)
  (prepare-vector-access): New helpers.
  (vector-length, vector-ref, vector-set!): New expanders.
2018-01-05 14:42:40 +01:00
Andy Wingo
3e271f1922 Allow peeling loops with bailouts
* module/language/cps/peel-loops.scm (compute-bailouts)
  (add-renamed-bailout, peel-loop, peel-loops-in-function): Allow
  peeling of loops with bailouts.
2018-01-05 14:23:29 +01:00
Andy Wingo
e4e02d8489 Prevent LICM of memory accesses guarded by effect-free predicates
* module/language/cps/licm.scm (loop-invariant?): Read or write effects
  can be guarded by effect-free branches; prevent hoisting of these
  expressions if the term isn't always reachable.
2018-01-05 11:48:06 +01:00
Andy Wingo
51fd5952cb Disable resolve-primitives pass below -O2
* module/language/tree-il/optimize.scm (optimize): Disable
  resolve-primitives below -O2.  This is because compile-cps is going to
  start expanding all primcalls it sees.
2018-01-05 10:40:03 +01:00
Andy Wingo
16db934bbc Add (system base optimize) module
* module/system/base/optimize.scm: New module.
* module/Makefile.am (SOURCES):
* am/bootstrap.am (SOURCES): Add new module.
* module/language/tree-il/optimize.scm (tree-il-optimizations): Rename
  from tree-il-default-optimization-options.  Directly specify the
  optimization level at which a pass should be enabled.
* module/language/cps/optimize.scm (cps-optimizations): Likewise, rename
  from cps-default-optimization-options.
* module/scripts/compile.scm (%options, show-optimization-help): Adapt
  to use new module.
2018-01-05 10:19:54 +01:00
Andy Wingo
118f516a8b $primcall always continues to $kargs
* module/language/cps/devirtualize-integers.scm (peel-trace): Update
  comment.
* module/language/cps/contification.scm (apply-contification): Update to
  never contify a return of $primcall to $kreceive.
* module/language/cps/verify.scm (check-arities): Require that primcalls
  continue to $kargs.
2018-01-03 21:26:00 +01:00
Andy Wingo
8248649966 Simplify prompt slot allocation now that bailouts can't continue
* module/language/cps/slot-allocation.scm (add-prompt-control-flow-edges):
  Simplify now that bailouts don't continue.
2018-01-03 21:26:00 +01:00
Andy Wingo
ad55ee83c3 $throw is a new kind of CPS term
* module/language/cps.scm ($throw): New term type that doesn't have a
  continuation.  Adapt all callers.  Remove now-unneeded
  "prune-bailouts" pass.
2018-01-03 21:25:55 +01:00
Andy Wingo
de5c81b1d1 Fix add-prompt-control-flow-edges for terms with no continuation
* module/language/cps/slot-allocation.scm (add-prompt-control-flow-edges):
  Allow for terms that don't continue, and add them to the minimal
  prompt control flow edges set.
2018-01-03 18:55:59 +01:00
Andy Wingo
ee15ca1455 $prompt is now its own kind of CPS term.
* module/language/cps.scm ($prompt): Rework to be its own term kind.
  Now $continue always continues to a single continuation.  Adapt
  callers.
2018-01-03 17:32:43 +01:00
Andy Wingo
29fee39c2a Variable renaming in type-fold.scm
* module/language/cps/type-fold.scm: Rename "name" variables that
  indicate primcalls to "op".
2018-01-03 16:32:33 +01:00
Andy Wingo
454f2eeb97 Fix sandbox
* module/ice-9/sandbox.scm (eval-in-sandbox): Remove use of
  deprecated-and-now-removed allow-legacy-syntax-objects? parameter.
2018-01-03 16:26:10 +01:00
Andy Wingo
afb0a92d50 $branch is now a distinct CPS term type
* module/language/cps.scm ($branch): Refactor to be its own CPS term
  type, not relying on $continue to specify a continuation (which before
  was only for the false case) or a source location.  Update allllllll
  callers.
2018-01-03 16:16:39 +01:00
Andy Wingo
108ade6b0e Re-add support for logbit?
* module/language/cps/type-fold.scm (logbit?): Adapt for logbit?
  continuing to $kargs.
* module/language/tree-il/cps-primitives.scm (logbit?): Declare this CPS
  primitive.
2017-12-27 15:46:31 +01:00
Andy Wingo
bc5a599cad Unknown primcalls convert as calls
* module/language/cps/reify-primitives.scm (reify-primitives): Remove
  case where $prim could continue to $kreceive; this isn't possible.
  However when reifying an unknown primcall, always add a $kreceive, as
  the continuation has to be $kargs.
* module/language/tree-il/compile-cps.scm (convert): Unknown primcalls
  convert as calls.  With this change, all primcalls should continue to
  $kargs, with the exception of 'throw.
2017-12-27 15:46:31 +01:00
Andy Wingo
0b4c1e2c29 Remove inline-constructors pass
* module/language/cps/constructors.scm: Remove pass, as "list" and
  "vector" are now inlined by CPS conversion, and nothing in the
  optimizer reifies "list" or "vector" primcalls.
* module/language/cps/optimize.scm (optimize-higher-order-cps)
  (cps-default-optimization-options):
* am/bootstrap.am:
* module/Makefile.am: Remove references to inline-constructors pass.
2017-12-27 15:46:31 +01:00
Andy Wingo
cf1611ef38 Contification also inlines "elide-values" pass
* module/language/cps/contification.scm (apply-contification): Inline
  returns to the corresponding $kargs.
* module/language/cps/licm.scm (loop-invariant?): Remove handling of
  "values" primcall, as this doesn't exist any more.
2017-12-27 15:46:31 +01:00
Andy Wingo
c9efff30de CPS conversion avoids residualizing unknown primcalls
* module/language/tree-il/compile-cps.scm: Avoid residualizing "apply"
  or "abort-to-prompt" primcalls; instead, these are just calls to
  $prim.
2017-12-27 15:46:31 +01:00
Andy Wingo
7f7cbe8b65 Inline "elide-values" optimization into CPS conversion
* module/language/tree-il/compile-cps.scm (adapt-arity, convert): Avoid
  reifying "values" primcalls unless necessary.  Effectively inlines the
  "elide-values" optimization into CPS conversion.
* module/language/cps/elide-values.scm: Remove, as it's now unneeded.
* module/language/cps/optimize.scm (optimize-higher-order-cps):
* module/Makefile.am:
* am/bootstrap.am: Remove elide-values references.
2017-12-27 15:46:31 +01:00
Andy Wingo
9111f8cdcd CPS conversion expands "list"
* module/language/tree-il/compile-cps.scm (build-list): New helper.
  (convert, canonicalize): Canonicalize "list" earlier.  Allow sinking
  of any initializer that can't capture the continuation, not just in
  cases where all initializers have this property.  Reify a cons chain
  internally as appropriate.
2017-12-27 15:46:31 +01:00
Andy Wingo
36e6a3daca Refactor lowering of Tree-IL primcalls to CPS
* module/language/tree-il/cps-primitives.scm: New file,
  replacing (language cps primitives).  Lists known primitives and their
  relation to Tree-IL explicitly, instead of assuming that any Tree-IL
  primcall that shares a name with a bytecode instruction is a CPS
  primcall.
* module/language/cps/verify.scm: Remove use of (language cps
  primitives) and primcall arity checking.  Would be nice to add this
  back at some point.
* module/language/tree-il/compile-cps.scm (convert): Refactor to use new
  tree-il-primitive->cps-primitive+nargs+nvalues helper.
* module/Makefile.am:
* am/bootstrap.am: Adapt.
2017-12-27 15:46:31 +01:00
Andy Wingo
549ad3ce8c Flesh out compile-bytecode for all heap objects
* module/language/cps/compile-bytecode.scm (compile-function): Organize
  emitters and flesh out with more heap type tag predicates.  Remove
  now-needless (language cps primitives) import.
2017-12-27 15:46:31 +01:00
Andy Wingo
140b69dfc6 Refactor list->seq to make return arity apparent
* module/language/tree-il.scm (list->seq): Change to let tail of seq
  indicate number of values.
2017-12-27 15:46:31 +01:00
Andy Wingo
7dbc571db1 Refactor reify-primitives pass
* module/language/cps/reify-primitives.scm (*ephemeral-reifiers*)
  (define-ephemeral, define-binary-signed-ephemeral)
  (define-binary-signed-ephemeral/imm, compute-known-primitives):
  (*known-primitives*, known-primitive?): New definitions.
  (reify-primitives): Extract reification of "ephemeral primitives".
2017-12-27 15:46:31 +01:00
Andy Wingo
b918784412 Remove compile-bytecode cases for ephemeral primitives
* module/language/cps/compile-bytecode.scm (compile-function): Remove
  cases for tag-fixnum/unlikely, etc.
2017-12-27 15:46:31 +01:00