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

20710 commits

Author SHA1 Message Date
Andy Wingo
35cd7fac8b Fix jmp-shortening on x64 when target within instruction.
* lightening/x86.c (jit_try_shorten): If the address is within the
  last instruction, don't shorten.  If the intstruction is a jump, we
  could elide it entirely in some cases, but we don't know if the user
  captured the PC before calling jit_patch_here.  Better to leave this
  to the user.

Thanks to Helmut Eller for the bug report and test case in
https://gitlab.com/wingo/lightening/-/issues/17.
2021-01-07 11:04:17 +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
64c89458e6 Fix source location bug for neoteric exprs introduced by refactoring
* libguile/read.c (scm_read_expression): Ungetc after capturing the
  column.
2020-09-10 22:11:34 +02:00
Andy Wingo
e9c5a1719b Move copy-tree to (ice-9 copy-tree); deprecate main binding
* doc/ref/api-data.texi (List Constructors):
* doc/ref/api-utility.texi (Copying): Update docs to mention module.
* libguile.h: Remove trees.h inclusion.
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
  (DOT_X_FILES, DOT_DOC_FILES, modinclude_HEADERS): Remove trees.c,
  trees.h, and related files.
* libguile/init.c (scm_i_init_guile): Remove trees.h and the
  scm_init_trees call.
* libguile/trees.c:
* libguile/trees.h: Remove.
* module/Makefile.am (SOURCES): Add ice-9/copy-tree.scm.
* module/ice-9/copy-tree.scm: New file.
* module/ice-9/deprecated.scm (copy-tree*): Export as copy-tree,
  proxying to (ice-9 copy-tree).
* module/system/repl/common.scm:
* module/web/client.scm:
* test-suite/tests/elisp.test:
* test-suite/tests/srfi-1.test:
* module/oop/goops/save.scm: Use (ice-9 copy-tree).
* test-suite/Makefile.am (SCM_TESTS): Add copy-tree.test.
* test-suite/tests/copy-tree.test: New file; test pulled from
  eval.test.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_copy_tree): Deprecate.
2020-09-10 21:57:21 +02:00
Andy Wingo
433b701a23 Update NEWS
* NEWS: Update.
* doc/ref/api-evaluation.texi (Scheme Read): Remove copy option.
2020-09-05 22:23:17 +02:00
Andy Wingo
6f6abb3bb5 Clean up srcprops implementation
* libguile/deprecated.c (scm_sym_copy, scm_make_srcprops): Deprecate.
* libguile/deprecated.h (scm_tc16_srcprops)
  (SCM_SOURCE_PROPERTY_FLAG_BREAK): Deprecate.
* libguile/private-options.h (SCM_COPY_SOURCE_P): Remove.
* libguile/read.c (struct t_read_opts, scm_read_options): Remove useless
  copy read option.
  (maybe_annotate_source): Change line and column to be tagged, and
  subtract off lookahead here.  Change all callers.
  (READ_OPTION_COPY_SOURCE_P): Remove, renumbering other options.
  (init_read_options): Remove copy option.
* libguile/srcprop.c: Change to put filename inline in source
  properties.  Update private implementation.
* libguile/srcprop.h (SCM_PROCTRACEP): Remove.  Unusable given that
  scm_sym_trace was undefined.
2020-09-03 22:55:08 +02:00
Andy Wingo
837580587b Tweak to initial heap size selection
* libguile/gc.c (DEFAULT_INITIAL_HEAP_SIZE): Bump a bit farther (2 MB on
  64-bit, 1 MB on 32-bit) as we now expand to this size instead of
  expanding by this amount.
  (scm_storage_prehistory): Expand to the initial heap size instead of
  expanding by the size.
2020-08-27 14:18:44 +02:00
Andy Wingo
fdea77d01c Bump DEFAULT_INITIAL_HEAP_SIZE
* libguile/gc.c (DEFAULT_INITIAL_HEAP_SIZE): Bump to 1.6 MB on 64-bit
  targets, or 800 kB on 32-bit targets, to account for increased
  footprint.  Prevents useless early GC.
  (scm_storage_prehistory): Remove unused code to dynamically change the
  free space divisor.
2020-08-27 14:07:01 +02:00
Andy Wingo
c8c67eba91 Bump objcode minor version to 4
* libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): Accept up to version 4.
* module/system/vm/assembler.scm (*bytecode-minor-version*): Produce
  version 4.
2020-08-26 21:46:42 +02:00
Andy Wingo
8b994be59f CSE computes online map of constant values, uses it to fold branches
* module/language/cps/cse.scm (intset-intersect*): New helper.  Use it
  to replace manual uses.
  (lset-unionq, meet-constants, adjoin-constant, set-constants): New
  helpers.
  (compute-consts): New function, to compute constants at each label,
  using not only definitions but flow.
  (<analysis>): Add consts to analysis.
  (elide-predecessor, prune-branch, forward-branch, compute-out-edges)
  (propagate-analysis, eliminate-common-subexpressions-in-fun): Plumb
  consts through the algorithm.
  (fold-branch): Fold an eq-constant? using the flow-determined constant
  info.  Finally allows compile-bytecode to fold to switch statements!
* module/language/cps/optimize.scm (optimize-first-order-cps): Move
  branch chain optimization before the final CSE/DCE pass.
2020-08-26 10:04:20 +02:00
Ludovic Courtès
449f50dd84 meta: Increment serial number in 'guile.m4'.
* meta/guile.m4: Bump "serial", for all the changes made since commit
5ad3881631 (2010).
2020-08-24 15:19:14 +02: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
cd5ab6377b Add $switch CPS term kind
* module/language/cps.scm ($switch): New term.
* doc/ref/compiler.texi (CPS in Guile): Add documentation.

* module/language/cps.scm (build-term, parse-cps, unparse-cps)
* module/language/cps/closure-conversion.scm (compute-non-operator-uses)
  (compute-singly-referenced-labels, rewrite-shared-closure-calls)
  (compute-free-vars, convert-one)
* module/language/cps/compile-bytecode.scm (compile-function)
* module/language/cps/contification.scm (compute-singly-referenced-labels)
  (compute-contification-candidates, apply-contification)
* module/language/cps/cse.scm (compute-truthy-expressions)
  (forward-cont, term-successors, eliminate-common-subexpressions-in-fun)
* module/language/cps/dce.scm (compute-known-allocations)
  (compute-live-code, process-eliminations)
* module/language/cps/devirtualize-integers.scm (compute-use-counts)
  (peel-trace)
* module/language/cps/effects-analysis.scm (compute-effects)
* module/language/cps/licm.scm (hoist-one, hoist-in-loop)
* module/language/cps/loop-instrumentation.scm (compute-loop-headers)
* module/language/cps/peel-loops.scm (rename-cont)
* module/language/cps/renumber.scm (sort-labels-locally, renumber)
* module/language/cps/rotate-loops.scm (rotate-loop)
  (rotate-loops-in-function)
* module/language/cps/self-references.scm (resolve-self-references)
* module/language/cps/simplify.scm (compute-singly-referenced-vars)
  (eta-reduce, compute-singly-referenced-labels, beta-reduce)
* module/language/cps/slot-allocation.scm (compute-defs-and-uses)
  (add-prompt-control-flow-edges, compute-var-representations)
* module/language/cps/specialize-numbers.scm (compute-significant-bits)
* module/language/cps/split-rec.scm (compute-free-vars)
* module/language/cps/type-fold.scm (local-type-fold)
* module/language/cps/types.scm (successor-count, infer-types)
* module/language/cps/utils.scm (compute-function-body)
  (compute-successors, compute-predecessors)
* module/language/cps/verify.scm (compute-available-definitions)
  (check-valid-var-uses, check-arities): Add support for new term.
2020-08-12 23:30:08 +02:00
Andy Wingo
a7f4a6f1c4 Fold eqv? to eq? on exact integers according to target fixnum range
* module/language/tree-il/peval.scm (peval): Fix folding to only reduce
  to eq? for values within both host and target range.
2020-08-12 23:30:08 +02:00
Andy Wingo
feafad7958 Fix JIT compilation for jtable
* libguile/jit.c (compile_jtable): Fix bounds check for index.
2020-08-12 23:30:08 +02:00
Daniel Llorens
de5d1a7f99 Fix bug #42713: srfi-64: Reset test-runner-current if done
Reported by Jérémy Korwin-Zmijowski
(https://lists.gnu.org/archive/html/bug-guile/2020-08/msg00010.html).

Fix from
7cf4c01039:

Apply fix from Per Bothner.

In Per's words:

  * testing.scm (%test-end): Reset test-runner-current if done.
  This fixes bug "Loading test source file multiple time without having
  report incrementing" reported to srfi-64 mailing list.

  * srfi-64-test.scm: Update due to recent srfi-64 implementation change.
2020-08-05 12:46:27 +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
1ee99d97db Baseline compiler emits eq-immediate? as appropriate
* module/language/tree-il/compile-bytecode.scm (eq?): Define
  eq-immediate? as immediate emitter.
  (canonicalize): Don't fuss so much about eq?; only if commutation is
  needed.  (Perhaps a more generic commutation pass is needed.)
  (compile-closure): Add support for emit/immediate for branches.
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
8366634db7 Add eq-immediate? instruction
* libguile/jit.c (compile_eq_immediate, compile_eq_immediate_slow): Add
  JIT compiler.
* libguile/vm-engine.c (eq_immediate): New instruction.
* doc/ref/vm.texi (Comparison Instructions): Document.
* module/system/vm/assembler.scm (encode-X8_S8_ZI16!/shuffle): New
  shuffler.
* module/system/vm/disassembler.scm (code-annotation): Add eq-immediate?
  case.
2020-08-03 22:19:12 +02:00
Andy Wingo
172e5ccfc1 Add sign-extending make-immediate instruction
* doc/ref/vm.texi (Instruction Set, Constant Instructions): Document new
  instruction.
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): New first
  word kind with zi16 operand.
* libguile/jit.c (compile_make_immediate, compile_make_immediate_slow):
  New compilers.
  (COMPILE_X8_S8_ZI16): New operand kind.
* libguile/vm-engine.c (make-immediate): New instruction.
* module/language/bytecode.scm:
* module/system/vm/assembler.scm (encode-X8_S8_ZI16<-/shuffle):
  (signed-bits, load-constant): Support the new instruction kind.
* module/system/vm/disassembler.scm (disassemblers)
  (sign-extended-immediate, code-annotation): Support for zi16
  operands.
2020-07-30 17:36:11 +02:00
Andy Wingo
f13b27a4cc Improve code generation for eq? on immediates
* module/language/tree-il/compile-bytecode.scm (canonicalize):
* module/language/tree-il/compile-cps.scm (canonicalize): Specialize
  eq-false? and similar predicates.
2020-07-30 16:30:23 +02:00
Andy Wingo
aa44a71750 Merge https://gitlab.com/wingo/lightening master branch 2020-07-30 14:34:52 +02:00
Andy Wingo
8b37b783ea Merge branch 'word-spills' into 'master'
Spill whole words to stack, even for uint8_t args

Closes #15

See merge request wingo/lightening!11
2020-07-30 12:34:20 +00:00
Andy Wingo
2784bee8e5 Spill whole words to stack, even for uint8_t args
* lightening/lightening.c (abi_gpr_to_mem): Write whole words when
  spilling GPRs to the stack.  Always correct given that all Lightening
  operations that write GPRs write the whole register, and the current
  ABI targets allow writing the extra words.  Closes #15.
2020-07-30 14:26:37 +02:00
Andy Wingo
2aa05ff3c4 Update use of jit_begin_data API
* libguile/jit.c (compile_jtable): Pass computed jump table size.
2020-07-30 14:12:26 +02:00
Andy Wingo
d4e730a458 Merge https://gitlab.com/wingo/lightening master branch 2020-07-30 14:11:26 +02:00
Andy Wingo
ca35ac9a4b Merge branch 'word-align-literal-pools' into 'master'
Literal pools have word-alignment, not u64-alignment

See merge request wingo/lightening!10
2020-07-30 12:09:24 +00:00
Andy Wingo
ca1cc01cdf Literal pools have word-alignment, not u64-alignment
Prevents useless over-alignment for ARM.

* lightening/lightening.c (struct jit_literal_pool_entry): Value is a
  uintptr_t.
  (emit_uintptr): New helper.
  (emit_abs_reloc): Use new helper.
  (patch_pending_literal): Value is a uintptr_t.
  (emit_literal_pool): Adapt to literal entry being uintptr_t.
2020-07-30 14:04:47 +02:00
Andy Wingo
a6fc30d810 Merge branch 'size-data' into 'master'
Allow jit_begin_data to declare max data size

See merge request wingo/lightening!9
2020-07-30 11:44:44 +00:00
Andy Wingo
44b07aef4b Allow jit_begin_data to declare max data size
* lightening.h:
* lightening/lightening.c (jit_begin_data): Add max data size
  parameter.  If nonzero, can allow the JIT to avoid prematurely
  emitting a constant pool.
  (jit_end_data): Allow pending literals.
* tests/jmp_table.c (run_test): Use new API.
2020-07-30 13:41:02 +02:00
Andy Wingo
5342eb542f Add JIT implementation for jtable
* libguile/jit.c (compile_jtable): Implement.
2020-07-30 13:26:12 +02:00
Andy Wingo
439e93a5ed Merge https://gitlab.com/wingo/lightening master branch 2020-07-30 13:07:02 +02:00
Andy Wingo
644ee3a37f Merge branch 'table-switch' into 'master'
Add support for emitting inline data and table switches

See merge request wingo/lightening!6
2020-07-30 11:06:08 +00:00
Andy Wingo
91c1591e41 Add support for emitting inline data and table switches
* lightening.h:
* lightening/lightening.c (jit_begin_data, jit_end_data)
  (jit_emit_u8, jit_emit_u16, jit_emit_u32, jit_emit_u64): Add new raw
  data-emitting primitives, bracketed by begin/end so that we can flush
  constant pools first, if needed.
* lightening/lightening.c (struct jit_state): Add new emitting_data
  flag.
  (jit_begin, jit_reset, jit_end): Handle the new flag.
  (emit_abs_reloc): Move here, from x86.c.
* lightening/x86.c (emit_abs_reloc): Remove.
  (jit_try_shorten): Don't shorten if loc == start; could be raw data.
* tests/jmp_table.c: New test.
2020-07-30 13:02:46 +02:00
Andy Wingo
7b4840d7df Merge branch 'fix-tail-call-test' into 'master'
Ensure tail caller and callee in jmpi test have compatible ABI

See merge request wingo/lightening!8
2020-07-30 10:01:28 +00:00
Andy Wingo
6c7813a05f Ensure tail caller and callee in jmpi test have compatible ABI
* tests/jmpi.c: Emit the tail callee using the JIT, to ensure that it
  saves and restores registers in the same way as the caller.  Fixes
  #16.
2020-07-30 11:52:57 +02:00
Andy Wingo
56d92850c6 Merge branch 'fix-aarch64-veneers' into 'master'
Fix patch_veneer on aarch64

See merge request wingo/lightening!7
2020-07-30 09:19:39 +00:00
Andy Wingo
b2ef1d5fba Fix patch_veneer on aarch64
* lightening/aarch64.c (patch_veneer): Fix absolutely bogus patch_veneer
  implementation.
2020-07-30 11:17:46 +02:00
Andy Wingo
bb7fa5bdc2 Add jtable instruction
* doc/ref/vm.texi (Instruction Set): Document new v32-x8-l24 instruction
  kind.
  (Branch Instructions): Document jtable.
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Add
  V32_X8_L24.
* libguile/jit.c (compile_jtable, compile_jtable_slow):
  (COMPILE_X8_S24__V32_X8_L24, analyze): Add stub JIT compiler
  implementation.
* libguile/vm-engine.c (jtable): New instruction.
* module/language/bytecode.scm (instruction-arity): Deprecate.
* module/system/vm/assembler.scm (encoder, assembler): Add V32_X8_L24
  case.
* module/system/vm/disassembler.scm (u32-ref, s32-ref): Move definitions
  to expansion-time only.
  (define-op-handlers): New definition, replacing visit-opcodes.
  (disassemblers, jump-parsers, stack-effect-parsers, clobber-parsers):
  Rework in terms of define-op-handlers.  Default case becomes #f, and
  add support for jtable.
  (disassemble-one, instruction-relative-jump-targets)
  (instruction-stack-size-after, instruction-slot-clobbers): Inline
  default case in the lookup procedure, not copied in the handler
  vector.
  (compute-labels): Add jtable case.
  (instruction-lengths-vector, instruction-length): Rework to allow
  variable-length instructions, and mark jtable as being
  variable-length.
  (instruction-has-fallthrough?): Add jtable to the no-fallthrough
  set.
2020-07-23 12:24:11 +02:00
Ludovic Courtès
5e1748f751 Update NEWS.
* NEWS: Update.
2020-06-24 15:42:12 +02:00
Ludovic Courtès
4e8ead96f7 GNU Guile 3.0.4 (SONAME fix).
* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
(LIBGUILE_INTERFACE_CURRENT): Increment.
(LIBGUILE_INTERFACE_REVISION): Reset.
(LIBGUILE_INTERFACE_AGE): Increment.  This accounts for commit, which
adds a new symbol to the ABI.
2020-06-24 15:30:55 +02:00
Ludovic Courtès
1b2be93d6e Revert "GNU Guile 3.0.3."
This change suggested an ABI incompatibility that's not there for normal
builds:

  https://lists.gnu.org/archive/html/guile-user/2020-06/msg00059.html

Reported by Chris Vine.

This reverts commit 5d052c87bd.
2020-06-24 15:30:47 +02:00
Ludovic Courtès
5d052c87bd GNU Guile 3.0.3.
* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
(LIBGUILE_INTERFACE_CURRENT): Increment.
(LIBGUILE_INTERFACE_REVISION, LIBGUILE_INTERFACE_AGE): Reset.
This accounts for commit b517a91ba4 and
similar, which remove C functions in '--disable-deprecated' builds.
2020-06-21 22:17:20 +02:00
Ludovic Courtès
492717db95 Update NEWS.
* NEWS: Update.
2020-06-21 22:17:20 +02:00
Ludovic Courtès
3523ad1326 Update NEWS.
* NEWS: Update.
2020-06-21 15:11:43 +02:00
Ludovic Courtès
7e814190e3 Merge upstream 'lightening'
* libguile/lightening: Merge from https://gitlab.com/wingo/lightening,
commit 24ef197b12.
2020-06-21 15:04:32 +02:00
Dale P. Smith
24ef197b12 Add 'movi' test.
This is a followup to 1bb909a44d.  It
reproduces the bug that 1bb909a44d fixes
on ARMv7.

* tests/movi.c: New file.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2020-06-20 16:34:37 +02:00
Ludovic Courtès
e20ca01d9b tests: Remove 'glibc' from the 'guix environment' command line.
* tests/Makefile (CC_IA32, CC_AARCH64, CC_ARMv7): Remove 'glibc' from
the 'guix environment' command line since it's redundant with
'gcc-toolchain'.
2020-06-20 16:14:10 +02:00
Ludovic Courtès
e3d9bdf03f tests: Make 'TARGETS' overridable.
This allows users to run "make TARGETS=armv7", for instance.

* tests/Makefile (TARGETS): Make it overridable.
2020-06-20 16:13:16 +02:00