summaryrefslogtreecommitdiff
path: root/module/system
AgeCommit message (Collapse)AuthorFilesLines
2021-11-15Add -Ooptimize-known-return-types at -O2Andy Wingo1-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.
2021-11-15Support C99 complex types in (system foreign)Daniel Llorens1-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.
2021-11-05module/system/base/target.scm: support riscv32Fabrice Fontaine1-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>
2021-11-03Add support for arcVineet Gupta1-2/+2
Signed-off-by: Vineet Gupta <vgupta@synopsys.com> NB: closes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=48816
2021-10-01Add ,optimize-cps REPL meta-commandAndy Wingo2-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.
2021-09-20(system repl command) autoloads the compiler, disassembler, and profiler.Ludovic Courtès1-4/+6
* module/system/repl/command.scm: Autoload (system base compile), (system vm disassembler), and (statprof).
2021-09-17Revert shift of ndim in array tag from 3df3ba1a2c956bba122328e1fc4be614171a4f42Daniel Llorens1-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.
2021-09-02foreign-library: fix darwin detectionAleix Conchillo Flaqué1-1/+1
* module/system/foreign-library.scm (system-library-extensions): fix darwin host detection. darwin host types have "-darwin" but not "-darwin-".
2021-08-16Remove array contp flagDaniel Llorens1-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.
2021-05-19Fix trace-calls-to-procedureRobin Green1-1/+1
Fixes #43102 and duplicate #48412.
2021-05-11Add support for recording inlinable module exportsAndy Wingo1-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.
2021-05-11Add pass to resolve free toplevel references in declarative modulesAndy Wingo1-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.
2021-05-11Bump objcode versionAndy Wingo1-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.
2021-05-10bug#45131: [PATCH] Compile directly to target language if no joint is found.Leo Prikler1-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.
2021-05-10Minor tweak to truncate-bitsAndy Wingo1-8/+5
* module/system/base/types/internal.scm (truncate-bits): Use bits-case in all cases.
2021-05-06Optimize truncate-bitsAndy Wingo1-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.
2021-04-26Bump minor objcode version for new intrinsicsAndy Wingo1-1/+1
* libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): Bump. * module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
2021-04-26Simplify module variable lookup slow-pathAndy Wingo1-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.
2021-04-21New pass: elide-arity-checksAndy Wingo1-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.
2021-04-21Allow $kargs as entry of $kfunAndy Wingo1-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.
2021-03-13On Cygwin, 'lib' DLLs use 'cyg' prefixMike Gran1-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
2021-03-10Add mkstemp; undocument mkstemp!Andy Wingo1-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.
2021-03-09Document syntax-sourcevAndy Wingo1-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.
2021-03-04Syntax objects print with source locationsAndy Wingo1-2/+11
* module/system/syntax.scm (print-syntax): Print source locations.
2021-02-25Assembler writes vector source propertiesAndy Wingo1-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.
2021-02-25Optimize run-time init and relocation procedureAndy Wingo1-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.
2021-02-20Syntax objects have "source" fieldAndy Wingo1-8/+13
* libguile/syntax.c (scm_make_syntax): Add optional "source" argument. Note that this function is internal. (scm_syntax_source): New function, replacing definition in boot-9.scm. * libguile/syntax.h: Add new declarations. * module/ice-9/psyntax-pp.scm: * module/ice-9/psyntax.scm (source-annotation): For syntax objects, the source annotation comes direct from the syntax object. * module/system/vm/assembler.scm (link-data, intern-constant): Write 5-word syntax objects.
2021-02-03Replace libltdl with raw dlopen, dlsymAndy Wingo1-0/+231
* NEWS: Update. * am/bootstrap.am (SOURCES): * module/Makefile.am (SOURCES): Add system/foreign-library.scm. * configure.ac: Replace ltdl check with -ldl check. * libguile/dynl.c: Rewrite to just expose core dlopen / dlsym / etc to a helper Scheme module. (scm_dynamic_link, scm_dynamic_pointer, scm_dynamic_function) (scm_dynamic_object_p, scm_dynamic_call): Rewrite in terms of (system foreign-library). * libguile/extensions.c (load_extension): Avoid scm_dynamic_call. * module/system/foreign-library.scm: New file. * module/oop/goops.scm (<dynamic-object>): Hackily export <foreign-library> instead of a class here. * doc/ref/api-foreign.texi (Foreign Function Interface): Rewrite to only document the new interfaces. Eventually we will deprecate dynamic-link and friends. * doc/ref/guile.texi (API Reference): Move Foreign Objects after Foreign Function Interface. Seems there should be some closer relationship but this will do for now. * doc/ref/tour.texi (Putting Extensions into Modules): * doc/ref/libguile-parallel.texi (Parallel Installations): Update for rename of Modules and Extensions to Foreign Extensions. * libguile/deprecated.h: * libguile/deprecated.c (scm_dynamic_unlink): Deprecate. * libguile/guile.c: Remove ltdl include. * test-suite/tests/foreign.test: Update tests to use new API, and update error expectations.
2021-01-12Finish call-with-port cleanupAndy Wingo1-2/+1
* module/rnrs/io/ports.scm (call-with-port): Remove local definition. * module/system/repl/server.scm (system): Call-with-port is imported via (ice-9 ports).
2021-01-07Bump copyright years for user-visible copyright messagesv3.0.5Andy Wingo1-2/+2
* module/ice-9/command-line.scm (version-etc): * module/scripts/compile.scm (show-version): * module/system/repl/common.scm (*version*): Bump to 2021.
2021-01-07New warnings: -Wuse-before-definition, -Wnon-idempotent-definitionAndy Wingo1-1/+13
* 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.
2020-09-10Move copy-tree to (ice-9 copy-tree); deprecate main bindingAndy Wingo1-0/+1
* 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-08-26Bump objcode minor version to 4Andy Wingo1-1/+1
* 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-12Add new pass to optimize branch chains to table dispatchAndy Wingo1-0/+1
* 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-03CPS compiler reduces eq? on constant to eq-constant?Andy Wingo3-27/+30
* 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-03Rework the way immediate encodings are calculated.Andy Wingo2-53/+67
* 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-03Add eq-immediate? instructionAndy Wingo2-1/+11
* 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-07-30Add sign-extending make-immediate instructionAndy Wingo2-1/+43
* 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-23Add jtable instructionAndy Wingo2-191/+218
* 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-06-01Change -O1 compiler to use baseline and also resolve primitivesAndy Wingo1-10/+2
* 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-05-14Fix ,optimize to be independent of tree-ilAndy Wingo1-10/+34
* module/system/repl/common.scm (repl-default-options): Add optimization-level and warning-level REPL options. (repl-optimization-level, repl-warning-level): New accessors, defaulting to the default level parameters. (repl-expand): Take target language as keyword argument rather than hard-coding tree-il. (repl-optimize): Take target language as keyword argument. Use REPL optimization and warning levels. Use generic lowering interface.
2020-05-13Bump objcode minor versionAndy Wingo1-1/+1
* libguile/loader.h (SCM_OBJCODE_MINOR_VERSION): * module/system/vm/assembler.scm (*bytecode-minor-version*): Bump, so that compiled files from Guile 3.0.3 will error when loaded on 3.0.2.
2020-05-12Delay loading CPS unless CPS compiler usedAndy Wingo1-13/+12
* 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-11Avoid having "guild compile" load optimizersAndy Wingo1-5/+39
* 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-11Fix shuffling assembler for new primcallsAndy Wingo1-1/+10
* module/system/vm/assembler.scm (encode-X8_S8_C8_S8-C32!/shuffle): New shuffling assembler.
2020-05-11Add new lookup, lookup-bound intrinsicsAndy Wingo1-0/+4
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): * libguile/intrinsics.c (lookup, lookup_bound): * libguile/intrinsics.c (scm_bootstrap_intrinsics): New intrinsics. * module/language/cps/reify-primitives.scm (reify-primitives): * module/language/cps/effects-analysis.scm (current-module): * module/language/cps/compile-bytecode.scm (compile-function): * module/system/vm/assembler.scm: Add compiler support.
2020-05-11Rename "lookup" intrinsic to "module-variable"Andy Wingo1-2/+2
It can return #f, unlike scm_(module_)?lookup. * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): * libguile/intrinsics.c (module_variable, scm_bootstrap_intrinsics): Rename. * module/language/cps/compile-bytecode.scm (compile-function): * module/language/cps/effects-analysis.scm (current-module): * module/language/cps/reify-primitives.scm (reify-lookup) (compute-known-primitives): * module/language/tree-il/compile-bytecode.scm (emit-cached-module-box) (emit-cached-toplevel-box, emit-toplevel-box): * module/language/tree-il/compile-cps.scm (toplevel-box): * module/system/vm/assembler.scm (module-variable): Adapt users.
2020-05-08Add compiler chooser implementation; fix bugs with previous commitAndy Wingo2-25/+33
* 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-08Sketch of how to choose different compiler based on -O0Andy Wingo1-6/+16
* module/system/base/compile.scm (next-pass, compute-compiler): Allow optimization level to determine pass order.
2020-05-08Define new "lowering" phase in compilerAndy Wingo2-8/+8
* 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.