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
Ludovic Courtès
a1793bc904
Revert "Honor '%fresh-auto-compile'."
...
This reverts commit 83d4c4d622
,
which came from a misunderstanding.
2018-01-15 23:17:24 +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
Ludovic Courtès
d01e0b084e
No tabs in C code.
...
* .dir-locals.el (c-mode): Set 'indent-tabs-mode' to nil in C.
2018-01-11 15:25:17 +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
Ludovic Courtès
cc8f41e7d8
Make sure the return value of 'scm_crypt' is always initialized.
...
* libguile/posix.c (scm_crypt): Always initialize 'ret'; error out even
when ERR is zero.
2018-01-10 16:19:09 +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
97301efca4
Remove obsolete rtl tests
...
* test-suite/tests/rtl.test (accum, cached-toplevel-ref)
(cached-toplevel-set!, cached-module-ref, cached-module-set!): Remove
tests that use box instructions. These tests have done their time and
now aren't of much value.
2018-01-10 07:59:21 +01:00
Andy Wingo
e2a06249ef
Save VM compare result before calling out to hooks
...
* libguile/vm.c (vm_dispatch_hook): Save the compare result before
calling out to the hook. This only really matters for the "next"
hook, which can be called between a compare and its corresponding
branch instruction.
2018-01-08 15:19:55 +01:00
Andy Wingo
b294a1e7d7
Sync IP before allocating closures
...
* libguile/vm-engine.c (vm_engine): Sync IP before allocating closures.
2018-01-08 15:19:45 +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
798f633624
Remove pair-related instructions
...
* libguile/vm-engine.c (VM_VALIDATE_PAIR, VM_VALIDATE_MUTABLE_PAIR):
Remove these now-unused definitions.
(VM_VALIDATE_VECTOR, VM_VALIDATE_MUTABLE_VECTOR): Likewise.
(cons, car, cdr, set-car!, set-cdr!): Remove instructions.
* libguile/vm.c (vm_error_not_a_pair, vm_error_not_a_mutable_pair):
Remove unused error cases.
2018-01-07 18:44:53 +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
94f8f70b22
Remove now-unused make-vector et al instructions
...
* libguile/vm-engine.c (make-vector, make-vector/immediate)
(vector-ref, vector-ref/immediate, vector-set!)
(vector-set!/immediate): Remove these now-unused instructions.
* libguile/vm.c (vm_error_not_a_vector, vm_error_not_a_mutable_vector):
Remove.
2018-01-07 16:34:13 +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
fa4cb2182d
Add resolve-primitives pass back to bootstrap
...
* bootstrap/Makefile.am (GUILE_OPTIMIZATIONS): Blah, add
-Oresolve-primitives.
2018-01-05 17:47:46 +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