summaryrefslogtreecommitdiff
path: root/module
AgeCommit message (Collapse)AuthorFilesLines
2019-11-14SRFI-18 uses core exceptionsAndy Wingo3-87/+66
* module/ice-9/boot-9.scm (exception-kind, exception-args): Export. * module/ice-9/exceptions.scm (exception-kind, exception-args): Re-export. * module/srfi/srfi-18.scm: Rewrite exception support in terms of core exceptions, not SRFI-34/35. * test-suite/tests/srfi-18.test: Since Guile doesn't expose the current exception handler as such, SRFI-18 captures it using delimited continuations. This means that we can't compare the result of (current-exception-handler) with the installed handler using eq?, even though the procedures are indeed equivalent. So, instead test handler behavior.
2019-11-13Rebase throw/catch on top of raise-exception/with-exception-handlerAndy Wingo3-230/+344
* libguile/exceptions.c: * libguile/exceptions.h: New files. * libguile.h: Add exceptions.h. * libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES, DOT_DOC_FILES, modinclude_HEADERS): Add exceptions.c and exceptions.h. * libguile/init.c (scm_i_init_guile): Initialize exceptions. * libguile/threads.c (scm_spawn_thread): Use new names for scm_i_make_catch_handler and scm_c_make_thunk. * libguile/throw.c: Rewrite to be implemented in terms of with-exception-handler / raise-exception. * libguile/throw.h: Use data types from exceptions.h. Move scm_report_stack_overflow and scm_report_out_of_memory to exceptions.[ch]. * module/ice-9/boot-9.scm (&error, &programming-error) (&non-continuable, make-exception-from-throw, raise-exception) (with-exception-handler): New top-level definitions. (throw, catch, with-throw-handler): Rewrite in terms of with-exception-handler and raise-exception. : New top-level definitions. * module/ice-9/exceptions.scm: Adapt to re-export &error, &programming-error, &non-continuable, raise-exception, and with-exception-handler from boot-9. (make-quit-exception, guile-quit-exception-converter): New exception converters. (make-exception-from-throw): Override core binding. * test-suite/tests/eval.test ("inner trim with prompt tag"): Adapt to "with-exception-handler" being the procedure on the stack. ("outer trim with prompt tag"): Likewise. * test-suite/tests/exceptions.test (throw-test): Use pass-if-equal. * module/srfi/srfi-34.scm: Reimplement in terms of core exceptions, and make "guard" actually re-raise continuations with the original "raise" continuation.
2019-11-07Move exceptions with key and args to coreAndy Wingo2-7/+17
* module/ice-9/boot-9.scm (&exception-with-key-and-args) (&quit-exception): New definitions. * module/ice-9/exceptions.scm (make-guile-exception): (guile-exception?, guile-exception-key, guile-exception-args): Update definitions.
2019-11-07Move the core of exception objects into coreAndy Wingo2-86/+105
* module/ice-9/boot-9.scm (&exception, &compound-exception) (simple-exceptions, make-exception, exception?, exception-type?) (make-exception-type, exception-predicate, exception-accessor): Move these definitions into core, from (ice-9 exceptions). * module/ice-9/exceptions.scm: Re-export definitions from core.
2019-11-07Move exception-handling routines after records in boot-9Andy Wingo1-258/+261
* module/ice-9/boot-9.scm: Move down definitions of catch, throw, and so on until they are after records.
2019-11-07Move false-if-exception down in boot-9Andy Wingo1-20/+27
* module/ice-9/boot-9.scm (false-if-exception): Move down.
2019-11-05Move adapter between "throw" and "raise" exceptions into coreAndy Wingo2-228/+223
* module/ice-9/exceptions.scm (&guile): (default-guile-exception-converter): (guile-common-exceptions): (convert-guile-exception): (&raise-object-wrapper): (make-raise-object-wrapper): (raise-object-wrapper?): (raise-object-wrapper-obj): (raise-object-wrapper-continuation): (raise-exception): (raise-continuable): (with-exception-handler): (exception-printer): (format-exception): (format-simple-exception): (%exception): (guile-syntax-error-converter): (guile-lexical-error-converter): (guile-assertion-failure-converter): (guile-undefined-variable-error-converter): (guile-implementation-restriction-converter): (guile-external-error-converter): (guile-system-error-converter): (guile-exception-converters): (set-guile-exception-converter!): Move here, from (rnrs exceptions). * module/rnrs/exceptions.scm: Re-export bindings from (ice-9 exceptions).
2019-11-04Rebase SRFI-35 on top of (ice-9 exceptions)Andy Wingo2-179/+70
* module/ice-9/exceptions.scm (exception-type?): New export. * module/srfi/srfi-35.scm: Rewrite in terms of (ice-9 exceptions).
2019-11-03Add (ice-9 exceptions) moduleAndy Wingo3-116/+283
* module/ice-9/exceptions.scm: New file, derived from (rnrs conditions). Perhaps unadvisedly, in this file I've renamed a number of the identifiers. I have never found that the R6RS identifiers made sense to me. For now this is an internal module that R6RS and SRFI-35 will be based on. * module/Makefile.am (SOURCES): Add the new file. * module/rnrs/conditions.scm (rnrs): Export renamed identifiers from (ice-9 exceptions).
2019-11-03Add `record-type-has-parent?'.Andy Wingo2-6/+8
* module/ice-9/boot-9.scm (record-type-has-parent?): New function. * module/srfi/srfi-35.scm (condition-type?): Use it.
2019-10-30Remove circularity in r6rs by rebasing conditions on core recordsAndy Wingo4-202/+121
* module/rnrs/conditions.scm: Use core record facilities to define the base condition types, define-condition-type, and the standard condition hierarchy. (simple-condition?): Rename from condition-internal?. * module/rnrs/exceptions.scm: Move `raise' definition here, out from the procedural records layer. (format-simple-condition): Reimplement in a simpler way, hopefully producing the same output. * module/rnrs/records/procedural.scm: * module/rnrs/records/inspection.scm: Import the exceptions and conditions modules, and use the normal raise function.
2019-10-29Rebase R6RS records on top of core recordsAndy Wingo4-255/+174
* module/ice-9/boot-9.scm (record-type-uid): New accessor. (make-record-type): Record UID in record type properties. * module/rnrs/conditions.scm (define-condition-type): Fix invalid invocation of make-record-type. * module/rnrs/records/inspection.scm: Rewrite to use core record inspection facilities. * module/rnrs/records/procedural.scm: Rewrite to use core make-record-type. Incidentally the result is that instances of derived R6RS record types are now flat instead of nested. * test-suite/tests/r6rs-records-procedural.test ("make-record-type-descriptor"): Relax a couple condition type checks, while we redo the exception system.
2019-10-29Add record-type-parent definition.Andy Wingo1-0/+5
* module/ice-9/boot-9.scm (record-type-parent): New definition.
2019-10-28Add support for immutable fields in core recordsAndy Wingo1-5/+38
* module/ice-9/boot-9.scm (make-record-type): Allow (mutable NAME) or (immutable NAME) as a field name, and record field mutability in a bitfield. (record-modifier): Throw an error if the field isn't mutable. * test-suite/tests/records.test ("records"): Add tests. * doc/ref/api-data.texi (Records): Update.
2019-10-27Rename final? record type flag; add support for opaque?Andy Wingo2-10/+19
* module/ice-9/boot-9.scm (record-type-extensible?): Rename from record-type-final?, with the opposite sense. (record-type-opaque?): New accessor. (make-record-type): Change #:final? to #:extensible?, with the opposite meaning. Add #:opaque? arg. * test-suite/tests/records.test ("records"): Add opaque tests; update extensible tests. * doc/ref/api-data.texi (Records): Update. * module/srfi/srfi-35.scm (&condition, make-condition-type): Update for make-record-type API change.
2019-10-27Guile `make-record-type' supports non-generative definitionAndy Wingo1-22/+45
* module/ice-9/boot-9.scm (prefab-record-types): New definition. (make-record-type): Add #:uid keyword. * test-suite/tests/records.test ("records"): Add tests. * doc/ref/api-data.texi (Records): Document #:uid
2019-10-27Change record type "flags" field to "properties"Andy Wingo1-5/+8
* module/ice-9/boot-9.scm (record-type-properties): Rename from record-type-flags. (record-type-final?): New accessor. (make-record-type): (define-record-type): * test-suite/tests/records.test ("records"): Adapt.
2019-10-23Rebase srfi-35 conditions on top of make-record-typeAndy Wingo1-231/+135
* module/srfi/srfi-35.scm: Import (ice-9 match), and remove now-unused srfi-1 import. (print-condition): Print more like records, as appears to be the intention. (&condition): Define using make-record-type. Adapt all callers. Also, compound conditions are now a disjoint type, handled specially by condition-ref, condition?, and so on. * test-suite/tests/srfi-35.test (v3): Fix an error in which a subcondition was initialized without initializers for all of its fields.
2019-10-23make-record-type does more validation on the fieldsAndy Wingo2-10/+40
* 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-23SRFI-9 uses make-record-typeAndy Wingo1-12/+7
* module/srfi/srfi-9.scm (%define-record-type): Use make-record-type, instead of rolling our own vtable. Shouldn't have any perf impact.
2019-10-22Record accessors respect subtypingAndy Wingo1-28/+41
* module/ice-9/boot-9.scm (make-record-type): Don't allow subtyping of final types. (%record-type-error): Remove helper. (record-accessor, record-modifier): Use computed record type predicate, to allow for subtyping. (define-record-type): Adapt to %record-type-error going away; these types are final so no accessor adaptation is needed. * test-suite/tests/records.test: Add tests. * doc/ref/api-data.texi (Records): Update.
2019-10-22Allow records to be subtypedAndy Wingo2-34/+98
* module/ice-9/boot-9.scm (record-type-vtable): Add slots for "flags" and a parent vector. (record-type-name, record-type-fields): Move up in the file. (record-type-constructor, record-type-flags, record-type-parents): New accessors. (make-record-type): Take #:final? and #:parent keyword arguments. (record-constructor): Delegate to record-type-constructor. (record-predicate): For non-final types --types that can be extended by subtyping -- implement an O(1) type predicate. (define-record-type): Initialize the new fields. * module/srfi/srfi-9.scm (%define-record-type): Initialize flags and parent fields.
2019-10-22Deprecate two-arg `record-constructor'Andy Wingo1-11/+18
* module/ice-9/boot-9.scm (record-constructor): Deprecate the two-arg form.
2019-10-22Re-implement (ice-9 gap-buffer) records in terms of srfi-9Andy Wingo1-38/+24
* module/ice-9/gap-buffer.scm (gap-buffer): Use srfi-9.
2019-10-21Remove (ice-9 channel)Andy Wingo2-171/+0
* module/ice-9/channel.scm: Remove. This file has had a bug since 2.0 or so that prevented loading the module; I can only conclude that it hasn't worked for years. * module/Makefile.am (SOURCES): Remove ice-9/channel.scm.
2019-10-21Refactor PEG recordsAndy Wingo1-21/+20
* module/ice-9/peg/using-parsers.scm (prec): Use SRFI-9 to define PEG record types. (peg:start, peg:end, peg:string, peg:tree, peg:substring): Implement in a more efficient way.
2019-09-27Extend `import' to allow R7RS-style srfi referencesAndy Wingo1-7/+15
* module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface): Allow for srfis to be accessed via (srfi 42 foo) in addition to (srfi :42 foo).
2019-09-27(ice-9 safe-r5rs) fixes for bound aux syntaxAndy Wingo2-129/+214
* module/ice-9/safe-r5rs.scm: Define local versions of `case' and `cond' that assume aux syntax is unbound. If this doesn't work, we can switch to exporting aux syntax. * module/ice-9/top-repl.scm (top-repl): Don't add (ice-9 r5rs) to the REPL environment.
2019-09-27(ice-9 null) also exports aux syntax, syntax-rulesAndy Wingo1-13/+16
* module/ice-9/null.scm: Add more syntactic exports.
2019-09-27Deprecate passing a non-zero size to make-moduleAndy Wingo8-27/+29
* module/ice-9/boot-9.scm (make-module): Issue a deprecation warning if users pass a non-zero size. (nested-define-module!, make-modules-in, beautify-user-module!) (resolve-interface, make-autoload-interface, %cond-expand-table): * module/ice-9/popen.scm (port/pid-table): * module/ice-9/session.scm (make-fold-modules): * module/language/ecmascript/function.scm (*program-wrappers*): * module/scripts/api-diff.scm (read-api-alist-file): * module/srfi/srfi-10.scm (reader-ctors): Update callers. Also remove some make-hash-table sizes.
2019-09-27(ice-9 null) also re-exports core aux syntaxAndy Wingo1-2/+2
* module/ice-9/null.scm: Re-export _, else, =>, and the ellipsis.
2019-09-27Avoid mutating arguments to resolve-interfaceAndy Wingo1-23/+28
* module/ice-9/boot-9.scm (resolve-interface): This function used to mutate the #:hide argument, which results in terrorism if the value is a literal.
2019-09-27Better R6RS compatibilityAndy Wingo1-1/+2
* module/ice-9/boot-9.scm (install-r6rs!): Also enable `hungry-eol-escapes'. * doc/ref/r6rs.texi (R6RS Incompatibilities): Document lack of unicode escapes in symbols.
2019-09-25Add --r6rs command-line optionAndy Wingo1-0/+6
* doc/ref/guile-invoke.texi (Command-line Options): Document --r6rs. * doc/ref/r6rs.texi (R6RS Incompatibilities): Mention that --r6rs calls install-r6rs!. * module/ice-9/command-line.scm (*usage*, compile-shell-switches): Implement --r6rs.
2019-09-25New function: install-r6rs!Andy Wingo1-0/+13
* doc/ref/r6rs.texi (R6RS Incompatibilities): Document install-r6rs!. * module/ice-9/boot-9.scm (install-r6rs!): New function.
2019-09-12Define top-level bindings for aux syntax: else, =>, _, ...Andy Wingo4-4/+21
* module/ice-9/boot-9.scm (else, =>, ..., _): New definitions. These are specified by the r6rs and the r7rs. * module/ice-9/sandbox.scm (core-bindings): Include the aux syntax definitions. * module/rnrs/base.scm: * module/rnrs.scm: Re-export aux syntax.
2019-09-12Use "G_" as the conventional alias for gettextAndy Wingo2-15/+15
Since the change in 2.2 noted in the NEWS as "Fix literal matching for module-bound literals", defining `_' makes `syntax-rules' and `match' fail to recognize `_' as the catch-all literal. This change adapts the recommendations to current practice in 2.2, as users have had to adapt to this change. * doc/ref/api-i18n.texi (Gettext Support): Update documentation. * module/language/tree-il/analyze.scm (proc-ref?, gettext?): G_ is the conventional abbreviation, not _. * test-suite/tests/tree-il.test: Adapt. * module/ice-9/command-line.scm: Use G_ instead of _.
2019-09-01Optimize fixnum or s64 -> f64 conversionsAndy Wingo9-4/+70
* libguile/intrinsics.c (scm_bootstrap_intrinsics): * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add "inexact" intrinsic. * libguile/jit.c (compile_s64_to_f64): New compiler. * libguile/vm-engine.c (s64->f64): New instruction. * module/language/cps/effects-analysis.scm (heap-numbers-equal?): * module/language/cps/reify-primitives.scm (compute-known-primitives): * module/language/cps/slot-allocation.scm (compute-var-representations): * module/language/cps/specialize-numbers.scm (fixnum->f64): (specialize-operations): * module/language/cps/type-fold.scm (scm->f64, inexact): * module/language/cps/types.scm (inexact, s64->f64): * module/language/tree-il/cps-primitives.scm (exact->inexact): * module/language/tree-il/primitives.scm (*interesting-primitive-names*): (*effect-free-primitives*): * module/system/vm/assembler.scm: Recognize exact->inexact as a primitive, and optimize it. Add compiler support for new "inexact" and "s64->f64" primcalls.
2019-08-29Have disassemble-file accept an optional output portDaniel Llorens1-2/+2
* module/system/vm/disassembler.scm (disassemble-file): As stated.
2019-08-28At optimization level -O3, seal declarative module-private bindingsAndy Wingo2-3/+52
* module/language/tree-il/letrectify.scm (compute-private-toplevels): New function; computes the subset of declarative bindings that are private to a module. If the module exports a macro, all bindings are public, as we have no way to know what binding might be exported. (letrectify): Add #:seal-private-bindings? keyword arg. If true, avoid making boxes for private definitions. * module/language/tree-il/optimize.scm (optimize): Add -Oseal-private-bindings, enabled at -O3.
2019-08-28Emit warning when using "load" in declarative modulesAndy Wingo1-0/+7
* module/ice-9/boot-9.scm (load): Emit a warning at compile-time when using "load" from a declarative module.
2019-08-28Fix bug in CSE auxiliary definitionsAndy Wingo1-16/+19
* module/language/cps/cse.scm (compute-equivalent-subexpressions): When CSE sees a definition like `(cons a b)', it will also record an "auxiliary definition" for `(car x)', where x is the variable defined by the cons, whereby calling `(car x)' can reduce to `a' if there is no intervening effect that clobbers the definitions. However, when the successor of the cons is a control-flow join, then any variables defined there have multiple definitions. It's incorrect to add the aux definition in that case. * test-suite/tests/compiler.test ("cse auxiliary definitions"): New test.
2019-08-26Compiler allocates boxed flonums in unmarked spaceAndy Wingo6-3/+31
This fixes a bug whereby the compiler would sometimes allocate floats in marked space. * libguile/gc-inline.h (scm_inline_gc_malloc_pointerless_words): New internal helper. * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): * libguile/intrinsics.c (allocate_pointerless_words): (allocate_pointerless_words_with_freelist): New intrinsics. * libguile/jit.c (compile_allocate_pointerless_words): (compile_allocate_pointerless_words_immediate): New compilers. * libguile/vm-engine.c (allocate_pointerless_words) (allocate_pointerless_words_immediate): New opcodes. * module/language/cps/compile-bytecode.scm (compile-function): * module/language/cps/effects-analysis.scm (param): * module/language/cps/reify-primitives.scm (reify-primitives): * module/language/cps/specialize-primcalls.scm (specialize-primcalls): * module/language/cps/types.scm (allocate-words): (allocate-words/immediate): * module/system/vm/assembler.scm (system): Add support for the new opcodes.
2019-08-25Allow mixed local definitions and expressionsAndy Wingo2-260/+314
This change to the expander allows mixed local definitions and expressions. The expansion turns: (let () (a) (define (b) 42) (b) (b)) into: (let () (letrec* ((t0 (begin (a) (if #f #f))) (b (lambda () 42))) (b))) Which is to say, expressions that precede definitions are expanded as definitions of a temporary via (begin EXP (if #f #f)). * module/ice-9/psyntax.scm (expand-body): Allow mixed definitions and expressions. * module/ice-9/psyntax-pp.scm: Regenerate. * test-suite/tests/syntax.test: Add a couple tests and update for new error messages.
2019-08-25Letrectify only on -O2; update docsAndy Wingo1-1/+6
* doc/ref/api-evaluation.texi (Compilation): Document the -O options. * doc/ref/api-modules.texi (Using Guile Modules): @@ docs refer to declarative modules. (Creating Guile Modules): Use when for 1-armed if. (Declarative Modules): Make implications of declarative bindings more explicit, and explicitly document ways to disable the optimization. * module/language/tree-il/optimize.scm (tree-il-optimizations): Punt letrectification to -O2.
2019-08-24Unbox floor/ceiling and trigonometric functions where possibleAndy Wingo8-8/+190
* libguile/intrinsics.c (scm_atan1): New intrinsic, wrapping scm_atan. (scm_bootstrap_intrinsics): Add new intrinsics. * libguile/intrinsics.h (scm_t_f64_from_f64_f64_intrinsic): New intrinsic type. (SCM_FOR_ALL_VM_INTRINSICS): Add intrinsics for floor, ceiling, sin, cos, tan, asin, acos, atan, and their unboxed counterparts. * libguile/jit.c (sp_f64_operand): New helper. (compile_call_f64_from_f64, compile_call_f64_from_f64_f64): Call out to intrinsics. * libguile/vm-engine.c (call-f64<-f64-f64): New opcode. * module/language/cps/effects-analysis.scm: Add new intrinsics. * module/language/cps/reify-primitives.scm (compute-known-primitives): Add new intrinsics. * module/language/cps/slot-allocation.scm (compute-var-representations): Add 'f64 slot types for the new unboxed intrinsics. * module/language/cps/specialize-numbers.scm (specialize-operations): Support unboxing the new intrinsics. * module/language/cps/types.scm: Define type inferrers for the new intrinsics. * module/language/tree-il/cps-primitives.scm: Define CPS translations for the new intrinsics. * module/language/tree-il/primitives.scm (*interesting-primitive-names*): (*effect-free-primitives*, atan): Define primitive resolvers. * module/system/vm/assembler.scm: Export assemblers for the new intrinsics. (define-f64<-f64-f64-intrinsic): New helper.
2019-08-18Define missing shuffling assembler for string-set! et alAndy Wingo1-0/+11
* module/system/vm/assembler.scm (encode-X8_S8_S8_S8-C32!/shuffle): Define shuffling assembler for this instruction type.
2019-08-18Skip tests that don't work under letrectificationAndy Wingo1-1/+12
* test-suite/tests/srfi-64-test.scm: Skip a couple of tests that have unspecified result due to eq? being unspecified on procedures. * module/language/tree-il/letrectify.scm (letrectify): Add a comment.
2019-08-18Enable letrectificationAndy Wingo1-4/+7
* module/language/tree-il/optimize.scm: Enable letrectification at -O1 and higher.
2019-08-18Add notion of declarative modulesAndy Wingo2-30/+41
* doc/ref/api-modules.texi (Declarative Modules): New subsection. * module/ice-9/boot-9.scm (module): Change eval-closure slot, which was deprecated and unused, to be a "declarative?" slot, indicating that definitions from the module are declarative. (user-modules-declarative?): New parameter. (make-fresh-user-module): Set declarative according to parameter. (define-module*, define-module): Add #:declarative? keyword argument, defaulting to the value of user-modules-declarative? parameter when the module was expanded. (guile-user): This module is not declarative. * module/language/tree-il/letrectify.scm (compute-declarative-toplevels): Use the new declarative? module flag.