summaryrefslogtreecommitdiff
path: root/libguile/gsubr.c
Commit message (Collapse)AuthorAgeFilesLines
* Allow for bind-optionals without alloc-frameAndy Wingo2019-06-061-7/+10
| | | | | | | | | | | | | | | | | | | | | This reduces subr trampoline instruction count for subrs with optional args. * libguile/gsubr.c (get_subr_stub_code): Insert bind-optionals instructions. (primitive_call_ip): Handle bind-optionals. * libguile/programs.c (try_parse_arity): Handle bind-optionals. * libguile/jit.c (struct scm_jit_state) (compile_call, compile_call_label, compile_tail_call) (compile_tail_call_label, compile_receive), compile_receive_values) (compile_shuffle_down, compile_return_values, compile_subr_call) (compile_foreign_call, compile_continuation_call) (compile_compose_continuation, compile_abort, compile_assert_nargs_ee) (compile_assert_nargs_ge, compile_assert_nargs_le) (compile_alloc_frame, compile_reset_frame, compile_push) (compile_pop, compile_drop, compile_expand_apply_argument) (compile_bind_kwargs, compile_bind_rest, compile_bind_optionals) (compile, compute_mcode): Separately track min and max frame sizes.
* Add internal function mapping subr index to functionAndy Wingo2018-08-191-2/+8
| | | | | | * libguile/gsubr.h: * libguile/gsubr.c (scm_subr_function_by_index): New internal function. (scm_subr_function): Use new function.
* Add instrumentation to VM builtinsAndy Wingo2018-08-171-2/+5
| | | | | | | | | | | | | | | | | | | * libguile/intrinsics.h: Add "intrinsic" for handle-interrupts code. Unlike the other intrinsics, this one isn't a function. * libguile/programs.c (try_parse_arity): Add cases for instructions used in VM builtins. (scm_primitive_call_ip): Return #f if call-ip not found. * libguile/vm-engine.c (handle-interrupts): Get code from intrinsics. * libguile/vm.c * libguile/vm.c (instrumented_code, define_vm_builtins): Add instrumentation to the builtins, so that they can be JIT-compiled. (INIT_BUILTIN): Remove min-arity setting; the fallback min-arity interpreter should figure it out. (scm_bootstrap_vm): Call the new define_vm_builtins function. * libguile/gsubr.c (primitive_call_ip): Return 0 if call IP not found. (primitive_subr_idx): Interpret call ip == 0 as not-a-subr. * module/system/vm/program.scm (program-arguments-alist): Allow a #f call-ip.
* Fix bugs with primitive code allocator; expose internallyAndy Wingo2018-08-061-40/+71
| | | | | | | | | | | | | | | | | | | | * lib/Makefile.am: Explicitly add flexmember. Already included though. * libguile/gsubr.c (alloc_subr_idx, record_subr_name): Factor out an "expected subr count" variable. (alloc_chunk, alloc): Rework so that when the arena grows, old code is still recognized as primitive. (scm_i_alloc_primitive_code_with_instrumentation): Fix bug whereby the JIT function data was initialized at a bogus address, because we were adding to a uint32_t* instead of a char*. Make internally public. (is_primitive_code): Recognize all allocated code as primitive. (alloc_subr_code): Adapt to scm_i_alloc_primitive_code_with_instrumentation rename. (primitive_subr_idx): If the call IP isn't a subr-call, return a sentinel value. (scm_i_primitive_name, scm_subr_function): Allow for primitives that aren't subrs. * libguile/gsubr.h: Decalre scm_i_alloc_primitive_code_with_instrumentation.
* Rewrite subr implementationAndy Wingo2018-07-291-209/+333
| | | | | | | | | | | | | | | | | | | | | | | | * libguile/gsubr.c: Reimplement to store subr names and procedures in a side table, and to allocate fresh vcode for each subr. This allows JIT of subrs, moves to a uniform all-code-starts-with-instrument-entry regime, and also allows statprof to distinguish between subrs based on IP. * libguile/gsubr.h (SCM_SUBRF, SCM_SUBR_NAME): Call out to functions, now that these are in a side table. (scm_subr_function, scm_subr_name): New exports. (scm_i_primitive_name): New internal function, for looking up a primitive name based on IP. (scm_apply_subr): Take the subr index. * libguile/vm-engine.c (subr-call): * libguile/jit.c (compile_subr_call): Adapt to take index as arg. * module/statprof.scm (sample-stack-procs, count-call): (stack-samples->procedure-data): Update to always record IP in stack samples and call counts. * module/system/vm/frame.scm (frame-procedure-name): Simplify. (frame-instruction-pointer-or-primitive-procedure-name): Removed. * libguile/programs.h: * libguile/programs.c (scm_primitive_code_name): New function. * module/system/vm/program.scm (primitive-code-name): New export.
* Use ptrdiff_t instead of scm_t_ptrdiffAndy Wingo2018-06-211-1/+1
| | | | | | | | | | | | | | | | | | | | | * libguile/continuations.h: * libguile/control.c: * libguile/control.h: * libguile/dynstack.c: * libguile/dynstack.h: * libguile/eval.c: * libguile/foreign.c: * libguile/frames.h: * libguile/gen-scmconfig.c: * libguile/gsubr.c: * libguile/gsubr.h: * libguile/loader.c: * libguile/numbers.h: * libguile/stacks.c: * libguile/throw.c: * libguile/vm-engine.c: * libguile/vm.c: * libguile/vm.h: Use ptrdiff_t from stddef.h.
* Replace uses of scm_t_int8, scm_t_uintmax, etc with stdint typesAndy Wingo2018-06-211-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/bitvectors.c: * libguile/bitvectors.h: * libguile/bytevectors.c: * libguile/bytevectors.h: * libguile/chars.c: * libguile/continuations.c: * libguile/control.c: * libguile/conv-integer.i.c: * libguile/conv-uinteger.i.c: * libguile/dynstack.c: * libguile/dynstack.h: * libguile/foreign.c: * libguile/frames.c: * libguile/frames.h: * libguile/gc-inline.h: * libguile/gc.h: * libguile/gsubr.c: * libguile/gsubr.h: * libguile/hash.c: * libguile/i18n.c: * libguile/instructions.c: * libguile/intrinsics.c: * libguile/intrinsics.h: * libguile/loader.c: * libguile/loader.h: * libguile/numbers.c: * libguile/numbers.h: * libguile/pairs.c: * libguile/ports-internal.h: * libguile/ports.c: * libguile/ports.h: * libguile/posix.c: * libguile/print.c: * libguile/print.h: * libguile/programs.c: * libguile/programs.h: * libguile/r6rs-ports.c: * libguile/random.c: * libguile/random.h: * libguile/scm.h: * libguile/socket.c: * libguile/srfi-4.c: * libguile/srfi-4.h: * libguile/stacks.c: * libguile/stime.c: * libguile/strings.c: * libguile/struct.c: * libguile/struct.h: * libguile/symbols.c: * libguile/threads.c: * libguile/threads.h: * libguile/uniform.c: * libguile/vm-engine.c: * libguile/vm.c: * libguile/vm.h: * libguile/vports.c: * test-suite/standalone/test-conversion.c: * test-suite/standalone/test-ffi-lib.c: * test-suite/standalone/test-scm-take-u8vector.c: * test-suite/standalone/test-srfi-4.c: Replace e.g. scm_t_uint8 with uint8_t.
* Update license notices in all C filesAndy Wingo2018-06-201-17/+17
| | | | | Update to newest recommended license notices from the FSF. Everything stays LGPLv3+ except guile-readline which is GPLv3+.
* Remove (C) from copyright statementsAndy Wingo2018-06-201-1/+1
| | | | | | As the FSF advises, 'There is no legal significance to using the three-character sequence “(C)”, but it does no harm.' It does take up space though! For that reason, we remove it here from our C files.
* Rationalize include order in C filesAndy Wingo2018-06-201-2/+5
| | | | | Include config.h first, then system includes, then libguile includes, in alphabetical order, then the include for the file in question.
* Make libguile header inclusion consistent within libguile c filesAndy Wingo2018-06-201-11/+11
| | | | | Change from '#include "libguile/foo.h"' and '#include <libguile/foo.h>' to '#include "foo.h"'.
* Remove Emacs local variables comments in Guile sourceAndy Wingo2018-06-201-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The .dir-locals.el file in the repository is sufficient for Emacs users. * libguile/__scm.h: * libguile/alist.c: * libguile/alist.h: * libguile/array-handle.c: * libguile/array-handle.h: * libguile/array-map.c: * libguile/array-map.h: * libguile/arrays.c: * libguile/arrays.h: * libguile/async.c: * libguile/async.h: * libguile/backtrace.c: * libguile/backtrace.h: * libguile/bitvectors.c: * libguile/bitvectors.h: * libguile/boolean.c: * libguile/boolean.h: * libguile/chars.c: * libguile/chars.h: * libguile/chooks.c: * libguile/chooks.h: * libguile/continuations.c: * libguile/continuations.h: * libguile/control.c: * libguile/conv-integer.i.c: * libguile/debug-malloc.h: * libguile/debug.c: * libguile/debug.h: * libguile/deprecation.c: * libguile/deprecation.h: * libguile/dynl.c: * libguile/dynl.h: * libguile/dynstack.c: * libguile/dynstack.h: * libguile/dynwind.c: * libguile/dynwind.h: * libguile/eq.c: * libguile/eq.h: * libguile/error.c: * libguile/error.h: * libguile/eval.c: * libguile/eval.h: * libguile/evalext.c: * libguile/evalext.h: * libguile/expand.c: * libguile/expand.h: * libguile/extensions.c: * libguile/extensions.h: * libguile/feature.c: * libguile/feature.h: * libguile/filesys.c: * libguile/filesys.h: * libguile/fluids.c: * libguile/fluids.h: * libguile/foreign.c: * libguile/fports.c: * libguile/fports.h: * libguile/frames.c: * libguile/frames.h: * libguile/gc-inline.h: * libguile/gc.c: * libguile/gc.h: * libguile/generalized-arrays.c: * libguile/generalized-arrays.h: * libguile/generalized-vectors.c: * libguile/generalized-vectors.h: * libguile/gettext.c: * libguile/gettext.h: * libguile/goops.c: * libguile/goops.h: * libguile/gsubr.c: * libguile/gsubr.h: * libguile/guardians.c: * libguile/guardians.h: * libguile/guile.c: * libguile/hash.c: * libguile/hash.h: * libguile/hashtab.c: * libguile/hashtab.h: * libguile/hooks.c: * libguile/hooks.h: * libguile/i18n.c: * libguile/i18n.h: * libguile/init.c: * libguile/init.h: * libguile/instructions.c: * libguile/instructions.h: * libguile/intrinsics.c: * libguile/intrinsics.h: * libguile/ioext.c: * libguile/ioext.h: * libguile/iselect.h: * libguile/keywords.c: * libguile/keywords.h: * libguile/list.c: * libguile/list.h: * libguile/load.c: * libguile/load.h: * libguile/loader.c: * libguile/loader.h: * libguile/macros.c: * libguile/macros.h: * libguile/mallocs.c: * libguile/mallocs.h: * libguile/memmove.c: * libguile/memoize.c: * libguile/memoize.h: * libguile/modules.c: * libguile/modules.h: * libguile/net_db.c: * libguile/net_db.h: * libguile/null-threads.c: * libguile/null-threads.h: * libguile/numbers.c: * libguile/numbers.h: * libguile/objprop.c: * libguile/objprop.h: * libguile/options.c: * libguile/options.h: * libguile/pairs.c: * libguile/pairs.h: * libguile/poll.c: * libguile/poll.h: * libguile/ports.c: * libguile/ports.h: * libguile/posix.c: * libguile/posix.h: * libguile/print.c: * libguile/print.h: * libguile/procprop.c: * libguile/procprop.h: * libguile/procs.c: * libguile/procs.h: * libguile/programs.c: * libguile/programs.h: * libguile/promises.c: * libguile/promises.h: * libguile/pthread-threads.h: * libguile/random.c: * libguile/random.h: * libguile/rdelim.c: * libguile/rdelim.h: * libguile/read.c: * libguile/read.h: * libguile/regex-posix.c: * libguile/regex-posix.h: * libguile/rw.c: * libguile/rw.h: * libguile/scmsigs.c: * libguile/scmsigs.h: * libguile/script.c: * libguile/script.h: * libguile/simpos.c: * libguile/simpos.h: * libguile/smob.c: * libguile/smob.h: * libguile/snarf.h: * libguile/socket.c: * libguile/socket.h: * libguile/sort.c: * libguile/sort.h: * libguile/srcprop.c: * libguile/srcprop.h: * libguile/stackchk.c: * libguile/stackchk.h: * libguile/stacks.c: * libguile/stacks.h: * libguile/stime.c: * libguile/stime.h: * libguile/strerror.c: * libguile/strings.c: * libguile/strings.h: * libguile/strorder.c: * libguile/strorder.h: * libguile/strports.c: * libguile/strports.h: * libguile/struct.c: * libguile/struct.h: * libguile/symbols.c: * libguile/symbols.h: * libguile/syntax.c: * libguile/syscalls.h: * libguile/tags.h: * libguile/threads.c: * libguile/threads.h: * libguile/throw.c: * libguile/throw.h: * libguile/trees.h: * libguile/unicode.c: * libguile/unicode.h: * libguile/uniform.c: * libguile/uniform.h: * libguile/values.c: * libguile/values.h: * libguile/variable.c: * libguile/variable.h: * libguile/vectors.c: * libguile/vectors.h: * libguile/version.c: * libguile/vm-engine.c: * libguile/vm-expand.h: * libguile/vm.c: * libguile/vm.h: * libguile/vports.c: * libguile/vports.h: * libguile/weak-list.h: * libguile/weak-set.c: * libguile/weak-set.h: * libguile/weak-table.c: * libguile/weak-table.h: * libguile/weak-vector.c: * libguile/weak-vector.h: Remove needless trailing comments.
* Remove _scm.hAndy Wingo2018-06-201-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/_scm.h: Remove. An internal header, never installed. * libguile/__scm.h: Remove horrible documentation. * libguile/Makefile.am (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): Remove _scm.h. * libguile/alist.c: * libguile/array-handle.c: * libguile/array-map.c: * libguile/arrays.c: * libguile/async.c: * libguile/atomic.c: * libguile/backtrace.c: * libguile/bitvectors.c: * libguile/boolean.c: * libguile/bytevectors.c: * libguile/chars.c: * libguile/continuations.c: * libguile/control.c: * libguile/debug-malloc.c: * libguile/debug.c: * libguile/deprecated.c: * libguile/deprecation.c: * libguile/dynl.c: * libguile/dynstack.c: * libguile/dynwind.c: * libguile/eq.c: * libguile/error.c: * libguile/eval.c: * libguile/evalext.c: * libguile/expand.c: * libguile/extensions.c: * libguile/fdes-finalizers.c: * libguile/feature.c: * libguile/filesys.c: * libguile/finalizers.c: * libguile/fluids.c: * libguile/foreign-object.c: * libguile/foreign.c: * libguile/fports.c: * libguile/frames.c: * libguile/gc-malloc.c: * libguile/gc.c: * libguile/gen-scmconfig.c: * libguile/generalized-arrays.c: * libguile/generalized-vectors.c: * libguile/gettext.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/guardians.c: * libguile/hash.c: * libguile/hashtab.c: * libguile/hooks.c: * libguile/i18n.c: * libguile/init.c: * libguile/instructions.c: * libguile/intrinsics.c: * libguile/ioext.c: * libguile/keywords.c: * libguile/list.c: * libguile/load.c: * libguile/loader.c: * libguile/macros.c: * libguile/mallocs.c: * libguile/memoize.c: * libguile/modules.c: * libguile/net_db.c: * libguile/null-threads.c: * libguile/numbers.c: * libguile/objprop.c: * libguile/options.c: * libguile/pairs.c: * libguile/poll.c: * libguile/ports-internal.h: * libguile/ports.c: * libguile/posix.c: * libguile/print.c: * libguile/procprop.c: * libguile/procs.c: * libguile/programs.c: * libguile/promises.c: * libguile/r6rs-ports.c: * libguile/random.c: * libguile/rdelim.c: * libguile/read.c: * libguile/regex-posix.c: * libguile/rw.c: * libguile/scmsigs.c: * libguile/script.c: * libguile/simpos.c: * libguile/smob.c: * libguile/socket.c: * libguile/sort.c: * libguile/srcprop.c: * libguile/srfi-1.c: * libguile/srfi-13.c: * libguile/srfi-14.c: * libguile/srfi-4.c: * libguile/srfi-60.c: * libguile/stackchk.c: * libguile/stacks.c: * libguile/stime.c: * libguile/strings.c: * libguile/strorder.c: * libguile/strports.c: * libguile/struct.c: * libguile/symbols.c: * libguile/syntax.c: * libguile/threads.c: * libguile/throw.c: * libguile/trees.c: * libguile/unicode.c: * libguile/uniform.c: * libguile/values.c: * libguile/variable.c: * libguile/vectors.c: * libguile/version.c: * libguile/vm.c: * libguile/vports.c: * libguile/weak-set.c: * libguile/weak-table.c: * libguile/weak-vector.c: Remove _scm.h includes.
* Devolve symbols.h from _scm.hAndy Wingo2018-06-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/_scm.h: Remove symbols.h. * libguile/array-handle.c: * libguile/array-map.c: * libguile/backtrace.c: * libguile/bytevectors.c: * libguile/chars.c: * libguile/continuations.c: * libguile/error.c: * libguile/eval.c: * libguile/evalext.c: * libguile/expand.c: * libguile/feature.c: * libguile/filesys.c: * libguile/foreign.c: * libguile/fports.c: * libguile/frames.c: * libguile/gc.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/i18n.c: * libguile/instructions.c: * libguile/intrinsics.c: * libguile/keywords.c: * libguile/load.c: * libguile/macros.c: * libguile/memoize.c: * libguile/modules.c: * libguile/net_db.c: * libguile/options.c: * libguile/ports.c: * libguile/posix.c: * libguile/print.c: * libguile/procprop.c: * libguile/procs.c: * libguile/r6rs-ports.c: * libguile/random.c: * libguile/read.c: * libguile/socket.c: * libguile/srcprop.c: * libguile/srfi-13.c: * libguile/srfi-14.c: * libguile/stacks.c: * libguile/strings.c: * libguile/strports.c: * libguile/struct.c: * libguile/threads.c: * libguile/throw.c: * libguile/vm.c: Add symbols.h.
* Remove modules.h from _scm.h.Andy Wingo2018-06-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/_scm.h: Remove modules.h. * libguile/arrays.c: * libguile/backtrace.c: * libguile/feature.c: * libguile/filesys.c: * libguile/foreign-object.c: * libguile/foreign.c: * libguile/fports.c: * libguile/frames.c: * libguile/gc.c: * libguile/gsubr.c: * libguile/i18n.c: * libguile/intrinsics.c: * libguile/macros.c: * libguile/numbers.c: * libguile/poll.c: * libguile/ports.c: * libguile/posix.c: * libguile/random.c: * libguile/read.c: * libguile/regex-posix.c: * libguile/scmsigs.c: * libguile/script.c: * libguile/socket.c: * libguile/srcprop.c: * libguile/srfi-14.c: * libguile/srfi-4.c: * libguile/stime.c: * libguile/struct.c: * libguile/syntax.c: * libguile/threads.c: * libguile/throw.c: Add modules.h.
* Devolve numbers.h from _scm.h.Andy Wingo2018-06-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/_scm.h: Remove numbers.h. * libguile/array-handle.c: * libguile/array-map.c: * libguile/arrays.c: * libguile/backtrace.c: * libguile/bitvectors.c: * libguile/bytevectors.c: * libguile/chars.c: * libguile/continuations.c: * libguile/debug-malloc.c: * libguile/error.c: * libguile/eval.c: * libguile/filesys.c: * libguile/foreign-object.c: * libguile/foreign.c: * libguile/fports.c: * libguile/frames.c: * libguile/gc.c: * libguile/generalized-arrays.c: * libguile/gettext.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/guardians.c: * libguile/hash.c: * libguile/hashtab.c: * libguile/hooks.c: * libguile/i18n.c: * libguile/instructions.c: * libguile/intrinsics.c: * libguile/ioext.c: * libguile/list.c: * libguile/memoize.c: * libguile/net_db.c: * libguile/options.c: * libguile/ports.c: * libguile/posix-w32.c: * libguile/posix.c: * libguile/procprop.c: * libguile/programs.c: * libguile/r6rs-ports.c: * libguile/random.c: * libguile/rdelim.c: * libguile/read.c: * libguile/regex-posix.c: * libguile/rw.c: * libguile/scmsigs.c: * libguile/simpos.c: * libguile/smob.c: * libguile/socket.c: * libguile/srcprop.c: * libguile/srfi-13.c: * libguile/srfi-14.c: * libguile/srfi-4.c: * libguile/stackchk.c: * libguile/stacks.c: * libguile/stime.c: * libguile/strings.c: * libguile/struct.c: * libguile/symbols.c: * libguile/threads.c: * libguile/throw.c: * libguile/vectors.c: * libguile/version.c: * libguile/vm.c: * libguile/vports.c: * libguile/weak-table.c: Add numbers.h.
* Fix libguile subcomponent headers not to include <libguile.h>Andy Wingo2018-06-141-4/+5
| | | | | | | | | | | | | | | | | | | * 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.
* Explicit interrupt handling in VMAndy Wingo2016-11-171-4/+22
| | | | | | | | | | | | | | | | | * libguile/foreign.c (CODE, get_foreign_stub_code): Add explicit handle-interrupts and return-values calls, as foreign-call will fall through. * libguile/gsubr.c (A, B, C, AB, AC, BC, ABC, SUBR_STUB_CODE) (scm_i_primitive_call_ip): Same. * libguile/vm-engine.c (VM_HANDLE_INTERRUPTS): Inline into handle-interrupts. (RETURN_ONE_VALUE, RETURN_VALUE_LIST): Inline into callers, and fall through instead of returning. (BR_BINARY, BR_UNARY, BR_ARITHMETIC, BR_U64_ARITHMETIC): Remove conditional VM_HANDLE_INTERRUPTS, as the compiler already inserted the handle-interrupts calls if needed. (vm_engine): Remove VM_HANDLE_INTERRUPTS invocations except in the handle-interrupts instruction.
* Parse bytecode to determine minimum arityAndy Wingo2016-06-241-31/+0
| | | | | | | | | | | | * libguile/programs.c (try_parse_arity): New helper, to parse bytecode to determine the minimum arity of a function in a cheaper way than grovelling through the debug info. Should speed up all thunk? checks and similar. (scm_i_program_arity): Simplify. * libguile/gsubr.h: * libguile/gsubr.c (scm_i_primitive_arity): * libguile/foreign.h: * libguile/foreign.c (scm_i_foreign_arity):
* Remove primitive?, add primitive-code?Andy Wingo2015-12-011-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to be able to identify frames that are primitive applications without assuming that slot 0 in a frame is an SCM value and without assuming that value is the procedure being applied. * libguile/gsubr.c (scm_i_primitive_code_p): New helper. (scm_i_primitive_arity): Use the new helper. * libguile/gsubr.h: Declare the new helper. * libguile/programs.h: * libguile/programs.c (scm_program_code_p): New function, replacing scm_primitive_p. (scm_primitive_call_ip): Fix FUNC_NAME definition. * module/statprof.scm (sample-stack-procs, count-call): Identify primitive frames from the IP, not the frame-procedure. Avoids the assumption that slot 0 in a frame is a SCM value. (statprof-proc-call-data): Adapt to primitive-code? change. * module/system/vm/frame.scm (frame-call-representation): Identify primitive frames from the IP, not the closure. Still more work to do here to avoid assuming slot 0 is a procedure. * module/system/vm/program.scm: Export primitive-code? instead of primitive?. (program-arguments-alist, program-arguments-alists): Identify primitives from the code instead of the flags on the program. Not sure this is a great change, but it does avoid having to define a primitive? predicate in Scheme.
* Small subr-call refactorAndy Wingo2015-10-221-1/+42
| | | | | | | * libguile/gsubr.c (scm_apply_subr): New internal helper. * libguile/vm-engine.c (subr-call): Call out to scm_apply_subr. * doc/ref/vm.texi (subr-call): Don't specify how the foreign pointer is obtained.
* Merge branch 'stable-2.0'Mark H Weaver2014-09-301-1/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: benchmark-suite/benchmarks/ports.bm libguile/async.h libguile/bytevectors.c libguile/foreign.c libguile/gsubr.c libguile/srfi-1.c libguile/vm-engine.h libguile/vm-i-scheme.c module/Makefile.am module/language/tree-il/analyze.scm module/language/tree-il/peval.scm module/scripts/compile.scm module/scripts/disassemble.scm test-suite/tests/asm-to-bytecode.test test-suite/tests/peval.test test-suite/tests/rdelim.test
| * Do not assume that 64-bit integers will be 64-bit aligned.Mark H Weaver2014-09-201-3/+4
| | | | | | | | | | | | * libguile/foreign.c (raw_bytecode, objcode_cells): * libguile/gsubr.c (raw_bytecode, objcode_cells): Use SCM_ALIGNED to ensure 64-bit alignment.
* | Rename objcodes?.{scm,c,h} to loader.{scm,c,h}Andy Wingo2013-11-191-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/loader.c: * libguile/loader.h: Rename from objcodes.[ch]. * module/system/vm/loader.scm: Rename from objcode.scm. * libguile/Makefile.am: * libguile/gsubr.c: * libguile/init.c: * libguile/procs.c: * libguile/vm.c: * module/Makefile.am: * module/ice-9/eval-string.scm: * module/language/rtl/spec.scm: * module/system/base/target.scm: * module/system/repl/command.scm: * module/system/repl/common.scm: * module/system/vm/debug.scm: * module/system/vm/disassembler.scm: * module/system/vm/objcode.scm: * test-suite/tests/compiler.test: * test-suite/tests/dwarf.test: * test-suite/tests/rtl-compilation.test: * test-suite/tests/rtl.test: Adapt.
* | Fix gsubr commentAndy Wingo2013-11-191-3/+3
| | | | | | | | * libguile/gsubr.c: Update comment to excise RTL.
* | Change SCM_PACK_RTL macros to SCM_PACK_OP / SCM_PACK_OP_ARGAndy Wingo2013-11-191-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/instructions.h: Guard in BUILDING_LIBGUILE. (SCM_PACK_OP_24): (SCM_PACK_OP_8_8_8): (SCM_PACK_OP_8_16): (SCM_PACK_OP_16_8): (SCM_PACK_OP_12_12): Rename from SCM_PACK_RTL_*, and splice in the opcode. (SCM_PACK_OP_ARG_8_24): New helper. * libguile/vm.c: * libguile/gsubr.c: * libguile/foreign.c: * libguile/control.c: * libguile/continuations.c: Adapt.
* | scm_rtl_op_* -> scm_op_*Andy Wingo2013-11-191-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | * libguile/instructions.h (scm_opcode): Rename from scm_rtl_opcode. Rename opcodes from scm_rtl_op_* to scm_op_*. * libguile/continuations.c: * libguile/control.c: * libguile/foreign.c: * libguile/gsubr.c: * libguile/instructions.c: * libguile/vm.c: Adapt.
* | Remove RTL_ infix from macrosAndy Wingo2013-11-191-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/programs.h (SCM_PROGRAM_P): (SCM_PROGRAM_CODE): (SCM_PROGRAM_FREE_VARIABLES): (SCM_PROGRAM_FREE_VARIABLE_REF): (SCM_PROGRAM_FREE_VARIABLE_SET): (SCM_PROGRAM_NUM_FREE_VARIABLES): (SCM_VALIDATE_PROGRAM): Remove RTL_ infix. * libguile/continuations.c: * libguile/continuations.h: * libguile/control.c: * libguile/foreign.c: * libguile/frames.c: * libguile/gsubr.c: * libguile/gsubr.h: * libguile/procprop.c: * libguile/procs.c: * libguile/programs.c: * libguile/stacks.c: * libguile/vm-engine.c: Adapt.
* | Rename scm_tc7_rtl_program to scm_tc7_programAndy Wingo2013-11-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/tags.h (scm_tc7_program): Rename from scm_tc7_rtl_program. * libguile/continuations.c: * libguile/control.c: * libguile/evalext.c: * libguile/foreign.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/print.c: * libguile/programs.c: * libguile/programs.h: * libguile/vm-engine.c: Adapt users. * module/system/vm/assembler.scm: Rename a tc7-rtl-program local to tc7-program. * libguile/tags.h (scm_tc7_program): Rename from scm_tc7_rtl_program. * libguile/continuations.c: * libguile/control.c: * libguile/evalext.c: * libguile/foreign.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/print.c: * libguile/programs.c: * libguile/programs.h: * libguile/vm-engine.c: Adapt users. * module/system/vm/assembler.scm: Rename a tc7-rtl-program local to tc7-program.
* | Fix reading and writing arities into DWARF.Andy Wingo2013-11-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/gsubr.h: * libguile/gsubr.c (scm_i_primitive_call_ip): * libguile/programs.c (scm_primitive_call_ip): Adapt to return an absolute address. * module/system/vm/assembler.scm (write-arity-headers): Adapt to write byte addresses (relative to the text base). * module/system/vm/debug.scm (arity-low-pc, arity-high-pc): Return absolute addresses, instead of word offsets relative to the text base. (find-first-arity): Adapt for absolute addresses. * module/system/vm/program.scm (program-arguments-alist): Adapt for arity-low-pc / arity-high-pc absolute addresses.
* | Foreign procedures are RTL programsAndy Wingo2013-10-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/foreign.c: Convert to using RTL stubs. Because RTL code has different GC characteristics than objcode -- it's mostly assumed that RTL code will never go away -- we go ahead and pre-generate code for 100 arguments. This is actually less memory than the stack VM code, and doesn't require any relocations at load-time: bonus! We'll cross the >=100 args bridge if we ever come to it. (get_foreign_stub_code) New function. (scm_i_foreign_arity): New helper, like scm_i_primitive_arity. (cif_to_procedure): Rework to make RTL programs. * libguile/foreign.h: Declare scm_pointer_to_scm and scm_scm_to_pointer. Declare new internal helpers. * libguile/gsubr.c (create_subr): Refactor to set the flags when the object is allocated. * libguile/instructions.h: Define SCM_PACK_RTL_12_12. * libguile/programs.c (scm_i_rtl_program_minimum_arity): Dispatch to scm_i_foreign_arity if the procedure has the FOREIGN flag. * libguile/programs.h (SCM_F_PROGRAM_IS_FOREIGN) (SCM_PROGRAM_IS_FOREIGN): New interfaces. * test-suite/tests/foreign.test ("procedure->pointer"): Add a test for foreign arities.
* | Subrs are RTL programsAndy Wingo2013-10-181-682/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/gsubr.c: Define RTL stubs instead of stack VM stubs. (SUBR_STUB_CODE, get_subr_stub_code): Adapt to return a uint32_t* pointer instead of a SCM value. (create_subr): Create RTL procedures instead of stack VM procedures. For RTL procedures, the function pointer, name, and generic address pointer go inline to the procedure, as free variables. (scm_i_primitive_arity, scm_i_primitive_call_ip): New helpers. (scm_c_make_gsubr, scm_c_define_gsubr, scm_c_make_gsubr_with_generic) (scm_c_define_gsubr_with_generic): Adapt to create_gsubr being renamed to create_subr. Remove gsubr test code. * libguile/gsubr.h (SCM_PRIMITIVE_P, SCM_PRIMITIVE_GENERIC_P): Only RTL programs can be primitives now. (SCM_SUBRF, SCM_SUBR_NAME, SCM_SUBR_GENERIC): These fields are now in the RTL free variables, not the object table. * libguile/programs.c (scm_i_rtl_program_name): (scm_i_rtl_program_documentation): (scm_i_rtl_program_properties): (scm_i_rtl_program_minimum_arity): Implement these appropriately for primitives, which lack debugging information. (scm_primitive_p, scm_primitive_call_ip): New helpers. * libguile/snarf.h: Remove static allocation for subrs. Since there is nothing to allocate besides the program itself, which needs runtime relocation, static allocation is not a win. * system/vm/program.scm: Fix up various arity-related things for primitives, which don't use ELF arity info. * test-suite/tests/eval.test ("stack involving a primitive"): Add an XFAIL until we get just one VM.
* | locking for putc, putsAndy Wingo2011-11-081-4/+4
| | | | | | | | | | | | | | * libguile/ports.c (scm_putc, scm_puts): * libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into _unlocked and locked variants. Change all callers to use the _unlocked versions.
* | most uses of scm_from_locale_symbol become scm_from_utf8_symbolAndy Wingo2011-10-251-1/+1
|/ | | | | | | | | | | | | | | | | | | * libguile/array-handle.c: * libguile/chars.c: * libguile/expand.c: * libguile/feature.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/instructions.c: * libguile/load.c: * libguile/macros.c: * libguile/memoize.c: * libguile/modules.c: * libguile/options.c: * libguile/print.c: * libguile/smob.c: * libguile/snarf.h: Change most uses of scm_from_locale_symbol to scm_from_utf8_symbol, as the symbols really are not locale-dependent.
* objcode type is an enumeration, not flagsAndy Wingo2011-01-271-2/+2
| | | | | | | | | | | | | | | | | | * libguile/objcodes.h (SCM_OBJCODE_TYPE_MMAP) (SCM_OBJCODE_TYPE_BYTEVECTOR, SCM_OBJCODE_TYPE_SLICE) (SCM_OBJCODE_TYPE_STATIC): Enumerate objcode types instead of expressing them as flags. (SCM_OBJCODE_TYPE): Type is held in bits 8-15. (SCM_OBJCODE_FLAGS): Flags are now shifted by 16 bits, not 8. (SCM_MAKE_OBJCODE_TAG): New helper. * libguile/continuations.c (STATIC_OBJCODE_TAG): * libguile/control.c (STATIC_OBJCODE_TAG): * libguile/foreign.c (STATIC_OBJCODE_TAG): * libguile/gsubr.c (STATIC_OBJCODE_TAG): * libguile/smob.c (STATIC_OBJCODE_TAG): * libguile/objcodes.c (make_objcode_by_mmap, scm_c_make_objcode_slice) (scm_bytecode_to_objcode): : Use SCM_MAKE_OBJCODE_TAG.
* Use "pointer" instead of "foreign" when dealing with wrapped pointers.Ludovic Courtès2010-07-281-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/foreign.h (scm_t_foreign_finalizer): Rename to... (scm_t_pointer_finalizer): ... this. (SCM_FOREIGN_P): Rename to... (SCM_POINTER_P): this. (SCM_VALIDATE_FOREIGN): Rename to... (SCM_VALIDATE_POINTER): ... this. (SCM_FOREIGN_HAS_FINALIZER): Rename to... (SCM_POINTER_HAS_FINALIZER): ... this. (scm_take_foreign_pointer): Rename to... (scm_from_pointer): ... this. (scm_foreign_address): Rename to... (scm_pointer_address): ... this. (scm_foreign_to_bytevector): Rename to... (scm_pointer_to_bytevector): ... this. (scm_foreign_set_finalizer_x): Rename to... (scm_set_pointer_finalizer_x): ... this. (scm_bytevector_to_foreign): Rename to... (scm_bytevector_to_pointer): ... this. (scm_i_foreign_print): Rename to... (scm_i_pointer_print): ... this. * libguile/foreign.c: Update accordingly. * libguile/tags.h (scm_tc7_foreign): Rename to... (scm_tc7_pointer): ... this. * libguile/foreign.c, libguile/deprecated.c, libguile/dynl.c, libguile/evalext.c, libguile/gc.c, libguile/goops.c, libguile/gsubr.c, libguile/gsubr.h, libguile/print.c, libguile/snarf.h, libguile/vm-i-system.c, module/system/foreign.scm, test-suite/standalone/test-ffi, test-suite/tests/foreign.test: Update accordingly.
* Simplify the (system foreign) API.Ludovic Courtès2010-07-261-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Suggested by Neil Jerram. * libguile/foreign.h (SCM_FOREIGN_TYPE, SCM_FOREIGN_VALUE_REF, SCM_FOREIGN_VALUE_SET, SCM_FOREIGN_LEN, SCM_FOREIGN_TYPED_P, SCM_FOREIGN_VALUE_P, SCM_VALIDATE_FOREIGN_VALUE, scm_foreign_set_x, scm_foreign_type): Remove. (scm_foreign_ref): Rename to... (scm_foreign_address): ... this. (scm_take_foreign_pointer): Update. (SCM_FOREIGN_POINTER): Remove CTYPE argument. Update callers. (scm_make_pointer): New declaration. * libguile/foreign.c (scm_to_uintptr, scm_from_uintptr): New macros. (scm_make_pointer): New function. (scm_take_foreign_pointer): Remove TYPE and LEN arguments. Update callers. (scm_foreign_ref): Remove to... (scm_foreign_address): ... this. Remove type-related code. (scm_foreign_set_x): Remove. (scm_foreign_to_bytevector): Change argument order; make LEN argument compulsory. (scm_i_foreign_print): Remove type printing. (unpack): Remove foreign-type checking. * libguile/deprecated.c (scm_dynamic_args_call): Update accordingly. * libguile/dynl.c (scm_dynamic_pointer): Remove the TYPE and LEN arguments; update callers. Update to the new foreign API. * libguile/dynl.h (scm_dynamic_pointer): Update. * libguile/gsubr.c (create_gsubr): Update to the new foreign API. * libguile/gsubr.h (SCM_SUBRF, SCM_SUBR_GENERIC): Ditto. * libguile/snarf.h (SCM_IMMUTABLE_FOREIGN): Ditto. * libguile/vm-i-system.c (subr_call): Ditto. * module/system/foreign.scm (null-pointer?): New procedure. * test-suite/standalone/test-ffi: Update to the new `bytevector->foreign' signature. * test-suite/tests/foreign.test ("null pointer")["null pointer identity", "null-pointer? %null-pointer"]: New tests. ["foreign-set! other-null-pointer", "foreign->bytevector other-null-pointer"]: Remove. ("make-pointer", "foreign<->bytevector"): New test prefixes.
* foreign.h presents a more pointer-centric interfaceAndy Wingo2010-01-261-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/foreign.c: * libguile/foreign.h: Rework interface to be more pointer-centric. Details are: (SCM_FOREIGN_TYPE_STRUCT, SCM_FOREIGN_TYPE_POINTER): Removed; now the pointer in a foreign is first-class. If it points to a native type like uint32, then it still has a tag; but if it points to something else, like a struct or a pointer or something, then its type is VOID (i.e., void*). (SCM_FOREIGN_POINTER): Rename from SCM_FOREIGN_OBJECT. (SCM_FOREIGN_VALUE_REF, SCM_FOREIGN_VALUE_SET): Rename from SCM_FOREIGN_OBJECT_REF and SCM_FOREIGN_OBJECT_SET, to indicate that they only work with value types. (SCM_FOREIGN_HAS_FINALIZER): Reserve a bit to indicate if the foreign pointer in question has a finalizer registered. (SCM_FOREIGN_LEN): For void* pointers, optionally store the length in bytes of the associated memory region. (SCM_FOREIGN_VALUE_P): Rename from SCM_FOREIGN_SIMPLE_P. (SCM_VALIDATE_FOREIGN_VALUE): Rename from SCM_VALIDATE_FOREIGN_SIMPLE. (scm_take_foreign_pointer): Rename from scm_c_take_foreign. Remove scm_c_from_foreign. (scm_foreign_type): New accessor. (scm_foreign_ref, scm_foreign_set_x): Take some optional args, used when dereferencing void pointers. * libguile/dynl.h: * libguile/dynl.c (scm_dynamic_pointer): New function, used by scm_dynamic_func. Adapt code to foreign.h changes. * libguile/goops.c (scm_enable_primitive_generic_x) (scm_set_primitive_generic_x): Use the SCM_SET_SUBR_GENERIC macro. * libguile/gsubr.c (create_gsubr): Adapt to API change. * libguile/gsubr.h (SCM_SUBRF, SCM_SUBR_GENERIC): Store the pointer directly, not indirected. * libguile/snarf.h (SCM_DEFINE, SCM_IMMUTABLE_FOREIGN): Store subr pointers directly. Adapt to SCM_FOREIGN_TYPE_VOID change. * libguile/vm-i-system.c (subr-call): Access the void* directly.
* remove scm_tc7_gsubrAndy Wingo2010-01-071-181/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/tags.h (scm_tc7_gsubr): Return to the pool of unused tc7s, as there are no more gsubrs. Yay :) * libguile/programs.h (SCM_F_PROGRAM_IS_PRIMITIVE): (SCM_PROGRAM_IS_PRIMITIVE): New flag and accessor. * libguile/gsubr.c (create_gsubr): * libguile/snarf.h (SCM_STATIC_PROGRAM): Give subrs a PRIMITIVE flag. * libguile/smob.h: * libguile/smob.c (scm_i_smob_arity): New internal procedure. Uses the old GSUBR type macros, local to the file. * libguile/procprop.c (scm_i_procedure_arity): Call out to scm_i_smob_arity, and remove a gsubr case. * libguile/gc.c (scm_i_tag_name): * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (scm_class_of): * libguile/vm.c (apply_foreign): * libguile/hash.c (scm_hasher): * libguile/debug.c (scm_procedure_name): * libguile/print.c (iprin1): Remove gsubr cases. * libguile/gsubr.h (SCM_PRIMITIVE_P): Fix to work with the new VM program regimen. (SCM_GSUBR_TYPE, SCM_GSUBR_MAKTYPE, SCM_GSUBR_MAX, SCM_GSUBR_REQ) (SCM_GSUBR_OPT, SCM_GSUBR_REST): Remove these macros, that are no longer useful. * libguile/gsubr.c (scm_i_gsubr_apply, scm_i_gsubr_apply_list) (scm_i_gsubr_apply_array): Remove internal gsubr application functions.
* subrs are now VM trampoline proceduresAndy Wingo2010-01-071-25/+768
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/_scm.h: Add foreign.h and programs.h to the private include list, as snarfing subrs with static allocation now needs access to some of their enums and macros. * libguile/gsubr.c (create_gsubr): Instead of creating a tc7_gsubr object, create a VM program with the call-subr opcode, so that the representation of subrs is now gsubrs. CPP and elisp, together at last. (scm_subr_objcode_trampoline): New function, used by the SCM_DEFINE snarf macro. * libguile/gsubr.h (SCM_SUBR_META_INFO, SCM_SUBR_PROPS) (SCM_SET_SUBR_GENERIC_LOC, SCM_SUBR_ARITY_TO_TYPE): Remove these macros. They were never deprecated, but hopefully people aren't using them. (SCM_SUBRF, SCM_SUBR_NAME, SCM_SUBR_GENERIC, SCM_SET_SUBR_GENERIC): Update to work on the new subr representation. * libguile/objcodes.h (SCM_F_OBJCODE_IS_STATIC): New flag, indicates that the "backing store" of the objcode is statically allocated. * libguile/procprop.c (scm_sym_name): Define here instead of in gsubr.c. * libguile/snarf.h (SCM_DEFINE): If we are doing static allocation, statically allocate the foreign object, the object table, and the program, and use some SCM_SNARF_INITtery to fix things up. Unfortunately I have not been able to make this immutable. It might be possible, though. (SCM_IMMUTABLE_CELL, SCM_STATIC_DOUBLE_CELL, SCM_IMMUTABLE_FOREIGN): (SCM_STATIC_SUBR_OBJVECT, SCM_STATIC_PROGRAM): New helper macros.
* move subr implementation details to gsubr.[ch]Andy Wingo2010-01-051-35/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/procs.h: Move subr macros to gsubr.h. * libguile/procs.c (scm_c_make_subr, scm_c_make_subr_with_generic) (scm_c_define_subr, scm_c_define_subr_with_generic): Remove these, because they deal in subr types, and now there is only one subr type. The body of this code is now in gsubr.c. * libguile/deprecated.h (scm_subr_p): Remove from procs.[ch] and define as a deprecated macro. Only used internally, but who knows who's out there. * libguile/goops.c (scm_generic_capability_p) (scm_enable_primitive_generic_x, scm_set_primitive_generic_x) (scm_primitive_generic_generic): Use the new SCM_PRIMITIVE_GENERIC_P macro instead of calling scm_subr_p. * libguile/gsubr.h (SCM_PRIMITIVE_P, SCM_PRIMITIVE_GENERIC_P): New macros, to replace scm_subr_p and hacky checking for generic capability. (SCM_SUBR_META_INFO, SCM_SUBR_NAME, SCM_SUBRF, SCM_SUBR_PROPS) (SCM_SUBR_GENERIC, SCM_SET_SUBR_GENERIC, SCM_SET_SUBR_GENERIC_LOC) (SCM_SUBR_ARITY_TO_TYPE): Moved here from procs.h. * libguile/gsubr.c (create_gsubr): Inline the scm_c_make_subr definition here, and work for generics too. Removed a scm_remember_upto_here_1 that was added earlier in the year when meta_info was not being traced by the GC. Adapt callers.
* remove tc7_subr_* and tc7_lsubr_*Andy Wingo2009-12-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/tags.h: Remove tc7 #defines for subrs, replacing them with placeholders. These were public, but hopfully unused. I don't see how to usefully deprecate them. * libguile/array-map.c (scm_array_map_x): Remove special cases for certain subr types. This might make things slower for the moment, otoh, native compilation should moot that question. * libguile/eval.i.c: * libguile/eval.c: Remove subr-handling cases. To regain this speed and more won't have to wait for native compilation, though -- this change smooths the way for subr dispatch in the VM. * libguile/gsubr.c (scm_i_gsubr_apply): Fix a bug in which we didn't detect too-many-arguments. This would only show up when using ceval, as only ceval called this function. * test-suite/tests/ramap.test ("array-map!"): Change the expected exception if passed a procedure of the wrong arity. It now gives wrong-num-args. more won't have to wait for native compilation, though -- this change smooths the way for subr dispatch in the VM. * libguile/goops.c (scm_class_of): Remove subr cases. No speed implication. * libguile/objects.c (scm_valid_object_procedure_p): Remove this public but undocumented, and useless, function. I do not think this will affect anyone at all. (scm_set_object_procedure_x): Replace a call to scm_valid_object_procedure_p with scm_procedure_p, and actually wrap with a scm_is_true. * module/oop/goops.scm (initialize-object-procedure): Don't call valid-object-procedure?.
* all subrs are gsubrsAndy Wingo2009-12-031-76/+23
| | | | | | | | | | | | | | | * libguile/gsubr.c (create_gsubr, create_gsubr_with_generic): Always create gsubrs -- never the specialized tc7 types. Allow gsubrs to have generics, there doesn't seem to be any reason not to. * libguile/macros.c (scm_make_synt): * libguile/values.c (scm_init_values): * libguile/eval.c (scm_init_eval): * libguile/gc.c (scm_init_gc): Use scm_c_define_gsubr instead of scm_c_define_subr. * libguile/goops.c (scm_class_of): Allow gsubrs to be primitive generics.
* first step to make the vm stop calling the interpreterAndy Wingo2009-12-011-0/+39
| | | | | | | | | | | | | | | | | | | * libguile/eval.h: * libguile/eval.c (scm_closure_apply): New function, applies a closure. Won't be necessary in the future, but for now here it is, with internal linkage. * libguile/gsubr.h: * libguile/gsubr.c (scm_i_gsubr_apply_array): New function, applies a gsubr to an array of values, potentially extending that array for optional arguments and rest arguments and such. * libguile/vm.c (apply_foreign): New function, applies a foreign function to arguments on the stack, in place. * libguile/vm-i-system.c (call): Add a case for procedures-with-setters (will go away when they are applicable structs). Instead of calling the evaluator for foreign functions, call apply_foreign.
* rename SCM_SNAME to SCM_SUBR_NAMEAndy Wingo2009-06-191-7/+7
| | | | | | | | | | | | * libguile/procs.h: Rename SCM_SNAME to SCM_SUBR_NAME. * libguile/debug.c: * libguile/eval.c: * libguile/eval.i.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/print.c: * libguile/procs.c: Update callers.
* Change Guile license to LGPLv3+Neil Jerram2009-06-171-6/+7
| | | | | | | | | | (Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* )
* Include <alloca.h> in `gsubr.c'.Ludovic Courtès2009-03-241-0/+2
| | | | | * libguile/gsubr.c: Include <alloca.h>. Reported by Carlo Bramini <carlo.bramix@libero.it>.
* Provide a C vararg interface to gsubr invocation.Ludovic Courtès2009-03-081-18/+108
| | | | | | | | | | | | | | | | * libguile/eval.i.c (CEVAL): Update calls to `scm_i_gsubr_apply ()' with a fixed number of arguments. Use `scm_i_gsubr_apply_list ()' for calls with a list of arguments of unknown length. (SCM_APPLY): Use `scm_i_gsubr_apply_list ()' instead of `scm_i_gsubr_apply ()'. * libguile/gsubr.c (gsubr_apply_raw): New. (scm_i_gsubr_apply): Change to take a C vararg list instead of a Scheme list. Use `gsubr_apply_raw ()'. (scm_i_gsubr_apply_list): Use `gsubr_apply_raw ()'. * libguile/gsubr.h (scm_i_gsubr_apply): Update prototype. (scm_i_gsubr_apply_list): New declaration.
* Mark `scm_gsubr_apply ()' as internal.Ludovic Courtès2009-03-021-2/+2
| | | | | | * libguile/gsubr.h (scm_gsubr_apply): Renamed to... (scm_i_gsubr_apply): this. Marked as `SCM_INTERNAL'. Callers updated.
* Change `scm_gsubr_apply ()' to take the gsubr as its first argument.Ludovic Courtès2009-03-021-3/+1
| | | | | | | | | * libguile/gsubr.c (scm_gsubr_apply): Make SELF the first argument instead of the first element of ARGS. * libguile/gsubr.h: Update. * libguile/eval.i.c (CEVAL): Update.