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

3801 commits

Author SHA1 Message Date
Andy Wingo
b09bbfe3c0 Remove free-ref, free-set!
* libguile/vm-engine.c (free-ref, free-set!): Remove ops.
* module/language/cps/effects-analysis.scm:
* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm (code-annotation):
* module/language/cps/compile-bytecode.scm (compile-function): Remove
  support for free-ref / free-set!.
2018-01-22 07:51:36 +01:00
Andy Wingo
dd203e5d7d Remove optimizer and backend support for struct ops
* module/language/cps/compile-bytecode.scm:
* module/language/cps/cse.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/types.scm:
* module/language/tree-il/cps-primitives.scm:
* module/system/vm/assembler.scm: Remove support for struct-ref,
  struct-set!, allocate-struct, struct-vtable CPS primcalls and bytecode
  instructions.
2018-01-22 07:51:08 +01:00
Andy Wingo
91bf9b1db3 Lower "make-struct/simple" to CPS
* module/language/tree-il/cps-primitives.scm (struct-init!): Add
  primitive, just used in internal translations.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*primitive-constructors*): Recognize "make-struct/simple" instead of
  allocate-struct.
* module/language/tree-il/compile-cps.scm (ensure-vtable): New helper.
  (allocate-struct, struct-init!): New lowerers.
  (convert): Add struct-init! case.
  (canonicalize): Convert make-struct/simple like vector.
2018-01-22 07:28:11 +01:00
Andy Wingo
5084fa4858 Introduce make-struct/simple
* libguile/struct.h:
* libguile/struct.c (scm_make_struct_simple): New function.
* module/ice-9/boot-9.scm (make-record-type): Recast in terms of
  make-struct/simple.
* module/ice-9/eval.scm (primitive-eval): Remove allocate-struct case.
* module/srfi/srfi-9.scm (%%set-fields, %define-record-type): Use
  make-struct/simple.
2018-01-21 21:03:35 +01:00
Andy Wingo
557acdbbba Instruction explosion for struct-ref, struct-set!
* module/language/cps/effects-analysis.scm (&memory-kind-mask): Add
  &bitmask, for the bitmask in vtables.
  (annotation->memory-kind): Add 'bitmask case.
* module/language/tree-il/compile-cps.scm (ensure-struct-index-in-range):
  (prepare-struct-scm-access): New helpers.
  (struct-ref/immediate, struct-set!/immediate): New exploded lowering
  routines.
  (struct-ref, struct-set!): New lowering routines that just do a call.
  (canonicalize): Remove struct-ref hack; lowering procedures will
  handle it.
* module/language/tree-il/cps-primitives.scm (bytevector-length): Define
  struct-set! as returning a value.
2018-01-19 21:57:03 +01:00
Andy Wingo
8573d94404 Remove optimizer and backend support for bv-u8-ref et al
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm:
* module/language/cps/slot-allocation.scm (compute-var-representations):
* module/language/cps/types.scm:
* module/system/vm/assembler.scm: Remove optimizer and backend support
  for bv- ops.
2018-01-16 16:43:25 +01:00
Andy Wingo
42837e9108 Instruction explosion for bv-length
* module/language/tree-il/compile-cps.scm (ensure-vector):
  (prepare-bytevector-access): Add assumptions on lengths.
  (bv-length): New lowerer.
2018-01-16 16:43:10 +01:00
Andy Wingo
4829cb3ce9 Add assume-u64 and assume-s64 dataflow restrictions
* 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/types.scm (assume-u64, assume-s64): Add primitives
  that assume the range of a u64 or s64 value is within certain bounds.
  This is useful when extracting e.g. a length from a 64-bit word when
  you know the length is less than 2**48.
2018-01-16 16:42:56 +01:00
Andy Wingo
94fdc5cad9 Instruction explosion for bytevector setters
* module/language/cps/compile-bytecode.scm (compile-function): Fix
  emitters for u64-set! et al.
* module/language/tree-il/compile-cps.scm (bytevector-set-converter):
  New helper.  Lower bytevector setters to pointer ops.
2018-01-16 10:05:03 +01:00
Andy Wingo
1b955b01c3 Add f32-ref, f64-ref lowering procs
* module/language/tree-il/compile-cps.scm (bytevector-ref-converter):
  Take kind as tag, not boolean.  Support floats.  Adapt and add
  lowerers for float-ref procedures.
2018-01-15 20:51:00 +01:00
Andy Wingo
0270d235bd Instruction explosion for integer bytevector ref procedures
* module/language/cps/compile-bytecode.scm (compile-function): Fix
  emitters for u16-ref et al.
* module/language/tree-il/compile-cps.scm (bytevector-ref-converter):
  (define-bytevector-ref-converter, define-bytevector-ref-converters):
  New helpers.  Use to define lowerers for bv-s32-ref et al.
2018-01-15 20:25:53 +01:00
Andy Wingo
535d6fad80 Custom bv-u8-ref lowering procedure
* module/language/tree-il/compile-cps.scm (untag-bytevector-index):
  (ensure-bytevector, prepare-bytevector-access): New helpers.
  (bv-u8-ref): New lowerer.
* module/language/cps/types.scm (annotation->type):
* module/language/cps/effects-analysis.scm (annotation->memory-kind):
  Support bytevectors.
2018-01-14 14:38:35 +01:00
Andy Wingo
73f55cb9ae Rename gc-pointer-ref to pointer-ref
The pointer dereferencing instructions will keep the pointer alive by
referencing a containing object.

* module/language/cps/compile-bytecode.scm:
* libguile/vm-engine.c:
* module/language/cps/cse.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/types.scm:
* module/system/vm/assembler.scm:
* module/system/vm/debug.scm: Rename instructions.
2018-01-14 13:40:05 +01:00
Andy Wingo
13cafca168 Add raw u8-ref, etc instructions
* libguile/vm-engine.c (PTR_REF, PTR_SET): New helper macros.
  (u8-ref, u16-ref, u32-ref, u64-ref, s8-ref, s16-ref, s32-ref, s64-ref)
  (u8-set!, u16-set!, u32-set!, u64-set!, s8-set!, s16-set!, s32-set!, s64-set!)
  (f32-ref, f64-ref, f32-set!, f64-set!): New instructions.
* module/system/vm/assembler.scm:
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/slot-allocation.scm (compute-var-representations):
* module/language/cps/types.scm: Add optimizer and backend support for
  the new instructions.
2018-01-14 12:59:02 +01:00
Andy Wingo
d355b42a3e Add optimizer and backend support for gc-pointer-ref
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/cse.scm (compute-equivalent-subexpressions):
* 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 (gc-pointer-ref/immediate):
  (gc-pointer-set!/immediate):
* module/system/vm/assembler.scm: Add support for pointer-ref.
2018-01-10 21:58:24 +01:00
Andy Wingo
9222e4df4b Add support for raw gc-managed pointer locals
* libguile/vm-engine.c (gc-pointer-ref/immediate)
  (gc-pointer-set!/immediate): New instructions.
  (SP_REF_PTR, SP_SET_PTR): New helper definitions.
* libguile/vm.c (SLOT_DESC_LIVE_GC): Rename from SLOT_DESC_LIVE_SCM, as
  it can indicate GC-protected raw pointers also.
  (scm_i_vm_mark_stack): Adapt.
* module/system/vm/assembler.scm (write-arities):
* module/system/vm/debug.scm (arity-definitions): Add gcptr
  representation.  This is a binary-incompatible change!
2018-01-10 21:05:16 +01:00
Andy Wingo
c7b3379a4c Instruction explosion for struct-vtable
* module/language/tree-il/compile-cps.scm (ensure-struct): New helper.xo
  (struct-vtable): New lowering procedure.
* module/language/cps/types.scm (annotation->type): Add struct.
  (scm-ref/tag, scm-set!/tag): Fix to get type from annotation.
* module/language/cps/effects-analysis.scm (annotation->memory-kind):
  Add struct.
2018-01-10 19:47:58 +01:00
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