summaryrefslogtreecommitdiff
path: root/module
AgeCommit message (Collapse)AuthorFilesLines
2024-04-23Tree-IL lowerer has #:dump-optimized-tree-il? optionAndy Wingo1-4/+19
* module/language/tree-il/optimize.scm (make-optimizer): If the keyword argument #:dump-optimized-tree-il? is present, print the Tree-IL that will be handed to the next compiler. Also re-enable #:verify-tree-il?.
2024-04-16linker: Create a sparse file only when writing to a file port.Ludovic Courtès1-5/+16
Fixes a regression introduced in 4a0c2433d97be9d995b3be74d90bc074d8efb5a7: the strategy wouldn’t work when writing to, say, a bytevector output port. * module/system/vm/linker.scm (link-elf)[write-padding]: Reintroduce loop for when PORT is not a file port. Remove first argument.
2024-04-15‘seek’ now accepts ‘SEEK_DATA’ and ‘SEEK_HOLE’ where supported.Ludovic Courtès1-1/+7
* libguile/ports.c (scm_seek): Let SEEK_DATA and SEEK_HOLE through. (scm_init_ice_9_ports): Define ‘SEEK_DATA’ and ‘SEEK_HOLE’. * module/ice-9/ports.scm: Export ‘SEEK_DATA’ and ‘SEEK_HOLE’ when defined. * test-suite/tests/ports.test ("size of sparse file") ("SEEK_DATA while on data", "SEEK_DATA while in hole") ("SEEK_HOLE while in hole"): New tests. * NEWS: Update.
2024-04-15linker: Create sparse files for padding.Ludovic Courtès1-10/+4
Since ‘*lcm-page-size*’ is 64 KiB, this saves disk space for small ‘.go’ files. * module/system/vm/linker.scm (link-elf)[write-padding]: Rewrite in terms of ‘seek’.
2024-04-13SRFI-19: Add support for ISO 8601 zones with a colon.Denis 'GNUtoo' Carikli1-0/+2
* module/srfi/srfi-19.scm (zone-reader): handle a colon in the zone. * test-suite/tests/srfi-19.test (SRFI date/time library test): Add test. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> [rlb@defaultvalue.org: adjust commit message; add NEWS]
2024-04-05eval-string: set port column to column, not lineNikita Domnitskii1-1/+1
* module/ice-9/eval-string.scm: set column to column, not line.
2024-03-20Fix effects analysis: field writes clobber object readsAndy Wingo1-31/+69
* module/language/cps/effects-analysis.scm (compute-clobber-map): Previously a whole-object read would not be clobbered by a specific field write. This crops up for the &read introduced at the site of `cons` for the synthetic car and cdr definitions. This error was there before but didn't cause bugs before 3.0.10 because cons got eagerly lowered to separate allocation and initialization instructions.
2024-03-18Fix inlinable-exports serialization for kwargsAndy Wingo2-3/+3
* module/language/tree-il/inlinable-exports.scm (inlinable-exp): Call assq-ref in the right order. Embarrassing! * module/language/tree-il/peval.scm (peval): Print the symbols so that we can diagnose later failures.
2024-03-17Expose read-c-struct, write-c-struct syntaxAndy Wingo1-12/+14
* module/system/foreign.scm (read-c-struct): Rename from read-fields. Export. (write-c-struct): Rename from write-fields. Export. (%write-c-struct, %read-c-struct): Add % prefix to these private bindings.
2024-03-17Rework read-fields, write-fields to not return offsetAndy Wingo1-14/+20
* module/system/foreign.scm (read-fields, write-fields): Don't return the final offset, as the offset after the final field is not necessarily the end of the struct, because of padding.
2024-03-17Remove vestigial code from srfi-9Andy Wingo1-7/+1
* module/srfi/srfi-9.scm (%define-record-type): No need to define record-layout.
2024-03-17Rework make-c-struct, parse-c-structAndy Wingo1-80/+152
* module/system/foreign.scm (bytevector-complex-single-native-ref) (bytevector-complex-single-native-set!) (bytevector-complex-double-native-ref) (bytevector-complex-double-native-set!): Be more static in our definitions. (compile-time-eval): (switch/compile-time-keys): New helpers. (align): Make available at compile-time. (read-field, read-fields, write-field, write-fields): New helpers. More efficient than the alist. (write-c-struct, read-c-struct): Rework in terms of new helpers. (parse-c-struct): Just use sizeof to get the size.
2024-03-17(scheme foreign): API is less configuration-dependentAndy Wingo1-29/+23
* libguile/foreign.h: * libguile/foreign.c: Always define complex-float and complex-double. Fall back to alignof float / 2*sizeof float if no complex numbers. (But with C99 surely it exists everywhere.) * module/system/foreign.scm (*writers*, *readers*): Always include complex-float and complex-double readers and writers. * test-suite/tests/foreign.test: Always run the complex tests.
2024-03-17(system base target) doesn't load (system foreign)Andy Wingo1-3/+11
* module/system/base/target.scm (%native-word-size): Use most-positive-fixnum instead of importing (system foreign).
2024-03-13peval: Indenting. NFC.Andy Wingo1-25/+25
* module/language/tree-il/peval.scm (peval): Reindent.
2024-03-13peval: Enable inlining for functions with kwargsAndy Wingo1-163/+265
* module/language/tree-il/peval.scm (peval): Handle all lambda inlining the same, and extend with support for multiple clauses and keyword arguments. * test-suite/tests/peval.test ("case-lambda"): Enable kwarg inlining.
2024-03-13New optimization: demux-lambdaAndy Wingo3-2/+129
Can help reduce case-lambda* / lambda* at Tree-IL optimization-time. * module/language/tree-il/demux-lambda.scm: New file. * am/bootstrap.am (SOURCES): Add new file. * module/language/tree-il/optimize.scm (make-optimizer): * module/system/base/optimize.scm (available-optimizations): Enable demux-lambda at level 2.
2024-02-20Macro-introduced top-level vars scope to their module even if unboundAndy Wingo2-56/+46
* module/ice-9/psyntax.scm (analyze-variable): Previously, a reference to a top-level variable in a module other than the current module would be silently rewritten to reference the current module, if the variable was unbound in its original module. This was a hack from the early days of when we extended psyntax to know about the module system. Fix to properly use the scope of the introduced binding instead of the scope of the macro use site. * test-suite/tests/syntax.test ("macro-introduced cross-module unbound identifiers"): Add test. * module/ice-9/psyntax-pp.scm: Regenerate.
2024-02-20Regenerate psyntax-pp.scmAndy Wingo1-3376/+2864
* module/ice-9/psyntax-pp.scm (syntax?): Regenerate. With the modified pretty-printer, things are a bit different.
2024-01-29Match on correct argument in make-custom-portJonas Hahnfeld1-1/+1
* module/ice-9/custom-ports.scm (make-custom-port): Match on correct argument for conversion strategy. * NEWS: Update. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-01-29Fix loading of custom-ports extensionJonas Hahnfeld1-1/+1
* module/ice-9/custom-ports.scm: Load extension also in expand and eval. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-01-29ftw: Fix getuid-or-false, getgid-or-false macros.Tomas Volf1-2/+2
Both macros were missing a quote for the procedure call, causing the actual return value to be compiled into the ftw.go, instead of the procedure call. Snippet from disassembly of ftw.go does confirm that: 55 (make-immediate 2 3990) ;; 997 at ice-9/ftw.scm:319:46 56 (make-long-immediate 1 120002) ;; 30000 at ice-9/ftw.scm:320:46 That effectively prevented ftw from entering directories without access for others. Simple reproduction: scheme@(guile-user)> ,use (ice-9 ftw) scheme@(guile-user)> (mkdir "/tmp/xxxx") scheme@(guile-user)> (chmod "/tmp/xxxx" #o0700) scheme@(guile-user)> (ftw "/tmp/xxxx" (lambda (_ __ f) (pk f) #t)) ;;; (directory-not-readable) $1 = #t scheme@(guile-user)> (system "ls -al /tmp/xxxx") total 0 drwx------ 1 wolf wolf 0 Oct 11 22:54 . drwxrwxrwt 1 root root 888 Oct 11 22:54 .. $2 = 0 The fix is to quote the procedure call, leading to the intended behavior. Fixes <https://bugs.gnu.org/55344>. * module/ice-9/ftw.scm (getuid-or-false): Quote the (getuid). (getgid-or-false): Quote the (getgid). * NEWS: Update. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-01-29default-frame-width is a parameterAndy Wingo1-3/+6
* module/system/repl/debug.scm (default-frame-width): A parameter instead of a fluid. (print-frames): Adapt use.
2024-01-29Ensure macro-introduced top-level identifiers are uniqueAndy Wingo1-11/+29
* module/ice-9/psyntax.scm (expand-top-sequence): When making a fresh name for an introduced identifier, the hash isn't enough: it's quite possible for normal programs to have colliding hash values, because Guile's hash functions on pairs doesn't traverse the whole tree. Therefore, append a uniquifying counter if the introduced name is already defined in the current expansion unit. * test-suite/tests/syntax.test ("duplicate top-level introduced definitions"): Add test.
2024-01-25Fix asymetric mutex locking when joining thread.Olivier Dion1-1/+3
If `join-thread' timeout, the thread mutex is not unlocked, resulting in deadlock to the next call to it or deadlock of the thread itself when it terminates. Thus, always unlock the mutex. Fixes <https://bugs.gnu.org/55356>. * module/ice-9/threads.scm (join-thread): Always unlock thread mutex. * test-suite/tests/threads.test (join-thread): New test to ensure the mutex is released. * NEWS: Update. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-01-24Bump user-visible copyright years to 2024.Ludovic Courtès3-6/+6
* module/ice-9/command-line.scm (version-etc): * module/scripts/compile.scm (show-version): * module/system/repl/common.scm (*version*): Bump to 2024.
2023-12-28debug: Print wider stack frames when not writing to a tty.Ludovic Courtès1-2/+12
This satisfies a longstanding complaint that Guile backtraces were being truncated too much by default (72 columns), often hindering debugging. * module/system/repl/debug.scm (default-frame-width): New variable. (print-frames): Change default #:width value depending on whether PORT is a tty.
2023-11-27Recognize append as a primcall and optimize itAndy Wingo2-2/+37
* module/language/tree-il/primitives.scm (*primitive-constructors*): (append): Recognize append and reduce it to only the two-operand form. * module/language/tree-il/peval.scm (peval): Add optimizations to append.
2023-11-27Avoid swallowing errors for (values) operands of elided primcallsAndy Wingo1-9/+12
* module/language/tree-il/peval.scm (peval): When visiting (values) in anything other than an effect or values context, residualize (values (values)), which will cause a run-time error. * test-suite/tests/peval.test ("values"): Add test.
2023-11-23Unbound vars fixupAndy Wingo1-1/+2
* module/language/tree-il/compile-cps.scm (%box-ref): Fix untested bug. The peril of a compiler spanning modules...
2023-11-23Allow targets to preclude unbound variablesAndy Wingo2-13/+32
Allowing variables to hold an unbound value and requiring a check on each load is suboptimal; the fixing letrec boolean check is better. So other runtimes (hoot) might preclude unbound variables by construction. Allow them to do so. * module/language/cps/guile-vm.scm (target-has-unbound-boxes?): New definition. * module/language/tree-il/compile-cps.scm (target-has-unbound-boxes?): (%box-ref): Only residualize an unbound check if the target has unbound boxes.
2023-11-23prompts avoid introducing throw; fixup peval testAndy Wingo1-6/+3
* test-suite/tests/peval.test ("partial evaluation"): Fix to expect raise-type-error from dynwind peval. Update prompt expectation similarly. * module/language/tree-il/primitives.scm (call-with-prompt): Use raise-type-error.
2023-11-23peval avoids introducing 'throwAndy Wingo3-8/+27
* module/language/tree-il/peval.scm (peval): Introduce raise-type-error for dynwind unwinder thunk check. * module/language/tree-il/compile-cps.scm (raise-type-error): * module/language/tree-il/compile-bytecode.scm (canonicalize): Handle raise-type-error, as it can be in Tree-IL now.
2023-11-23CPS conversion does not introduce "throw"Andy Wingo2-216/+157
This keeps things higher level, and is a step towards structured exceptions in guile. * module/language/cps/guile-vm/reify-primitives.scm (reify-primitives): Turn raise-type-error, raise-range-error, and raise-arity-error into variants of "throw". Lower raise-exception to a non-tail primcall. * module/language/tree-il/compile-cps.scm: Instead of residualizing "throw/value+data" throws, exceptions introduced by CPS lowering are more structured: raise-type-error, raise-range-error, and raise-arity-error. Also, lower raise-exception to an ordinary `$throw` instead of eagerly producing the non-tail call to a $prim.
2023-11-20Fix bug lowering logand/immediate to ulogand/immediateAndy Wingo2-16/+13
* module/language/cps/specialize-numbers.scm (logand/immediate): Define a sigbits handler. (specialize-operations): Require logand/immediate operand to be u64 to lower to ulogand/immediate. Shouldn't be necessary but even if only u64 bits are used, negative fixnums will have the sign bit set, which trips up further unboxed uses which error if the operand to `scm->u64` is negative. * module/language/cps/type-fold.scm (rem): Emit logand/immediate.
2023-11-20Fix mistype in specialize-numbersAndy Wingo1-1/+1
* module/language/cps/specialize-numbers.scm (compute-specializable-u64-vars): We were failing to match scm->u64/truncate.
2023-11-20Allow target runtime to override symbol hashAndy Wingo2-35/+99
Also rework so that the symbol hash uses the low bits instead of high bits. We can do this because, for the guile-vm target, now we compute the full target hash. * module/language/cps/guile-vm.scm (jenkins-lookup3-hashword2): (target-symbol-hash, target-symbol-hash-bits): New exported functions.. * module/language/cps/switch.scm (optimize-branch-chain): Change to use target-symbol-hash and target-symbol-hash-bits from the current target-runtime.
2023-11-20Add logand/immediate, ulogand/immediate primcallsAndy Wingo9-31/+64
* libguile/jit.c (compile_ulogand_immediate, compile_ulogand_immediate_slow) * libguile/vm-engine.c (ulogand_immediate): New JIT and interpreter support for ulogand/immediate. * module/language/cps/guile-vm/lower-primcalls.scm (string-ref): (vtable-vtable?): (vtable-field-boxed?): Emit ulogand/immediate. * module/language/cps/guile-vm/reify-primitives.scm (reify-primitives): Remove logand/immediate. Only emit ulogand/immediate if the immediate is a u8. Refactor mul/immediate. * module/language/cps/specialize-numbers.scm (specialize-operations): Produce ulogand/immediate if the result is a u64. * module/language/cps/effects-analysis.scm: * module/language/cps/types.scm (logand/immediate): Add effect and type inference for logand/immediate, ulogand/immediate, * module/language/cps/utils.scm (primcall-raw-representations): ulogand/immediate makes a u64. * module/language/tree-il/compile-cps.scm (convert): Generate logand/immediate if possible. * module/language/cps/compile-bytecode.scm (compile-function): * module/system/vm/assembler.scm (system): Add ulogand/immediate emitter. * libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): Bump.
2023-11-17Mark symbol-hash primcall as having unboxed resultAndy Wingo1-1/+2
* module/language/cps/utils.scm (primcall-raw-representations): Add symbol-hash.
2023-11-17Add CPS primcall for symbol-hashAndy Wingo4-2/+14
* module/language/cps/effects-analysis.scm: symbol-hash is effect-free. * module/language/cps/guile-vm/lower-primcalls.scm (symbol-hash): Lower to word-ref/immediate. * module/language/cps/switch.scm (optimize-branch-chain): Emit symbol-hash instead of word-ref/immediate. * module/language/cps/types.scm (symbol-hash): Infer result.
2023-11-15peval: better primcall folding in effect contextsAndy Wingo2-10/+32
* module/language/tree-il/peval.scm (peval): If a primcall is effect-free, don't require that its args are too: just revisit args as a sequence in effect context. * module/language/tree-il/effects.scm (effect-free-primcall?): New exported function.
2023-11-15peval: elide effect-free primcalls in effect contextAndy Wingo1-1/+9
* module/language/tree-il/peval.scm (peval): fix-letrec can residualize useless primcalls, when a let or letrec-bound var is unused. Fix to elide these.
2023-11-15Add extensibility to Tree-IL effects analysisAndy Wingo1-3/+19
* module/language/tree-il/effects.scm (add-primcall-effect-analyzer!): New facility. * module/language/tree-il/effects.scm (make-effects-analyzer): If a primcall's args cause no effects, call out to a user-provided effect-free? primitive for a primcall. If true, the primcall will be marked as depending on all effects but causing none; this will allow it to be elided by letrectify or peval.
2023-11-15Allow string->utf8 to constant-foldAndy Wingo10-90/+150
* module/language/tree-il/primitives.scm (*interesting-primitive-names*): (*primitive-accessors*): Add string->utf8, utf8->string, and string-utf8-length. (primitive-module): New public function, moved here from (language tree-il compile-bytecode). * module/language/tree-il/compile-bytecode.scm: Use primitive-module from (language tree-il primitives). * module/language/tree-il/peval.scm (peval): A bugfix: load primitives from their proper module. Allows bytevector primitives to fold. * module/language/cps/guile-vm/reify-primitives.scm: * module/language/cps/effects-analysis.scm: * module/language/cps/types.scm * module/language/tree-il/primitives.scm: * module/language/tree-il/cps-primitives.scm: * module/language/tree-il/effects.scm (make-effects-analyzer): Add string->utf8, utf8->string, and string-utf8-length. * module/language/tree-il/compile-cps.scm (string->utf8) (string-utf8-length, utf8->string): New custom lowerers, including type checks and an unboxed result for string-utf8-length. * module/system/vm/assembler.scm: * libguile/intrinsics.h: * libguile/intrinsics.c: Because string-utf8-length returns an unboxed value, we need an intrinsic for it; go ahead and add an intrinsic for string->utf8 and utf8->string too, as we will likely be able to use these in the future.
2023-11-15Fix pretty-print with a per-line prefixAndy Wingo1-1/+1
* module/ice-9/pretty-print.scm (pretty-print): Include the per-line prefix in the indent. * test-suite/tests/print.test ("pretty-print"): Add test.
2023-11-02Update set of decimal zeroes for Unicode 15.1.0Andy Wingo1-4/+5
* module/scheme/char.scm (*decimal-zeroes*): Update.
2023-09-29Add test for r7rs string-for-eachDaniel Llorens1-18/+19
* test-suite/tests/r7rs.test: As stated. * module/scheme/base.scm: Reindent and add minimal doc.
2023-09-29Fix (scheme base) string-for-each.Taylan Kammer1-2/+24
* module/scheme/base.scm (r7:string-for-each): New procedure. Fixes <https://bugs.gnu.org/40584>.
2023-09-18Fix docstring for symbol->string, string->symbolAndy Wingo1-2/+2
* libguile/symbols.c (scm_symbol_to_string, scm_string_to_symbol): Remove some confusing documentation that assumes that Guile is case-insensitive, and which uses a word that may be perceived as a slur. * module/ice-9/test.scm: * test-suite/tests/r4rs.test: Rename a test to avoid using a slur.
2023-09-18Better compilation for symbol->keyword, keyword->symbolAndy Wingo6-6/+55
* module/language/tree-il/primitives.scm (*interesting-primitive-names*): (*effect-free-primitives*): Recognize keyword->symbol, symbol->keyword. * module/language/tree-il/cps-primitives.scm: Plumb through to CPS. (keyword->symbol): * module/language/cps/effects-analysis.scm: New prims have no effect. Fix effects for string->symbol. (annotation->memory-kind): Add keywords. * module/language/cps/guile-vm/lower-primcalls.scm (keyword->symbol): Lower to scm-ref/immediate. * module/language/cps/types.scm (annotation->type): Add case for keywords. * module/language/tree-il/compile-cps.scm: Add converters for new prims, with type guards.