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

4114 commits

Author SHA1 Message Date
Andy Wingo
8ce6f359bb ursh, ursh/immediate, etc only residualized if count < 64
* module/language/cps/reify-primitives.scm (reify-primitives): Remove
  cases for ursh/immediate etc, as these should all be within range, by
  construction.
* module/language/cps/specialize-numbers.scm (specialize-operations):
  Only reify ursh/immediate, etc if the shift count is less than 64.
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
  Remove specialization cases for ursh/immediate etc; this is the domain
  of specialize-numbers.
* module/language/cps/types.scm (ursh, srsh, ulsh): Limit arguments to
  be less than 63.
  (ulsh/immediate): Assume parameter is in range.
2017-11-15 19:57:36 +01:00
Andy Wingo
0951551fb4 Compiler specializes comparisons to immediate integers
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm (load-const/unlikely):
* module/language/cps/types.scm (load-const/unlikely):
* module/language/cps/primitives.scm (*macro-instruction-arities*): Add
  new primcall, load-const/unlikely.
* module/language/cps/specialize-numbers.scm: Rework comparison
  specialization.  Add support for specializing comparisons against
  integer immediates.
2017-11-15 14:19:09 +01:00
Andy Wingo
294dbaad35 Add support for comparisons against integer immediates
* libguile/vm-engine.c (s64-imm=?, u64-imm<?, imm-u64<?, s64-imm<?)
  (imm-s64<?): New instructions.
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Add new
  X8_S12_Z12 word type used by the new S64/immediate instructions.  A
  Z12 is a 12-bit signed integer immediate.
* module/system/vm/assembler.scm: Export new instructions, and add
  X8_S12_Z12 support.  Also, add missing shufflers for X8_S12_C12.
* module/language/bytecode.scm (compute-instruction-arity):
* module/system/vm/disassembler.scm (unpack-s12, disassembler): Add
  support for X8_S12_Z12.
* module/language/cps/types.scm (define-predicate-inferrer/param): New
  helper.
  (u64-=, u64-<, s64-<): Remove type checkers; this procedure does not
  cause &type-check.
  (u64-imm=?, s64-imm=?, u64-imm<?, imm-u64<?, s64-imm<?, imm-s64<?):
  New type inferrers.
* module/language/cps/type-fold.scm (define-unary-branch-folder*): New
  helper.
  (u64-imm=?, s64-imm=?, u64-imm<?, imm-u64<?, s64-imm<?, imm-s64<?):
  New branch folders.
* module/language/cps/reify-primitives.scm (reify-primitives): Reify
  constants for new immediate branching primcalls if values out of
  range.
* module/language/cps/effects-analysis.scm: Add support for new
  primcalls.
* module/language/cps/compile-bytecode.scm (compile-function): Add
  support for new primcalls and instructions.  Compile u64-imm-= to
  s64-imm=?.
2017-11-15 14:18:39 +01:00
Andy Wingo
4a0a930f1c Don't fold comparisons that might contain a NaN.
* module/language/cps/type-fold.scm (compare-integer-ranges): Rename
  from compare-ranges, as we can't compare ranges that might include a
  NaN.
  (<, =): Update uses.
2017-11-14 10:40:02 +01:00
Andy Wingo
7e79a3291e Better untagging of fixnums
* module/language/cps/compile-bytecode.scm (compile-function): Add
  support for tag-fixnum/unlikely.
* module/language/cps/cse.scm (compute-equivalent-subexpressions): Add
  equivalent subexpressions for tag-fixnum.
* module/language/cps/effects-analysis.scm:
* module/language/cps/primitives.scm (*macro-instruction-arities*): Add
  tag-fixnum/unlikely.
* module/language/cps/specialize-numbers.scm (specialize-u64-unop)
  (specialize-u64-binop, specialize-u64-shift)
  (specialize-u64-comparison): Make the arg unboxers and result boxers
  into keyword arguments.
  (specialize-s64-unop): New helper.
  (specialize-fixnum-comparison, specialize-fixnum-scm-comparison)
  (specialize-scm-fixnum-comparison): Rename from
  specialize-s64-comparison et al.  Perhaps this should be expanded
  again to include the whole s64 range, once we start to expand scm->s64
  et al.
  (specialize-operations): Specialize arithmetic, etc on signed
  operands and results.  Use less powerful unboxing/boxing ops if
  possible -- e.g. tag-fixnum instead of u64->scm.  Prefer fixnum
  comparisons over u64 comparisons.
  (compute-specializable-fixnum-vars): New helper.
  (compute-specializable-phis): Specialize fixnum phis as well.
  (specialize-primcalls): Specialize untag-fixnum of a constant to
  load-s64.
* module/language/cps/type-fold.scm (u64->scm, s64->scm):
  (scm->s64, scm->u64): Reduce to fixnum ops where possible.
* module/language/cps/types.scm: Remove type checkers for ops that don't
  throw type errors.  Alias tag-fixnum/unlikely to tag-fixnum.
2017-11-13 14:39:30 +01:00
Andy Wingo
dae0004627 Better range inference
* module/language/cps/types.scm (&fx32-min, &fx32-max, &fx64-min)
  (&fx64-max): New internal definitions.
* module/language/cps/types.scm (type-entry-saturating-union): Add more
  stops as we saturate ranges towards infinity.
2017-11-13 14:32:53 +01:00
Andy Wingo
a88614fb17 Slot allocation allows s64/u64 representations of same var
* module/language/cps/slot-allocation.scm (compute-var-representations):
  If an optimization pass decided to e.g. use untag-fixnum for one
  definition of a variable and e.g. vector-length for the other, assume
  that their values are compatible.  We don't know at this point whether
  the values are meant to be s64 (e.g. because vector-length is a subset
  of the s64 range) or u64 (e.g. because although we're calling
  untag-fixnum on the value, actually we now that the value is
  non-negative, or actually we just want the unsigned bits).  Anyway we
  default to u64.  In the future we can perhasps be more precise.
2017-11-13 10:34:29 +01:00
Andy Wingo
b97321dbfd Add srsh, srsh/immediate instructions
* libguile/vm-engine.c (srsh, srsh/immediate): New instructions.
* module/language/cps/compile-bytecode.scm (compile-function):
* 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 (srsh, srsh/immediate):
* module/system/vm/assembler.scm: Add support for new instructions.

* module/language/cps/types.scm (ulsh, ursh): Remove type checkers, as
  these are effect-free.  Limit range of ursh count.
2017-11-13 10:25:20 +01:00
Andy Wingo
83a03a324b Specialize rsh/lsh, not ash
* module/language/cps/specialize-numbers.scm (specialize-operations):
  Replace "ash" specializer with "rsh"/"lsh" specializer.
2017-11-11 22:08:22 +01:00
Andy Wingo
107f70a633 Add missing lsh/immediate, rsh/immediate type inferrers
* module/language/cps/types.scm (lsh/immediate, rsh/immediate): Add
  missing type inferrers.
2017-11-11 22:08:22 +01:00
Andy Wingo
e8226be0c0 Type folding has "macro reduction" phase
* module/language/cps/type-fold.scm (*primcall-macro-reducers*):
  (define-primcall-macro-reducer, define-unary-primcall-macro-reducer):
  (define-binary-primcall-macro-reducer): New facility, for reductions
  on which reductions should run.  Define macro reducers for mul, lsh,
  and rsh.  Move mul reducer to be a mul/immediate reducer.
  (logbit?): Use target fixnum range.
  (local-type-fold): Adapt to call macro reducers first.
* module/language/cps/reify-primitives.scm (reify-primitives): Reify
  mul/immediate back to mul.
2017-11-11 22:08:14 +01:00
Andy Wingo
b331ea3193 Convert "ash" to "lsh"/"rsh" when lowering to CPS
* module/language/cps/effects-analysis.scm: Remove case for "ash".
* module/language/cps/types.scm (ash): Remove.
* module/language/tree-il/compile-cps.scm (convert, canonicalize):
  Convert "ash" to "lsh"/"rsh" early on.
* module/system/base/target.scm (target-fixnum?): New procedure.
2017-11-11 22:08:14 +01:00
Andy Wingo
a268c02fa0 Compiler uses target fixnum range
* module/system/base/target.scm (target-most-negative-fixnum):
  (target-most-positive-fixnum): New definitions.
* module/language/cps/types.scm (constant-type, define-exact-integer!)
  (&min/fixnum, &max/fixnum): Use new definitions.
  (&max/vector): Use target-max-vector-length.
2017-11-11 22:08:14 +01:00
Andy Wingo
8b5f9648ff Add tag-fixnum instruction
* libguile/vm-engine.c (tag-fixnum): New instruction.
* 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/types.scm (&min/fixnum, &max/fixnum, tag-fixnum):
* module/system/vm/assembler.scm: Add support for the new instruction.
2017-11-11 22:08:14 +01:00
Andy Wingo
7bfdd46ea5 Use immediate primcalls when unfolding constructors
* module/language/cps/constructors.scm (inline-vector): Use immediate
  primcalls.
2017-11-11 22:08:14 +01:00
Andy Wingo
b27065fdf2 Closure conversion uses immediate variants of vector instructions
* module/language/cps/closure-conversion.scm (convert-one): Use
  immediate variants of vector instructions.
2017-11-11 22:08:14 +01:00
Andy Wingo
9da03136e5 Specialize comparisons to SCM as s64
* module/language/cps/specialize-numbers.scm (specialize-s64-comparison)
  (specialize-s64-scm-comparison, specialize-scm-s64-comparison): New
  helpers.
  (specialize-scm-u64-comparison, specialize-u64-scm-comparison):
  Remove.  Comparing SCM as s64 is better as fixnums are a subset of
  s64, not u64.
  (specialize-operations): Prefer s64 comparisons when we can't
  specialize both arguments; this at least inlines the fixnum case.
2017-11-11 22:08:14 +01:00
Andy Wingo
7a7f71de5c Canonicalize <=, >=, and > primcalls to <
* module/language/tree-il/compile-cps.scm (canonicalize): Convert <=,
  >=, and > primcalls to <.
* module/language/cps/primitives.scm (*comparisons*):
* module/language/cps/effects-analysis.scm: Remove superfluous
  primcalls.
* module/language/cps/specialize-numbers.scm
  (specialize-u64-scm-comparison): Only emit < primcalls for ordered
  comparisons.
  (specialize-scm-u64-comparison): New helper.
* module/language/cps/specialize-numbers.scm (specialize-operations):
  Remove support for >=, <=, and the like.
* module/language/cps/type-fold.scm: Remove folders for <= and so on.
* module/language/cps/types.scm (define-=-inferrer, define-<-inferrer):
  New helpers; use them for all = and < variants.  Remove checkers and
  inferrers for <= and the like.
* module/language/cps/compile-bytecode.scm (compile-function): Remove
  unnecessary cases.
2017-11-11 22:08:14 +01:00
Andy Wingo
8b3258716c Refactor numeric comparison bytecode emission
* module/language/cps/compile-bytecode.scm (compile-function): Refactor.
2017-11-11 22:08:14 +01:00
Andy Wingo
375eab5610 Fix effects analysis bug introduced with primcall param
* module/language/cps/effects-analysis.scm (primitive-effects): Fix
  swapped name and param.  Embarrassing!
2017-11-11 22:08:14 +01:00
Ludovic Courtès
6ad28ae3bc http: Fix typo in proxy handling in 'write-request-line'.
Reported by Mark H Weaver <mhw@netris.org>
at <https://lists.gnu.org/archive/html/guix-devel/2017-11/msg00190.html>.

* module/web/http.scm (write-request-line): Fix more typos introduced in
96b994b6f8.
2017-11-11 15:14:54 +01:00
Ludovic Courtès
7d0d9e2c25 http: Fix typo in proxy handling in 'write-request-line'.
Reported by Konrad Hinsen <konrad.hinsen@fastmail.net>
at <https://lists.gnu.org/archive/html/guix-devel/2017-11/msg00070.html>.

* module/web/http.scm (write-request-line): Move 'string-index' first in
'cond' clause.  Fixes a regression introduced in
96b994b6f8.
2017-11-10 22:54:49 +01:00
Ludovic Courtès
b322ac67d3 Print exception location only once.
Fixes a regression introduced in commit
39090e677e.

* module/ice-9/boot-9.scm (exception-printers)[print-exception]: Remove
extraneous 'print-location' call.
2017-11-09 21:56:39 +01:00
Ludovic Courtès
81d2e35266 Allow GDB support to be used with GDB-linked-against-Guile-2.0.
* libguile/Makefile.am (INSTANTIATE): New variable.
(install-data-hook): Use it.
* libguile/libguile-2.2-gdb.scm: Autoload (system vm debug).
Augment %load-path and %load-compiled-path, and reload (system base
types).
* module/system/base/types.scm: Remove #:hide to be 2.0-compatible.
Use (system syntax internal) conditionally when on 2.2.
2017-11-05 18:21:35 +01:00
Andy Wingo
f96a670332 Add new "throw" VM ops
* libguile/throw.h (scm_ithrow, scm_throw): Mark as SCM_NORETURN.
* libguile/throw.c (scm_throw, scm_ithrow): Adapt to not return.
* libguile/vm-engine.c (throw, throw/value, throw/value+data): New
  instructions.
* libguile/vm.c (vm_throw, vm_throw_with_value)
  (vm_throw_with_value_and_data): New helpers.
* module/language/cps/compile-bytecode.scm (compile-function): Add cases
  for new instructions.
* module/language/cps/prune-bailouts.scm (prune-bailouts): More simple,
  now that there are no $kreceives in play.
* module/language/cps/reify-primitives.scm (reify-clause): Update
  reification of no-clause functions to use new throw op.
* module/language/tree-il/compile-cps.scm (convert): Convert invocations
  of the variable-arity 'throw primitive from Tree-IL to the new
  fixed-arity CPS instructions.
* module/system/vm/assembler.scm (emit-throw/value*)
  (emit-throw/value+data*, emit-throw): Export new instructions.
* module/system/vm/disassembler.scm (code-annotation): Add annotation.
2017-11-05 15:00:16 +01:00
Andy Wingo
cf486700b7 error, scm-error primcalls expand to `throw'
* module/language/tree-il/primitives.scm (scm-error, error): Expand
  into `throw'.
* module/language/tree-il/peval.scm (peval): Reify "throw" for dynwind
  error.
* module/language/tree-il/compile-cps.scm (canonicalize): Reify "throw"
  for call-with-prompt error.
* module/language/cps/prune-bailouts.scm (prune-bailouts): Don't expect
  "error" or "scm-error" here.
2017-11-05 15:00:16 +01:00
Andy Wingo
17bd5a8938 Add lsh, rsh instructions
* libguile/vm-engine.c (lsh, rsh, lsh/immediate, rsh/immediate): New
  instructions taking unboxed bit counts.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm:
* module/language/cps/specialize-numbers.scm (specialize-f64-unop):
  (specialize-u64-unop): Add ability to specialize add/immediate, etc,
  and add lsh/immediate as well.
  (specialize-u64-binop, specialize-u64-shift): Move rsh/lsh
  specialization to its own procedure, given that the bit count is
  already unboxed.
  (specialize-operations): Adapt to support more /immediate
  instructions.
* module/language/cps/type-fold.scm (mul): Reify an lsh/immediate
  instead of an ash.
* module/language/cps/types.scm (compute-ash-range): Add type inferrers
  for lsh, rsh, and their immediate variants.
* module/system/vm/assembler.scm: Export emit-lsh and so on.
* module/language/tree-il/compile-cps.scm (convert): Convert "ash" on
  immediates to rsh/immediate or lsh/immediate.
2017-11-05 15:00:16 +01:00
Andy Wingo
dea84a46b4 Earlier conversion to /imm primcalls
* module/language/tree-il/compile-cps.scm (convert): Convert to /imm
  variants of primcalls early on, to decrease complexity of later
  passes.
2017-11-05 15:00:16 +01:00
Andy Wingo
5457f28af9 Specialize primcalls more aggressively
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
  Don't restrict /imm params to encodeable immediates; specialize any
  imm.  Rely on reify-primitives to undo the transformation if needed.
2017-11-05 15:00:16 +01:00
Andy Wingo
ecff426b89 (system base types) uses target's idea of max size_t
* module/system/base/target.scm (target-max-size-t):
  (target-max-size-t/scm, target-max-vector-length): New public
  functions.
* module/language/cps/types.scm (type-entry-saturating-union): Remove
  restriction of polymorphic types to be within max-size-t; this could
  incorrectly apply constraints on numeric values.
  (&max/size, &max/scm-size): Use target-max-size-t.
  (*max-size-t*): Remove; replace uses with (target-max-size-t).
2017-11-05 15:00:16 +01:00
Andy Wingo
e8b883035d Tweak optimization order
* module/language/cps/optimize.scm (optimize-first-order-cps): Move up
  the simplify-primcalls pass, to allow DCE to take away unneeded
  constants.  An incremental step
2017-11-05 15:00:16 +01:00
Andy Wingo
1160690fde reify-primitives reifies constants for out-of-range imm params
* module/language/cps/reify-primitives.scm (reify-primitives): Add pass
  to re-reify constant arguments for primcalls with immediate parameters
  that can't be encoded as bytecode.
2017-11-05 15:00:16 +01:00
Andy Wingo
cc1b23ffe8 Remaining /immediate instructions take primcall imm param
* module/language/cps/compile-bytecode.scm (compile-function): Update
  add/immediate, etc.
* module/language/cps/slot-allocation.scm (compute-needs-slot):
  Simplify.
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
  Rework for add/immediate, etc.
* module/language/cps/types.scm (define-unary-result!)
  (define-binary-result!): Take types as params instead of variables, so
  we can share this code with /imm variants.
  (add/immediate, sub/immediate, uadd/immediate, usub/immediate)
  (umul/immediate, ulsh/immediate, ursh/immediate): Update type
  inferrers.
2017-11-05 15:00:16 +01:00
Andy Wingo
56d639bfe5 builtin-ref takes immediate parameter
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/reify-primitives.scm (builtin-ref):
* module/language/cps/slot-allocation.scm (compute-needs-slot):
  Builtin-ref uses immediate parameter.
2017-11-05 15:00:16 +01:00
Andy Wingo
d7ecf35d70 Immediate parameter for struct-ref et al
* 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/slot-allocation.scm (compute-needs-slot):
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
* module/language/cps/types.scm (allocate-struct/immediate)
  (struct-ref/immediate, struct-set!/immediate): Immediate struct
  constructor and accessor use immediate primcall parameters.
2017-11-05 15:00:16 +01:00
Andy Wingo
f9b8763921 Immediate variants of vector-ref, etc use immediate param
* 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/slot-allocation.scm (compute-needs-slot):
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
* module/language/cps/types.scm (make-vector/immediate):
  (vector-ref/immediate, vector-set!/immediate): Use immediate primcall
  param.
2017-11-05 15:00:16 +01:00
Andy Wingo
2f45cfcb9c free-ref, free-set take immediate parameters
* module/language/cps/closure-conversion.scm (convert-one):
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm (define-primitive-effects*)
  (expression-effects, primitive-effects): Only fall back to passing
  constant table if the immediate parameter is false.  Adapt closure
  effects analysis.
* module/language/cps/slot-allocation.scm (compute-needs-slot): Remove
  special cases for free-ref/free-set!.
2017-11-05 15:00:16 +01:00
Andy Wingo
6be04684e6 load-f64, etc take immediate parameters
* module/language/cps/compile-bytecode.scm (compile-function): Make
  load-f64, load-s64, and load-u64 take an immediate parameter instead
  of a CPS value.
* module/language/cps/effects-analysis.scm: Remove CPS argument from
  immediate load instructions.
* module/language/cps/slot-allocation.scm (compute-needs-slot): Remove
  special case for load-64 etc.
* module/language/cps/specialize-numbers.scm
  (specialize-u64-scm-comparison): Adapt.
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
  Adapt.
* module/language/cps/types.scm (define-type-inferrer*): Also take param
  argument.
  (define-type-inferrer, define-predicate-inferrer): Adapt.
  (define-type-inferrer/param): New helper.
  (load-f64, load-s64, load-u64): Adapt inferrers to pass on value from
  param.
* module/language/cps/utils.scm (compute-constant-values): Adapt.
2017-11-05 15:00:16 +01:00
Andy Wingo
4fb538e90e cache-current-module, etc use immediate primcall parameters
* module/language/bytecode.scm (*macro-instruction-arities*):
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm (current-module):
* module/language/cps/primitives.scm (*macro-instruction-arities*):
* module/language/cps/prune-top-level-scopes.scm (compute-used-scopes):
  (prune-top-level-scopes):
* module/language/cps/reify-primitives.scm (module-box):
* module/language/cps/slot-allocation.scm (compute-needs-slot):
* module/language/tree-il/compile-cps.scm (toplevel-box):
  (module-box, capture-toplevel-scope): Move the primcalls that deal
  with top-level references to use immediate parameters.
2017-11-05 15:00:16 +01:00
Andy Wingo
c54c151eb6 $primcall has a "param" member
* module/language/cps.scm ($primcall): Add "param" member, which will be
  a constant parameter to the primcall.  The idea is that constants used
  by primcalls as immediates don't need to participate in optimizations
  in any way -- they should not participate in CSE, have the same
  lifetime as the primcall so not part of DCE either, and don't need
  slot allocation.  Indirecting them through a named $const binding is
  complication for no benefit.  This change should eventually improve
  compilation time and memory usage, once we fully take advantage of it,
  as the number of labels and variables will go down.
* 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/effects-analysis.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/handle-interrupts.scm:
* module/language/cps/licm.scm:
* module/language/cps/peel-loops.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/rotate-loops.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/specialize-numbers.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/split-rec.scm:
* module/language/cps/type-checks.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm:
* module/language/cps/utils.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt all users.
2017-11-05 15:00:16 +01:00
Daniel Llorens
e0bcda4ad9 Fix bitvectors and non-zero lower bound arrays in truncated-print
* module/ice-9/arrays.scm (array-print-prefix): New private function.
* libguile/arrays.c (scm_i_print_array): Reuse (array-print-prefix) from
  (ice-9 arrays). Make sure to release the array handle.
* module/ice-9/pretty-print.scm (truncated-print): Support
  bitvectors.
  Don't try to guess the array prefix but call array-print-prefix from
  (ice-9 arrays) instead.
  Fix call to print-sequence to support non-zero lower bound arrays.
* test-suite/tests/arrays.test: Test that arrays print properly.
* test-suite/tests/print.test: Test truncated-print with bitvectors,
  non-zero lower bound arrays.
2017-10-31 13:23:44 +01:00
Daniel Llorens
3bfd4aaa6e Fix sort, sort! for arrays with nonzero lower bound
* module/ice-9/arrays.scm (array-copy): New function, export.
* module/Makefile.am: Install (ice-9 arrays).
* doc/ref/api-data.texi: Add documentation for (ice-9 arrays).
* libguile/quicksort.i.c: Use signed bounds throughout.
* libguile/sort.c (scm_restricted_vector_sort_x): Fix error calls. Fix
  calls to quicksort.
* test-suite/tests/sort.test: Actually test that the sorted results
  match the original data. Test cases for non-zero base index arrays for
  sort, sort!, and stable-sort!.
2017-10-31 13:23:17 +01:00
Andy Wingo
9ceab9962a Simplify special immediate predicate inferrer.
* module/language/cps/types.scm
  (define-special-immediate-predicate-inferrer): Simplify.
2017-10-30 12:06:11 +01:00
Andy Wingo
9d62724c08 Remove disassembler support for old-style jump instructions
* module/system/vm/disassembler.scm (code-annotation, compute-labels)
  (instruction-has-fallthrough?, define-jump-parser): Remove
  disassembler support for old-style jump instructions.
2017-10-30 12:06:11 +01:00
Andy Wingo
c92b80be2d Emit new instructions in function preludes
* module/system/vm/assembler.scm (standard-prelude, opt-prelude):
  (kw-prelude): Emit new instructions in function preludes.  Now all
  branches are via the new instructions.  Remove exports for old
  branches.
2017-10-30 12:06:07 +01:00
Andy Wingo
5fb9b7d542 Remove assembler exports for old-style predicates and branches
* module/system/vm/assembler.scm: Remove emit-br, emit-br-if-true, etc,
  as these all now use new-style instructions.
2017-10-30 11:55:27 +01:00
Andy Wingo
0d42f5467f Lower logtest branches to instead be 'zero? logand'
* module/language/cps/compile-bytecode.scm (compile-function): Rename
  the binary* helper back to binary, update uses, and remove logtest
  branch as we no longer put logtest in test context.
* module/language/cps/primitives.scm (*comparisons*): Remove logtest.
* module/language/cps/type-fold.scm: Remove logtest folder.
  (logbit?): Fold to logand.
* module/language/cps/types.scm (logtest): Update to be a type inferrer
  and not a predicate inferrer.
* module/language/tree-il/peval.scm (peval): Transform logtest and
  logbit? to (zero? (logand _ _)).
2017-10-30 11:50:45 +01:00
Andy Wingo
d1c69b5c95 Remove compiler support for u64-scm comparisons
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm:
* module/language/cps/primitives.scm (*comparisons*):
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm: Remove compiler support for u64-scm
  comparisons, as this is now inlined.
2017-10-29 21:02:56 +01:00
Andy Wingo
6bb0a96fa1 Inline u64/scm comparisons
* module/language/cps/specialize-numbers.scm
  (specialize-u64-scm-comparison): Inline comparisons against fixnums.
2017-10-29 20:35:30 +01:00
Andy Wingo
f34abbc396 Add hacks around lack of allocation sinking
* 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/primitives.scm (*macro-instruction-arities*):
* module/language/cps/specialize-numbers.scm (compute-specializable-vars):
* module/language/cps/types.scm: Add new variants of u64->scm and
  s64->scm that can't be replaced by CSE's auxiliary definitions, so we
  can sink unlikely allocations to side branches.  This is a hack until
  we can get allocation sinking working
2017-10-29 20:33:35 +01:00