* 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.
* 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/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 _ _)).
* 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.
* 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
* module/language/tree-il/compile-cps.scm (canonicalize, convert):
Simplify handling of branching primcalls so that `convert' only ever
sees branching primcalls in a test context.
* 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/language/tree-il/compile-cps.scm (convert): Fold test of
constants directly to their branches without reifying booleans, to
simplify "and" chains early.
* module/language/cps/compile-bytecode.scm (compile-function): Add
support for heap-object? in test context.
* module/language/cps/primitives.scm (*immediate-predicates*):
(*heap-type-predicates*, *comparisons*): New sets of predicates for
which the VM has branching operations.
(heap-type-predicate?): New predicate.
(*branching-primcall-arities*): Make a hash table.
(branching-primitive?, prim-arity): Adapt
to *branching-primcall-arities* being a hash table.
* module/language/cps/type-fold.scm (heap-object?): Add folder.
* module/language/tree-il/compile-cps.scm (convert): Precede heap type
checks with a heap-object? guard.
* 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/base/types/internal.scm (visit-immediate-tags)
(visit-heap-tags): New helpers.
* module/system/base/types/internal.scm (define-tags, define-tag): New
helpers.
(immediate-tags, heap-tags): Use define-tags to define all of the tag
values. For consistency some names are changed:
(%tc2-fixnum): Renamed from %tc2-inum.
(%tc8-flag): Removed.
(%tc16-null): Renamed from %tc16-eol.
(%tc7-weak-vector): Renamed from %tc7-wvect.
(%tc7-hash-table): Renamed from %tc7-hashtable.
(%tc7-flonum): Renamed from %tc7-real.
(visit-heap-tags, visit-immediate-tags): New exports.
* module/system/base/types.scm (cell->object): Adapt to renamings.
(match-bit-pattern): Add a case to match immediate SCM bits
literally.
(scm->object): Adapt to use the special immediate values directly.
* module/system/vm/disassembler.scm (immediate-tag-annotations):
(heap-tag-annotations): Adapt to new names.
* module/language/cps/types.scm (&special-immediate): Model all special
immediates (iflags) under this type bit. This makes type analysis
less precise on these values as we have to use ranges instead of sets
to represent the values, but it frees up bits for other purposes,
allowing us to totally model all types in Guile.
(&eof): New &special-immediate value.
(&other-heap-object): New type bit.
Adapt inferrers.
* module/language/cps/type-fold.scm
(define-special-immediate-predicate-folder): New helper, used for
iflag comparisons.
(local-type-fold): Adapt scalar-value for &special-immediate change.
Delegate branch on $values to a primcall to `false?'.
This will allow heap-object? / inum? predicates to do something useful.
* module/language/cps/types.scm (&fixnum, &bignum): Split &exact-integer
into these types. Keep &exact-integer as a union type.
(type<=?): New helper.
(constant-type): Return &fixnum or &bignum as appropriate.
(define-exact-integer!): New helper, tries to make exact integer
results be &fixnum if they are within range. Adapt users.
(restricted-comparison-ranges, define-binary-result!): Use type<=?
instead of = for &exact-integer.
* module/language/cps/type-fold.scm (logtest, mul, logbit?): Use
type<=?.
* module/language/cps/specialize-numbers.scm (inferred-sigbits):
(specialize-operations): Use type<=?.
* 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.
* module/system/base/types/internal.scm: New file, extracted
from (system base types).
* module/system/base/types.scm: Use (system base types internal) and
adapt to %tc1-pair, %tc2-inum, and %tc3-heap-object name changes.
* module/Makefile.am (SOURCES):
* am/bootstrap.am (SOURCES): Add new file.
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT): Layout is a "pr" field.
* module/ice-9/boot-9.scm (record-type-vtable): Record vtable fields are
writable.
(<parameter>): "pw" fields.
* module/oop/goops.scm (<class>, %compute-layout): <read-only> fields
are "pw" underneath.
* module/rnrs/records/procedural.scm (record-type-vtable)
(record-constructor-vtable, make-record-type-descriptor): Use "pw"
fields in vtables.
* module/srfi/srfi-35.scm (%condition-type-vtable)
(struct-layout-for-condition): "pw" fields in vtables.
* test-suite/tests/goops.test:
* test-suite/tests/structs.test: Use "pw" fields only.
* benchmark-suite/benchmarks/structs.bm: Update for make-struct/no-tail,
to use pw fields, and also to remove useless tests that the compiler
would optimize away.
* doc/ref/api-data.texi (Vtables): Add a note about the now-vestigial
permissions character and update documentation.
(Structure Basics, Meta-Vtables): Update examples.
* libguile/hash.c (scm_i_struct_hash): Remove code that would handle
opaque/self fields.
* libguile/print.h (SCM_PRINT_STATE_LAYOUT): Use "pw" fields.
* libguile/struct.c (scm_struct_init): Simplify check for hidden
fields.
* libguile/values.c (scm_init_values): Field is "pw".
* module/oop/goops.scm (opaque-slot?, read-only-slot?): New helpers.
(allocate-slots): Protect opaque and read-only slots by wrapping the
slot accessors instead of relying on struct permissions.
(%compute-layout): Remove opaque-slot case.
* libguile/struct.c (scm_make_struct): Remove support for tail arrays
and self slots.
(set_vtable_layout_flags): Always initialize the nfields member.
(scm_is_valid_vtable_layout): Remove support for tail arrays and self
slots.
(scm_i_struct_inherit_vtable_magic): No need to issue deprecation
warning for self slots, as they are no longer supported.
(scm_struct_init): Remove support for tail arrays and self slots.
(scm_c_make_structv): Throw an exception if n_tail is not 0.
(scm_allocate_struct): Adapt to scm_struct_init change.
(scm_i_make_vtable_vtable): Initialize slots manually, to avoid
relying on an already-initialized nfields member.
(scm_struct_ref, scm_struct_set_x): Simplify.
* module/oop/goops.scm: As we now rely on nfields being valid, when
recalculating slots during boot we need to avoid resetting nfields of
<class>, even temporarily, as that would prevent any further access to
<class>!
* libguile/struct.c: Replace uses of scm_make_struct with
scm_make_struct_no_tail or scm_c_make_struct.
(scm_make_struct_no_tail): Move this function to C instead of Scheme
to be able to deprecate scm_make_struct.
* libguile/struct.h (scm_make_struct_no_tail): New public declaration.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_make_struct): Deprecate.
* libguile/print.c:
* libguile/procs.c:
* libguile/stacks.c: Replace uses of scm_make_struct with
scm_make_struct_no_tail.
* test-suite/tests/coverage.test:
* test-suite/tests/structs.test: Use make-struct/no-tail instead of
make-struct.
* NEWS: Add entry.
* module/oop/goops.scm (fold-class-slots): Remove "redefined" field from
class objects. Redefinable classes are now handled in a layer on top
of GOOPS core.