* libguile/intrinsics.c (scm_to_uint64_truncate): New intrinsic.
(scm_bootstrap_intrinsics): Init new intrinsics.
* libguile/intrinsics.h: Add scm->u64, scm->u64/truncate, and scm->s64
as intrinsics, with their corresponding types.
* libguile/vm-engine.c (call-u64<-scm, call-s64<-scm): New intrinsic
calling ops.
(scm->u64, scm->s64, scm->u64/truncate): Disable opcodes.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
Add intrinsics as new macroinstructions.
* module/system/vm/assembler.scm: Declare new intrinsic assemblers.
* module/language/cps/effects-analysis.scm (string-ref): Remove effects
declaration, given that the primitive is exploded now.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
Add string-set!.
* libguile/vm-engine.c (string-set!): Disable opcode.
* module/language/cps/types.scm (string-ref, string-set!): Remove type
checker and inferrers for string-ref and string-set!, as both are
exploded. In the case of string-set! there are still type-check
effects in the intrinsic call but they can't be elided by the checker,
as we don't track when strings are read-only.
* module/language/tree-il/compile-cps.scm (ensure-char): New helper.
(string-set!): New primcall exploded converter.
* libguile/intrinsics.h: Rename intrinsic types added in previous
commit.
* libguile/vm-engine.c (call-scm<-scm-scm, call-scm<-scm-uimm): New
instructions.
* libguile/vm.c: Include intrinsics.h.
* module/language/bytecode.scm
* module/language/bytecode.scm (*intrinsic-codes*, *intrinsic-names*):
New internal definitions.
(intrinsic-name->index, intrinsic-index->name): New exported
definitions.
* module/system/vm/assembler.scm (encode-X8_S8_S8_S8-C32<-/shuffle):
(encode-X8_S8_S8_C8-C32<-/shuffle): New shuffling encoders.
(shuffling-encoder-name): Add case for new shuffling encoders.
(define-scm<-scm-scm-intrinsic, define-scm<-scm-uimm-intrinsic): New
helpers. Define encoders for "add", etc.
* 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!
* 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?.
* 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.
* module/system/base/types/internal.scm (heap-tags): Rename complex and
fraction predicates to "compnum?" and "fracnum?", as they aren't the
same as the Scheme predicates "complex?" and "fraction?".
* module/system/vm/assembler.scm (check-urange): Hoist exact-integer?
check so that the side effect is entirely in this function and not in
`logand'. Allows devirtualize-integers to peel off a nice straight
trace.
* 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=?.
* 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.
* 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.
* 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.
* 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.
* module/system/base/types/internal.scm (heap-tags): Rename number to
heap-number.
* module/system/vm/assembler.scm: Adapt for emit-heap-number?.
* module/system/base/types.scm (%tc7-heap-number): Rename from
%tc7-number.
* module/system/vm/disassembler.scm (immediate-tag-annotations)
(heap-tag-annotations): Generate using tag visitors.
* module/system/vm/assembler.scm
(define-immediate-tag=?-macro-assembler)
(define-heap-tag=?-macro-assembler): New helpers. Use these to
generate immediate-tag=? and heap-tag=? macro assemblers.
* module/system/vm/assembler.scm: Export assemblers for the new
instructions.
* module/system/vm/disassembler.scm (immediate-tag-annotations)
(heap-tag-annotations, code-annotation): Add support for disassembling
the new instructions, with good annotations.
(compute-labels, instruction-has-fallthrough?, define-jump-parser):
Add support for new branching instructions.