summaryrefslogtreecommitdiff
path: root/libguile
AgeCommit message (Collapse)AuthorFilesLines
2019-12-10Move assert-nargs-le slow path out of lineAndy Wingo1-10/+5
* libguile/jit.c (compile_assert_nargs_le) (compile_assert_nargs_le_slow): Move slow path out of line.
2019-12-10Add out-of-line slow path for abortAndy Wingo1-7/+3
* libguile/jit.c (compile_abort, compile_abort_slow): Move interpreter fallback to slow path.
2019-12-10Add out-of-line slow path for compose-continuationAndy Wingo1-6/+2
* libguile/jit.c (compile_compose_continuation) (compile_compose_continuation_slow): Move interpreter fallback to slow path.
2019-12-10Add subr-call out-of-line slow pathAndy Wingo1-9/+14
* libguile/jit.c (emit_branch_if_heap_object_has_tc7): New helper. (compile_subr_call, compile_subr_call_slow): Add a slow path for the values case.
2019-12-10Move alloc-frame slow path out of lineAndy Wingo1-25/+50
* libguile/jit.c (compile_alloc_frame, compile_alloc_frame_slow): Move slow path out of line. (emit_alloc_frame_for_sp_fast, emit_alloc_frame_for_sp_slow): New helpers. (emit_alloc_frame): Refactor to use the new helpers. (compile_push, compile_push_slow): Use the new helpers. (compile_assert_nargs_ee_locals, compile_assert_nargs_ee_locals_slow): Split off a slow path.
2019-12-10Move assert-nargs-ge slow path out of lineAndy Wingo1-12/+5
* libguile/jit.c (compile_assert_nargs_ge) (compile_assert_nargs_ge_slow): Move slow path out of line.
2019-12-10Move assert-nargs-ee slow path out of lineAndy Wingo1-11/+14
* libguile/jit.c (compile_assert_nargs_ee) (compile_assert_nargs_ee_slow): Move slow path out of line.
2019-12-10Move receive-values slow path out of lineAndy Wingo1-18/+10
* libguile/jit.c (compile_receive_values, compile_receive_values_slow): Move slow path out of line.
2019-12-10Move receive slow path out of lineAndy Wingo1-7/+4
* libguile/jit.c (compile_receive, compile_receive_slow): Move slow path out of line.
2019-12-10Move handle-interrupts slow path out of lineAndy Wingo1-17/+9
* libguile/jit.c (compile_handle_interrupts) (compile_handle_interrupts_slow): Move slow path out of line.
2019-12-10Move add, sub slow paths out of lineAndy Wingo1-37/+34
* libguile/jit.c (compile_call_scm_from_scm_sc) (compile_call_scm_from_scm_scm_slow): Move non-fixnum path out of line.
2019-12-10Move add/immediate, sub/immediate slow paths out of lineAndy Wingo1-29/+34
* libguile/jit.c (compile_call_scm_from_scm_uimm) (compile_call_scm_from_scm_uimm_slow): Move non-fixnum path out of line.
2019-12-10Add infrastructure for out-of-line JIT compilation of slow pathsAndy Wingo1-20/+750
* libguile/jit.c (struct pending_reloc): Rename target_vcode_offset field to target_label_offset. (inline_label_offset, slow_label_offset): New helpers. (emit_direct_tail_call): Use inline_label_offset helper. (add_pending_reloc): Factor out of add_inter_instruction_patch. (add_inter_instruction_patch): Use inline_label_offset helper. (add_slow_path_patch): New helper. (continue_after_slow_path): New helper. Add slow path compilers for all instructions. (compile_slow_path): New helper. (compile): Compile slow paths after main code. (compute_mcode): Allocate twice as many labels.
2019-12-09Remove vm->sp_min_since_gcAndy Wingo4-50/+13
* libguile/jit.c (emit_alloc_frame_for_sp): * libguile/vm-engine.c (ALLOC_FRAME, RESET_FRAME): * libguile/vm.c (vm_increase_sp, scm_i_vm_prepare_stack): (return_unused_stack_to_os, vm_expand_stack, alloc_frame): (scm_call_with_stack_overflow_handler): * libguile/vm.h (struct scm_vm): Remove sp_min_since_gc handling. It was a very minor optimization when it was centralized in vm.c, but now with JIT it's causing too much duplicate code generation.
2019-12-09Fix non-deterministic crash in 'finalization_thread_proc'.Ludovic Courtès1-13/+18
Fixes <https://bugs.gnu.org/37757>. Reported by Jesse Gibbons <jgibbons2357@gmail.com>. * libguile/finalizers.c (finalization_thread_proc): Do not enter the "switch (data.byte)" condition when data.n <= 0.
2019-12-08Fix JIT tier-up from within loops for already-JIT-compiled functionsAndy Wingo1-26/+30
* libguile/jit.c (scm_jit_compute_mcode): If a caller wants mcode for a loop but the function already has mcode, instead of punting, just compile again.
2019-11-25Fix stack overflow if printing a pre-boot error throws an errorAndy Wingo1-5/+14
* libguile/throw.c (scm_throw): Fall back to fprintf if all is lost.
2019-11-18ports: 'scm_port_poll' honors "w" flags.Ludovic Courtès1-1/+1
Fixes <https://bugs.gnu.org/36709>. Reported by Mark H Weaver <mhw@netris.org>. * libguile/ports.c (scm_port_poll): Replace second POLLIN by POLLOUT.
2019-11-16Allow equality between arrays of vu8 and u8Andy Wingo1-3/+15
* libguile/array-map.c (scm_array_equal_p): Treat vu8 and u8 arrays as equivalent.
2019-11-13Rebase throw/catch on top of raise-exception/with-exception-handlerAndy Wingo7-393/+750
* 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-07Remove boot "catch" definition.Andy Wingo1-5/+4
* libguile/throw.c (scm_init_throw): Remove boot definition of "catch".
2019-09-01Optimize fixnum or s64 -> f64 conversionsAndy Wingo4-1/+26
* 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-26Compiler allocates boxed flonums in unmarked spaceAndy Wingo5-2/+114
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-25Fix fatan2 intrinsic initializationAndy Wingo1-1/+1
* libguile/intrinsics.c (scm_bootstrap_intrinsics): Fix fatan2 initialization.
2019-08-24Revert "Revert scm_c_make_char rename"Andy Wingo7-33/+33
My reversion of Mark's commit was in error; the supposed ABI change was never released. This reverts commit 3925a64682be333af2e8d15e8173f06d3272f4e4.
2019-08-24Unbox floor/ceiling and trigonometric functions where possibleAndy Wingo4-2/+88
* 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-19Fix the jitless fixAndy Wingo1-1/+1
* libguile/vm.c (capture_continuation): Use #if, not #ifdef, to test the condition.
2019-08-19Disable some JIT compilation code when JIT configured outAndy Wingo1-0/+7
* libguile/vm.c (vm_recompute_disable_mcode, capture_continuation): Disable logic if JIT not configured.
2019-08-18Add "mod" field to tree-il toplevel ref, set, defineAndy Wingo2-17/+24
Add "mod" field to <toplevel-ref>, <toplevel-set>, and <toplevel-define>, indicating the expander's idea of what the current module is when a toplevel variable is accessed or created. This will help in later optimizations. * libguile/expand.c (TOPLEVEL_REF, TOPLEVEL_SET, TOPLEVEL_DEFINE) (expand, expand_define, expand_set_x, convert_assignment): * libguile/expand.h (SCM_EXPANDED_TOPLEVEL_REF_FIELD_NAMES): (SCM_MAKE_EXPANDED_TOPLEVEL_REF, SCM_EXPANDED_TOPLEVEL_SET_FIELD_NAMES): (SCM_MAKE_EXPANDED_TOPLEVEL_SET, SCM_EXPANDED_TOPLEVEL_DEFINE_FIELD_NAMES): (SCM_MAKE_EXPANDED_TOPLEVEL_DEFINE): * module/ice-9/compile-psyntax.scm (translate-literal-syntax-objects): * module/ice-9/psyntax-pp.scm: * module/ice-9/psyntax.scm: * module/language/tree-il.scm: * module/language/tree-il.scm (parse-tree-il, make-tree-il-folder): (pre-post-order): * module/language/tree-il/analyze.scm (goops-toplevel-definition): (macro-use-before-definition-analysis, proc-ref?, format-analysis): * module/language/tree-il/compile-cps.scm (convert): * module/language/tree-il/debug.scm (verify-tree-il): * module/language/tree-il/effects.scm (make-effects-analyzer): * module/language/tree-il/fix-letrec.scm (free-variables): * module/language/tree-il/peval.scm (peval): * test-suite/tests/tree-il.test: Adapt uses.
2019-08-04Add support for optimized unboxed abs and sqrtAndy Wingo4-1/+56
Some components of this have been wired up for a while; this commit finishes the compiler, runtime, and JIT support. * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): * libguile/intrinsics.c (scm_bootstrap_intrinsics): Declare the new intrinsics. * libguile/jit.c (compile_call_f64_from_f64): Define code generators for the new intrinsics. * libguile/vm-engine.c (call-f64<-f64): New instruction. * module/language/cps/effects-analysis.scm: * module/language/cps/reify-primitives.scm (compute-known-primitives): * module/language/cps/slot-allocation.scm (compute-var-representations): * module/language/cps/specialize-numbers.scm (specialize-operations): * module/language/tree-il/cps-primitives.scm (abs): * module/system/vm/assembler.scm (system, define-f64<-f64-intrinsic): (sqrt, abs, fsqrt, fabs): * module/language/cps/types.scm (fsqrt, fabs): Add new f64<-f64 primitives.
2019-08-03Fix some compiler warnings on 64-bit buildsAndy Wingo1-18/+2
2019-08-02Fix calls to handle-interrupts trampoline on ARMv7Andy Wingo1-2/+0
* libguile/jit.c (initialize_jit): Keep handle_interrupts_trampoline as an address, not a function pointer.
2019-08-02Merge from stable-2.2Andy Wingo1-12/+12
2019-08-02Merge from stable-2.2Andy Wingo1-3/+1
2019-08-02Revert scm_c_make_char renameAndy Wingo7-33/+33
This was, I think, an unintentional ABI change. Reverts 579dd2da449be194a95d41a27317a453c1aa0568.
2019-08-02Merge from stable-2.2Andy Wingo1-7/+2
2019-08-02Merge from stable-2.2Andy Wingo1-9/+38
2019-08-02Merge from stable-2.2Andy Wingo1-1/+1
2019-08-02Merge from stable-2.2Andy Wingo1-2/+2
2019-08-02Merge from stable-2.2Andy Wingo2-7/+50
2019-08-02Merge from stable-2.2Andy Wingo1-6/+5
2019-08-02Merge from stable-2.2Andy Wingo1-2/+2
2019-08-02Merge from stable-2.2Andy Wingo1-0/+2
2019-08-02Merge from stable-2.2Andy Wingo8-71/+139
2019-08-02Merge from stable-2.2Andy Wingo1-4/+13
2019-06-30'strftime' and 'strptime' honor the locale encoding.Ludovic Courtès1-12/+12
Fixes <https://bugs.gnu.org/35920>. Reported by Christopher Lam <christopher.lck@gmail.com>. * libguile/stime.c (scm_strftime): Use 'scm_to_locale_stringn' instead of 'scm_to_utf8_stringn'. (scm_strptime): Likewise, and use 'scm_string_length' instead of 'u8_strnlen'. * test-suite/tests/time.test ("strftime")["strftime passes wide characters"]: Wrap body in 'with-locale'. ["strftime fr_FR.utf8", "strftime fr_FR.iso88591"]: New tests. ("strptime")["strftime fr_FR.utf8", "strftime fr_FR.iso88591"]: New tests.
2019-06-24Remove references to 'inet-ntoa' and 'inet-aton'.Ludovic Courtès1-3/+1
These procedures were removed in Guile 2.2 by commit fc7bd367ab4b5027a7f80686b1e229c62e43c90b (May 2011). * libguile/socket.h (scm_inet_aton, scm_inet_ntoa): Remove. * module/system/repl/server.scm (make-tcp-server-socket): Use 'inet-pton' instead of 'inet-aton'. * doc/ref/web.texi (HTTP): Likewise in 'declare-header!' example. * doc/ref/posix.texi (Network Address Conversion): Remove documentation of 'inet-ntoa' and 'inet-aton'.
2019-06-20Add an inlined jit fast-path for allocate-words/immediateAndy Wingo3-7/+46
* libguile/intrinsics.c (allocate_words_with_freelist) (scm_bootstrap_intrinsics): * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): New intrinsic. * libguile/jit.c (compile_allocate_words_immediate): Add fast-path. A marginal improvement.
2019-06-20Inline freelist vectors into scm_threadAndy Wingo3-35/+27
* libguile/gc-inline.h: * libguile/threads.h (SCM_INLINE_GC_GRANULE_WORDS) (SCM_INLINE_GC_GRANULE_BYTES, SCM_INLINE_GC_FREELIST_COUNT): Move definitions here, from gc-inline.h. (struct scm_thread): Inline freelist vectors. * libguile/threads.c (thread_mark): Update marker for pointerless freelists. (on_thread_exit): Clear individual freelist entries, instead of the vector as a whole. (guilify_self_2): No need to alloc freelist vectors.
2019-06-20Rearrange scm_thread for better localityAndy Wingo1-12/+12
* libguile/threads.h (struct scm_thread): Move async-related bits up, so that the VM can access them easier. Likewise for freelists (which we will inline soon).