summaryrefslogtreecommitdiff
path: root/module/system
Commit message (Collapse)AuthorAgeFilesLines
* Remove unnecessary module imports.Ludovic Courtès2023-02-2420-44/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These were found with: make GUILE_WARNINGS='-W1 -Wunused-module' * module/ice-9/copy-tree.scm: * module/ice-9/eval-string.scm: * module/ice-9/getopt-long.scm: * module/ice-9/poll.scm: * module/ice-9/popen.scm: * module/ice-9/sandbox.scm: * module/ice-9/threads.scm: * module/sxml/apply-templates.scm: * module/sxml/simple.scm: * module/system/base/types.scm: * module/system/repl/command.scm: * module/system/repl/common.scm: * module/system/repl/coop-server.scm: * module/system/repl/debug.scm: * module/system/repl/error-handling.scm: * module/system/repl/repl.scm: * module/system/repl/server.scm: * module/system/vm/assembler.scm: * module/system/vm/disassembler.scm: * module/system/vm/dwarf.scm: * module/system/vm/elf.scm: * module/system/vm/frame.scm: * module/system/vm/inspect.scm: * module/system/vm/linker.scm: * module/system/vm/program.scm: * module/system/vm/trace.scm: * module/system/vm/trap-state.scm: * module/system/vm/traps.scm: * module/system/xref.scm: * module/texinfo/indexing.scm: * module/texinfo/plain-text.scm: * module/texinfo/reflection.scm: * module/texinfo/string-utils.scm: * module/web/client.scm: * module/web/http.scm: * module/web/request.scm: * module/web/response.scm: Remove imports of unused modules.
* Add -Wunused-module.Ludovic Courtès2023-02-241-1/+10
| | | | | | | | | | | * module/language/tree-il/analyze.scm (<module-info>): New record type. (unused-module-analysis): New variable. (make-unused-module-analysis): New analysis. (make-analyzer): Add it. * module/system/base/message.scm (%warning-types): Add 'unused-module'. * test-suite/tests/tree-il.test (%opts-w-unused-module): New variable. ("warnings")["unused-module"]: New test prefix. * NEWS: Update.
* linker: Do not store entire ELF in memory when writing to a file.Ludovic Courtès2023-01-171-11/+59
| | | | | | | | | | | | | | | | | | | | | This reduces the amount of memory that needs to be allocated while writing the ELF file to disk. Note: We're abusing #:page-aligned? in 'link-elf' to choose whether to return a bytevector or a procedure. * module/system/vm/linker.scm (process-reloc): Subtract SECTION-OFFSET when writing to BV. (write-linker-object): Pass BV directly to the linker object writer. (link-elf): When PAGE-ALIGNED? is false, call 'bytevector-slice' from here. When it is true, return a procedure that takes a port and writes to it, without having to allocate a bytevector for the whole ELF container. * module/language/bytecode/spec.scm (bytecode->value): Handle X being a procedure instead of a bytevector. (bytecode) <#:printer>: Likewise. * test-suite/tests/linker.test (link-elf-with-one-main-section): Pass #:page-aligned? #f.
* linker: Linker object writer takes a single argument.Ludovic Courtès2023-01-172-44/+33
| | | | | | | | | | | | | | * module/system/vm/linker.scm (write-linker-object): Pass the 'linker-object-writer' a single argument. (string-table-writer, add-elf-objects): Adjust writers accordingly. (string-table-writer): (add-elf-objects): * module/system/vm/assembler.scm (link-data, link-text-object) (link-frame-maps, link-dynamic-section) (link-symtab, link-arities, link-docstrs) (link-procprops, link-debug): Likewise. * test-suite/tests/linker.test (link-elf-with-one-main-section): Likewise.
* linker, assembler: Avoid intermediate bytevectors.Ludovic Courtès2023-01-172-101/+161
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reduces the amount of memory used during linking and reduces the number of copies to be done between bytevectors. * module/system/vm/linker.scm (<linker-object>): Remove 'bv' field and add 'size' and 'writer'. (make-linker-object): Adjust accordingly. (string-table-size): New procedure. (link-string-table!): Remove. (string-table-writer): New procedure. (allocate-segment): Adjust 'make-linker-object' call. (find-shstrndx): Call the 'linker-object-writer' of O. (add-elf-objects): Adjust 'make-linker-object' call. Remove 'make-bytevector' allocations and move serialization to lazy 'writer' procedures. Define 'segments' and 'add-header-segment!'. Return the latter as the first value. * module/system/vm/assembler.scm (make-object): Remove 'bv' parameter and add 'size' and 'writer'. (link-data): Remove 'make-bytevector' call and move serialization to a lazy 'writer' procedure. (link-text-object): Likewise. (link-frame-maps): Likewise. (link-dynamic-section): Likewise. (link-shstrtab): Likewise. (link-symtab): Likewise. (link-arities): Likewise, and remove 'bytevector-append'. (link-docstrs): Likewise. (link-procprops): Likewise. (link-debug): Likewise, and define 'copy-writer'. * test-suite/tests/linker.test (link-elf-with-one-main-section): Adjust accordingly.
* linker: Separate effectful part of 'add-elf-objects'.Ludovic Courtès2023-01-171-5/+15
| | | | | | | * module/system/vm/linker.scm (add-elf-objects)[write-and-reloc]: Split into... [compute-reloc, write-object-elf-header!]: ... this. Adjust accordingly.
* assembler: Separate effectful part of 'link-docstrs'.Ludovic Courtès2023-01-171-10/+13
| | | | | * module/system/vm/assembler.scm (link-docstrs): Define 'write-docstrings!' and use it.
* assembler: Separate effectful part of 'link-frame-maps'.Ludovic Courtès2023-01-171-19/+24
| | | | | * module/system/vm/assembler.scm (link-frame-maps)[make-frame-maps]: Define 'write!' and use it.
* assembler: Separate effectful part of 'link-procprops'.Ludovic Courtès2023-01-171-14/+26
| | | | | * module/system/vm/assembler.scm (link-procprops): Define 'write-procprops!' and use it.
* assembler: Separate effectful part of 'link-dynamic-section'.Ludovic Courtès2023-01-171-30/+45
| | | | | * module/system/vm/assembler.scm (link-dynamic-section): Define 'relocs' once for all. Define 'write!' and use it.
* assembler: Separate effectful part of 'link-symtab'.Ludovic Courtès2023-01-171-15/+22
| | | | | * module/system/vm/assembler.scm (link-symtab): Define 'names' and 'write-symbols!'. Use it.
* assembler: Separate 'process-relocs' from 'patch-relocs!'.Ludovic Courtès2023-01-171-35/+51
| | | | | | | | * module/system/vm/assembler.scm (process-relocs): Remove 'buf' parameter and turn into a pure function. (patch-relocs!): New procedure. Perform the side effects previously done in 'process-relocs'. (link-text-object): Adjust accordingly.
* Bump user-visible copyright years to 2023.Ludovic Courtès2023-01-131-1/+1
| | | | | | * module/ice-9/command-line.scm (version-etc): * module/scripts/compile.scm (show-version): * module/system/repl/common.scm (*version*): Bump to 2023.
* Recognize LoongArch compilation targets.Zhang Ning2022-12-211-0/+2
| | | | | | * module/system/base/target.scm (cpu-endianness): Add case for "Loongarch" variants Signed-off-by: Zhang Ning <zhangn1985@outlook.com>
* Avoid 'frame-local-ref' errors when printing backtrace.Andrew Whatson2022-11-291-2/+10
| | | | | | | Workaround for <https://bugs.gnu.org/57948>. * module/system/vm/frame.scm (frame-call-representation): Treat a binding as "unspecified" if its slot exceeds 'frame-num-locals'.
* disassembler: Show intrinsic name for 'call-' instructions.Ludovic Courtès2022-11-011-1/+46
| | | | | | | * module/system/vm/disassembler.scm (code-annotation)[intrinsic-name]: New procedure. Add clauses for intrinsics. * NEWS: Update.
* Properly display locations in "source vector" form.Andrew Whatson2022-08-261-6/+13
| | | | | | | | Locations are stored in tree-il records in "source vector" form, but `location-string' was rendering these as <unknown-location>. * module/system/base/message.scm (location-string): Support locations passed as a file/line/column vector.
* Add missing #:modules argument for coverage-data->lcov.Jessica Tallon2022-06-161-3/+9
| | | | | | | | | | | | | The code coverage function `coverage-data->lcov` has a documented `modules` argument, however that was missing from the source. I have added it so when supplied it only converts the coverage data for the supplied modules. If not supplied it defaults the old behavour of including all the modules currently loaded. * module/system/vm/coverage.scm (coverage-data->lcov): Add #:modules parameter and honor it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Allow empty vendor string in GNU target triplets.Taylor R Campbell2022-06-161-1/+8
| | | | | | | | | | | | | | | | | NetBSD and pkgsrc have been using an empty vendor string since the mid-'90s, such as x86_64--netbsd. pkgsrc has been carrying around a workaround just the guile build for a long time. (Before that, NetBSD omitted the vendor altogether, so if x86_64 existed then it might have been `x86_64-netbsd', but that caused more problems.) This change makes Guile accept an empty vendor string so workarounds are no longer necessary. * module/system/base/target.scm (validate-target): Allow empty vendor string in GNU target triplets. * test-suite/tests/cross-compilation.test ("cross-compilation"): Add tests for "x86_64--netbsd". Co-authored-by: Ludovic Courtès <ludo@gnu.org>
* Bump user-visible copyright years to 2022Andy Wingo2022-02-111-2/+2
| | | | | * module/ice-9/command-line.scm (version-etc): * module/system/repl/common.scm (*version*): Bump to 2022.
* psyntax: Pass source vectors to tree-il constructors.Ludovic Courtès2022-02-071-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | Avoiding systematic conversion from source vectors to property alists saves 20% on the final heap size of a process doing: (compile-file FILE #:optimization-level 1) where FILE is large. * module/language/tree-il.scm (tree-il-src/ensure-alist): New procedure with setter. Export as 'tree-il-src'. * module/ice-9/psyntax.scm (build-void, build-call) (build-conditional, build-lexical-reference, build-lexical-assignment) (build-global-reference, build-global-assignment) (build-global-definition, build-simple-lambda, build-case-lambda) (build-lambda-case, build-primcall, build-primref) (build-data, build-sequence, build-let, build-named-let) (build-letrec, expand-body): Remove (sourcev->alist src) calls. * module/ice-9/psyntax-pp.scm: Regenerate. * module/language/tree-il/analyze.scm (shadowed-toplevel-analysis): Use 'tree-il-src' instead of accessing the 'src' slot directly. * module/system/vm/assembler.scm (link-debug): Adjust so PC can be followed by a vector or an alist.
* Deprecate symbol properties.Ludovic Courtès2022-02-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | * libguile/strings.c (scm_i_make_symbol): Remove 'props' argument. Use 3 words instead of 'scm_double_cell'. * libguile/strings.h: Adjust accordingly. * libguile/symbols.c (scm_i_str2symbol, scm_i_str2uninterned_symbol): Likewise. (scm_symbol_fref, scm_symbol_pref, scm_symbol_fset_x, scm_symbol_pset_x): Move to... * libguile/deprecated.c: ... here. Rewrite in terms of object properties. (symbol_function_slot, symbol_property_slot): New variables. * libguile/symbols.h (SCM_SYMBOL_FUNC, SCM_SET_SYMBOL_FUNC) (SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS) (scm_symbol_fref, scm_symbol_pref, scm_symbol_fset_x) (scm_symbol_pset_x): Move to... * libguile/deprecated.h: ... here. Mark declarations as 'SCM_DEPRECATED'. * module/system/base/types.scm (cell->object): Remove 'props' field for %TC7-SYMBOL. * doc/ref/api-data.texi (Symbol Props): Remove. * NEWS: Update.
* Rework bootstrap to be reproducibleAndy Wingo2022-02-011-3/+3
| | | | | | | | | | | | | | | | | | * configure.ac: * Makefile.am (SUBDIRS): Replace bootstrap/ with stage0, stage1, and stage2. * am/bootstrap.am: Include all files and all rules. * meta/build-env.in (GUILE_AUTO_COMPILE): Always turn off auto-compilation. Take a GUILE_BOOTSTRAP_STAGE argument, which can be stage0, stage1, stage2, or unset. Adapt the load-compiled path accordingly. * meta/uninstalled-env.in: Include .go files from stage2. * module/Makefile.am: Rework to use boostrap.am. * module/system/base/optimize.scm (available-optimizations): Punt the inlinable-exports machinery to -O2. * stage0/Makefile.am: * stage1/Makefile.am: * stage2/Makefile.am: New files.
* Support C99 complex types conditionally in (system foreign)Mikael Djurfeldt2021-12-011-4/+12
| | | | | | | 496f69dba2fdf1720b40349932fcdecd444107c3 introduced C99 complex types in libguile/foreign.h and (system foreign). Since these types are provided conditionally in foreign.h based on autoconf tests they need to be used conditionally in (system foreign) based on their presence.
* Add -Ooptimize-known-return-types at -O2Andy Wingo2021-11-151-0/+1
| | | | | | * module/language/cps/optimize.scm (optimize-first-order-cps): * module/system/base/optimize.scm (available-optimizations): Add optimize-known-return-types at -O2.
* Support C99 complex types in (system foreign)Daniel Llorens2021-11-151-0/+16
| | | | | | | | | | * libguile/foreign.h (SCM_FOREIGN_TYPE_COMPLEX_FLOAT, SCM_FOREIGN_TYPE_COMPLEX_DOUBLE): New enums. * module/system/foreign.scm (complex-float, complex-double): Export new types. (make-c-struct, parse-c-struct): Support the new types. * libguile/foreign.c (complex-float, complex-double): Define new types. (alignof, sizeof, pack, unpack): Support the new types. * test-suite/tests/foreign.test: Test.
* module/system/base/target.scm: support riscv32Fabrice Fontaine2021-11-051-0/+1
| | | | | | | | | | | | Fix the following build failure on riscv32: system/base/target.scm:132:16: In procedure triplet-pointer-size: unknown CPU word size "riscv32" Fixes: - http://autobuild.buildroot.org/results/6705630c1484239ec8b73d57ebc2e2570fbfc8f8 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
* Add support for arcVineet Gupta2021-11-031-2/+2
| | | | | | Signed-off-by: Vineet Gupta <vgupta@synopsys.com> NB: closes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=48816
* Add ,optimize-cps REPL meta-commandAndy Wingo2021-10-012-10/+23
| | | | | | | | | * module/system/repl/command.scm (*command-table*): Add optimize-cps / optx. (optimize-cps): Define meta-command. * module/system/repl/common.scm (optimize*): New helper. (repl-optimize): Use helper. (repl-optimize-cps): New public function.
* (system repl command) autoloads the compiler, disassembler, and profiler.Ludovic Courtès2021-09-201-4/+6
| | | | | * module/system/repl/command.scm: Autoload (system base compile), (system vm disassembler), and (statprof).
* Revert shift of ndim in array tag from 3df3ba1a2c956bba122328e1fc4be614171a4f42Daniel Llorens2021-09-171-1/+1
| | | | | | | To avoid breaking ABI. * libguile/arrays.h (SCM_I_ARRAY_DIM, scm_i_raw_array): As stated. * module/system/vm/assembler.scm: As stated.
* foreign-library: fix darwin detectionAleix Conchillo Flaqué2021-09-021-1/+1
| | | | | | * module/system/foreign-library.scm (system-library-extensions): fix darwin host detection. darwin host types have "-darwin" but not "-darwin-".
* Remove array contp flagDaniel Llorens2021-08-161-2/+3
| | | | | | | | | | | | | | | | | | | | | This flag was set, but never used in Guile, and there was no documented API to access it. To check if an array is contiguous, use (array-contents <> #t). * libguile/arrays.h (scm_i_raw_array): New function. SCM_I_ARRAY_CONTIGUOUS, SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG, SCM_I_ARRAY_CONTP: Remove. scm_t_array_dim: Declare here, not in array-handle.h. SCM_I_ARRAY_NDIM: Shift by one bit since the contp flag isn't there anymore. * module/syste/vm/assembler.scm: Match removal of contp flag. * libguile/arrays.c (scm_i_make_array): Reuse scm_i_raw_array. (scm_i_ra_set_contp): Remove. (scm_transpose_array): Don't set or clear the contp flag. (scm_make_shared_array): Don't set or clear the contp flag. (scm_make_typed_array): Don't set the contp flag. * libguile/array-map.c (scm_i_array_rebase): Reuse scm_i_raw_array.
* Fix trace-calls-to-procedureRobin Green2021-05-191-1/+1
| | | | Fixes #43102 and duplicate #48412.
* Add support for recording inlinable module exportsAndy Wingo2021-05-111-2/+4
| | | | | | | | | | | * 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.
* Add pass to resolve free toplevel references in declarative modulesAndy Wingo2021-05-111-0/+1
| | | | | | | | | | * 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.
* Bump objcode versionAndy Wingo2021-05-111-1/+1
| | | | | | * libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): * module/system/vm/assembler.scm (*bytecode-minor-version*): Bump, as we're going to start adding inlinable exports.
* bug#45131: [PATCH] Compile directly to target language if no joint is found.Leo Prikler2021-05-101-11/+15
| | | | | | | | | | 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.
* Minor tweak to truncate-bitsAndy Wingo2021-05-101-8/+5
| | | | | * module/system/base/types/internal.scm (truncate-bits): Use bits-case in all cases.
* Optimize truncate-bitsAndy Wingo2021-05-061-4/+17
| | | | | | * module/system/base/types/internal.scm (truncate-bits): Inline cases for 16, 32, and 64, to avoid allocating bignums for the boundary conditions.
* Bump minor objcode version for new intrinsicsAndy Wingo2021-04-261-1/+1
| | | | | * libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): Bump. * module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
* Simplify module variable lookup slow-pathAndy Wingo2021-04-261-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/intrinsics.h: * libguile/intrinsics.c (lookup_bound_public, lookup_bound_private): Two new intrinsics. (scm_bootstrap_intrinsics): Wire them up. * libguile/jit.c (compile_call_scm_from_scmn_scmn): (compile_call_scm_from_scmn_scmn_slow): (COMPILE_X8_S24__N32__N32__C32): Add JIT support for new instruction kind. * libguile/vm-engine.c (call-scm<-scmn-scmn): New instruction, takes arguments as non-immediate offsets, to avoid needless loads and register pressure. * module/language/cps/effects-analysis.scm: Add cases for new primcalls. * module/language/cps/compile-bytecode.scm (compile-function): Add new primcalls. * module/language/cps/reify-primitives.scm (cached-module-box): If the variable is bound, call lookup-bound-public / lookup-bound-private as appropriate instead of separately resolving the module, name, and doing the bound check. * module/language/tree-il/compile-bytecode.scm (emit-cached-module-box): Use new instructions. * module/system/vm/assembler.scm (define-scm<-scmn-scmn-intrinsic): (lookup-bound-public, lookup-bound-private): Add assembler support.
* New pass: elide-arity-checksAndy Wingo2021-04-211-0/+1
| | | | | | | | | | * 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.
* Allow $kargs as entry of $kfunAndy Wingo2021-04-211-0/+15
| | | | | | | | | | | | | | | * module/language/cps.scm: * module/language/cps/contification.scm: * module/language/cps/cse.scm: * module/language/cps/dce.scm: * module/language/cps/simplify.scm: * module/language/cps/slot-allocation.scm: * module/language/cps/types.scm: Allow $kargs to follow $kfun. In that case, the function must be well-known and callers are responsible for calling with the appropriate arity. * module/language/cps/compile-bytecode.scm: Emit "unchecked-arity" for $kargs following $kfun. * module/system/vm/assembler.scm: Adapt.
* On Cygwin, 'lib' DLLs use 'cyg' prefixMike Gran2021-03-131-1/+23
| | | | | | | | | | | | | When using automake and libtool to build DLLs on Cygwin, libtool will rename libXXX to cygXXX. 'load-foreign-library' should emulate libltdl behavior and search for DLLs using that convention. * module/system/foreign-library.scm (lib->cyg): new helper function (load-foreign-library): add rename-on-cygwin? option to rename libraries using Cygwin semantics * test-suite/tests/foreign.test: new test section 'lib->cyg' * doc/ref/api-foreign.text: document new rename-on-cygwin? option for load-foreign-library
* Add mkstemp; undocument mkstemp!Andy Wingo2021-03-101-6/+6
| | | | | | | | | | | | | | | | * 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.
* Document syntax-sourcevAndy Wingo2021-03-091-1/+2
| | | | | | | * NEWS: Add doc link. * doc/ref/api-macros.texi (Syntax Transformer Helpers): Document syntax-sourcev. * module/system/syntax.scm: Re-export syntax-sourcev.
* Syntax objects print with source locationsAndy Wingo2021-03-041-2/+11
| | | | * module/system/syntax.scm (print-syntax): Print source locations.
* Assembler writes vector source propertiesAndy Wingo2021-02-251-2/+2
| | | | | | | * module/system/vm/assembler.scm (intern-constant, link-data): Write the vector representation of source instead of the alist. Saves a lot of heap size, object file size, and init time when serializing syntax objects with source.
* Optimize run-time init and relocation procedureAndy Wingo2021-02-251-57/+109
| | | | | | | | * module/system/vm/assembler.scm (<asm>, make-assembler) (intern-constant, emit-init-constants): Instead of loading a dependent value each time it's needed in the relocation procedure, eagerly patch values when they are created. Allows keeping values in registers, which decreases code size.