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

243 commits

Author SHA1 Message Date
Andy Wingo
cbfad75fa6 Add support for recording inlinable module exports
* module/language/tree-il/inlinable-exports.scm: New module.
* am/bootstrap.am:
* module/Makefile.am:
* module/language/tree-il/optimize.scm (make-optimizer):
* module/system/base/optimize.scm (available-optimizations): Wire up new
module.
* module/ice-9/boot-9.scm (module): Add inlinable-exports field.
(define-module*): Add #:inlinable-exports kwarg.
2021-05-11 21:39:07 +02:00
Andy Wingo
a892791b43 Add pass to resolve free toplevel references in declarative modules
* am/bootstrap.am (SOURCES):
* module/Makefile.am (SOURCES):
* module/language/tree-il/optimize.scm (make-optimizer): Wire up the new
pass.
* module/language/tree-il/resolve-free-vars.scm: New pass.
* module/system/base/optimize.scm (available-optimizations): Enable new
pass at -O1.
2021-05-11 21:39:07 +02:00
Leo Prikler
5c6a944173 bug#45131: [PATCH] Compile directly to target language if no joint is found.
This enables the compilation from "manually" written Tree-IL to
bytecode.  See also <https://bugs.gnu.org/45131>.

* system/base/compile.scm (read-and-compile)[(joint #f)]<? eof-object?>:
Join exps using the default joiner for to.
<exp>: Compute compiler for to.
* test-suite/test/compiler.test ("read-and-compile tree-il"): New test.
2021-05-10 10:16:10 +02:00
Andy Wingo
1432088f27 Minor tweak to truncate-bits
* module/system/base/types/internal.scm (truncate-bits): Use bits-case
in all cases.
2021-05-10 10:07:12 +02:00
Andy Wingo
05614f792b Optimize truncate-bits
* module/system/base/types/internal.scm (truncate-bits): Inline cases
for 16, 32, and 64, to avoid allocating bignums for the boundary
conditions.
2021-05-06 21:51:37 +02:00
Andy Wingo
86e86ec1c7 New pass: elide-arity-checks
* module/language/cps/elide-arity-checks.scm: New file.  Elides argument
count checks for known callers.
* am/bootstrap.am (SOURCES):
* module/Makefile.am (SOURCES): Add new file.
* module/language/cps/optimize.scm (optimize-first-order-cps):
* module/system/base/optimize.scm (available-optimizations): Add new
pass.
2021-04-21 22:41:12 +02:00
Andy Wingo
85433fc2b1 Add mkstemp; undocument mkstemp!
* doc/ref/posix.texi (File System): Update to document mkstemp only.
* libguile/filesys.c: Make a mkstemp that doesn't modify the input
template.  Instead the caller has to get the file name from
port-filename.
(scm_mkstemp): Use the new mkstemp to implement mkstemp!.  Can't
deprecate yet though as the replacement hasn't been there for long
enough.
* libguile/posix.c (scm_tempnam): Update to mention mkstemp instead.
* module/system/base/compile.scm (call-with-output-file/atomic): Use
mkstemp.
* test-suite/tests/posix.test:
* test-suite/tests/r6rs-files.test: Use mkstemp.
* NEWS: Update.
2021-03-10 20:40:10 +01:00
Andy Wingo
9d5978a756 New warnings: -Wuse-before-definition, -Wnon-idempotent-definition
* module/ice-9/boot-9.scm (%auto-compilation-options): Add
  use-before-definition and non-idempotent-definition.
* module/language/tree-il/analyze.scm (<use-before-def-info>): New
  analysis info.
  (make-use-before-definition-analysis): New function.
  (goops-toplevel-definition): Move down.
  (unbound-variable-analysis, macro-use-before-definition): Remove, as
  they are subsumed by use-before-def.  There are some deprecated
  bindings though.
  (make-analyzer): Rework to allow for use-before-def analysis to handle
  multiple
* module/system/base/message.scm (%warning-types): Add handlers for the
  new warning types.
* test-suite/tests/tree-il.test: Add tests.
* doc/ref/api-evaluation.texi (Compilation): Update.
2021-01-07 10:26:33 +01:00
Andy Wingo
03998db647 Add new pass to optimize branch chains to table dispatch
* module/language/cps/switch.scm: New pass.

* module/Makefile.am (SOURCES):
* am/bootstrap.am (SOURCES): Add switch.scm.

* module/system/base/optimize.scm (available-optimizations):
* module/language/cps/optimize.scm (optimize-first-order-cps): Run
  switch optimization at level 2.

* libguile/hash.c (JENKINS_LOOKUP3_HASHWORD2): Add note regarding
  cross-compilation.

* module/language/cps/graphs.scm (intmap-select): New definition.
* module/language/cps/utils.scm (compute-singly-referenced-labels): Move
  here, from various places.  Doesn't take a body intset argument.

* module/language/cps/contification.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/simplify.scm: Use compute-singly-referenced-labels
  from utils.

* module/language/cps/effects-analysis.scm (annotation->memory-kind*):
  (annotation->memory-kind): Add symbol annotation cases.
2020-08-12 23:30:08 +02:00
Andy Wingo
d238566d0e CPS compiler reduces eq? on constant to eq-constant?
* module/language/cps/compile-bytecode.scm (compile-function): Expect
  eq-constant? instead of eq-null?, etc.
* module/language/cps/effects-analysis.scm: Likewise.
* module/language/cps/reify-primitives.scm (reify-primitives): For
  eq-constant?, reify a $const unless the constant is an immediate whose
  encoding fits in 16 bits.
* module/language/cps/type-fold.scm (materialize-constant): Helper to
  make a constant from a type, min, and max.
  (fold-eq-constant?): New helper.
  (eq-constant?): New folder.
  (undefined?): Define specifically.
  (define-nullish-predicate-folder): Renamd from
  define-special-immediate-predicate-folder.  Use only for null?, false,
  and nil?.
  (*branch-reducers*): New mechanism.  Reduce eq? to eq-constant? if
  possible.
  (local-type-fold): Refactor to use materialize-constant, and to allow
  reducing branches.
* module/language/cps/types.scm (constant-type): Return three values
  instead of a type entry.
  (constant-type-entry): New function that returns a type entry.  Adapt
  callers.
  (infer-constant-comparison): New helper.
  (eq-constant?): New inferrer.
  (undefined?): New inferrer.
* module/language/tree-il/compile-bytecode.scm (eq-constant?): Fix
  truncate-bits signed arg.
  (define-immediate-type-predicate): Adapt to visit-immediate-tags
  change.
* module/language/tree-il/compile-cps.scm (convert): Convert eq? to
  constant to eq-constant?.  Advantaged is that it gets fixnums and
  chars in addition to special immediates.
* module/language/tree-il/cps-primitives.scm (define-immediate-type-predicate):
  Adapt to allow #f as pred.
* module/system/base/types/internal.scm (immediate-tags): Use #f as pred
  for false, nil, etc.
  (immediate-bits->scm): Adapt.
* module/system/vm/assembler.scm (emit-eq-null?, emit-eq-nil?)
  (emit-eq-false?, emit-eq-true?, emit-unspecified?, emit-eof-object?):
  Remove specialized emitters.
* module/system/vm/assembler.scm (define-immediate-tag=?-macro-assembler):
  Allow for pred to be #f.
* module/system/vm/disassembler.scm (define-immediate-tag-annotation):
  Adapt to pred being #f.
2020-08-03 22:19:18 +02:00
Andy Wingo
daf3e88a81 Rework the way immediate encodings are calculated.
* module/system/base/types/internal.scm (scm->immediate-bits):
  (immediate-bits->scm, sign-extend, truncate-bits): New public
  routines.
* module/system/vm/assembler.scm (immediate-bits): Reimplement in terms
  of scm->immediate-bits and similar.
  (X8_S8_I16, X8_S8_ZI16): Rework operand encodings.
  (load-constant): Use truncate-bits to determine which cases apply.
2020-08-03 22:19:18 +02:00
Andy Wingo
e2066d2e63 Change -O1 compiler to use baseline and also resolve primitives
* bootstrap/Makefile.am (GUILE_OPTIMIZATIONS): Change to just -O1.
* module/language/tree-il/spec.scm (choose-compiler): Use CPS for -O2
  and higher.
* module/system/base/optimize.scm (available-optimizations): CPS for -O2
  and higher, but -Oresolve-primitives now at -O1 also.
2020-06-01 21:15:39 +02:00
Andy Wingo
cb8cabe85f Delay loading CPS unless CPS compiler used
* module/language/tree-il/spec.scm: Remove #:compilers declaration;
  instead rely on choose-compiler.
  (choose-compiler): Load compilers on demand.
* module/system/base/compile.scm (find-language-joint): Use next-pass
  instead of lookup-compilation-order, to avoid loading unused
  compilers.
  (read-and-compile): Adapt to find-language-joint change.
  (compute-compiler): Export.
* module/scripts/compile.scm (compile): Use compute-compiler to load
  compiler modules.
2020-05-12 09:54:19 +02:00
Andy Wingo
b5108ccb2a Avoid having "guild compile" load optimizers
* module/language/cps/optimize.scm (cps-optimizations):
* module/language/tree-il/optimize.scm (tree-il-optimizations):
* module/system/base/optimize.scm (available-optimizations): Invert the
  dependency tree to hold the names and default optimization levels in a
  central place instead of in the optimizers.  It moves definitions
  farther from uses, but it avoids us having to load the CPS optimizer
  if we don't need it, which improves bootstrap times.
2020-05-11 15:42:20 +02:00
Andy Wingo
f711ab85b2 Add compiler chooser implementation; fix bugs with previous commit
* module/system/base/compile.scm (next-pass): Invoke the language's
  compiler chooser if there is more than one compiler.
  (compute-compiler): Ensure from and to are languages.
* module/system/base/language.scm (<language>): Add compiler-chooser
  field.
* module/language/brainfuck/spec.scm (choose-compiler, brainfuck):
  Define a compiler chooser.
2020-05-08 22:56:37 +02:00
Andy Wingo
ded883b6f0 Sketch of how to choose different compiler based on -O0
* module/system/base/compile.scm (next-pass, compute-compiler): Allow
  optimization level to determine pass order.
2020-05-08 17:28:55 +02:00
Andy Wingo
4311dc9858 Define new "lowering" phase in compiler
* module/language/cps/compile-bytecode.scm (compile-bytecode):
* module/language/tree-il/compile-bytecode.scm (compile-bytecode):
* module/language/tree-il/compile-cps.scm (compile-cps): Rely on
  compiler to lower incoming term already.
* module/language/tree-il/optimize.scm (make-lowerer): New procedure.
* module/system/base/compile.scm (compute-lowerer): New procedure,
  replaceing add-default-optimizations.
  (compute-compiler): Lower before running compiler.
* module/system/base/language.scm (<language>): Change
  optimizations-for-level field to "lowerer".
* module/scripts/compile.scm (%options, compile): Parse -O0, -O1 and so
  on to #:optimization-level instead of expanding to all the
  optimization flags.
* module/language/cps/optimize.scm (lower-cps): Move here from
  compile-bytecode.scm.
  (make-cps-lowerer): New function.
* module/language/cps/spec.scm (cps): Declare lowerer.
2020-05-08 17:07:56 +02:00
Andy Wingo
e9c0f3071d Warning and optimization levels always small integers
* module/language/tree-il/analyze.scm (make-analyzer): Expect an int for
  optimization level.
* module/scripts/compile.scm (%options, show-warning-help): No more
  -Wnone / Wall; use -W0 or -W9 instead.
* module/system/base/compile.scm (level-validator): Validate small int.
  (compute-analyzer, add-default-optimizations): Likewise.
* test-suite/tests/optargs.test (without-compiler-warnings):
* test-suite/tests/tree-il.test (call-with-warnings): Parameterize level
  to 0, not #f.
* bootstrap/Makefile.am (GUILE_WARNINGS): Use -W0, not -Wnone.
2020-05-08 16:35:04 +02:00
Andy Wingo
116f94d661 Add language-specific analysis pass to compiler infrastructure
* module/system/base/compile.scm (compute-analyzer): Compute analyzer to
  run on expressions before the compiler runs.
  (add-default-optimizations): Flesh out; still a stub.a
  (read-and-compile, compile, compile-and-load, compile-file): Default
  warning and optimization levels.
  (default-warning-level): New parameter, defaulting to 1.
  (default-optimization-level): New parameter, defaulting to 2.
  Currently unused.
* module/system/base/language.scm (<language>): Add
  optimizations-for-level and analyzer fields.
* module/language/tree-il/compile-bytecode.scm (compile-bytecode):
* module/language/tree-il/compile-cps.scm (optimize-tree-il): No need to
  run warnings passes here; compilers infrastructure will run them.
* module/language/tree-il/spec.scm (tree-il): Define make-analyzer as
  analyzer.
* module/language/tree-il/analyze.scm (make-analyzer): New exported
  procedure.
  (%warning-passes): New private variable.
* .dir-locals.el: Add with-test-prefix/c&e indent mode.
* test-suite/tests/cross-compilation.test:
* test-suite/tests/optargs.test:
* test-suite/tests/tree-il.test: Adjust to disable default warnings.
2020-05-08 15:39:41 +02:00
Andy Wingo
c8c19f2ef3 Add #:optimization-level, #:warning-level compile keyword args
* module/system/base/compile.scm (compile-file, compile-and-load)
  (read-and-compile, compile): New #:optimization-level, #:warning-level
  keyword args.
  (compute-analyzer, add-default-optimizations, compute-compiler): Add
  infra for pass-specific optimizations for a level.  Not yet wired up.
2020-05-08 12:17:30 +02:00
Andy Wingo
52f308e272 Rework compile-fold
Instead of returning a list of passes, returns a closure that does it
all.

* module/system/base/compile.scm (compute-compiler): New function.
  (read-and-compile, compile): Use compile-compiler.
2020-05-08 11:49:01 +02:00
Andy Wingo
6bb996ec66 Use more `match' in (system base compile)
* module/system/base/compile.scm (validate-options): New helper.
  (compile-file, compile-and-load, compile): Call the new helper.
  (compile-passes, compile-fold, find-language-joint):
  (default-language-joiner, decompile-passes, decompile-fold): Use more
  "match".
2020-05-08 10:12:33 +02:00
Andy Wingo
cdb9030f45 Slight (system base compile) refactor
* module/system/base/compile.scm (call-once): Use when instead of if.
2020-05-07 21:22:26 +02:00
Andy Wingo
f38735ffc6 Remove compilation order cache
* module/system/base/language.scm (define-language): Remove
  invalidate-compilation-cache! call.
  (invalidate-compilation-cache!): Deprecate.
  (*decompilation-cache*, *compilation-cache*): Remove.
  (lookup-compilation-order, lookup-decompilation-order): Don't use a
  cache.
  (*current-language*): Only define this when deprecation is enabled.
2020-05-07 21:16:13 +02:00
Andy Wingo
457bc9f1d3 Update (system base compile) header
* module/system/base/compile.scm (system): Clean up imports.
2020-05-05 22:15:46 +02:00
Andy Wingo
f116bd1009 make-record-type does more validation on the fields
* module/ice-9/boot-9.scm (make-record-type): Validate that the fields
  are a unique list of symbols.  Deprecate passing a string as a type
  name.
* module/system/base/syntax.scm (define-record): Update to pass a symbol
  as a type name.
* test-suite/tests/records.test (rtd-foo, rtd-fŏŏ, "records"): Adapt to
  make record types with symbol names.
2019-10-23 14:42:29 +02:00
Ludovic Courtès
c6f70e4b04 Add -Wshadowed-toplevel.
* module/language/tree-il/analyze.scm (shadowed-toplevel-analysis): New
variable.
* module/language/tree-il/compile-cps.scm (%warning-passes): Add it.
* module/system/base/message.scm (%warning-types): Add it.
* test-suite/tests/tree-il.test ("warnings")["shadowed-toplevel"]: New
test prefix.
* module/ice-9/boot-9.scm (%auto-compilation-options): Add it.
* doc/ref/api-evaluation.texi (Compilation): Add 'shadowed-toplevel' and
'macro-use-before-definition'.
2018-08-07 12:34:32 +02:00
Ludovic Courtès
5f75df03c6 types: Recognize 'scm_t_port_type' and decode port type name.
* module/system/base/types.scm (read-c-string, inferior-port-type): New
procedures.
(inferior-port): Use 'inferior-port-type' to determine the port type.
(cell->object): Rename 'flags+type' to 'flags' in the '%tc7-port' case.
* test-suite/tests/types.test ("opaque objects"): Adjust port testse.
(test-inferior-ports): New macro.
("ports"): New test prefix.
2018-08-07 12:13:45 +02:00
Mark H Weaver
a72e296176 elisp: Fix cross-compilation support.
* module/system/base/target.scm (with-native-target): New exported
procedure.
* module/language/elisp/spec.scm: In the top-level body expression, call
'compile-and-load' within 'with-native-target' to compile native code.
* module/language/elisp/compile-tree-il.scm
(eval-when-compile, defmacro): Compile native code.
2018-08-07 12:07:18 +02:00
Shea Levy
2662cafd6a Recognize RISC-V compilation targets.
* module/system/base/target.scm (cpu-endianness): Add case for "riscv" variants.

Signed-off-by: Shea Levy <shea@shealevy.com>
Signed-off-by: Mark H Weaver <mhw@netris.org>
2018-08-07 11:40:46 +02:00
Andy Wingo
dff85f6f9f Explode atomic box ops to new atomic instructions
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Add C8_S24
  word type.
* libguile/vm-engine.c (UNPACK_8_24): New helper.
  (atomic-scm-ref/immediate, atomic-scm-set!/immediate)
  (atomic-swap-scm!/immediate, atomic-scm-compare-and-swap!/immediate):
  New instructions.
  (make-atomic-box, atomic-box-ref, atomic-box-set!, atomic-box-swap!)
  (atomic-box-compare-and-swap!): Disable these ops.
* module/language/bytecode.scm (compute-instruction-arity): Add C8_S24
  support.
* module/system/vm/assembler.scm: Add C8_S24 support.  Export assemblers
  for new opcodes.
* module/system/vm/disassembler.scm (disassembler): Support C8_S24.
* module/language/cps/compile-bytecode.scm (compile-function): Replace
  old atomic-box assemblers with the new instructions.
* module/language/cps/effects-analysis.scm (annotation->memory-kind):
* module/language/cps/types.scm (annotation->type): Add cases for atomic
  boxes.  Mark as all memory kinds because atomic ops serialize memory
  accesses.
* module/language/tree-il/compile-cps.scm (make-atomic-box):
  (ensure-atomic-box, atomic-box-ref, atomic-box-set!):
  (atomic-box-swap!, atomic-box-compare-and-swap!): Explode these ops to
  more basic instructions.
* module/system/base/types/internal.scm (%tc7-atomic-box): Add forgotten
  export.
2018-04-13 10:09:56 +02:00
Andy Wingo
41689edfc3 Slim heap-allocated flonums
* libguile/numbers.h (struct scm_t_double, struct scm_t_complex): Avoid
  adding an extra padding word on systems with 8-byte pointers.
* module/system/base/types.scm (cell->object): Update to compute correct
  offset of embedded double.
2018-04-10 20:01:52 +02: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
16db934bbc Add (system base optimize) module
* module/system/base/optimize.scm: New module.
* module/Makefile.am (SOURCES):
* am/bootstrap.am (SOURCES): Add new module.
* module/language/tree-il/optimize.scm (tree-il-optimizations): Rename
  from tree-il-default-optimization-options.  Directly specify the
  optimization level at which a pass should be enabled.
* module/language/cps/optimize.scm (cps-optimizations): Likewise, rename
  from cps-default-optimization-options.
* module/scripts/compile.scm (%options, show-optimization-help): Adapt
  to use new module.
2018-01-05 10:19:54 +01:00
Andy Wingo
f75d0adc3f Fix mismatch between CPS and Scheme "complex?" predicate
* 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?".
2017-12-27 15:46:31 +01:00
Andy Wingo
82b57d113c Merge until 81d2e35266 from stable-2.2 2017-11-29 21:10:25 +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
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
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
b4db70854b Rename "number" tag to "heap-number"
* 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.
2017-10-29 14:07:25 +01:00
Andy Wingo
0a9fa88a85 Refactor (system base types internal) to use more macros
* 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.
2017-10-29 10:05:20 +01:00
Andy Wingo
38c6f6fabf Add (system base types internal).
* 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.
2017-10-25 12:55:30 +02:00
Andy Wingo
2f9ad7d9bc Merge stable-2.2 into master
This commit resolves conflicts by removing the deprecated make-struct.
2017-09-22 12:02:25 +02:00
Andy Wingo
dd11b82162 Use make-struct/no-tail instead of make-struct
* module/ice-9/boot-9.scm:
* module/language/cps/effects-analysis.scm:
* module/language/elisp/falias.scm:
* module/language/tree-il.scm:
* module/language/tree-il/primitives.scm:
* module/rnrs/records/procedural.scm:
* module/srfi/srfi-35.scm:
* module/system/base/syntax.scm: Change uses of make-struct to
  make-struct/no-tail.
2017-09-20 22:07:18 +02:00
Andy Wingo
ee5994a517 remove self field of vtables
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT, scm_vtable_index_self):
  Remove "self" field.  Renumber the other fields.
* module/oop/goops.scm (<self-slot>): Remove.
  (fold-class-slots): Adapt for "self" slot removal.  Adapt all users.
  (class-redefinition): Now that there is no "self" slot to update, use
  %modify-instance instead of %modify-class.
* libguile/goops.c (class_self): Remove.
  (scm_sys_modify_class): Remove.
* libguile/goops.h (scm_sys_modify_class): Remove.
* module/rnrs/records/procedural.scm: Import vtable-offset-user.
  Renumber rtd indexes using vtable-offset-user.
* module/srfi/srfi-35.scm (%condition-type-vtable): Remove mention of
  vtable fields.
* module/system/base/types.scm (address->inferior-struct): Adapt for
  different vtable field layout.
2017-09-14 09:49:55 +02:00
Andy Wingo
7e91ff651b Remove indirection in structs
* libguile/gc.c (scm_storage_prehistory): Register struct displacement
  here.
* libguile/goops.c (scm_sys_modify_instance): Fix the format of a
  comment.
* libguile/modules.c (scm_post_boot_init_modules): Update for new format
  of struct vtable references.
* libguile/struct.c (scm_i_alloc_struct): Update to include slots
  directly, instead of being indirected by an embedded pointer.
  (scm_c_make_structv, scm_allocate_struct, scm_i_make_vtable_vtable):
  Adapt to pass vtable bits as argument to scm_i_alloc_struct, not
  vtable data bits.
  (scm_init_struct): Remove two-word displacement from libgc.
* libguile/struct.h: Update comment.
  (SCM_STRUCT_SLOTS, SCM_STRUCT_DATA): Update definitions.
  (SCM_STRUCT_VTABLE_DATA, SCM_STRUCT_VTABLE_SLOTS): Remove.
  (SCM_STRUCT_VTABLE, SCM_STRUCT_LAYOUT, SCM_STRUCT_PRINTER)
  (SCM_STRUCT_FINALIZER, SCM_STRUCT_VTABLE_FLAGS)
  (SCM_STRUCT_VTABLE_FLAG_IS_SET): Simplify definitions.
* module/system/base/types.scm (cell->object, address->inferior-struct):
  Adapt to struct representation change.
2017-09-14 09:44:33 +02:00
Ludovic Courtès
d7778b3d6a types: Hide one of the 'bytevector->string' procedures.
* module/system/base/types.scm: Hide 'bytevector->string' from (rnrs io
ports).
2017-04-14 23:26:41 +02:00
Andy Wingo
64c5cc58fc Add disjoint syntax object type
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
  (DOT_X_FILES, DOT_DOC_FILES, noinst_HEADERS): Add syntax.c and
  syntax.h.
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (class_syntax, scm_class_of, scm_goops_early_init):
* libguile/init.c (scm_init_guile):
* libguile/print.c (iprin1):
* libguile/tags.h (scm_tc7_syntax):
* module/oop/goops.scm (<syntax>):
* module/system/base/types.scm (%tc7-syntax, cell->object):
* module/system/vm/disassembler.scm (code-annotation): Wire up the new
  data type.
* libguile/syntax.c:
* libguile/syntax.h: New files.
* module/ice-9/boot-9.scm: Move new definitions to (system syntax
  internal).
* module/system/syntax.scm (print-syntax): New helper.
* module/system/vm/assembler.scm (statically-allocatable?)
  (intern-constant, link-data): Arrange to be able to write syntax
  objects into images.
* module/language/cps/types.scm (&syntax): New type.  Remove
  &hash-table; it was never detected, an internal binding, and we need
  the bit to avoid going into bignum territory.
2017-03-28 19:23:13 +02:00
Mark H Weaver
84a740d86a psyntax: Generate identifiers in a deterministic fashion.
Fixes <http://bugs.gnu.org/20272>.

* module/ice-9/boot-9.scm (module-generate-unique-id!)
(module-gensym): New procedures.
(module): Add 'next-unique-id' field.
(the-root-module): Inherit 'next-unique-id' value from early stub.
(make-module, make-autoload-interface): Adjust calls to
module-constructor.
* module/ice-9/psyntax.scm (gen-label, new-mark): Generate unique
identifiers from the module name and the per-module unique-id.
(build-lexical-var, generate-temporaries): Use
'module-gensym' instead of 'gensym'.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/language/tree-il/fix-letrec.scm (fix-letrec!): Use
'module-gensym' instead of 'gensym'.
* module/system/base/syntax.scm (define-record): Likewise.
(transform-record): Likewise.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2017-03-07 20:48:40 +01:00