guile-config/guile-config
*.go
TAGS
-/meta/guile-2.0.pc
-/meta/guile-2.0-uninstalled.pc
+/meta/guile-2.2.pc
+/meta/guile-2.2-uninstalled.pc
gdb-pre-inst-guile
cscope.out
cscope.files
/test-suite/standalone/test-scm-values
/test-suite/standalone/test-scm-to-latin1-string
/test-suite/standalone/test-scm-c-bind-keyword-arguments
+/libguile/vm-operations.h
+ /test-suite/standalone/test-foreign-object-c
+ /test-suite/standalone/test-srfi-4
## Process this file with Automake to create Makefile.in
##
## Copyright (C) 1998, 2004, 2006, 2008, 2009, 2010,
- ## 2011, 2013 Free Software Foundation, Inc.
+ ## 2011, 2013, 2014 Free Software Foundation, Inc.
##
## This file is part of GUILE.
##
api-scm.texi \
api-snarf.texi \
api-smobs.texi \
+ api-foreign-objects.texi \
scheme-ideas.texi \
api-data.texi \
api-procedures.texi \
api-foreign.texi \
api-regex.texi \
api-lalr.texi \
+ api-peg.texi \
api-languages.texi \
api-evaluation.texi \
api-memory.texi \
compiler.texi \
fdl.texi \
libguile-concepts.texi \
- libguile-smobs.texi \
+ libguile-foreign-objects.texi \
libguile-snarf.texi \
libguile-linking.texi \
libguile-extensions.texi \
libguile-autoconf.texi: autoconf-macros.texi
autoconf-macros.texi: $(top_srcdir)/meta/guile.m4
- GUILE_INSTALL_LOCALE=1 GUILE_AUTO_COMPILE=0 \
- $(top_builddir)/meta/uninstalled-env guild \
+ GUILE_AUTO_COMPILE=0 $(top_builddir)/meta/uninstalled-env guild \
snarf-guile-m4-docs $(top_srcdir)/meta/guile.m4 \
> $(srcdir)/$@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 2010,
- @c 2011, 2012, 2013 Free Software Foundation, Inc.
+ @c 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node Control Mechanisms
@end deffn
@deffn {Scheme Procedure} make-prompt-tag [stem]
-Make a new prompt tag. Currently prompt tags are generated symbols.
-This may change in some future Guile version.
+Make a new prompt tag. A prompt tag is simply a unique object.
+Currently, a prompt tag is a fresh pair. This may change in some future
+Guile version.
@end deffn
@deffn {Scheme Procedure} default-prompt-tag
Return the default prompt tag. Having a distinguished default prompt
tag allows some useful prompt and abort idioms, discussed in the next
-section.
+section. Note that @code{default-prompt-tag} is actually a parameter,
+and so may be dynamically rebound using @code{parameterize}.
+@xref{Parameters}.
@end deffn
@deffn {Scheme Procedure} abort-to-prompt tag val1 val2 @dots{}
the respective calls so an application can communicate extra
information to those functions.
- If the data consists of an @code{SCM} object, care should be taken
- that it isn't garbage collected while still required. If the
- @code{SCM} is a local C variable, one way to protect it is to pass a
- pointer to that variable as the data parameter, since the C compiler
- will then know the value must be held on the stack. Another way is to
- use @code{scm_remember_upto_here_1} (@pxref{Remembering During
- Operations}).
+ If the data consists of an @code{SCM} object, care should be taken that
+ it isn't garbage collected while still required. If the @code{SCM} is a
+ local C variable, one way to protect it is to pass a pointer to that
+ variable as the data parameter, since the C compiler will then know the
+ value must be held on the stack. Another way is to use
+ @code{scm_remember_upto_here_1} (@pxref{Foreign Object Memory
+ Management}).
@end deftypefn
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 2010, 2012, 2014
+@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 2010, 2012, 2013, 2014
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
garbage collector and the error reporting system.
Memory blocks that are associated with Scheme objects (for example a
- smob) should be allocated with @code{scm_gc_malloc} or
+ foreign object) should be allocated with @code{scm_gc_malloc} or
@code{scm_gc_malloc_pointerless}. These two functions will either
return a valid pointer or signal an error. Memory blocks allocated this
- way can be freed with @code{scm_gc_free}; however, this is not strictly
- needed: memory allocated with @code{scm_gc_malloc} or
- @code{scm_gc_malloc_pointerless} is automatically reclaimed when the
- garbage collector no longer sees any live reference to it@footnote{In
- Guile up to version 1.8, memory allocated with @code{scm_gc_malloc}
- @emph{had} to be freed with @code{scm_gc_free}.}.
+ way may be released explicitly; however, this is not strictly needed,
+ and we recommend @emph{not} calling @code{scm_gc_free}. All memory
+ allocated with @code{scm_gc_malloc} or @code{scm_gc_malloc_pointerless}
+ is automatically reclaimed when the garbage collector no longer sees any
+ live reference to it@footnote{In Guile up to version 1.8, memory
+ allocated with @code{scm_gc_malloc} @emph{had} to be freed with
+ @code{scm_gc_free}.}.
Memory allocated with @code{scm_gc_malloc} is scanned for live pointers.
This means that if @code{scm_gc_malloc}-allocated memory contains a
@deftypefn {C Function} void scm_gc_free (void *@var{mem}, size_t @var{size}, const char *@var{what})
Explicitly free the memory block pointed to by @var{mem}, which was
- previously allocated by one of the above @code{scm_gc} functions.
+ previously allocated by one of the above @code{scm_gc} functions. This
+ function is almost always unnecessary, except for codebases that still
+ need to compile on Guile 1.8.
Note that you need to explicitly pass the @var{size} parameter. This
is done since it should normally be easy to provide this parameter
It is especially important to call this function when large unmanaged
allocations, like images, may be freed by small Scheme allocations, like
- SMOBs.
+ foreign objects.
@end deftypefn
This knowledge should make it straightforward to add new functions to
Guile that can be called from Scheme. Adding new data types is also
- possible and is done by defining @dfn{smobs}.
+ possible and is done by defining @dfn{foreign objects}.
The @ref{Programming Overview} section of this part contains general
musings and guidelines about programming with Guile. It explores
* Linking Programs With Guile:: More precisely, with the libguile library.
* Linking Guile with Libraries:: To extend Guile itself.
* General Libguile Concepts:: General concepts for using libguile.
- * Defining New Types (Smobs):: Adding new types to Guile.
+ * Defining New Foreign Object Types:: Adding new types to Guile.
* Function Snarfing:: A way to define new functions.
* Programming Overview:: An overview of Guile programming.
* Autoconf Support:: Putting m4 to good use.
@include libguile-linking.texi
@include libguile-extensions.texi
@include libguile-concepts.texi
- @include libguile-smobs.texi
+ @include libguile-foreign-objects.texi
@include libguile-snarf.texi
@include libguile-program.texi
@include libguile-autoconf.texi
* Snarfing Macros:: Macros for snarfing initialization actions.
* Simple Data Types:: Numbers, strings, booleans and so on.
* Compound Data Types:: Data types for holding other data.
- * Smobs:: Defining new data types in C.
+ * Foreign Objects:: Defining new data types in C.
+ * Smobs:: Use foreign objects instead.
* Procedures:: Procedures.
* Macros:: Extending the syntax of Scheme.
* Utility Functions:: General utility functions.
* Input and Output:: Ports, reading and writing.
* Regular Expressions:: Pattern matching and substitution.
* LALR(1) Parsing:: Generating LALR(1) parsers.
+* PEG Parsing:: Parsing Expression Grammars.
* Read/Load/Eval/Compile:: Reading and evaluating Scheme code.
* Memory Management:: Memory management and garbage collection.
* Modules:: Designing reusable code libraries.
@include api-snarf.texi
@include api-data.texi
@include api-compound.texi
+ @include api-foreign-objects.texi
@include api-smobs.texi
@include api-procedures.texi
@include api-macros.texi
@include api-io.texi
@include api-regex.texi
@include api-lalr.texi
+@include api-peg.texi
@include api-evaluation.texi
@include api-memory.texi
@include api-modules.texi
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2010, 2013, 2014
-@c Free Software Foundation, Inc.
+@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2010,
- @c 2011, 2013 Free Software Foundation, Inc.
++@c 2011, 2013, 2014 Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node General Libguile Concepts
by any active Scheme values. This activity is called @dfn{garbage
collection}.
- It is easy for Guile to remember all blocks of memory that it has
- allocated for use by Scheme values, but you need to help it with finding
- all Scheme values that are in use by C code.
-
- You do this when writing a SMOB mark function, for example
- (@pxref{Garbage Collecting Smobs}). By calling this function, the
- garbage collector learns about all references that your SMOB has to
- other @code{SCM} values.
-
- Other references to @code{SCM} objects, such as global variables of type
- @code{SCM} or other random data structures in the heap that contain
- fields of type @code{SCM}, can be made visible to the garbage collector
- by calling the functions @code{scm_gc_protect} or
- @code{scm_permanent_object}. You normally use these functions for long
- lived objects such as a hash table that is stored in a global variable.
- For temporary references in local variables or function arguments, using
- these functions would be too expensive.
-
- These references are handled differently: Local variables (and function
- arguments) of type @code{SCM} are automatically visible to the garbage
- collector. This works because the collector scans the stack for
- potential references to @code{SCM} objects and considers all referenced
- objects to be alive. The scanning considers each and every word of the
- stack, regardless of what it is actually used for, and then decides
- whether it could possibly be a reference to a @code{SCM} object. Thus,
- the scanning is guaranteed to find all actual references, but it might
- also find words that only accidentally look like references. These
- `false positives' might keep @code{SCM} objects alive that would
- otherwise be considered dead. While this might waste memory, keeping an
- object around longer than it strictly needs to is harmless. This is why
- this technique is called ``conservative garbage collection''. In
- practice, the wasted memory seems to be no problem.
+ Guile's garbage collector will automatically discover references to
+ @code{SCM} objects that originate in global variables, static data
+ sections, function arguments or local variables on the C and Scheme
+ stacks, and values in machine registers. Other references to @code{SCM}
+ objects, such as those in other random data structures in the C heap
+ that contain fields of type @code{SCM}, can be made visible to the
+ garbage collector by calling the functions @code{scm_gc_protect} or
+ @code{scm_permanent_object}. Collectively, these values form the ``root
+ set'' of garbage collection; any value on the heap that is referenced
+ directly or indirectly by a member of the root set is preserved, and all
+ other objects are eligible for reclamation.
+
+ The Scheme stack and heap are scanned precisely; that is to say, Guile
+ knows about all inter-object pointers on the Scheme stack and heap.
+ This is not the case, unfortunately, for pointers on the C stack and
+ static data segment. For this reason we have to scan the C stack and
+ static data segment @dfn{conservatively}; any value that looks like a
+ pointer to a GC-managed object is treated as such, whether it actually
+ is a reference or not. Thus, scanning the C stack and static data
+ segment is guaranteed to find all actual references, but it might also
+ find words that only accidentally look like references. These ``false
+ positives'' might keep @code{SCM} objects alive that would otherwise be
+ considered dead. While this might waste memory, keeping an object
+ around longer than it strictly needs to is harmless. This is why this
+ technique is called ``conservative garbage collection''. In practice,
+ the wasted memory seems to be no problem, as the static C root set is
+ almost always finite and small, given that the Scheme stack is separate
+ from the C stack.
The stack of every thread is scanned in this way and the registers of
the CPU and all other memory locations where local variables or function
There are situations, however, where a @code{SCM} object needs to be
around longer than its reference from a local variable or function
parameter. This happens, for example, when you retrieve some pointer
- from a smob and work with that pointer directly. The reference to the
- @code{SCM} smob object might be dead after the pointer has been
- retrieved, but the pointer itself (and the memory pointed to) is still
- in use and thus the smob object must be protected. The compiler does
- not know about this connection and might overwrite the @code{SCM}
- reference too early.
+ from a foreign object and work with that pointer directly. The
+ reference to the @code{SCM} foreign object might be dead after the
+ pointer has been retrieved, but the pointer itself (and the memory
+ pointed to) is still in use and thus the foreign object must be
+ protected. The compiler does not know about this connection and might
+ overwrite the @code{SCM} reference too early.
To get around this problem, you can use @code{scm_remember_upto_here_1}
and its cousins. It will keep the compiler from overwriting the
- reference. For a typical example of its use, see @ref{Remembering
- During Operations}.
+ reference. @xref{Foreign Object Memory Management}.
+
@node Control Flow
@subsection Control Flow
guile mode for the first time, it gets a Scheme representation and is
listed by @code{all-threads}, for example.
-Threads in guile mode can block (e.g., do blocking I/O) without causing any
-problems@footnote{In Guile 1.8, a thread blocking in guile mode would prevent
-garbage collection to occur. Thus, threads had to leave guile mode whenever
-they could block. This is no longer needed with Guile 2.0.}; temporarily
-leaving guile mode with @code{scm_without_guile} before blocking slightly
-improves GC performance, though. For some common blocking operations, Guile
-provides convenience functions. For example, if you want to lock a pthread
-mutex while in guile mode, you might want to use @code{scm_pthread_mutex_lock}
-which is just like @code{pthread_mutex_lock} except that it leaves guile mode
-while blocking.
+Threads in guile mode can block (e.g., do blocking I/O) without causing
+any problems@footnote{In Guile 1.8, a thread blocking in guile mode
+would prevent garbage collection to occur. Thus, threads had to leave
+guile mode whenever they could block. This is no longer needed with
+Guile 2.@var{x}.}; temporarily leaving guile mode with
+@code{scm_without_guile} before blocking slightly improves GC
+performance, though. For some common blocking operations, Guile
+provides convenience functions. For example, if you want to lock a
+pthread mutex while in guile mode, you might want to use
+@code{scm_pthread_mutex_lock} which is just like
+@code{pthread_mutex_lock} except that it leaves guile mode while
+blocking.
All libguile functions are (intended to be) robust in the face of
#ifndef SCM_LIBGUILE_H
#define SCM_LIBGUILE_H
- /* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
-/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2012, 2014 Free Software Foundation, Inc.
++/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
#include "libguile/finalizers.h"
#include "libguile/fluids.h"
#include "libguile/foreign.h"
+ #include "libguile/foreign-object.h"
#include "libguile/fports.h"
#include "libguile/gc.h"
-#include "libguile/gdbint.h"
#include "libguile/generalized-arrays.h"
#include "libguile/generalized-vectors.h"
#include "libguile/goops.h"
#include "libguile/srfi-4.h"
#include "libguile/version.h"
#include "libguile/vports.h"
-#include "libguile/weaks.h"
+#include "libguile/weak-set.h"
+#include "libguile/weak-table.h"
+#include "libguile/weak-vector.h"
#include "libguile/backtrace.h"
#include "libguile/debug.h"
#include "libguile/stacks.h"
debug.c \
deprecated.c \
deprecation.c \
+ dynstack.c \
dynwind.c \
eq.c \
error.c \
finalizers.c \
fluids.c \
foreign.c \
+ foreign-object.c \
fports.c \
frames.c \
gc-malloc.c \
gc.c \
- gdbint.c \
gettext.c \
generalized-arrays.c \
generalized-vectors.c \
keywords.c \
list.c \
load.c \
+ loader.c \
macros.c \
mallocs.c \
memoize.c \
modules.c \
null-threads.c \
numbers.c \
- objcodes.c \
objprop.c \
options.c \
pairs.c \
version.c \
vm.c \
vports.c \
- weaks.c
+ weak-set.c \
+ weak-table.c \
+ weak-vector.c
DOT_X_FILES = \
alist.x \
fluids.x \
foreign.x \
fports.x \
+ frames.x \
gc-malloc.x \
gc.x \
gettext.x \
hooks.x \
i18n.x \
init.x \
+ instructions.x \
ioext.x \
keywords.x \
list.x \
load.x \
+ loader.x \
macros.x \
mallocs.x \
memoize.x \
print.x \
procprop.x \
procs.x \
+ programs.x \
promises.x \
r6rs-ports.x \
random.x \
variable.x \
vectors.x \
version.x \
+ vm.x \
vports.x \
- weaks.x
-
-# vm-related snarfs
-DOT_X_FILES += frames.x instructions.x objcodes.x programs.x vm.x
+ weak-set.x \
+ weak-table.x \
+ weak-vector.x
EXTRA_DOT_X_FILES = @EXTRA_DOT_X_FILES@
vectors.doc \
version.doc \
vports.doc \
- weaks.doc
+ weak-set.doc \
+ weak-table.doc \
+ weak-vector.doc
EXTRA_DOT_DOC_FILES = @EXTRA_DOT_DOC_FILES@
-DOT_I_FILES = vm-i-system.i vm-i-scheme.i vm-i-loader.i
-
-.c.i:
- $(AM_V_GEN)$(GREP) '^VM_DEFINE' $< > $@
+vm-operations.h: vm-engine.c
+ @echo '/* This file was generated automatically from $<; do not' > $@
+ @echo ' edit. See the source file for copyright information. */' >> $@
+ @echo '' >> $@
+ @echo "#define FOR_EACH_VM_OPERATION(M) \\" >> $@
+ $(AM_V_GEN)$(GREP) '^ *VM_DEFINE_OP' $< \
+ | sed -e 's,VM_DEFINE_OP (\(.*\)).*, M (\1) \\,' >> $@
+ @echo '' >> $@
BUILT_SOURCES = cpp-E.c cpp-SIG.c libpath.h \
scmconfig.h \
- $(DOT_I_FILES) $(DOT_X_FILES) $(EXTRA_DOT_X_FILES)
+ $(DOT_I_FILES) vm-operations.h $(DOT_X_FILES) $(EXTRA_DOT_X_FILES)
# Force the generation of `guile-procedures.texi' because the top-level
# Makefile expects it to be built.
install-exec-hook:
rm -f $(DESTDIR)$(bindir)/guile-snarf.awk
-install-data-hook: libguile-2.0-gdb.scm
+install-data-hook: libguile-2.2-gdb.scm
@$(MKDIR_P) $(DESTDIR)$(libdir)
-## We want to install libguile-2.0-gdb.scm as SOMETHING-gdb.scm.
+## We want to install libguile-2.2-gdb.scm as SOMETHING-gdb.scm.
## SOMETHING is the full name of the final library. We want to ignore
## symlinks, the .la file, and any previous -gdb.py file. This is
## inherently fragile, but there does not seem to be a better option,
## Perhaps we can deal with them normally once the merge seems to be
## working.
noinst_HEADERS = conv-integer.i.c conv-uinteger.i.c \
+ elf.h \
srfi-14.i.c \
quicksort.i.c \
win32-uname.h \
- private-gc.h private-options.h ports-internal.h
+ private-options.h ports-internal.h
# vm instructions
-noinst_HEADERS += vm-engine.c vm-i-system.c vm-i-scheme.c vm-i-loader.c
+noinst_HEADERS += vm-engine.c
libguile_@GUILE_EFFECTIVE_VERSION@_la_DEPENDENCIES = @LIBLOBJS@
deprecated.h \
deprecation.h \
dynl.h \
+ dynstack.h \
dynwind.h \
eq.h \
error.h \
filesys.h \
fluids.h \
foreign.h \
+ foreign-object.h \
fports.h \
frames.h \
gc.h \
- gdb_interface.h \
- gdbint.h \
+ gc-inline.h \
gettext.h \
generalized-arrays.h \
generalized-vectors.h \
keywords.h \
list.h \
load.h \
+ loader.h \
macros.h \
mallocs.h \
memoize.h \
net_db.h \
null-threads.h \
numbers.h \
- objcodes.h \
objprop.h \
options.h \
pairs.h \
values.h \
variable.h \
vectors.h \
- vm-engine.h \
+ vm-builtins.h \
vm-expand.h \
vm.h \
vports.h \
- weaks.h
+ weak-set.h \
+ weak-table.h \
+ weak-vector.h
nodist_modinclude_HEADERS = version.h scmconfig.h
cpp-E.syms cpp-E.c cpp-SIG.syms cpp-SIG.c \
c-tokenize.lex \
scmconfig.h.top libgettext.h unidata_to_charset.pl libguile.map \
- libguile-2.0-gdb.scm
+ libguile-2.2-gdb.scm
# $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) \
# guile-procedures.txt guile.texi
dynl.x: libpath.h
alldotdocfiles = $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES)
-snarf2checkedtexi = GUILE_INSTALL_LOCALE=1 GUILE_AUTO_COMPILE=0 \
- $(top_builddir)/meta/uninstalled-env guild snarf-check-and-output-texi
+snarf2checkedtexi = GUILE_AUTO_COMPILE=0 $(top_builddir)/meta/uninstalled-env guild snarf-check-and-output-texi
dotdoc2texi = cat $(alldotdocfiles) | $(snarf2checkedtexi)
guile.texi: $(alldotdocfiles) guile$(EXEEXT)
MOSTLYCLEANFILES = \
scmconfig.h scmconfig.h.tmp
-CLEANFILES = libpath.h *.x *.doc guile-procedures.txt guile-procedures.texi guile.texi \
- vm-i-*.i
+CLEANFILES = libpath.h *.x *.doc guile-procedures.txt guile-procedures.texi guile.texi
MAINTAINERCLEANFILES = c-tokenize.c
-/* Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2008,2009,2010,2011,2012,2014
+/* Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2008,2009,2010,2011,2012,2013,2014
* Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
#include "libguile/strings.h"
#include "libguile/strports.h"
#include "libguile/vectors.h"
-#include "libguile/weaks.h"
#include "libguile/vm.h"
#include "libguile/validate.h"
SCM_VARIABLE (scm_var_make_extended_generic, "make-extended-generic");
-/* FIXME, exports should come from the scm file only */
-#define DEFVAR(v, val) \
- { scm_module_define (scm_module_goops, (v), (val)); \
- scm_module_export (scm_module_goops, scm_list_1 ((v))); \
- }
-
-
/* Class redefinition protocol:
A class is represented by a heap header h1 which points to a
static SCM class_fluid;
static SCM class_dynamic_state;
static SCM class_frame;
-static SCM class_objcode;
-static SCM class_vm;
static SCM class_vm_cont;
static SCM class_bytevector;
static SCM class_uvec;
static SCM class_bitvector;
static SCM vtable_class_map = SCM_BOOL_F;
-static scm_i_pthread_mutex_t vtable_class_map_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
/* Port classes. Allocate 3 times the maximum number of port types so that
input ports, output ports, and in/out ports can be stored at different
{
SCM class;
- scm_i_pthread_mutex_lock (&vtable_class_map_lock);
-
+ scm_i_pthread_mutex_lock (&scm_i_misc_mutex);
if (scm_is_false (vtable_class_map))
- vtable_class_map = scm_make_weak_key_hash_table (SCM_UNDEFINED);
+ vtable_class_map = scm_c_make_weak_table (0, SCM_WEAK_TABLE_KIND_KEY);
+ scm_i_pthread_mutex_unlock (&scm_i_misc_mutex);
if (scm_is_false (scm_struct_vtable_p (vtable)))
abort ();
- class = scm_hashq_ref (vtable_class_map, vtable, SCM_BOOL_F);
-
- scm_i_pthread_mutex_unlock (&vtable_class_map_lock);
+ class = scm_weak_table_refq (vtable_class_map, vtable, SCM_BOOL_F);
if (scm_is_false (class))
{
/* Don't worry about races. This only happens when creating a
vtable, which happens by definition in one thread. */
- scm_i_pthread_mutex_lock (&vtable_class_map_lock);
- scm_hashq_set_x (vtable_class_map, vtable, class);
- scm_i_pthread_mutex_unlock (&vtable_class_map_lock);
+ scm_weak_table_putq_x (vtable_class_map, vtable, class);
}
return class;
return class_dynamic_state;
case scm_tc7_frame:
return class_frame;
- case scm_tc7_objcode:
- return class_objcode;
- case scm_tc7_vm:
- return class_vm;
case scm_tc7_vm_cont:
return class_vm_cont;
case scm_tc7_bytevector:
get_n_set = SCM_CDR (get_n_set), slots = SCM_CDR (slots))
{
SCM slot_name = SCM_CAR (slots);
- SCM slot_value = SCM_PACK (0);
+ SCM slot_value = SCM_GOOPS_UNBOUND;
if (!scm_is_null (SCM_CDR (slot_name)))
{
slot_value = scm_i_get_keyword (tmp,
initargs,
n_initargs,
- SCM_PACK (0),
+ SCM_GOOPS_UNBOUND,
FUNC_NAME);
}
}
- if (SCM_UNPACK (slot_value))
+ if (!SCM_GOOPS_UNBOUNDP (slot_value))
/* set slot to provided value */
set_slot_value (class, obj, SCM_CAR (get_n_set), slot_value);
else
/* set slot to its :init-form if it exists */
tmp = SCM_CADAR (get_n_set);
if (scm_is_true (tmp))
- {
- slot_value = get_slot_value (class, obj, SCM_CAR (get_n_set));
- if (SCM_GOOPS_UNBOUNDP (slot_value))
- set_slot_value (class,
- obj,
- SCM_CAR (get_n_set),
- scm_call_0 (tmp));
- }
+ set_slot_value (class,
+ obj,
+ SCM_CAR (get_n_set),
+ scm_call_0 (tmp));
}
}
SCM_SYMBOL (sym_default_slot_definition_class, "default-slot-definition-class");
SCM_SYMBOL (sym_slots, "slots");
SCM_SYMBOL (sym_getters_n_setters, "getters-n-setters");
-SCM_SYMBOL (sym_keyword_access, "keyword-access");
SCM_SYMBOL (sym_nfields, "nfields");
scm_list_1 (sym_default_slot_definition_class),
scm_list_1 (sym_slots),
scm_list_1 (sym_getters_n_setters),
- scm_list_1 (sym_keyword_access),
scm_list_1 (sym_nfields),
SCM_UNDEFINED);
}
prep_hashsets (scm_class_class);
- DEFVAR(name, scm_class_class);
+ scm_module_define (scm_module_goops, name, scm_class_class);
/**** <top> ****/
name = scm_from_latin1_symbol ("<top>");
scm_class_top = scm_basic_make_class (scm_class_class, name,
SCM_EOL, SCM_EOL);
- DEFVAR(name, scm_class_top);
+ scm_module_define (scm_module_goops, name, scm_class_top);
/**** <object> ****/
name = scm_from_latin1_symbol ("<object>");
scm_class_object = scm_basic_make_class (scm_class_class, name,
scm_list_1 (scm_class_top), SCM_EOL);
- DEFVAR (name, scm_class_object);
+ scm_module_define (scm_module_goops, name, scm_class_object);
/* <top> <object> and <class> were partially initialized. Correct them here */
SCM_SET_SLOT (scm_class_object, scm_si_direct_subclasses, scm_list_1 (scm_class_class));
SCM_GLOBAL_SYMBOL (scm_sym_args, "args");
-
-SCM
-scm_apply_generic (SCM gf, SCM args)
-{
- return scm_apply (SCM_STRUCT_PROCEDURE (gf), args, SCM_EOL);
-}
-
-SCM
-scm_call_generic_0 (SCM gf)
-{
- return scm_call_0 (SCM_STRUCT_PROCEDURE (gf));
-}
-
-SCM
-scm_call_generic_1 (SCM gf, SCM a1)
-{
- return scm_call_1 (SCM_STRUCT_PROCEDURE (gf), a1);
-}
-
-SCM
-scm_call_generic_2 (SCM gf, SCM a1, SCM a2)
-{
- return scm_call_2 (SCM_STRUCT_PROCEDURE (gf), a1, a2);
-}
-
-SCM
-scm_call_generic_3 (SCM gf, SCM a1, SCM a2, SCM a3)
-{
- return scm_call_3 (SCM_STRUCT_PROCEDURE (gf), a1, a2, a3);
-}
+SCM_SYMBOL (sym_delayed_compile, "delayed-compile");
static SCM delayed_compile_var;
}
}
+/* Dirk:FIXME:: In all of these scm_wta_dispatch_* routines it is
+ * assumed that 'gf' is zero if uninitialized. It would be cleaner if
+ * some valid SCM value like SCM_BOOL_F or SCM_UNDEFINED were chosen.
+ */
+
+SCM
+scm_wta_dispatch_0 (SCM gf, const char *subr)
+{
+ if (!SCM_UNPACK (gf))
+ scm_error_num_args_subr (subr);
+
+ return scm_call_0 (gf);
+}
+
+SCM
+scm_wta_dispatch_1 (SCM gf, SCM a1, int pos, const char *subr)
+{
+ if (!SCM_UNPACK (gf))
+ scm_wrong_type_arg (subr, pos, a1);
+
+ return scm_call_1 (gf, a1);
+}
+
+SCM
+scm_wta_dispatch_2 (SCM gf, SCM a1, SCM a2, int pos, const char *subr)
+{
+ if (!SCM_UNPACK (gf))
+ scm_wrong_type_arg (subr, pos, (pos == SCM_ARG1) ? a1 : a2);
+
+ return scm_call_2 (gf, a1, a2);
+}
+
+SCM
+scm_wta_dispatch_n (SCM gf, SCM args, int pos, const char *subr)
+{
+ if (!SCM_UNPACK (gf))
+ scm_wrong_type_arg (subr, pos, scm_list_ref (args, scm_from_int (pos)));
+
+ return scm_apply_0 (gf, args);
+}
+
/******************************************************************************
*
* Protocol for calling a generic fumction
static void
make_stdcls (SCM *var, char *name, SCM meta, SCM super, SCM slots)
{
- SCM tmp = scm_from_locale_symbol (name);
+ SCM tmp = scm_from_utf8_symbol (name);
*var = scm_basic_make_class (meta, tmp,
scm_is_pair (super) ? super : scm_list_1 (super),
slots);
- DEFVAR(tmp, *var);
+ scm_module_define (scm_module_goops, tmp, *var);
}
scm_class_class, scm_class_top, SCM_EOL);
make_stdcls (&class_frame, "<frame>",
scm_class_class, scm_class_top, SCM_EOL);
- make_stdcls (&class_objcode, "<objcode>",
- scm_class_class, scm_class_top, SCM_EOL);
- make_stdcls (&class_vm, "<vm>",
- scm_class_class, scm_class_top, SCM_EOL);
make_stdcls (&class_vm_cont, "<vm-continuation>",
scm_class_class, scm_class_top, SCM_EOL);
make_stdcls (&class_bytevector, "<bytevector>",
static SCM
make_class_from_template (char const *template, char const *type_name, SCM supers, int applicablep)
{
- SCM class, name;
+ SCM name;
if (type_name)
{
char buffer[100];
sprintf (buffer, template, type_name);
- name = scm_from_locale_symbol (buffer);
+ name = scm_from_utf8_symbol (buffer);
}
else
name = SCM_GOOPS_UNBOUND;
- class = scm_basic_make_class (applicablep ? scm_class_procedure_class : scm_class_class,
- name, supers, SCM_EOL);
-
- /* Only define name if doesn't already exist. */
- if (!SCM_GOOPS_UNBOUNDP (name)
- && scm_is_false (scm_module_variable (scm_module_goops, name)))
- DEFVAR (name, class);
- return class;
+ return scm_basic_make_class (applicablep ? scm_class_procedure_class : scm_class_class,
+ name, supers, SCM_EOL);
}
static SCM
make_class_from_symbol (SCM type_name_sym, SCM supers, int applicablep)
{
- SCM class, name;
+ SCM name;
+
if (scm_is_true (type_name_sym))
{
name = scm_string_append (scm_list_3 (scm_from_locale_string ("<"),
else
name = SCM_GOOPS_UNBOUND;
- class = scm_basic_make_class (applicablep ? scm_class_procedure_class : scm_class_class,
- name, supers, SCM_EOL);
-
- /* Only define name if doesn't already exist. */
- if (!SCM_GOOPS_UNBOUNDP (name)
- && scm_is_false (scm_module_variable (scm_module_goops, name)))
- DEFVAR (name, class);
- return class;
+ return scm_basic_make_class (applicablep ? scm_class_procedure_class : scm_class_class,
+ name, supers, SCM_EOL);
}
SCM
{
long i;
- for (i = 0; i < scm_numptob; ++i)
+ for (i = scm_c_num_port_types () - 1; i >= 0; i--)
scm_make_port_classes (i, SCM_PTOBNAME (i));
}
SCM name = scm_from_latin1_symbol ("no-applicable-method");
scm_no_applicable_method =
scm_make (scm_list_3 (scm_class_generic, k_name, name));
- DEFVAR (name, scm_no_applicable_method);
+ scm_module_define (scm_module_goops, name, scm_no_applicable_method);
}
return SCM_UNSPECIFIED;
#include "libguile/fports.h"
#include "libguile/frames.h"
#include "libguile/gc.h"
-#include "libguile/gdbint.h"
#include "libguile/generalized-arrays.h"
#include "libguile/generalized-vectors.h"
#include "libguile/goops.h"
#include "libguile/modules.h"
#include "libguile/net_db.h"
#include "libguile/numbers.h"
-#include "libguile/objcodes.h"
+#include "libguile/loader.h"
#include "libguile/objprop.h"
#include "libguile/options.h"
#include "libguile/pairs.h"
#include "libguile/version.h"
#include "libguile/vm.h"
#include "libguile/vports.h"
-#include "libguile/weaks.h"
#include "libguile/guardians.h"
#include "libguile/extensions.h"
#include "libguile/uniform.h"
{
stream_body_data *body_data = (stream_body_data *) data;
SCM port = scm_fdes_to_port (body_data->fdes, body_data->mode, SCM_BOOL_F);
-
- SCM_REVEALED (port) = 1;
+ scm_set_port_revealed_x (port, SCM_INUM1);
return port;
}
(scm_standard_stream_to_port (1, isatty (1) ? "w0" : "w"));
scm_set_current_error_port
(scm_standard_stream_to_port (2, isatty (2) ? "w0" : "w"));
+ scm_set_current_warning_port (scm_current_error_port ());
}
scm_storage_prehistory ();
scm_threads_prehistory (base); /* requires storage_prehistory */
- scm_weaks_prehistory (); /* requires storage_prehistory */
+ scm_weak_table_prehistory (); /* requires storage_prehistory */
#ifdef GUILE_DEBUG_MALLOC
scm_debug_malloc_prehistory ();
#endif
- scm_symbols_prehistory (); /* requires weaks_prehistory */
+ scm_symbols_prehistory (); /* requires weak_table_prehistory */
scm_modules_prehistory ();
scm_init_array_handle ();
scm_bootstrap_bytevectors (); /* Requires array-handle */
scm_bootstrap_instructions ();
- scm_bootstrap_objcodes ();
+ scm_bootstrap_loader ();
scm_bootstrap_programs ();
scm_bootstrap_vm ();
scm_register_r6rs_ports ();
scm_register_foreign ();
+ scm_register_foreign_object ();
scm_register_srfi_1 ();
scm_register_srfi_60 ();
scm_register_poll ();
scm_init_stime ();
scm_init_gc (); /* Requires hooks and `get_internal_run_time' */
scm_init_gc_protect_object (); /* requires threads_prehistory */
- scm_init_gdbint (); /* Requires strports, gc_protect_object */
scm_init_gettext ();
scm_init_ioext ();
scm_init_keywords (); /* Requires smob_prehistory */
scm_init_throw (); /* Requires smob_prehistory */
scm_init_trees ();
scm_init_version ();
- scm_init_weaks ();
+ scm_init_weak_set ();
+ scm_init_weak_table ();
+ scm_init_weak_vectors ();
scm_init_guardians (); /* requires smob_prehistory */
scm_init_vports ();
scm_init_standard_ports (); /* Requires fports */
scm_initialized_p = 1;
-#ifdef STACK_CHECKING
scm_stack_checking_enabled_p = SCM_STACK_CHECKING_P;
-#endif
scm_init_rdelim ();
scm_init_rw ();
/* Capture the dynamic state after loading boot-9, so that new threads end up
in the guile-user module. */
scm_init_threads_default_dynamic_state ();
+
+ /* Finally, cause finalizers to run in a separate thread. */
+ scm_init_finalizer_thread ();
}
/*
# We're at the root of the module hierarchy.
modpath =
-# Build eval.go first.
-$(GOBJECTS): ice-9/eval.go
-CLEANFILES += ice-9/eval.go
-nobase_mod_DATA += ice-9/eval.scm
-nobase_ccache_DATA += ice-9/eval.go
-EXTRA_DIST += ice-9/eval.scm
-ETAGS_ARGS += ice-9/eval.scm
+# Build eval.go first. Then build psyntax-pp.go, as the expander has to
+# run on every loaded scheme file. It doesn't pay off at compile-time
+# to interpret the expander in parallel!
+$(GOBJECTS): ice-9/psyntax-pp.go
+ice-9/psyntax-pp.go: ice-9/eval.go
+CLEANFILES += ice-9/eval.go ice-9/psyntax-pp.go
+nobase_mod_DATA += ice-9/eval.scm ice-9/psyntax-pp.scm
+nobase_ccache_DATA += ice-9/eval.go ice-9/psyntax-pp.go
+EXTRA_DIST += ice-9/eval.scm ice-9/psyntax-pp.scm
+ETAGS_ARGS += ice-9/eval.scm ice-9/psyntax-pp.scm
+
+VM_TARGETS := system/vm/assembler.go system/vm/disassembler.go
+$(VM_TARGETS): $(top_builddir)/libguile/vm-operations.h
ice-9/boot-9.go: ice-9/boot-9.scm ice-9/quasisyntax.scm ice-9/r6rs-libraries.scm
ice-9/match.go: ice-9/match.scm ice-9/match.upstream.scm
# We can compile these in any order, but it's fastest if we compile
-# psyntax and boot-9 first, then the compiler itself, then the rest of
-# the code.
+# boot-9 first, then the compiler itself, then the rest of the code.
SOURCES = \
- ice-9/psyntax-pp.scm \
ice-9/boot-9.scm \
+ language/tree-il/peval.scm \
+ system/vm/elf.scm \
ice-9/vlist.scm \
srfi/srfi-1.scm \
- language/tree-il/peval.scm \
- language/tree-il/cse.scm \
+ system/vm/linker.scm \
+ system/vm/dwarf.scm \
+ system/vm/assembler.scm \
\
language/tree-il.scm \
- language/glil.scm \
- language/assembly.scm \
$(TREE_IL_LANG_SOURCES) \
- $(GLIL_LANG_SOURCES) \
- $(ASSEMBLY_LANG_SOURCES) \
+ $(CPS_LANG_SOURCES) \
$(BYTECODE_LANG_SOURCES) \
- $(OBJCODE_LANG_SOURCES) \
$(VALUE_LANG_SOURCES) \
$(SCHEME_LANG_SOURCES) \
$(SYSTEM_BASE_SOURCES) \
\
$(ICE_9_SOURCES) \
+ $(SYSTEM_SOURCES) \
$(SRFI_SOURCES) \
$(RNRS_SOURCES) \
$(OOP_SOURCES) \
- $(SYSTEM_SOURCES) \
$(SCRIPTS_SOURCES) \
$(ECMASCRIPT_LANG_SOURCES) \
$(ELISP_LANG_SOURCES) \
ice-9/ChangeLog-2008
ice-9/psyntax-pp.scm.gen:
- GUILE_INSTALL_LOCALE=1 GUILE_AUTO_COMPILE=0 \
- $(top_builddir_absolute)/meta/guile -s $(srcdir)/ice-9/compile-psyntax.scm \
+ $(top_builddir_absolute)/meta/guile --no-auto-compile -s $(srcdir)/ice-9/compile-psyntax.scm \
$(srcdir)/ice-9/psyntax.scm $(srcdir)/ice-9/psyntax-pp.scm
.PHONY: ice-9/psyntax-pp.scm.gen
# Keep this rule in sync with that in `am/guilec'.
ice-9/psyntax-pp.go: ice-9/psyntax.scm ice-9/psyntax-pp.scm
- $(AM_V_GUILEC)GUILE_INSTALL_LOCALE=1 GUILE_AUTO_COMPILE=0 \
+ $(AM_V_GUILEC)GUILE_AUTO_COMPILE=0 \
$(top_builddir)/meta/uninstalled-env \
guild compile --target="$(host)" $(GUILE_WARNINGS) \
-L "$(abs_srcdir)" -L "$(abs_builddir)" \
language/tree-il/canonicalize.scm \
language/tree-il/analyze.scm \
language/tree-il/inline.scm \
- language/tree-il/compile-glil.scm \
+ language/tree-il/compile-cps.scm \
language/tree-il/debug.scm \
language/tree-il/spec.scm
-GLIL_LANG_SOURCES = \
- language/glil/spec.scm language/glil/compile-assembly.scm
-
-ASSEMBLY_LANG_SOURCES = \
- language/assembly/spec.scm \
- language/assembly/compile-bytecode.scm \
- language/assembly/decompile-bytecode.scm \
- language/assembly/disassemble.scm
-
-BYTECODE_LANG_SOURCES = \
+CPS_LANG_SOURCES = \
+ language/cps.scm \
+ language/cps/arities.scm \
+ language/cps/closure-conversion.scm \
+ language/cps/compile-bytecode.scm \
+ language/cps/constructors.scm \
+ language/cps/contification.scm \
+ language/cps/cse.scm \
+ language/cps/dce.scm \
+ language/cps/dfg.scm \
+ language/cps/effects-analysis.scm \
+ language/cps/elide-values.scm \
+ language/cps/primitives.scm \
+ language/cps/prune-bailouts.scm \
+ language/cps/prune-top-level-scopes.scm \
+ language/cps/reify-primitives.scm \
+ language/cps/renumber.scm \
+ language/cps/self-references.scm \
+ language/cps/slot-allocation.scm \
+ language/cps/simplify.scm \
+ language/cps/spec.scm \
+ language/cps/specialize-primcalls.scm \
+ language/cps/verify.scm
+
+BYTECODE_LANG_SOURCES = \
+ language/bytecode.scm \
language/bytecode/spec.scm
-OBJCODE_LANG_SOURCES = \
- language/objcode/spec.scm
-
VALUE_LANG_SOURCES = \
language/value/spec.scm
language/ecmascript/spec.scm
ELISP_LANG_SOURCES = \
+ language/elisp/falias.scm \
language/elisp/lexer.scm \
language/elisp/parser.scm \
language/elisp/bindings.scm \
language/elisp/runtime.scm \
language/elisp/runtime/function-slot.scm \
language/elisp/runtime/value-slot.scm \
- language/elisp/runtime/macros.scm \
- language/elisp/runtime/subrs.scm \
language/elisp/spec.scm
BRAINFUCK_LANG_SOURCES = \
system/base/ck.scm
ICE_9_SOURCES = \
- ice-9/r4rs.scm \
ice-9/r5rs.scm \
ice-9/deprecated.scm \
ice-9/and-let-star.scm \
ice-9/null.scm \
ice-9/occam-channel.scm \
ice-9/optargs.scm \
+ ice-9/peg/simplify-tree.scm \
+ ice-9/peg/codegen.scm \
+ ice-9/peg/cache.scm \
+ ice-9/peg/using-parsers.scm \
+ ice-9/peg/string-peg.scm \
+ ice-9/peg.scm \
ice-9/poe.scm \
ice-9/poll.scm \
ice-9/posix.scm \
system/vm/inspect.scm \
system/vm/coverage.scm \
system/vm/frame.scm \
- system/vm/instruction.scm \
- system/vm/objcode.scm \
+ system/vm/loader.scm \
system/vm/program.scm \
system/vm/trace.scm \
system/vm/traps.scm \
system/vm/trap-state.scm \
+ system/vm/debug.scm \
+ system/vm/disassembler.scm \
system/vm/vm.scm \
system/foreign.scm \
+ system/foreign-object.scm \
system/xref.scm \
system/repl/debug.scm \
system/repl/error-handling.scm \
EXTRA_DIST += oop/ChangeLog-2008
+ELISP_SOURCES = \
+ language/elisp/boot.el
+
NOCOMP_SOURCES = \
ice-9/match.upstream.scm \
ice-9/psyntax.scm \
srcdir="$(srcdir)" \
builddir="$(builddir)" \
@LOCALCHARSET_TESTS_ENVIRONMENT@ \
- GUILE_INSTALL_LOCALE=1 GUILE_AUTO_COMPILE=0 "${top_builddir}/meta/uninstalled-env"
+ GUILE_AUTO_COMPILE=0 "${top_builddir}/meta/uninstalled-env"
## Check for headers in $(srcdir) and build dir before $(CPPFLAGS), which
## may point us to an old, installed version of guile.
endif HAVE_SHARED_LIBRARIES
+ # test-foreign-object-scm
+ check_SCRIPTS += test-foreign-object-scm
+ TESTS += test-foreign-object-scm
+
+ # test-foreign-object-c
+ test_foreign_object_c_SOURCES = test-foreign-object-c.c
+ test_foreign_object_c_CFLAGS = ${test_cflags}
+ test_foreign_object_c_LDADD = $(LIBGUILE_LDADD)
+ check_PROGRAMS += test-foreign-object-c
+ TESTS += test-foreign-object-c
+
# test-list
test_list_SOURCES = test-list.c
test_list_CFLAGS = ${test_cflags}
check_PROGRAMS += test-smob-mark
TESTS += test-smob-mark
+check_SCRIPTS += test-stack-overflow
+TESTS += test-stack-overflow
+
+check_SCRIPTS += test-out-of-memory
+TESTS += test-out-of-memory
+
EXTRA_DIST += ${check_SCRIPTS}