1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-04 05:50:26 +02:00
Commit graph

20082 commits

Author SHA1 Message Date
Andy Wingo
cd8c1f7e5d Remove _scm.h verify.h inclusion
* libguile/_scm.h: Remove unneeded verify.h inclusion.
2018-06-17 19:49:15 +02:00
Andy Wingo
68d9780ce4 Remove errno.h include from _scm.h.
* libguile/_scm.h: Remove errno.h include.
* libguile/bytevectors.c:
* libguile/debug.c:
* libguile/finalizers.c:
* libguile/loader.c:
* libguile/poll.c:
* libguile/strings.c:
* libguile/threads.c:
* libguile/vm.c: Add errno.h include.  Sort includes as needed.
2018-06-17 19:46:33 +02:00
Andy Wingo
5c511be7b6 Remove _scm.h inclusion of config.h
* libguile/_scm.h: Remove inclusion of config.h.  All includers already
  include config.h.
* libguile/syscalls.h: Remove config.h inclusion here too.
2018-06-17 19:46:14 +02:00
Andy Wingo
7b4ab0895b Inline definition of SIZEOF_SCM_T_BITS
* libguile/_scm.h (SIZEOF_SCM_T_BITS): Remove definition.
* libguile/conv-integer.i.c (SCM_TO_TYPE_PROTO, SCM_FROM_TYPE_PROTO):
* libguile/conv-uinteger.i.c (SCM_FROM_TYPE_PROTO):
* libguile/gc.c (DEFAULT_INITIAL_HEAP_SIZE):
* libguile/hashtab.c:
* libguile/loader.c:
* libguile/socket.c:
* libguile/vm-engine.c (VM_NAME): Use SIZEOF_UINTPTR_T instead of
  SIZEOF_SCM_T_BITS.
2018-06-17 19:21:42 +02:00
Andy Wingo
ea3c5cf909 Refactor regarding internal detection of ia64
* libguile/_scm.h: Remove hack to define __ia64__.
* libguile/continuations.c (capture_auxiliary_stack): Use __ia64 or
  __ia64__ to detect itanium.
2018-06-17 19:16:14 +02:00
Andy Wingo
ba26559795 Remove _scm hack to undefine HAVE_STRUCT_TIMESPEC
* libguile/_scm.h (HAVE_STRUCT_TIMESPEC): Remove hack to undefine this
  variable, which is never defined in Guile's build.
2018-06-17 19:14:38 +02:00
Andy Wingo
5159a15306 More _scm.h refactoring
* libguile/foreign.c (ROUND_UP): Copy here.
* libguile/vm.c (SCM_NOINLINE): Move here, to the only file that uses
  it.
  (ROUND_UP): Copy here.
* libguile/_scm.h (ROUND_UP, SCM_NOINLINE): Remove.  Centralizing
  private definitions isn't bad, but _scm.h also includes a bunch of
  Guile API as well, and the include itself is poorly named.
2018-06-17 19:10:52 +02:00
Andy Wingo
5176db70ca Move syscall-related private defines to their own header
* libguile/syscalls.h: New private header.
* libguile/Makefile.am
  (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): Add syscalls.h.
* libguile/_scm.h: Remove SCM_SYSCALL and all the bits relating to
  e.g. stat versus stat64.
* libguile/filesys.c:
* libguile/fports.c:
* libguile/i18n.c:
* libguile/ioext.c:
* libguile/poll.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/rw.c:
* libguile/scmsigs.c:
* libguile/script.c:
* libguile/socket.c:
* libguile/strports.c: Include syscalls.h.
2018-06-17 18:18:26 +02:00
Andy Wingo
f84ce5442e Refactor handling of auxiliary stacks and setjmp/longjmp
* libguile/__scm.h (scm_i_jmp_buf): Remove definition, which was a shim
  for ia64.  Instead, always use setjmp/longjmp and jmp_buf.
* libguile/_scm.h (SCM_I_SETJMP, SCM_I_LONGJMP): Remove; instead use
  setjmp and longjmp.
* libguile/continuations.c (capture_auxiliary_stack):
  (restore_auxiliary_stack): New helpers.
  (scm_i_make_continuation): Use capture_auxiliary_stack.
  (copy_stack_and_call): Use restore_auxiliary_stack.  No need to stash
  the aux stack on the thread, either.
* libguile/continuations.h (scm_t_contregs): Use
  SCM_HAVE_AUXILIARY_STACK to flag when to have an auxiliary_stack
  member.
* libguile/control.h:
* libguile/control.c (reify_partial_continuation, scm_c_abort):
  (scm_suspendable_continuation_p): Adapt to use setjmp/longjmp
  directly.
* libguile/deprecated.h: Add deprecated scm_i_jmp_buf define.
* libguile/dynstack.h:
* libguile/dynstack.c (PROMPT_JMPBUF):
  (scm_dynstack_push_prompt, scm_dynstack_find_prompt):
  (scm_dynstack_wind_prompt): Adapt to jmp_buf type.
* libguile/eval.c (eval): Use jmp_buf and setjmp directly.
* libguile/gc-malloc.c: No need for ia64-specific things.
* libguile/gc.c: No need for ia64-specific things.
* libguile/gc.h: No need to declare scm_ia64_ar_bsp.
* libguile/init.c: Remove typedef of setjmp_type for Cray, unused.
* libguile/threads.c (guilify_self_1): No more pending_rbs_continuation
  in scm_i_thread, and register_backing_store_base is handled by libgc.
  (scm_ia64_ar_bsp): Remove definitions; inlined into continuations.c's
  capture_auxiliary_stack.
* libguile/threads.h (scm_i_thread): jmpbuf member is plain jmp_buf.
* libguile/throw.c (catch): Just use jmp_buf and setjmp.
* libguile/vm-engine.c (VM_NAME): Adapt prototype to take jmp_buf
  pointer.
* libguile/vm.c (vm_abort): Adapt jmp_buf types.
  (scm_call_n): Use setjmp.
2018-06-17 13:41:03 +02:00
Andy Wingo
574f67d1b6 Add configure check for auxiliary stacks
* configure.ac: Add a check for struct GC_stack_base.reg_base, which is
  a proxy for checking for the only aspect of ia64 that we care about.
* libguile/gen-scmconfig.c:
* libguile/gen-scmconfig.h.in: Arrange to define
  SCM_HAVE_AUXILIARY_STACK.
2018-06-17 13:41:03 +02:00
Andy Wingo
b2515e65bd Remove unused getters for register backing store base
* libguile/gc.h:
* libguile/threads.c: Remove unused implementations of
  scm_ia64_register_backing_store_base, as libgc does this for us.
2018-06-17 13:41:03 +02:00
Andy Wingo
418a7d7af9 Remove #ifdef cases for VMS and Cray.
* libguile/__scm.h:
* libguile/_scm.h:
* libguile/feature.c (scm_init_feature): Remove VMS and Cray cases.
2018-06-17 13:41:03 +02:00
Andy Wingo
f6ec873a8b Move "min" and "max" macros out of _scm.h
* libguile/_scm.h: Remove definitions of min and max macros.
* libguile/array-map.c (MAX):
* libguile/foreign.c (MAX):
* libguile/numbers.c (MIN):
* libguile/quicksort.i.c (MIN):
* libguile/socket.c (MAX):
* libguile/strports.c (MAX): Inline definitions into callers.  We're
  going to remove _scm.h, which will pay off this duplication.
2018-06-17 13:41:03 +02:00
Andy Wingo
2f39771c84 Simplify definition of SCM_SYSCALL.
* libguile/_scm.h (SCM_SYSCALL): Simplify definition.
2018-06-17 13:41:03 +02:00
Andy Wingo
791341bdd2 Move some definitions out of _scm.h
* libguile/_scm.h:
* libguile/loader.h (SCM_OBJCODE_ENDIANNESS):
  (SCM_OBJCODE_WORD_SIZE, SCM_OBJCODE_MAJOR_VERSION):
  (SCM_OBJCODE_MINOR_VERSION, SCM_OBJCODE_MAJOR_VERSION_STRING):
  (SCM_OBJCODE_MINOR_VERSION_STRING):
  (SCM_OBJCODE_VERSION_STRING, SCM_OBJCODE_MACHINE_VERSION_STRING): Move
  definitions to loader.h.
2018-06-17 13:41:03 +02:00
Andy Wingo
83584ef231 Fix libguile subcomponent headers not to include <libguile.h>
* libguile/bytevectors.h: Include uniform.h, for use in the macros.
* libguile/extensions.h: Include libpath.h, for the
  SCM_EFFECTIVE_VERSION, which is almost always used with these
  routines.
* libguile/frames.h:
* libguile/instructions.h:
* libguile/intrinsics.h:
* libguile/loader.h:
* libguile/programs.h:
* libguile/vm.h: Include <libguile/__scm.h> instead of <libguile.h>.
  Cuts a circular include, but also precipitates a lot of maintenance in
  the .c files.

* libguile/*.c: Update C files to add needed all needed includes that
  before were getting automatically pulled in by the indirect inclusion
  of libguile.h.
2018-06-14 22:20:47 +02:00
Andy Wingo
ceaf782770 Call out to expand_stack through new VM intrinsic
* libguile/intrinsics.h (scm_t_vp_sp_intrinsic): New type.
  (SCM_FOR_ALL_VM_INTRINSICS): Add expand-stack.
* libguile/vm-engine.c (ALLOC_FRAME): Call through the intrinsics.
* libguile/vm.c (scm_bootstrap_vm): Initialize the expand-stack
  intrinsic.
2018-06-11 21:27:37 +02:00
Andy Wingo
3b463516ef Remove unused vm_error_unbound
* libguile/vm.c: Remove unused function.
2018-06-11 21:21:30 +02:00
Mark H Weaver
ac9f0831c1
Add copyright header for (language elisp falias), and fix typo.
* module/language/elisp/falias.scm: Add copyright header.
* module/language/elisp/spec.scm: Fix typo in header.
2018-06-11 10:14:28 -04:00
Mark H Weaver
bff75635e5
elisp: Fix cross-compilation support.
* module/system/base/target.scm (with-native-target): New exported
procedure.
* module/language/elisp/spec.scm: In the top-level body expression, call
'compile-and-load' within 'with-native-target' to compile native code.
* module/language/elisp/compile-tree-il.scm
(eval-when-compile, defmacro): Compile native code.
2018-06-11 10:12:54 -04:00
Mark H Weaver
9fbb367256
Fix error reporting in 'load-thunk-from-memory'.
Previously 'load-thunk-from-memory' would often throw to 'system-error'
based on a stale value in 'errno', leading to incorrect error messages.

* libguile/loader.c (load_thunk_from_memory): Set 'errno' to 0 before
jumping to cleanup in the ABORT preprocessor macro, and also in the case
when 'process_dynamic_segment' reports an error.
2018-06-11 10:12:52 -04:00
Mark H Weaver
ff2adb04cb
goops: Fix 'instance?' to work on objects that aren't structs.
Fixes <https://bugs.gnu.org/31606>
Reported by Tommi Höynälänmaa <tommi.hoynalanmaa@gmail.com>

* module/oop/goops.scm (instance?): Check that OBJ is a struct
before applying 'struct-vtable' to it.
2018-06-11 10:12:50 -04:00
Mark H Weaver
e1dffd3504
Avoid inexact arithmetic in the type inferrer for 'sqrt'.
* module/language/cps/types.scm: Use 'exact-integer-sqrt' and avoid
inexact arithmetic in the range analysis of the type inferrer for
'sqrt'.
2018-06-11 10:12:47 -04:00
Mark H Weaver
2733e97395
Fix type inference for bitwise logical operators.
Fixes <https://bugs.gnu.org/31474> and related bugs.
Reported by Jan Nieuwenhuizen <janneke@gnu.org>.

* module/language/cps/types.scm (next-power-of-two): Remove procedure.
(non-negative?, lognot*, saturate+, saturate-, logand-bounds)
(logsub-bounds, logior-bounds, logxor-bounds): New procedures.  Use them
to improve and fix bugs in the range analysis of the type inferrers for
'logand', 'logsub', 'logior', 'ulogior', 'logxor', 'ulogxor', and
'lognot'.
2018-06-11 10:12:45 -04:00
Mark H Weaver
df93752479
Revert "Minor CSE run-time optimization"
Fixes <https://bugs.gnu.org/30020>.
Reported by David Thompson <dthompson2@worcester.edu>.

This reverts commit d4883307ca.
2018-06-11 10:12:43 -04:00
Mark H Weaver
1951edff58
Fix typo in comment within numbers.c 2018-06-11 10:12:35 -04:00
Andy Wingo
dbe5a7edc6 Remove unused macro in vm-engine
* libguile/vm-engine.c (VARIABLE_BOUNDP): Remove.
2018-05-14 16:55:30 +02:00
Andy Wingo
601d0eaf83 Remove implementations of now-unused toplevel-box et al instructions
* libguile/vm-engine.c (resolve, define!, toplevel-box, module-box):
  Remove implementations.
2018-05-14 16:46:22 +02:00
Andy Wingo
76eac85084 Use intrinsics for top-level refs outside captured scopes
* module/language/tree-il/compile-cps.scm (toplevel-box): Reify
  intrinsic calls for top-level references outside captured scopes.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Update set of macro-instructions.
2018-05-14 16:25:50 +02:00
Andy Wingo
ceffb5e990 Compile "define!" via intrinsic
* libguile/intrinsics.c (scm_bootstrap_intrinsics):
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add new define!
  intrinsic.
* module/language/cps/compile-bytecode.scm (compile-function): Adapt
  compilation for define! to take two arguments.
* module/language/cps/effects-analysis.scm (current-module): Update
  define! for two arguments.
* module/language/tree-il/compile-cps.scm (convert): When reifying
  "define", grab the current module.
* module/system/vm/assembler.scm (define!): Define assembler as
  intrinsic.
2018-05-14 15:15:22 +02:00
Andy Wingo
77e7bea4c2 Remove backend support for cached-module-box et al.
* module/language/cps/compile-bytecode.scm (compile-function): Remove
  unused assemblers for cached-module-box, cached-toplevel-box, and
  cache-current-module!.
* module/language/cps/effects-analysis.scm (&cache): New memory kind.
  (cache-current-module!): Set &cache memory, not &box.
  (resolve-module, lookup-module, cache-ref, cache-set!): Add effect
  annotations.
* module/system/vm/assembler.scm (emit-cache-current-module!)
  (emit-cached-toplevel-box, emit-cached-module-box): Remove
  assemblers.
* module/system/vm/disassembler.scm (code-annotation, fold-code-range):
  Remove special cases for toplevel-box and module-box.
* module/system/xref.scm (program-callee-rev-vars): Add a FIXME for the
  future.
2018-05-14 14:04:59 +02:00
Andy Wingo
667d808f58 Instruction explosion for cache-current-module, cached-toplevel-box
* module/language/cps/reify-primitives.scm (primitive-ref): When
  reifying xoprimitives, explode cached-module-box references.
  (cache-current-module!, cached-toplevel-box): Do instruction
  explosion.
2018-05-14 14:04:59 +02:00
Andy Wingo
3edf02cbe5 Instruction explosion for cached-module-box
* module/language/cps/reify-primitives.scm (reify-lookup):
  (reify-resolve-module): New helpers.
  (cached-module-box): Explode.
2018-05-14 14:04:59 +02:00
Andy Wingo
f6de1b0620 Add cache-ref, cache-set! macro-instructions
* module/system/vm/assembler.scm (<cache-cell>): Remove "scope" member.
  Just be an opaque key comparable with equal?.
  (intern-cache-cell): Remove scope arg.
  (intern-module-cache-cell): Remove; callers use intern-cache-cell now.
  (cache-current-module!, cached-toplevel-box, cached-module-box): Create
  cache keys that by construction won't collide between types.
  (cache-ref, cache-set!): Add new macro assemblers.
* module/language/cps/reify-primitives.scm:
* module/language/cps/compile-bytecode.scm: Add cases for new macro
  instructions.
2018-05-14 14:04:59 +02:00
Andy Wingo
fb344a25d5 Add intrinsics for module operations
* libguile/intrinsics.c (scm_bootstrap_intrinsics):
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS):
* module/system/vm/assembler.scm (resolve-module, lookup): New intrinsics.
* module/language/cps/compile-bytecode: Add cases for primcalls
  corresponding to new intrinsics.
2018-05-14 14:04:54 +02:00
Andy Wingo
16a996f052 Add scm_maybe_resolve_module
* libguile/modules.c (scm_maybe_resolve_module): New API function, like
  resolve-module but not ensuring that the module is created.
  (scm_public_variable, scm_private_variable): Adapt to call
  scm_maybe_resolve_module.
* libguile/modules.h (scm_maybe_resolve_module): Declare new API.
2018-05-14 11:27:30 +02:00
Andy Wingo
ad96291ffe Mark call-scm<-scm-u64 as defining a result
* libguile/vm-engine.c (call-scm<-scm-u64): Add OP_DST.
2018-05-13 10:22:03 +02:00
Andy Wingo
9a72e21262 VM syncs IP in pop-fluid
* libguile/vm-engine.c (pop-fluid): Sync IP before popping, as setting a
  fluid may allocate.
2018-05-09 11:07:35 +02:00
Andy Wingo
ed8b1adeab Remove unused macros in VM
* libguile/vm-engine.c (ARGS1, ARGS2, RETURN, RETURN_EXP)
  (UNPACK_16_8): Remove.
2018-05-08 20:50:40 +02:00
Andy Wingo
007fcf699f VM calls =? through intrinsic
* libguile/intrinsics.c (numerically_equal_p): New intrinsic.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Declare new
  intrinsic.
* libguile/vm-engine.c (=?): Call through intrinsic.
2018-05-08 14:16:02 +02:00
Andy Wingo
0a8a7e9fd0 VM calls "<?" through intrinsic.
* libguile/intrinsics.c (less_p): New intrinsic.
  (scm_bootstrap_intrinsics): Wire up intrinsic.
* libguile/intrinsics.h: Declare new intrinsic.
* libguile/vm-engine.c (less_p): Call through intrinsic.
2018-05-08 12:03:53 +02:00
Andy Wingo
41bc98985f VM calls out to heap-numbers-equal? through intrinsics
* libguile/numbers.h:
* libguile/eq.c (scm_i_heap_numbers_equal_p): Change to return boolean
  directly instead of tagged Scheme value.
  (scm_eqv_p): Adapt caller of scm_i_heap_numbers_equal_p.
* libguile/intrinsics.c (scm_bootstrap_intrinsics):
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Declare
  heap-numbers-equal? intrinsic.
* libguile/vm-engine.c (heap-numbers-equal?): Call out through the
  intrinsics table.
2018-05-08 11:49:46 +02:00
Andy Wingo
84cb7c45fd Remove implementation of lsh, rsh instructions
* libguile/vm-engine.c: Remove implementation of now-gone instructions.
2018-05-01 07:10:56 +02:00
Andy Wingo
1532b570e5 lsh, rsh etc are intrinsics
* libguile/intrinsics.c (lsh, rsh, lsh_immediate, rsh_immediate): New
  intrinsics.
  (scm_bootstrap_intrinsics): Wire up the intrinsics.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add new
  intrinsics.
* libguile/vm-engine.c (call-scm<-scm-u64): New intrinsic caller.
  (lsh, rsh, lsh/immediate, rsh/immediate): Disable.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Add new intrinsics.
* module/system/vm/assembler.scm: Adapt assemblers for new intrinsics.
2018-05-01 07:02:45 +02:00
Andy Wingo
e014bf3fc5 Remove old VM ops for fluid-ref et al
* libguile/vm-engine.c (wind, unwind, push_fluid, pop_fluid)
  (fluid_ref, push_dynamic_state, pop_dynamic_state): Remove now-unused
  implementations.
2018-04-29 10:44:19 +02:00
Andy Wingo
89fda6da60 push and pop dynamic state via intrinsics
* libguile/intrinsics.c (push_dynamic_state, pop_dynamic_state): New
  intrinsics.
  (scm_bootstrap_intrinsics): Add new intrinsics.
* libguile/intrinsics.h: Declare new intrinsics.
* libguile/vm-engine.c (call-thread-scm): New intrinsic caller.
  (push-dynamic-state, pop-dynamic-state): Disable.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Add new intrinsics.
* module/system/vm/assembler.scm (push-dynamic-state)
  (pop-dynamic-state): Emit as intrinsics.
2018-04-29 10:41:24 +02:00
Andy Wingo
2eb9c755d1 Intrinsics for dynamic state instructions
* libguile/intrinsics.c (wind, unwind, push_fluid, pop_fluid)
  (fluid_ref): New intrinsics.
  (scm_bootstrap_intrinsics): Wire them up.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Declare new
  intrinsics.
* libguile/vm-engine.c (wind, unwind, push_fluid, pop_fluid)
  (fluid_ref): Disable these instructions.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Add new intrinsics.
* module/system/vm/assembler.scm (wind, unwind, push_fluid, pop_fluid)
  (fluid_ref): Assemble as intrinsics.
2018-04-29 10:22:30 +02:00
Andy Wingo
4779a10223 Add support for dynamic-state-related intrinsics
* libguile/vm-engine.c (call-thread, call-thread-scm-scm)
  (call-scm<-thread-scm): New intrinsics.
* module/system/vm/assembler.scm (define-thread-scm-scm-intrinsic)
  (define-thread-intrinsic, define-scm<-thread-scm-intrinsic): New
  helpers.
  (encode-X8_S12_S12-C32!/shuffle): New shuffler.
* libguile/intrinsics.h: Add new intrinsic types.
2018-04-29 10:13:50 +02:00
Andy Wingo
c927ca7111 Fix width of operands to intrinsic call instructions
* libguile/vm-engine.c (call-scm<-scm, etc): The operands were getting
  unpacked into 8-bit locals, which were too small.  Fix to use 16-bit
  locals.
2018-04-29 09:55:24 +02:00
Paulo Andrade
94a188844d Correct typo and values in jit_sparc-sz.c 2018-04-25 16:02:52 -03:00