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

3340 commits

Author SHA1 Message Date
Andy Wingo
486b322fd5 Fix frame-call-representation for change to <binding>.
* module/system/vm/frame.scm (frame-call-representation): Fix for change
  to <binding>.
2016-02-02 11:09:00 +01:00
Andy Wingo
8998f1539f Update statprof documentation; deprecate `with-statprof'
* module/statprof.scm: Remove most of the commentary, as it was
  duplicated in the manual and was getting out of date.
  (stats): Remove self-secs-per-call and cum-secs-per-call fields as
  they can be computed from the other fields.
  (statprof-call-data->stats): Adapt.
  (statprof-stats-self-secs-per-call):
  (statprof-stats-cum-secs-per-call): New functions.
  (statprof-display/flat): Don't print the seconds-per-call fields, as
  we are no longer stopping the clock around call counters.  Anyway
  these times were quite misleading.
  (with-statprof): Deprecate.  It took its keyword arguments at the
  beginning; very complicated!  Better to use the `statprof' function.
  (`statprof' was introduced after `with-statprof' and then
  `with-statprof' was adapted to use it.)

* doc/ref/statprof.texi (Statprof): Port this documentation away from
  the automatically generated text and update it for the new interfaces
  like #:display-style.

* module/system/base/syntax.scm (record-case): Remove comment that
  referenced with-statprof.  Add comment indicating that record-case
  should be replaced.

* doc/ref/scheme-using.texi (Profile Commands): Update to mention
  keyword arguments and to link to the statprof documentation.
2016-02-01 15:12:36 +01:00
Andy Wingo
4066ee3192 Better call-counting profiles in statprof
* module/statprof.scm: Update commentary.
  (count-call): Don't bother stopping and starting the timer.  The
  overhead of call counting perturbs timing too much already, and
  somewhat paradoxically stopping and starting the timer takes too much
  time.
  (skip-count-call): New function.
  (stack-samples->procedure-data, stack-samples->callee-lists): If we
  are counting calls, skip any part of the stack that is inside
  count-call.
2016-02-01 11:27:14 +01:00
Andy Wingo
cd0b61a04e Frame <binding> objects capture frame, can ref value directly
* module/system/repl/debug.scm (print-locals): Adapt to
  frame-binding-ref change.

* module/system/vm/frame.scm (<binding>): Add `frame' field.
  (available-bindings): Capture the frame.
  (binding-ref, binding-set!): New functions, accessing a local variable
  value directly from a frame.
  (frame-binding-ref, frame-binding-set!): Remove.  As these are very
  low-level debugging interfaces introduced in 2.0, never documented,
  and quite tied to the VM, we feel comfortable making this change.
  (frame-call-representation): Adapt to available-bindings change.
  (frame-environment, frame-object-binding): Adapt to binding-ref
  interface change.

* doc/ref/vm.texi (Stack Layout): Mention that slots can be re-used.
  Update disassembly in example.

* doc/ref/api-debug.texi (Frames): Remove documentation for
  frame-local-ref, frame-local-set!, and frame-num-locals.  Replace with
  documentation for frame-bindings, binding accessors, and binding-ref /
  binding-set!.
2016-01-31 11:15:58 +01:00
Andy Wingo
67e8aa85e8 Remove frame-local-ref, frame-local-set!
* libguile/frames.h (scm_frame_num_locals, scm_frame_local_ref)
  (scm_frame_local_set_x): Remove.  As long as we are changing the
  interface in a backward-incompatible way, we might as well remove
  these.
* libguile/frames.c (scm_frame_num_locals, scm_frame_local_ref)
  (scm_frame_local_set_x, scm_init_frames_builtins, scm_init_frames):
  Arrange to make frame-local-ref et al private to frames.scm.

* module/system/vm/frame.scm: Load scm_init_frames_builtins extensions.
  (frame-instruction-pointer-or-primitive-procedure-name): New public
  function.
  (frame-binding-ref, frame-binding-set!): Allow binding objects as
  vars.

* module/system/repl/debug.scm (print-locals): Pass binding directly to
  frame-binding-ref.

* module/statprof.scm (sample-stack-procs, count-call): Use new
  frame-instruction-pointer-or-primitive-procedure-name function.
2016-01-31 10:45:02 +01:00
Andy Wingo
9eb841c2d8 Fix uniform vector compilation to foreign byte orders.
* module/system/vm/assembler.scm (define-byte-order-swapper): New
  helper.
  (byte-swap/2!, byte-swap/4!, byte-swap/8!): New functions.
  (link-data): Swap bytes in uniform vectors on foreign byte orders.
2016-01-29 10:24:40 +01:00
Andy Wingo
e4be4aea34 Fix cross-compilation of immediates to targets with different word sizes
* module/system/vm/assembler.scm (immediate-bits): Rename from
  immediate?, and return the bits.  Take asm argument so that we measure
  what's an immediate not on the host but for the target.  Adapt all
  callers.
  (write-immediate): Take bits instead of SCM object.  Adapt callers.
  (write-placeholder): New helper, to write bits for #f.  Adapt callers
  that wrote #f to use write-placeholder.
2016-01-29 09:50:32 +01:00
Andy Wingo
f61870979c Fix type inference of integer division
* module/language/cps/types.scm (define-binary-result!): Fix inference
  of integer division.
2016-01-17 16:58:36 +01:00
Andy Wingo
ee85113f4a statprof: Better tree-format profiles
* module/statprof.scm (statprof-fetch-call-tree): Add #:precise? keyword
  argument, defaulting to false.  Search for cycles after computing
  printable source locations instead of doing so over addresses -- it
  could be that two addresses map to the same source location, and from
  the user's perspective they are then indistinguishable in the
  printout.
2016-01-11 21:56:48 +01:00
Andy Wingo
cf2fadf603 statprof: Add tree #:display-style.
* module/statprof.scm (statprof-display/flat): Rename from
  statprof-display.  Use real format; we have it.
  (statprof-display-anomalies): Likewise use real format.
  (procedure=?): Remove unused function.
  (collect-cycles): New helper.
  (statprof-fetch-call-tree): Fix to root the trees correctly -- it was
  interpreting them in the wrong order.  Detect cycles so that it's not
  so terrible.  Use precise locations for source locations.  Probably
  need to add an option to go back to the per-function behavior.
  (statprof-display/tree): New helper, uses statprof-fetch-call-tree to
  display a profile in a nested tree.
  (statprof-display): Add #:style argument, which can be `flat',
  `anomalies', or `tree'.
  (statprof): Add #:display-style argument, proxying to #:style,
  defaulting to 'flat.
2016-01-11 21:56:48 +01:00
Andy Wingo
6d7c09c8a9 web: Be less strict when parsing entity tags.
* module/web/http.scm (parse-entity-tag): Be less strict, accepting
  unquoted strings as well.

* test-suite/tests/web-http.test ("response headers"): Add a test for
  etag parsing.
2016-01-07 10:53:57 +01:00
Andy Wingo
4137c224e2 Remove unused function in simplify.scm
* module/language/cps/simplify.scm (intset-add*): Remove unused
  function.
2016-01-04 23:33:24 +01:00
Andy Wingo
f56f580a4a Inline some helpers in intset.scm.
* module/language/cps/intset.scm (round-down): Inline.
  (clone-branch-and-set): Inline, and inline the vector-move-left!.
2016-01-04 22:48:30 +01:00
Andy Wingo
9091454c2e Include missing #:simplify? option in (language cps optimize).
* module/language/cps/optimize.scm (cps-default-optimization-options):
  Add missing #:simplify? option.  Otherwise the simplification pass was
  running even at -O0.
2016-01-04 22:43:30 +01:00
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
52965e03ec Better folding of branches on $values
* module/language/cps/type-fold.scm (local-type-fold): Fold branches on
  $values, if we can.
2016-01-03 16:17:53 +01:00
Andy Wingo
39002f251e Eta-reduce branches
* module/language/cps/simplify.scm (compute-eta-reductions): Eta-reduce
  branches as well, so that passing a constant to a branch will fold to
  the true or false branch, provided that the test variable was just
  used in the branch.
2016-01-03 16:16:54 +01:00
Andy Wingo
5d171d998c Fix module for reification of srfi-4 primitives
* module/language/cps/reify-primitives.scm (primitive-module): Add cases
  for SRFI-4 primitives.  These primitives are only treated as such for
  the purposes of Tree-IL primitive expansion; perhaps the right fix is
  elsewhere, but it's here for now.
2015-12-30 17:14:22 +01:00
Andy Wingo
a9c2606451 Type inference copes better with unsorted graphs
* module/language/cps/types.scm (&min/0, &min/s64, &max/s64, &max/size)
  (&max/u64, &max/vector): New clamped variable range accessors.  Use
  them in type inferrers.
2015-12-26 22:12:09 +01:00
Andy Wingo
620b640a4e Fix bug in intmap-map
* module/language/cps/utils.scm (intmap-map): Use transient intmap-add!
  on an empty intmap to build the result instead of intmap-replace! on
  the argument.  Avoids spooky action-at-a-distance mutation of the
  argument if it happens to be a transient -- although the intmap-fold
  will correctly traverse a snapshot of the argument and the result will
  be correct, the argument value would be modified in place, causing
  strange results to calling code that passes in a transient.
2015-12-26 22:12:09 +01:00
Andy Wingo
8a39162160 Assembler O(n) in instruction encodings, not instruction count
* module/system/vm/assembler.scm: Change define encoders for all of the
  kinds of instructions and have the emit-foo procedures call the common
  encoders.  No change to public interface.  This decreases the amount
  of generated code in the assembler.
2015-12-26 22:12:09 +01:00
Andy Wingo
362907810b Fix emit-receive* for many locals
* module/system/vm/assembler.scm (emit-receive*): Fix to use FP-relative
  move instead of SP-relative move.
2015-12-26 22:12:09 +01:00
Andy Wingo
9e1c07bda6 Assembler works on byte offsets, not u32 offsets
* module/system/vm/assembler.scm (u32-ref, u32-set!, s32-ref, s32-set!):
  Remove these helpers.
* module/system/vm/assembler.scm (<asm>): Track offsets in bytes, not
  u32 units.
  (emit, assembler, process-relocs, process-labels, link-text-object)
  (link-frame-maps, link-symtab, write-arities, link-docstrs)
  (link-procprops, link-debug): Adapt.

* module/system/vm/linker.scm (process-reloc): Add addend before
  dividing by 4 for rel32/4 symbols.
2015-12-26 22:12:09 +01:00
Andy Wingo
3c271457f1 Fix build when threads are disabled
* module/language/cps/intmap.scm: Remove srfi-18 import.  We just need
  current-thread which is actually defined in (guile), and
  importing (srfi srfi-18) raises an error if Guile is compiled without
  threads support.
2015-12-16 09:48:37 +00:00
Andy Wingo
a1471e0244 Add another simplification pass to make rotate-loops work better
* module/language/cps/optimize.scm (optimize-first-order-cps): Toss in
  another simplification pass.
2015-12-03 09:12:25 +00:00
Andy Wingo
1d4b4ec39c Add support for comparing u64 values with SCM values
* libguile/vm-engine.c (BR_U64_SCM_COMPARISON): New helper.
  (br-if-u64-<=-scm, br-if-u64-<-scm, br-if-u64-=-scm)
  (br-if-u64->-scm, br-if-u64->=-scm): New instructions, to compare an
  untagged u64 with a tagged SCM.  Avoids many u64->scm operations.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm:
* module/language/cps/type-fold.scm:
* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm (code-annotation, compute-labels):
* module/language/cps/primitives.scm (*branching-primcall-arities*): Add
  support for new opcodes.
* module/language/cps/specialize-numbers.scm
  (specialize-u64-scm-comparison): New helper.
* module/language/cps/specialize-numbers.scm (specialize-operations):
  Specialize u64 comparisons.
* module/language/cps/types.scm (true-comparison-restrictions): New helper.
  (define-comparison-inferrer): Use the new helper.  Add support for
  u64-<-scm et al.
2015-12-03 09:01:24 +01:00
Andy Wingo
7a43a3a181 Refactor range checking in assembler instruction packers
* module/system/vm/assembler.scm (check-urange, check-srange): New
  helpers.
  (pack-u8-u24, pack-u8-s24, pack-u1-u7-u24, pack-u8-u12-u12):
  (pack-u8-u8-u16, pack-u8-u8-u8-u8): Use the new helpers.  Not only
  makes the code nicer but also reduces register pressure.
2015-12-02 22:12:30 +01:00
Andy Wingo
9514dc7b95 Add ursh/immediate and ulsh/immediate ops
* libguile/vm-engine.c (ursh/immediate, ulsh/immediate): New ops.
* module/language/cps/effects-analysis.scm:
* module/language/cps/slot-allocation.scm (compute-var-representations)
  (compute-needs-slot):
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
* module/language/cps/compile-bytecode.scm (compile-function):
* module/system/vm/assembler.scm:
* module/language/cps/types.scm: Add support for new ops, and specialize
  ursh and ulsh.
2015-12-02 22:11:19 +01:00
Andy Wingo
246887171c Assembler has a single growable vector
* module/system/vm/assembler.scm (<asm>): Instead of writing words into
  a list of fixed-size buffers, use a growable vector.
  (expand, emit): Instead of assuming that there is enough space for
  only one word, check that there is space for the entire instruction at
  the beginning.
2015-12-02 08:45:30 +01:00
Andy Wingo
dbd9265cc0 More efficient assembler instructions
* module/system/vm/assembler.scm (pack-u8-u24, pack-u8-s24):
  (pack-u1-u7-u24, pack-u8-u12-u12, pack-u8-u8-u16): Tweak to expose
  more possibilities for untagging u64 values.
2015-12-02 08:45:30 +01:00
Andy Wingo
73065c7131 Specialize u64 bit operations
* module/language/cps/specialize-numbers.scm (specialize-u64-binop):
  (specialize-operations): Specialize u64 bit operations.
2015-12-02 08:45:30 +01:00
Andy Wingo
3d6dd2f81c Add untagged bitwise operations
* libguile/vm-engine.c (ulogand, ulogior, ulogsub, ulsh, ursh)
  (scm->u64/truncate): New ops.
* 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/specialize-primcalls.scm (specialize-primcalls):
* module/language/cps/types.scm:
* module/language/cps/utils.scm (compute-constant-values):
* module/system/vm/assembler.scm: Wire up support for the new ops.
2015-12-02 08:45:30 +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
8bf77f7192 Add support for unboxed s64 values
* libguile/frames.c (enum stack_item_representation):
  (scm_to_stack_item_representation):
  (scm_frame_local_ref, scm_frame_local_set_x): Support for S64
  representations.

* libguile/frames.h (union scm_vm_stack_element): Add signed 64-bit
  integer field.

* libguile/vm-engine.c (scm->s64, s64->scm, load-s64): New
  instructions.

* 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-var-representations)
  (compute-needs-slot, allocate-slots):
* module/language/cps/utils.scm (compute-constant-values):
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
  Add support for new primcalls.

* module/language/cps/types.scm (&s64): New type.
  (&s64-min, &s64-max, &u64-max): New convenience definitions.
  (&range-min, &range-max): Use &s64-min and &u64-max names.
  (scm->s64, load-s64, s64->scm): Add support for new primcalls.

* module/system/vm/assembler.scm (emit-scm->s64, emit-s64->scm)
  (emit-load-s64): New exports.
* module/system/vm/assembler.scm (write-arities): Support for s64
  slots.

* module/system/vm/debug.scm (arity-definitions): Support for s64
  slots.
2015-12-01 15:42:19 +01:00
Andy Wingo
f34688ad25 New instructions load-f64, load-u64
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Add word
  types for immediate f64 and u64 values.
  (TYPE_WIDTH): Bump up by a bit, now that we have 32 word types.
  (NOP, parse_instruction): Use 64-bit meta type.

* libguile/vm-engine.c (load-f64, load-u64): New instructions.

* module/language/bytecode.scm (compute-instruction-arity): Add parser
  for new instruction word types.

* module/language/cps/compile-bytecode.scm (compile-function): Add
  special-cased assemblers for new instructions, and also for scm->u64
  and u64->scm which I missed before.

* module/language/cps/effects-analysis.scm (load-f64, load-u64): New
  instructions.

* module/language/cps/slot-allocation.scm (compute-needs-slot): load-f64
  and load-u64 don't need slots.
  (compute-var-representations): Update for new instructions.

* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
  Specialize scm->f64 and scm->u64 to make-f64 and make-u64.

* module/language/cps/types.scm (load-f64, load-u64): Wire up to type
  inference, though currently type inference only runs before
  specialization.

* module/language/cps/utils.scm (compute-defining-expressions): For some
  reason I don't understand, it's possible to see two definitions that
  are equal but not equal? here.  Allow for now.
  (compute-constant-values): Punch through type conversions to get
  constant u64/f64 values.

* module/system/vm/assembler.scm (assembler): Support for new word
  types.  Export the new assemblers.
2015-12-01 11:30:55 +01:00
Andy Wingo
bdfa1c1b42 Add tagged and untagged arithmetic ops with immediate operands
* libguile/vm-engine.c (add/immediate, sub/immediate)
  (uadd/immediate, usub/immediate, umul/immediate): New instructions.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/slot-allocation.scm (compute-needs-slot):
* module/language/cps/types.scm:
* module/system/vm/assembler.scm (system):
* module/language/cps/effects-analysis.scm: Support
  for new instructions.

* module/language/cps/optimize.scm (optimize-first-order-cps): Move
  primcall specialization to the last step -- the only benefit of doing
  it earlier was easier reasoning about side effects, and we're already
  doing that in a more general way with (language cps types).
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
  Specialize add and sub to add/immediate and sub/immediate, and
  specialize u64 addition as well.  U64 specialization doesn't work now
  though because computing constant values doesn't work for U64s; oh
  well.
2015-12-01 11:30:55 +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
e003466039 Specialize u64 arithmetic
* module/language/cps/specialize-numbers.scm (specialize-operations):
  (specialize-u64-binop): Specialize u64 addition, subtraction, and
  multiplication.
2015-12-01 11:30:55 +01:00
Andy Wingo
d2808b16e5 Better range inference for indexes of vector-ref, string-ref et al
* module/language/cps/types.scm (vector-ref, vector-set!)
  (string-ref, string-set!, struct-ref, struct-set!)
  (define-bytevector-accessors, define-bytevector-uaccessors): Clamp
  range of object and index to be within the range of indices, with a
  maximum of *max-size-t*.
2015-12-01 11:30:55 +01:00
Andy Wingo
672853657c Slower range saturation in type inference
* module/language/cps/types.scm (*max-size-t*): New definition.
  (type-entry-saturating-union): Saturate more slowly, first stopping at
  [0,*max-size-t*] then at [&range-min, &range-max] before saturating to
  [-inf.0, +inf.0].  This allows most offset phi variables to have their
  range inferred within the u64 range.
2015-12-01 11:30:55 +01:00
Andy Wingo
d294d5d1e1 Add unsigned 64-bit arithmetic operators: uadd, usub, umul
* libguile/vm-engine.c (uadd, usub, umul): New ops.
* module/language/cps/effects-analysis.scm (uadd, usub, umul): Add
  effects analysis.
* module/language/cps/slot-allocation.scm (compute-var-representations):
  The new ops define 'u64 values.
* module/language/cps/types.scm (uadd, usub, umul): Add type checkers
  and inferrers.
* module/system/vm/assembler.scm (emit-uadd, emit-usub, emit-umul): New
  assemblers.
2015-12-01 11:30:55 +01:00
Andy Wingo
2906d963ea Unbox u64 phi values
* module/language/cps/specialize-numbers.scm
  (compute-specializable-vars): Refactor to work on any kind of
  unboxable value, not just f64 values.
  (compute-specializable-f64-vars, compute-specializable-u64-vars): New
  helpers.
  (apply-specialization): Support for u64 values.
2015-12-01 11:30:55 +01:00
Andy Wingo
4305b39336 Beginning of u64 phi unboxing
* module/language/cps/specialize-numbers.scm
  (compute-specializable-u64-vars): New stub.
* module/language/cps/specialize-numbers.scm
  (compute-specializable-phis): Rename from
  compute-specializable-f64-phis, and return an intmap instead of an
  intset.  The values distinguish f64 from u64 vars.
* module/language/cps/specialize-numbers.scm (apply-specialization):
  Start of u64 phi unboxing.
* module/language/cps/specialize-numbers.scm (specialize-phis):
  (specialize-numbers): Adapt.
2015-12-01 11:30:55 +01:00
Andy Wingo
163fcf5adb Specialize u64 comparisons
* module/language/cps/specialize-numbers.scm
  (specialize-u64-comparison): New function.
* module/language/cps/specialize-numbers.scm (specialize-operations):
  Rename from specialize-f64-operations, as it will specialize both
  kinds.  Add a case to specialize u64 comparisons.
* module/language/cps/specialize-numbers.scm (specialize-numbers): Adapt
  to specialize-operations name change.
2015-12-01 11:30:55 +01:00
Andy Wingo
07607f66b8 Add instructions to branch on u64 comparisons
* libguile/vm-engine.c (BR_U64_ARITHMETIC): New helper.
  (br-if-u64-=, br-if-u64-<, br-if-u64->=): New instructions.

* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm:
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm (u64-=, infer-u64-comparison-ranges):
  (define-u64-comparison-inferrer, u64-<, u64-<=, u64->=, u64->):
* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm (code-annotation):
  (compute-labels): Compiler and toolchain support for the new
  instructions.
2015-12-01 11:30:54 +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