Andy Wingo [Sat, 5 Dec 2009 11:38:32 +0000 (12:38 +0100)]
decruftify scm_sys_protects
* libguile/root.h
* libguile/root.c (scm_sys_protects): It used to be that for some reason
we'd define a special array of "protected" values. This was a little
silly, always, but with the BDW GC it's completely unnecessary. Also
many of these variables were unused, and none of them were good API.
So remove this array, and either eliminate, make static, or make
internal the various values.
* libguile/snarf.h: No need to generate calls to scm_permanent_object.
* guile-readline/readline.c (scm_init_readline): No need to call
scm_permanent_object.
* libguile/array-map.c (ramap, rafe): Remove the dubious nullvect
optimizations.
* libguile/async.c (scm_init_async): No need to init scm_asyncs, it is
no more.
* libguile/eval.c (scm_init_eval): No need to init scm_listofnull, it is
no more.
* libguile/gc.c: Make scm_protects a static var.
(scm_storage_prehistory): Change the sanity check to use the address
of protects.
(scm_init_gc_protect_object): No need to clear the scm_sys_protects,
as it is no more.
* libguile/keywords.c: Make the keyword obarray a static var.
* libguile/numbers.c: Make flo0 a static var.
* libguile/objprop.c: Make object_whash a static var.
* libguile/properties.c: Make properties_whash a static var.
* libguile/srcprop.h:
* libguile/srcprop.c: Make scm_source_whash a global with internal
linkage.
* libguile/strings.h:
* libguile/strings.c: Make scm_nullstr a global with internal linkage.
* libguile/vectors.c (scm_init_vectors): No need to init scm_nullvect,
it's unused.
Andy Wingo [Sat, 5 Dec 2009 10:50:21 +0000 (11:50 +0100)]
further boot cleanups
* libguile/srfi-14.c (define_charset):
* libguile/deprecated.c (scm_create_hook): Don't bother making the
returned objects (hooks or charsets) into permanent objects; they are
already defined, and then the caller probably stores them away too.
* libguile/init.c (scm_i_init_guile): Add a couple annotations.
Andy Wingo [Sat, 5 Dec 2009 10:43:20 +0000 (11:43 +0100)]
more boot cleanup
* libguile/bytevectors.c (scm_bootstrap_bytevectors): Remove a call to
scm_gc_protect_object.
* libguile/gc.h:
* libguile/gc.c (scm_init_gc_protect_object): Rename from
scm_init_storage, and just return void. Make the GC boot procs have
internal linkage.
* libguile/init.c: Adapt to the name change.
Andy Wingo [Sat, 5 Dec 2009 10:30:09 +0000 (11:30 +0100)]
remove a bunch of needless scm_permanent_object calls
* libguile/array-handle.c:
* libguile/bytevectors.c:
* libguile/deprecated.c:
* libguile/eval.c:
* libguile/feature.c:
* libguile/filesys.c:
* libguile/gc.c:
* libguile/gdbint.c:
* libguile/goops.c:
* libguile/instructions.c:
* libguile/load.c:
* libguile/modules.c:
* libguile/numbers.c:
* libguile/options.c:
* libguile/ports.c:
* libguile/scmsigs.c:
* libguile/srcprop.c:
* libguile/srfi-4.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/vm.c: Remove calls to scm_permanent_object, as they are no
longer needed with the BDW GC.
Andy Wingo [Sat, 5 Dec 2009 10:16:54 +0000 (11:16 +0100)]
some scm_i_init_guile cleanups
* libguile/init.c (scm_i_init_guile): Since hash tables are tc7 objects,
things that depend on hash tables no longer depend on smobs, so move
smob_prehistory up a bit. No more struct_prehistory.
* libguile/struct.h:
* libguile/struct.c (scm_struct_prehistory): Remove empty function.
Andy Wingo [Sat, 5 Dec 2009 10:10:11 +0000 (11:10 +0100)]
remove scm_ports_prehistory
* libguile/ports.h:
* libguile/ports.c (scm_ports_prehistory): Remove this function. Just
initialize global vars to NULL/0 instead of needing a prehistory
function.
Andy Wingo [Sat, 5 Dec 2009 09:55:37 +0000 (10:55 +0100)]
add printer for dynamic-states
* libguile/fluids.c:
* libguile/fluids.h:
* libguile/print.c: Add dynamic-state printing infrastructure.
Andy Wingo [Sat, 5 Dec 2009 09:52:18 +0000 (10:52 +0100)]
fluids are tc7 objects
If you're wondering what I'm doing, I'm trying to eventually reimplement
smobs in terms of structs, so that applicable smobs can just follow the
applicable struct dispatch path. But to do that I have to get structs
initialized before things that use smobs, which means transforming a
bunch of smobby things to tc7 things. But this transformation is good
for performance anyway, and we currently have a glut of unused tc7s,
so here we go...
* libguile/tags.h (scm_tc7_fluid, scm_tc7_dynamic_state): Fluids (and
dynamic states) now have tc7s.
* libguile/fluids.h: Remove scm_fluids_prehistory, and add internal
scm_i_fluid_print. Update a comment.
* libguile/fluids.c: Update for tc7 representation. Also remove the next
pointers while we're at it, as they aren't used in the new BDW GC.
* libguile/eq.c (scm_equal_p): Remove the hashtable case. Hashtables
could never be equal? before, I don't see why to add stubs doing the
same thing now.
* libguile/print.c (iprin1):
* libguile/gc.c (scm_i_tag_name):
* libguile/evalext.c (scm_self_evaluating_p): Add fluid and
dynamic_state cases.
* libguile/goops.h: Remove scm_class_hashtable; it will be static.
* libguile/goops.c: Make <hashtable> static, and add <fluid> and
<dynamic-state> classes.
* libguile/hashtab.h:
* libguile/hashtab.c: Remove scm_i_hashtable_equal_p.
* libguile/init.c (scm_i_init_guile): Remove call to fluids_prehistory.
Andy Wingo [Sat, 5 Dec 2009 09:07:07 +0000 (10:07 +0100)]
hash tables have a tc7
* libguile/tags.h (scm_tc7_hashtable): Allocate a tc7 for hashtables.
* libguile/hashtab.h: Adjust macros accordingly.
(scm_i_hashtable_print, scm_i_hashtable_equal_p): New internal
functions.
(scm_hashtab_prehistory): Remove, no more need for this.
* libguile/hashtab.c (scm_hash_fn_remove_x): Fix a longstanding bug.
(make_hash_table): Adapt to the new hash table representation.
* libguile/eq.c (scm_equal_p)
* libguile/evalext.c (scm_self_evaluating_p)
* libguile/print.c (iprin1)
* libguile/gc.c (scm_i_tag_name): Add some tc7_hashtab cases.
* libguile/init.c: Remove unused environments init functions. Remove
call to hashtab_prehistory.
* libguile/goops.h (scm_class_hashtable)
* libguile/goops.c (scm_class_of, create_standard_classes): Have to
make a class for hash tables manually, because they aren't smobs any
more.
Andy Wingo [Fri, 4 Dec 2009 18:20:11 +0000 (19:20 +0100)]
eval.c closures are now applicable smobs, not tc3s
* libguile/debug.c (scm_procedure_name): Remove a SCM_CLOSUREP case and
some dead code.
(scm_procedure_module): Remove. This was introduced a few months ago
for the hygienic expander, but now it is no longer needed, as the
expander keeps track of this information itself.
* libguile/debug.h: Remove scm_procedure_module.
* libguile/eval.c: Instead of using tc3 closures, define a "boot
closure" applicable smob type, and represent closures with that. The
advantage is that after eval.scm is compiled, boot closures take up no
address space (besides a smob number) in the runtime, and require no
special cases in procedure dispatch.
* libguile/eval.h: Remove the internal functions scm_i_call_closure_0
and scm_closure_apply, and the public function scm_closure.
* libguile/gc.c (scm_storage_prehistory): No tc3_closure displacement
registration.
(scm_i_tag_name): Remove closure case, and a dead cclo case.
* libguile/vm.c (apply_foreign):
* libguile/print.c (iprin1):
* libguile/procs.c (scm_procedure_p, scm_procedure_documentation);
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (scm_class_of): Remove tc3_closure/tcs_closure cases.
* libguile/hash.c (scm_hasher):
* libguile/hooks.c (scm_add_hook_x): Use new scm_i_procedure_arity.
* libguile/macros.c (macro_print): Print all macros using the same code.
(scm_macro_transformer): Return any procedure, not just programs.
* libguile/procprop.h:
* libguile/procprop.c (scm_i_procedure_arity): Instead of returning a
list that the caller has to parse, have the same prototype as
scm_i_program_arity. An incompatible change, but it's an internal
function anyway.
(scm_procedure_properties, scm_set_procedure_properties)
(scm_procedure_property, scm_set_procedure_property): Remove closure
cases, and use scm_i_program_arity for arity.
* libguile/procs.h (SCM_CLOSUREP, SCM_CLOSCAR, SCM_CODE)
(SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS)
(SCM_CLOSURE_BODY, SCM_PROCPROPS, SCM_SETPROCPROPS, SCM_ENV)
(SCM_TOP_LEVEL): Remove these macros that pertain to boot closures
only. Only eval.c should know abut boot closures.
* libguile/procs.c (scm_closure_p): Remove this function. There is a
simple stub in deprecated.scm now.
(scm_thunk_p): Use scm_i_program_arity.
* libguile/tags.h (scm_tc3_closure): Remove. Yay, another tc3 to play
with!
(scm_tcs_closures): Remove.
* libguile/validate.h (SCM_VALIDATE_CLOSURE): Remove.
* module/ice-9/deprecated.scm (closure?): Add stub.
* module/ice-9/documentation.scm (object-documentation)
* module/ice-9/session.scm (help-doc, arity)
* module/oop/goops.scm (compute-getters-n-setters)
* module/oop/goops/describe.scm (describe)
* module/system/repl/describe.scm (display-object, display-type):
Remove calls to closure?.
Andy Wingo [Fri, 4 Dec 2009 15:39:34 +0000 (16:39 +0100)]
remove cxrs
* libguile/pairs.h:
* libguile/pairs.c: Previously scm_cdadr et al were implemented as
#defines that called scm_i_chase_pairs, and the Scheme-exposed
functions themselves were cxr subrs, which got special help in the
interpreter. Since now the special help is unnecessary (because the
compiler inlines and expands calls to car, cdadr, etc), the complexity
is a loss. So just implement cdadr etc using normal functions. There's
an advantage too, in that the compiler can unroll the cxring, reducing
branches.
* libguile/tags.h (scm_tc7_cxr): Remove this tag.
(scm_tcs_subrs): Now there's only one kind of subr, yay!
* libguile/debug.c (scm_procedure_name)
* libguile/evalext.c (scm_self_evaluating_p)
* libguile/gc.c (scm_i_tag_name)
* libguile/goops.c (scm_class_of)
* libguile/hash.c (scm_hasher)
* libguile/print.c (iprin1)
* libguile/procprop.c (scm_i_procedure_arity)
* libguile/procs.c (scm_procedure_p, scm_subr_p)
(scm_make_procedure_with_setter)
* libguile/vm.c (apply_foreign): Remove cxr cases. Replace uses of
scm_tcs_subrs with scm_tc7_gsubr.
Andy Wingo [Fri, 4 Dec 2009 12:05:00 +0000 (13:05 +0100)]
remove rpsubrs
* libguile/tags.h: Remove rpsubrs (I chose to interpret the terse name
as "recursive predicate subrs"). Just use gsubrs with rest arguments,
or do a fold yourself.
* libguile/array-map.c (scm_i_array_equal_p): Do the comparison in
order, why not.
* libguile/chars.c:
* libguile/eq.c:
* libguile/numbers.c:
* libguile/strorder.c: Add 0,2,1 gsubr wrappers for rpsubrs like eq?, <,
etc.
* libguile/goops.c (scm_class_of)
* libguile/procprop.c (scm_i_procedure_arity)
* libguile/procs.c (scm_thunk_p)
* libguile/vm.c (apply_foreign): Remove rpsubr cases.
* test-suite/tests/numbers.test ("=", "<"): Turn a couple xfails into
passes.
Andy Wingo [Thu, 3 Dec 2009 16:05:14 +0000 (17:05 +0100)]
remove asubrs
* libguile/tags.h (scm_tcs_subrs, scm_tc7_asubr): Remove definitions.
* libguile/goops.c (scm_class_of)
* libguile/procprop.c (scm_i_procedure_arity)
* libguile/procs.c (scm_thunk_p)
* libguile/vm.c (apply_foreign): Remove cases for asubrs.
* libguile/array-map.c: Gut all of the optimizations, because there are
no more asubrs, soon won't be rpsubrs, and all of this should happen
on the Scheme level, ideally.
Andy Wingo [Thu, 3 Dec 2009 14:58:43 +0000 (15:58 +0100)]
speed up scm_call_N for non-programs
* libguile/eval.c (scm_call_0, scm_call_1, scm_call_2, scm_call_3): All
of these should dispatch through the VM, without consing.
Andy Wingo [Thu, 3 Dec 2009 14:55:54 +0000 (15:55 +0100)]
simplify apply_foreign
* libguile/vm.c (apply_foreign): Simplify.
Andy Wingo [Sun, 6 Sep 2009 15:28:23 +0000 (17:28 +0200)]
+, -, min, lcm, gcd now documented
* test-suite/tests/numbers.test: Change some xfail documented? tests to
passes.
Andy Wingo [Sun, 6 Sep 2009 14:47:19 +0000 (16:47 +0200)]
change asubrs to be gsubrs
* libguile/numbers.h:
* libguile/numbers.c (scm_i_gcd, scm_i_lcm, scm_i_logand, scm_i_logior)
(scm_i_logxor, scm_i_min, scm_i_max, scm_i_sum, scm_i_difference)
(scm_i_product, scm_i_divide): Change asubrs to be gsubrs.
Andy Wingo [Sun, 6 Sep 2009 12:15:28 +0000 (14:15 +0200)]
+ is not an asubr
* libguile/numbers.h:
* libguile/numbers.c (scm_i_sum): Rework so that scm_sum is just a
normal function. Its generic is actually provided by scm_i_sum, a
gsubr with rest args. In that way, + is no longer an asubr.
Andy Wingo [Sun, 6 Sep 2009 11:51:31 +0000 (13:51 +0200)]
remove scm_tc7_dsubr
* libguile/tags.h: Remove scm_tc7_dsubr. There are no more users of
this.
* libguile/array-map.c:
* libguile/eval.c:
* libguile/eval.i.c:
* libguile/goops.c:
* libguile/procprop.c:
* libguile/procs.h: Remove all dsubr cases.
Andy Wingo [Thu, 3 Sep 2009 20:35:01 +0000 (22:35 +0200)]
remove "primitive numerics" from the docs
* doc/ref/api-data.texi: Update for $sin deprecation.
Andy Wingo [Thu, 3 Sep 2009 20:29:10 +0000 (22:29 +0200)]
implement transcendental sin, cos etc in c; deprecate $sin, $cos, etc
* libguile/deprecated.h:
* libguile/deprecated.c (scm_asinh, scm_acosh, scm_atanh): Deprecate
these stand-ins for the C99 asinh, acosh, and atanh functions. Guile
is not gnulib.
(scm_sys_atan2): Deprecate as well, in favor of scm_atan.
* libguile/numbers.h:
* libguile/numbers.c (scm_sin, scm_cos, scm_tan)
(scm_sinh, scm_cosh, scm_tanh)
(scm_asin, scm_acos, scm_atan)
(scm_sys_asinh, scm_sys_acosh, scm_sys_atanh): New functions,
replacing the combination of dsubrs and boot-9 wrappers with C subrs
that handle complex values. The latter three have _sys_ in their names
due to the name conflict with the deprecated scm_asinh et al.
Remove the $abs, $sin etc "dsubrs".
* module/ice-9/boot-9.scm: Remove transcendental functions, as this all
happens in C now.
* module/ice-9/deprecated.scm: Add aliases for $sin et al.
* test-suite/tests/ramap.test ("array-map!"): Adjust "dsubr" tests to
use sqrt, not $sqrt. They don't actually test dsubrs now. In the
two-source test, I'm pretty sure the dsubr array-map! should have been
failing, as indeed it does now; I've changed the test case to expect
the failure. I'd still like to know why it was succeeding before.
Andy Wingo [Thu, 3 Sep 2009 10:19:39 +0000 (12:19 +0200)]
expt implemented in C, handles complex numbers
* libguile/numbers.h:
* libguile/numbers.c (scm_expt): Rename from scm_sys_expt, and handle
the complex cases as well.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_sys_expt): Add a deprecated shim.
* module/ice-9/boot-9.scm (expt): Remove definition, scm_expt does all
we need.
Andy Wingo [Thu, 3 Sep 2009 09:57:29 +0000 (11:57 +0200)]
remove tc7_subr_* and tc7_lsubr_*
* 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?.
Andy Wingo [Thu, 3 Sep 2009 09:14:24 +0000 (11:14 +0200)]
all subrs are gsubrs
* 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.
Andy Wingo [Thu, 3 Dec 2009 12:09:58 +0000 (13:09 +0100)]
replace frame implementation with VM frames
* libguile/stacks.h: Rework so that a stack doesn't copy information out
of VM frames, it just holds onto a VM frame, along with the stack id
and length. VM frames are now the only representation of frames in
Guile.
(scm_t_info_frame, SCM_FRAME_N_SLOTS, SCM_FRAME_REF, SCM_FRAME_NUMBER)
(SCM_FRAME_FLAGS, SCM_FRAME_SOURCE, SCM_FRAME_PROC, SCM_FRAME_ARGS)
(SCM_FRAME_PREV, SCM_FRAME_NEXT)
(SCM_FRAMEF_VOID, SCM_FRAMEF_REAL, SCM_FRAMEF_PROC)
(SCM_FRAMEF_EVAL_ARGS, SCM_FRAMEF_OVERFLOW)
(SCM_FRAME_VOID_P, SCM_FRAME_REAL_P, SCM_FRAME_PROC_P)
(SCM_FRAME_EVAL_ARGS_P, SCM_FRAME_OVERFLOW_P): Remove these macros
corresponding to the old frame implementation.
(scm_frame_p scm_frame_source, scm_frame_procedure)
(scm_frame_arguments): These definitions are now in frames.h.
(scm_last_stack_frame): Remove declaration of previously-removed
constructor. Probably should re-instate it though.
(scm_frame_number, scm_frame_previous, scm_frame_next)
(scm_frame_real_p, scm_frame_procedure_p, scm_frame_evaluating_args_p)
(scm_frame_overflow_p) : Remove these procedures corresponding to the
old stack implementation.
* libguile/stacks.c: Update for new frames implementation.
* libguile/frames.h:
* libguile/frames.c: Rename functions operating on VM frames to have a
scm_frame prefix, not scm_vm_frame -- because they really are the only
frames we have. Rename corresponding Scheme functions too, from
vm-frame-foo to frame-foo.
* libguile/deprecated.h: Remove scm_stack and scm_info_frame data types.
* libguile/vm.c (vm_dispatch_hook): Adapt to scm_c_make_frame name
change.
* module/system/vm/frame.scm: No need to export functions provided
frames.c now, as we load those procedures into the default environment
now. Rename functions, and remove a couple of outdated, unused
functions. The bottom half of this file is still bitrotten, though.
* libguile/backtrace.c: Rework to operate on the new frame
representation. Also fix a bug displaying file names for compiled
procedures.
* libguile/init.c: Load the VM much earlier, just because we can. Also
it allows us to have frames.[ch] loaded in time for stacks to be
initialized, so that scm_frame_arguments can do the right thing.
Andy Wingo [Thu, 3 Dec 2009 10:03:39 +0000 (11:03 +0100)]
remove debug frames
* libguile/debug.h (scm_t_debug_frame): Remove this type, as it was
internal to the old evaluator.
(SCM_EVALFRAME, SCM_APPLYFRAME, SCM_VOIDFRAME, SCM_MACROEXPF)
(SCM_TAILREC, SCM_TRACED_FRAME, SCM_ARGS_READY, SCM_DOVERFLOW)
(SCM_MAX_FRAME_SIZE, SCM_FRAMETYPE)
(SCM_EVALFRAMEP, SCM_APPLYFRAMEP, SCM_VOIDFRAMEP, SCM_MACROEXPFP)
(SCM_TAILRECP, SCM_TRACED_FRAME_P, SCM_ARGS_READY_P, SCM_OVERFLOWP)
(SCM_SET_MACROEXP, SCM_SET_TAILREC, SCM_SET_TRACED_FRAME)
(SCM_SET_ARGSREADY, SCM_SET_OVERFLOW)
(SCM_CLEAR_MACROEXP, SCM_CLEAR_TRACED_FRAME, SCM_CLEAR_ARGSREADY):
Remove macro accessors to scm_t_debug_frame.
(SCM_DEBUGOBJP, SCM_DEBUGOBJ_FRAME, SCM_SET_DEBUGOBJ_FRAME):
(scm_debug_object_p, scm_make_debugobj): Remove debugobj accessors.
(scm_i_unmemoize_expr): Remove unused declaration.
* libguile/debug.c (scm_debug_options): No more max limit on frame
sizes.
(scm_start_stack): Just call out to scm_vm_call_with_new_stack.
(scm_debug_object_p, scm_make_debugobj, scm_init_debug): No more
debugobj smob type.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_i_deprecated_last_debug_frame)
(scm_last_debug_frame): Remove deprecated debug-frame bits.
* libguile/stacks.c (scm_make_stack): Rework this function and its
dependents to only walk VM frames.
(scm_stack_id): Call out to the holder of the VM frame in question,
which should be a VM or a VM continuation, for the stack ID. Currently
this bit is stubbed out.
(scm_last_stack_frame): Removed. It seems this is mainly useful for a
debugger, and we need to rewrite the debugger to work on the Scheme
level.
* test-suite/tests/continuations.test ("continuations"): Remove test for
last-stack-frame.
* libguile/continuations.h (struct scm_t_contregs):
* libguile/continuations.c (scm_make_continuation):
(copy_stack_and_call, scm_i_with_continuation_barrier): No need to
save and restore debug frames.
* libguile/threads.h (scm_i_thread): Don't track debug frames.
(scm_i_last_debug_frame, scm_i_set_last_debug_frame): Remove macro
accessors.
* libguile/threads.c (guilify_self_1): Don't track debug frames.
* libguile/throw.c: No need to track debug frames in a jmpbuf.
* libguile/vm-engine.c (vm_engine, VM_PUSH_DEBUG_FRAMES): Don't push
debug frames.
* libguile/vm.h:
* libguile/vm.c (scm_vm_call_with_new_stack): New function. Currently
stubbed out though.
Andy Wingo [Wed, 2 Dec 2009 23:15:02 +0000 (00:15 +0100)]
clarify comments in eval.scm
* module/ice-9/eval.scm: Add some more comments.
Andy Wingo [Tue, 1 Dec 2009 22:54:25 +0000 (23:54 +0100)]
really boot primitive-eval from scheme.
* libguile/eval.c (scm_primitive_eval, scm_c_primitive_eval):
(scm_init_eval): Rework so that scm_primitive_eval always calls out to
the primitive-eval variable. The previous definition is the default
value, which is probably overridden by scm_init_eval_in_scheme.
* libguile/init.c (scm_i_init_guile): Move ports and load-path up, so we
can debug when initing eval. Call scm_init_eval_in_scheme. Awesome.
* libguile/load.h:
* libguile/load.c (scm_init_eval_in_scheme): New procedure, loads up
ice-9/eval.scm to replace the primitive-eval definition, if everything
is there and up-to-date.
* libguile/modules.c (scm_module_transformer): Export to Scheme, so it's
there for eval.go.
* module/ice-9/boot-9.scm: No need to define module-transformer.
* module/ice-9/eval.scm (capture-env): Only reference the-root-module if
modules are booted.
(primitive-eval): Inline a definition for identity. Throw a more
standard error for "wrong number of arguments".
* module/ice-9/psyntax.scm (chi-install-global): The macro binding for a
syncase macro is now a pair: the transformer, and the module that was
current when the transformer was installed. The latter is used for
hygiene purposes, replacing the use of procedure-module, which didn't
work with the interpreter's shared-code closures.
(chi-macro): Adapt for the binding being a pair, and get the hygiene
from the cdr.
(eval-local-transformer): Adapt to new form of macro bindings.
* module/ice-9/psyntax-pp.scm: Regenerated.
* .gitignore: Ignore eval.go.stamp.
* module/Makefile.am: Reorder for fastest serial compilation, now that
there are no ordering constraints. I did a number of experiments here
and this seems to be the best; but the bulk of the time is compiling
psyntax-pp.scm with eval.scm. Not so great.
* libguile/vm-engine.c (vm-engine): Throw a more standard error for
"wrong type to apply".
* test-suite/tests/gc.test ("gc"): Remove a hack that shouldn't affect
the new evaluator, and throw in another (gc) for good measure.
* test-suite/tests/goops.test ("defining classes"):
* test-suite/tests/hooks.test (proc1): We can't currently check what the
arity is of a closure made by eval.scm -- or more accurately all
closures have 0 required args and no rest args. So punt for now.
* test-suite/tests/syntax.test ("letrec"): The scheme evaluator can't
check that a variable is unbound, currently; perhaps the full "fixing
letrec" expansion could fix this. But barring that, punt.
Andy Wingo [Tue, 1 Dec 2009 21:20:03 +0000 (22:20 +0100)]
apply goes to the vm, not the interpreter
* libguile/eval.c (eval): Call scm_vm_apply instead of apply.
(apply): Deleted, no longer referenced. Heh.
(scm_apply): Call scm_vm_apply.
* libguile/init.c (scm_i_init_guile): Bootstrap the VM before the
evaluator.
* libguile/vm.c (scm_vm_apply): Actually it's not necessary that the
procedure is a program; so that's cool, relax the check.
Andy Wingo [Tue, 1 Dec 2009 21:11:15 +0000 (22:11 +0100)]
vm doesn't call the evaluator at all (at least not directly)
* libguile/vm-i-system.c (goto/args, mv-call): Finish the port to use
apply_foreign instead of scm_apply.
Andy Wingo [Tue, 1 Dec 2009 20:59:42 +0000 (21:59 +0100)]
first step to make the vm stop calling the interpreter
* 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.
Andy Wingo [Mon, 30 Nov 2009 22:32:28 +0000 (23:32 +0100)]
add new scheme evaluator
* module/ice-9/eval.scm: New evaluator, written in Scheme. Whee!
Batteries included but not wired up.
* module/Makefile.am: Abuse touch(1) to make sure eval.go gets built
before everything. Can't just depend on eval.go, because eval.go will
get the timestamp of eval.scm, which might be newer than foo.go (and
thus foo.scm). Something better is warranted.
Andy Wingo [Mon, 30 Nov 2009 21:21:31 +0000 (22:21 +0100)]
add memoized expression accessors to scheme
* libguile/eval.c: Fix a comment.
(eval): Abstract out the variable memoization into a function,
scm_memoize_variable_access_x.
* libguile/memoize.c (memoized_tags): Fix a couple names.
(scm_memoize_variable_access_x): New internal function. Actually it's
public to Scheme, but we can't do much about that, because the new
evaluator will need it.
(scm_memoized_expression_typecode, scm_memoized_expression_data): New
accessors for memoized code, for Scheme.
(scm_memoized_typecode): Looks up the typecode for a symbol.
Andy Wingo [Mon, 30 Nov 2009 21:17:46 +0000 (22:17 +0100)]
export scm_define to scheme as define!
* libguile/modules.c (scm_define): Export to Scheme as `define!'. The
evaluator needs it, and actually it's an OK thing to have around.
Andy Wingo [Mon, 30 Nov 2009 21:16:59 +0000 (22:16 +0100)]
wire through the existing vm ops for variable-ref and variable-set!
* module/language/tree-il/compile-glil.scm (*primcall-ops*): Compile
variable-ref and variable-set instructions specially.
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*): Add cases for variable-ref and
variable-set!. The latter is a little tricky, because the args are
switched for the VM op, and we can't really change that easily.
Andy Wingo [Mon, 30 Nov 2009 21:14:52 +0000 (22:14 +0100)]
fixes to variable-ref, variable-set vm ops
* libguile/vm-i-system.c (variable-ref, variable-set): Fix declared
number of pops and pushes.
Andy Wingo [Sat, 28 Nov 2009 10:18:14 +0000 (11:18 +0100)]
promises are in their own file now
* libguile.h:
* libguile/Makefile.am:
* libguile/eval.c:
* libguile/eval.h:
* libguile/init.c:
* libguile/promises.c:
* libguile/promises.h: Split promises out into their own file.
Andy Wingo [Sat, 28 Nov 2009 00:19:50 +0000 (01:19 +0100)]
new evaluator, y'all
* libguile/eval.c: So, ladies & gents, a new evaluator. It's similar to
the old one, in that we memoize and then evaluate, but in this
incarnation, memoization of an expression happens before evaluation,
not lazily as the expression is evaluated. This makes the evaluation
itself much cleaner, in addition to being threadsafe. In addition,
since this C evaluator will in the future just serve to bootstrap the
Scheme evaluator, we don't have to pay much concern for debugging
conveniences. So the environment is just a list of values, and the
memoizer pre-computes where it's going to find each individual value
in the environment.
Interface changes are commented below, with eval.h.
(scm_evaluator_traps): No need to reset the debug mode after rnning te
traps thing. But really, the whole traps system needs some love.
* libguile/memoize.h:
* libguile/memoize.c: New memoizer, which runs before evaluation,
checking all syntax before evaluation begins. Significantly, no
debugging information is left for lexical variables, which is not so
great for interactive debugging; perhaps we should change this to have
a var list in the future as per the classic interpreters. But it's
quite fast, and the resulting code is quite good. Also note that it
doesn't produce ilocs, memoized code is a smob whose type is in the
first word of the smob itself.
* libguile/eval.h (scm_sym_and, scm_sym_begin, scm_sym_case)
(scm_sym_cond, scm_sym_define, scm_sym_do, scm_sym_if, scm_sym_lambda)
(scm_sym_let, scm_sym_letstar, scm_sym_letrec, scm_sym_quote)
(scm_sym_quasiquote, scm_sym_unquote, scm_sym_uq_splicing, scm_sym_at)
(scm_sym_atat, scm_sym_atapply, scm_sym_atcall_cc)
(scm_sym_at_call_with_values, scm_sym_delay, scm_sym_eval_when)
(scm_sym_arrow, scm_sym_else, scm_sym_apply, scm_sym_set_x)
(scm_sym_args): Remove public declaration of these symbols.
(scm_ilookup, scm_lookupcar, scm_eval_car, scm_eval_body)
(scm_eval_args, scm_i_eval_x, scm_i_eval): Remove public declaration
of these functions.
(scm_ceval, scm_deval, scm_ceval_ptr): Remove declarations of these
deprecated functions.
(scm_i_print_iloc, scm_i_print_isym, scm_i_unmemocopy_expr)
(scm_i_unmemocopy_body): Remove declarations of these internal
functions.
(scm_primitive_eval_x, scm_eval_x): Redefine as macros for their less
destructive siblings.
* libguile/Makefile.am: Add memoize.[ch] to the build.
* libguile/debug.h (scm_debug_mode_p, scm_check_entry_p)
(scm_check_apply_p, scm_check_exit_p, scm_check_memoize_p)
(scm_debug_eframe_size): Remove these vars that were tied to the old
evaluator's execution model.
(SCM_RESET_DEBUG_MODE): Remove, no more need for this.
(SCM_MEMOIZEDP, SCM_MEMOIZED_EXP, SCM_MEMOIZED_ENV): Remove macros
referring to old memoized code representation.
(scm_local_eval, scm_procedure_environment, scm_memoized_environment)
(scm_make_memoized, scm_memoized_p): Remove functions operating on old
memoized code representation.
(scm_memcons, scm_mem_to_proc, scm_proc_to_mem): Remove debug-only
code for old evaluator.
* libguile/debug.c: Remove code to correspond with debug.h removals.
(scm_debug_options): No need to set the debug mode or frame limit
here, as we don't have C stack limits any more. Perhaps this is a bug,
but as long as we can compile eval.scm, we should be fine.
* libguile/init.c (scm_i_init_guile): Init memoize.c.
* libguile/modules.c (scm_top_level_env, scm_env_top_level)
(scm_env_module, scm_system_module_env_p): Remove these functions.
* libguile/print.c (iprin1): No more need to handle isyms. Adapt to new
form of interpreted procedures.
* libguile/procprop.c (scm_i_procedure_arity): Adapt to new form of
interpreted procedures.
* libguile/procs.c (scm_thunk_p): Adapt to new form of interpreted
procedures.
* libguile/procs.h (SCM_CLOSURE_FORMALS): Removed, this exists no more.
(SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS): New
accessors.
* libguile/srcprop.c (scm_source_properties, scm_source_property)
(scm_set_source_property_x): Remove special cases for memoized code.
* libguile/stacks.c (read_frame): Remove a source-property case for
interpreted code.
(NEXT_FRAME): Remove a case that I don't fully understand, that seems
to be designed to skip over apply frames. Will be obsolete in the
futures.
(read_frames): Default source value for interpreted frames to #f.
(narrow_stack): Don't pay attention to the system_module thing.
* libguile/tags.h: Remove isyms and ilocs. Whee!
* libguile/validate.h (SCM_VALIDATE_MEMOIZED): Fix to use the new
MEMOIZED_P formulation.
* module/ice-9/psyntax-pp.scm (do, quasiquote, case): Adapt for these no
longer being primitive macros.
* module/ice-9/boot-9.scm: Whitespace change, but just a poke to force a
rebuild due to and/or/cond/... not being primitives any more.
* module/ice-9/deprecated.scm (unmemoize-expr): Deprecate, it's
unmemoize-expression now.
* test-suite/tests/eval.test ("define set procedure-name"): XFAIL a
couple of tests here; I don't know what to do about them. I reckon the
expander should ensure that defined values are named.
* test-suite/tests/chars.test ("basic char handling"): Fix expected
exception when trying to apply a char.
Andy Wingo [Sat, 28 Nov 2009 00:19:31 +0000 (01:19 +0100)]
goops moving away from evaluator opcodes, and a primitive compilation fix
* module/oop/goops.scm (@slot-ref, @slot-set!): Define "primitives" for
these. Probably should do something more general, though, allowing
@struct-ref.
* module/language/tree-il/primitives.scm (add-interesting-primitive!):
Error if the primitive isn't bound.
Andy Wingo [Fri, 27 Nov 2009 10:37:17 +0000 (11:37 +0100)]
remove (lang elisp), as it won't work with the new evaluator
* lang/: Delete. This causes me some pain, but the new elisp compiler is
coming soon, and the old one really won't work with the new evaluator.
* Makefile.am:
* configure.ac: Autotoolery for elisp removal.
* test-suite/tests/elisp.test: Comment out the body of the elisp test.
The tests themselves should be useful in the new world, though.
Andy Wingo [Thu, 26 Nov 2009 21:11:40 +0000 (22:11 +0100)]
local-eval will go away
* module/ice-9/debugger/commands.scm:
* module/ice-9/debugging/traps.scm:
* module/ice-9/emacs.scm:
* module/ice-9/gds-client.scm: Add some FIXMEs due to impending
local-eval removal.
* module/oop/goops.scm (make-generic-bound-check-getter): Just the
compiled closure case here.
Andy Wingo [Fri, 27 Nov 2009 20:31:43 +0000 (21:31 +0100)]
no special treatment for memoized code in srcprop.c
* libguile/srcprop.c (scm_set_source_properties_x): No need to treat
memoized code specially.
* test-suite/tests/srcprop.test ("set-source-property!")
("set-source-properties!"): Well, just throw 'unresolved on these for
now, because we need a few more things to land before these can be
fixed, or even considered.
Andy Wingo [Fri, 27 Nov 2009 22:12:35 +0000 (23:12 +0100)]
factor copy-tree and cons-source out of eval.[ch]
* libguile.h:
* libguile/Makefile.am
* libguile/init.c (scm_i_init_guile): Add trees.[ch] to the build.
* libguile/eval.c:
* libguile/eval.h: Remove scm_copy_tree and scm_cons_source...
* libguile/trees.h:
* libguile/trees.c:
* libguile/srcprop.h:
* libguile/srcprop.c: ... factoring them out here and here,
respectively.
* test-suite/tests/eval.test ("memoization"): Change expected exception
for circular data structures, given new copy-tree location.
Andy Wingo [Fri, 27 Nov 2009 20:17:42 +0000 (21:17 +0100)]
remove unused scm_eval_stack var
* libguile/private-options.h:
* libguile/eval.c (scm_eval_stack): Remove declaration and definition of
unused scm_eval_stack variable.
Andy Wingo [Fri, 27 Nov 2009 23:22:47 +0000 (00:22 +0100)]
remove evaluator-specific code from macros.c
* libguile/macros.c (macro_print): No special printing for macros
whose code is an interpreted procedure.
Andy Wingo [Fri, 27 Nov 2009 19:50:40 +0000 (20:50 +0100)]
remove class-environment slot, goops grubs less in the evaluator
* libguile/goops.h (scm_sys_tag_body): Remove declaration of undefined
function.
(SCM_CLASS_CLASS_LAYOUT, scm_si_environment, SCM_N_CLASS_SLOTS)
(scm_class_environment) Remove class environment slot and getter.
* libguile/goops.c (compute_getters_n_setters): Use scm_primitive_eval
to produce the init thunk, instead of scm_i_eval_x; though really we
should be doing this in Scheme.
(scm_basic_basic_make_class, build_class_class_slots)
(create_basic_classes, scm_class_environment): Remove class
environment slot.
(get_slot_value, set_slot_value): Use scm_call_1 instead of evaluator
tricks.
* module/oop/goops.scm: Remove class-environment export, and
environments throughout the file.
Andy Wingo [Fri, 27 Nov 2009 19:43:22 +0000 (20:43 +0100)]
fix to gdb_eval to use newer interfaces
* libguile/gdbint.c (gdb_eval): Use scm_primitive_eval instead of
scm_i_eval_x.
Andy Wingo [Fri, 27 Nov 2009 19:36:09 +0000 (20:36 +0100)]
formally deprecate trampolines
* libguile/eval.c:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_trampoline_0, scm_trampoline_1)
(scm_trampoline_2): Actually deprecate trampolines.
* srfi/srfi-1.c: Fix all trampoline uses in srfi-1.c.
Andy Wingo [Fri, 27 Nov 2009 17:13:59 +0000 (18:13 +0100)]
remove uses of trampolines within guile itself
* libguile/eval.c (scm_map, scm_for_each)
* libguile/hashtab.c (scm_hash_for_each_handle)
* libguile/list.c (scm_filter, scm_filter_x)
* libguile/quicksort.i.c:
* libguile/sort.c (scm_restricted_vector_sort_x, scm_sorted_p)
(scm_merge, scm_merge_list_x, scm_merge_x)
(scm_merge_list_step, scm_sort_x, scm_sort, scm_merge_vector_x)
(scm_merge_vector_step, scm_stable_sort_x, scm_sort_list_x)
(scm_sort_list)nn
* libguile/srfi-13.c (scm_string_any, scm_string_every)
(scm_string_tabulate, scm_string_trim, string_trim_right)
(scm_string_trim_both, scm_string_index, scm_string_index_right)
(scm_string_skip, scm_string_skip_right, scm_string_count)
(scm_string_map, scm_string_map_x, scm_string_for_each)
(scm_string_for_each_index, scm_string_filter, scm_string_delete):
Remove uses of trampolines.
Andy Wingo [Fri, 27 Nov 2009 16:35:37 +0000 (17:35 +0100)]
gut the backtrace implementation for memoized code
* libguile/backtrace.c (display_header, display_expression)
(display_error_body, display_backtrace_get_file_line, display_frame):
Gut the implementation for memoized code, as memoized code as it is
currently understood is going away.
Andy Wingo [Fri, 27 Nov 2009 16:24:12 +0000 (17:24 +0100)]
remove some deprecated things, undeprecate scm_the_root_module()
* libguile/deprecated.h
* libguile/deprecated.c (SCM_ILOC00, SCM_IDINC, SCM_IDSTMSK)
(scm_s_expression, scm_s_test, scm_s_body, scm_s_bindings)
(scm_s_variable, scm_s_clauses, scm_s_formals, SCM_EVALIM2)
(SCM_EVALIM, SCM_XEVAL, SCM_XEVALCAR): Remove these macros and
constants, deprecated in 2003.
(scm_the_root_module): Undeprecate, it's actually a useful function,
that other parts of the code use.
* libguile/modules.h (scm_the_root_module): Undeprecated.
* libguile/modules.c (scm_the_root_module): Rename from
the_root_module. Use it in the rest of this file.
Andy Wingo [Thu, 20 Aug 2009 23:17:32 +0000 (01:17 +0200)]
tweak to eval.c
* libguile/eval.c (eval_letrec_inits): Rename from ceval_letrec_inits.
Caller changed.
Andy Wingo [Thu, 20 Aug 2009 23:14:57 +0000 (01:14 +0200)]
eval.i.c -> eval.c
* libguile/Makefile.am:
* libguile/eval.i.c: Remove eval.i.c.
* libguile/eval.c: Fold eval.i.c's contents into eval.c.
Andy Wingo [Thu, 20 Aug 2009 23:06:00 +0000 (01:06 +0200)]
more ceval excision
* libguile/eval.c:
* libguile/eval.i.c: Rename deval to eval. Substitute in some
preprocessor macros.
Andy Wingo [Thu, 20 Aug 2009 23:00:28 +0000 (01:00 +0200)]
remove code from eval.i.c that was only for CEVAL.
* libguile/eval.i.c: Remove CEVAL-only code.
Andy Wingo [Thu, 20 Aug 2009 22:54:34 +0000 (00:54 +0200)]
Don't double-include eval.i.c -- let's only build deval.
* libguile/eval.c (SCM_I_XEVAL, SCM_I_XEVALCAR): No more debug_p args,
we are always debugging. Adapt all callers.
(ceval_letrec_inits): For some reason this function is used by deval.
No idea why. Pull it out here.
* libguile/eval.i.c (SCM_APPLY): scm_dapply is scm_apply.
Andy Wingo [Thu, 20 Aug 2009 22:38:48 +0000 (00:38 +0200)]
gut trampolines
* libguile/eval.c: Gut the trampoline implementation. We'll be doing
much more clever things here that will obviate the need for the
procedure arg of map and for-each to be allocated in many cases...
trampolines were a noble attempt at optimizing in the wrong place.
* srfi/srfi-1.c (scm_srfi1_lset_difference_x): Validate that we get a
proc, because the trampoline won't do it for us.
* test-suite/tests/sort.test ("sort"):
* test-suite/tests/srfi-1.test ("count", "fold", "list-index"):
Change expected exceptions, due to trampoline functions not doing any
computation.
Andy Wingo [Thu, 20 Aug 2009 22:37:39 +0000 (00:37 +0200)]
expand out named let to letrec in the eval case
* module/ice-9/psyntax.scm: In the eval case, expand out named let to
letrec.
* module/ice-9/psyntax-pp.scm: Regenerated.
Ludovic Courtès [Sun, 29 Nov 2009 15:45:38 +0000 (16:45 +0100)]
Make `SCM' type definition acceptable for C++ compilers.
* libguile/tags.h (SCM) [SCM_DEBUG_TYPING_STRICTNESS == 1]: Use a named
struct to avoid errors from C++ compilers such as "error: non-local
function ‘<anonymous struct>* foo(<anonymous struct>*)’ uses anonymous
type". This fixes a regression introduced in
c6054feaf03f8bde236f5e45a946f38827074923 ("Add support for static
allocation of cells, strings and stringbufs."). Reported by Linas
Vepstas <linasvepstas@gmail.com>.
Ludovic Courtès [Sat, 28 Nov 2009 21:52:16 +0000 (22:52 +0100)]
Remove remaining uses of discouraged constructs, really.
* libguile/throw.c, libguile/vm-engine.h, libguile/vm-i-system.c,
libguile/vm.c: Replace uses of discouraged constructs by their
current counterparts.
Ludovic Courtès [Sat, 28 Nov 2009 14:11:31 +0000 (15:11 +0100)]
Remove remaining uses of discouraged constructs.
* libguile/frames.c, libguile/instructions.c, libguile/objcodes.c,
libguile/programs.c, libguile/throw.c, libguile/vm-i-scheme.c,
libguile/vm.c: Replace uses of discouraged constructs by their
current counterparts.
Ludovic Courtès [Fri, 27 Nov 2009 16:00:51 +0000 (17:00 +0100)]
Disable encoding scanning on non-seekable file ports.
* libguile/read.c (scm_i_scan_for_encoding): Don't attempt to scan
non-seekable file ports.
Andy Wingo [Wed, 25 Nov 2009 23:13:53 +0000 (00:13 +0100)]
header tidyings
* libguile/goops.h:
* libguile/struct.h: c-backslash-region some vars.
Andy Wingo [Wed, 25 Nov 2009 23:12:12 +0000 (00:12 +0100)]
brace placement fixes
* libguile/goops.c (scm_sys_allocate_instance):
* libguile/vm-i-loader.c (load-wide-string): Fix some brace placements.
Andy Wingo [Fri, 20 Nov 2009 16:25:13 +0000 (17:25 +0100)]
push goops compile delay out to 30 invocations, for great justice
* module/oop/goops/dispatch.scm (timer-init): Init to 30 for faster
goops load time.
Andy Wingo [Fri, 20 Nov 2009 12:42:13 +0000 (13:42 +0100)]
generic method cache begone
* libguile/goops.h (SCM_GENERIC_METHOD_CACHE)
(SCM_SET_GENERIC_METHOD_CACHE, scm_si_generic_cache)
* libguile/goops.c (create_standard_classes): Remove slot for generic
method cache. Yay!
Andy Wingo [Fri, 20 Nov 2009 12:31:07 +0000 (13:31 +0100)]
remove code that manages the method cache
* libguile/goops.h (SCM_MCACHE_N_SPECIALIZED)
(SCM_SET_MCACHE_N_SPECIALIZED, SCM_INITIAL_MCACHE_SIZE)
(scm_make_method_cache, scm_memoize_method, scm_mcache_lookup_cmethod)
(scm_mcache_compute_cmethod):
* libguile/goops.c: Remove these procedures which managed the method
cache. There's still a slot there but it's not initialized. The method
cache is no longer necessary.
* module/oop/goops/dispatch.scm (memoize-method!): Change to not take a
"cache" argument.
* libguile/eval.i.c:
* libguile/vm-i-system.c: Remove dispatch via the method cache.
Andy Wingo [Fri, 20 Nov 2009 12:18:07 +0000 (13:18 +0100)]
remove method cache management code from (oop goops dispatch)
* module/oop/goops/dispatch.scm: Remove old method cache things.
Andy Wingo [Fri, 20 Nov 2009 12:11:52 +0000 (13:11 +0100)]
generics now dispatch as applicable structs
* libguile/eval.i.c (CEVAL, SCM_APPLY): Dispatch applicable structs
before pure generics. In practice what this means is that we never hit
the mcache case, because all pure generics are applicable structs.
We're moving over to having generics dispatch themselves. Also, they
don't prepend the struct as an arg; in order to have that effect, the
user has closures.
* libguile/goops.c (scm_apply_generic, scm_call_generic_0):
(scm_call_generic_1, scm_call_generic_2, scm_call_generic_3): Dispatch
directly to the struct procedures.
(scm_var_make_extended_generic): Remove a duplicate definition for
scm_var_make_extended_generic.
(create_standard_classes): Mark all instances of
<applicable-struct-class> (themselves classes) as applicable classes.
Meaning: generics are now applicable structs.
* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT): The hashsets are actually
uw slots -- or at least, making subclasses maps the int slots to be uw
slots
* libguile/vm-i-system.c (call, goto/args, mv-call): Dispatch applicable
structs in the VM.
* module/oop/goops/dispatch.scm (emit-linear-dispatch): Fix bug in the
non-rest cache miss case.
(delayed-compile): Rework to avoid fluids.
(cache-dispatch): Don't call `equal?', it causes bootstrapping
problems with the primitive-generic equal?. Using our own version is
faster anyway.
Andy Wingo [Sun, 8 Nov 2009 10:49:06 +0000 (11:49 +0100)]
make sure that when equal? is extended, that the generic has a method
* libguile/goops.h:
* libguile/goops.c (scm_set_primitive_generic_x): New function, for now
local to the goops module.
* module/oop/goops.scm (equal?): Make sure that when equal? is extended,
that the generic already has a default method.
Andy Wingo [Sun, 8 Nov 2009 10:34:30 +0000 (11:34 +0100)]
remove cache-mutex slot from generics
* libguile/goops.c:
* libguile/goops.h: Remove cache-mutex slot from generics, and renumber
other slots.
Andy Wingo [Sun, 8 Nov 2009 10:29:48 +0000 (11:29 +0100)]
remove locking in method memoization
* libguile/goops.c (scm_memoize_method): Don't lock around method
memoization, as the new protocol will be reeentrant and lock-free.
Andy Wingo [Sun, 8 Nov 2009 10:24:23 +0000 (11:24 +0100)]
limn goops flags, remove foreign objs, rename entity to applicable-struct
* libguile/goops.c (scm_class_applicable_struct)
(scm_class_applicable_struct_with_setter)
(scm_class_applicable_struct_class): Rename from
scm_class_entity, scm_class_entity_with_setter, and
scm_class_entity_class.
(scm_class_simple_method): Removed; this abstraction is not used.
(scm_class_foreign_class, scm_class_foreign_object): Remove these,
they are undocumented and unused. They might come back later.
(scm_sys_inherit_magic_x): Simply inherit the vtable flags from the
class's class. Flags are about layout, and it is the class that
determines the layout of the instance.
(scm_basic_basic_make_class): Don't bother setting GOOPS_OR_VALID,
inherit-magic will do that.
(scm_basic_make_class): Inherit magic after setting the layout. Allows
the struct magic checker to do its job.
(scm_accessor_method_slot_definition): Move implementation to Scheme.
Removes the need for the accessor flag.
(scm_sys_allocate_instance): Adapt to scm_i_alloc_struct name change,
and that alloc-struct will handle finalization.
(scm_compute_applicable_methods): Remove accessor check, as it's
unnecessary.
(scm_make): Adapt to new generic slot order, and no more
simple-method.
(create_standard_classes): What was the GF slot "dispatch-procedure"
is now the applicable-struct slot "procedure". No more foreign class,
foreign object, or simple method. Rename <entity> and friends to
<applicable-struct> and friends. No more entity-with-setter -- though
perhaps it will come back too. Instead generic-with-setter is its own
thing.
* libguile/goops.h (SCM_CLASSF_METACLASS): "A goops class that is a
vtable" -- no need for a separate flag.
(SCM_CLASSF_FOREIGN, SCM_CLASSF_SIMPLE_METHOD)
(SCM_CLASSF_ACCESSOR_METHOD): Removed these unused flags.
(SCM_ACCESSORP): Removed.
Renumber generic slots, rename entity classes, and remove the foreign
class, foreign object, and simple method classes.
* libguile/struct.c (scm_i_struct_inherit_vtable_magic): New function,
called when making new vtables.applicable structs
(scm_i_alloc_struct): Remove 8-bit alignment check, as libGC
guarantees this for us. Handle finalizer registration here.
(scm_make_struct): Factor some things to scm_i_alloc_struct and
scm_i_struct_inherit_vtable_magic.
(scm_make_vtable_vtable): Adapt to scm_i_alloc_struct name change.
* libguile/struct.h (scm_i_alloc_struct): Change name from
scm_alloc_struct, and make internal.
* module/oop/goops.scm (oop): Don't declare #:replace <class> et al,
because <class> isn't defined in the core any more.
(accessor-method-slot-definition): Defined in Scheme now.
Remove <foreign-object> methods.
(initialize on <class>): Prep layout before inheriting magic, as in
scm_basic_make_class.
* module/oop/goops/dispatch.scm (delayed-compile)
(memoize-effective-method!): Adapt to 'procedure slot name change.
Andy Wingo [Fri, 6 Nov 2009 16:17:33 +0000 (17:17 +0100)]
%invalidate-method-cache invalidates the dispatch procedure too
* libguile/goops.c (make_dispatch_procedure, clear_method_cache):
Properly reset the dispatch procedure.
Andy Wingo [Fri, 6 Nov 2009 10:25:50 +0000 (11:25 +0100)]
generic dispatch protocol in scheme, not yet wired up
* module/oop/goops/dispatch.scm: Add a dispatch protocol in Scheme. The
idea is that instead of using a hardcoded C protocol, we compile
dispatch procedures at runtime. To avoid too much thrashing at bootup,
there is a simple JIT mechanism -- dispatch will be data-driven,
through the cache, for the first 5 invocations, then a dispatch
procedure will be compiled from the cache.
My initial timings indicate that interpreted dispatch takes about
100us, and that compiled dispatch takes about 60us. Compilation itself
takes about 16000us (16 ms). The compiled procedure dispatch times
will improve soon, hopefully.
Andy Wingo [Fri, 6 Nov 2009 09:27:19 +0000 (10:27 +0100)]
eqv? not a generic, equal? dispatches to generic only for objects
* libguile/eq.c (scm_eqv_p): Not a generic any more. Since eqv? is used
by e.g. `case', which should be able to compile into dispatch tables,
it really doesn't make sense to dispatch out to a generic.
(scm_equal_p): So it was always the case that (equal? 'foo "foo") =>
#f. But (equal? 'foo 'bar) could actually be extended by a generic.
This was a bug, if you follow the other logic of the code. Changed so
that generic functions can only extend the domain of equal? when
operating on goops objects.
* oop/goops.scm: No more eqv? generic.
* test-suite/tests/goops.test: Remove eqv? tests.
Andy Wingo [Thu, 5 Nov 2009 16:35:44 +0000 (17:35 +0100)]
generic tweaks; realizing what the setter slot actually is
* libguile/goops.h (scm_si_dispatch_procedure)
(scm_si_effective_methods): Rename the new generics slots to
"effective-methods" and "dispatch-procedure".
(scm_si_generic_setter): Rename this one from "%setter" to "setter",
and it's not a cache -- it's a pointer to the setter, which is also a
generic. I didn't realize that before. It's better this way (like it
always was.)
(SCM_SET_GENERIC_DISPATCH_PROCEDURE)
(SCM_CLEAR_GENERIC_EFFECTIVE_METHODS): New helper macros.
* libguile/goops.c (clear_method_cache): Clear the new dispatch
procedure and the effective methods as well.
(create_standard_classes): Rename slots, and fix the setter slots.
Andy Wingo [Thu, 5 Nov 2009 12:16:40 +0000 (13:16 +0100)]
more clarity in (oop goops dispatch)
* module/oop/goops/dispatch.scm (memoize-method!): If we don't have a
no-applicable-method, just call no-applicable-method directly.
* test-suite/tests/goops.test ("no-applicable-method"): Add some tests.
Andy Wingo [Thu, 5 Nov 2009 11:54:41 +0000 (12:54 +0100)]
remove code-table slot from methods
* libguile/goops.c (scm_sys_invalidate_method_cache_x, scm_make)
(create_standard_classes): Remove code-table slot from methods. The
generic cache completely does its job, afaict.
* libguile/goops.h (scm_si_formals, scm_si_body, scm_si_make_procedure):
Renumber slots.
* module/oop/goops.scm (initialize on <method>): No more code-table
slot.
* module/oop/goops/compile.scm: Always "compile" a method, instead of
looking for a hit in an always-empty cache.
Andy Wingo [Thu, 5 Nov 2009 11:41:54 +0000 (12:41 +0100)]
remove used-by slot from generics
* libguile/goops.c (clear_method_cache)
(scm_sys_invalidate_method_cache_x, scm_make)
(create_standard_classes): Remove the used-by method from generics, as
it is not used at all.
* libguile/goops.h: Renumber generic slots.
* module/oop/goops/dispatch.scm (memoize-method!): No more used-by slot.
Andy Wingo [Thu, 5 Nov 2009 10:32:16 +0000 (11:32 +0100)]
first step towards effective methods
* libguile/goops.c (create_standard_classes):
* libguile/goops.h *scm_si_applicable_methods, scm_si_effective_method)
(scm_si_applicable_setter_methods, scm_si_effective_setter_method):
Add space for the new form of the generic cache and effective method.
Andy Wingo [Tue, 3 Nov 2009 22:59:51 +0000 (23:59 +0100)]
a very big commit cleaning up structs & goops. also applicable structs.
I tried to split this one, and I know it's a bit disruptive, but this
stuff really is one big cobweb. So instead we'll pretend like these are
separate commits, by separating the changelog.
Applicable struct runtime support.
* libguile/debug.c (scm_procedure_source):
* libguile/eval.c (scm_trampoline_0, scm_trampoline_1)
(scm_trampoline_2):
* libguile/eval.i.c (CEVAL):
* libguile/goops.c (scm_class_of):
* libguile/procprop.c (scm_i_procedure_arity):
* libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow
for applicable structs. Whee!
* libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym
for scm_vtable_index_self.
(scm_vtable_index_printer): Alias scm_vtable_index_instance_printer.
(scm_struct_i_free): Alias scm_vtable_index_instance_finalize.
(scm_struct_i_flags): Alias scm_vtable_index_flags.
(SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now.
(SCM_SET_VTABLE_DESTRUCTOR): Implement by hand.
Hidden slots.
* libguile/struct.c (scm_make_struct_layout): Add support for "hidden"
fields, writable fields that are not visible to make-struct. This
allows us to add fields to vtables and not break existing make-struct
invocations.
(scm_struct_ref, scm_struct_set_x): Always get struct length from the
vtable. Support hidden fields.
* libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New
slot classes, to correspond to the new vtable slots.
(scm_sys_prep_layout_x): Turn hidden slots into 'h'.
(build_class_class_slots): Reorder the class slots to account for
vtable fields coming out of negative-land, for name as a vtable slot,
and for hidden fields.
(create_standard_classes): Define <hidden-slot> and
<protected-hidden-slot>.
Clean up struct.h.
* libguile/struct.h: Lay things out cleaner. There are no more hidden
(negative) words. Names are nicer. The exposition is nicer. But the
basics are the same. The incompatibilities are that <vtable> has more
slots now, and that scm_alloc_struct's signature has changed. The
former is ameliorated by the "hidden" slots mentioned before, and the
latter, well, it was always a very internal thing...
(scm_t_struct_finalize): New type, a finalizer function to be run when
instances of a vtable are collected.
(scm_t_struct_free): Removed, structs' data is managed by the GC now,
and not freed by vtable functions.
* libguile/struct.c: (scm_vtable_p): Now we keep flags on
vtable-vtables, so this check is cheaper.
(scm_alloc_struct): No hidden words. Yippee.
(struct_finalizer_trampoline): Entersify.
(scm_make_struct): No need to babysit extra words, though now we have
to babysit flags. Propagate the vtable, applicable, and setter flags
appropriately.
(scm_make_vtable_vtable): Update for new simplicity.
(scm_print_struct): A better printer.
(scm_init_struct): Define <applicable-struct-vtable>, a magical vtable
like CL's funcallable-standard-class. Also define
<applicable-struct-with-setter-vtable>.
Remove foreign object implementation.
* libguile/goops.h:
* libguile/goops.c (scm_make_foreign_object, scm_make_class)
(scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these
were undocumented and unworking.
Clean up goops.h, a little.
* libguile/goops.h:
* libguile/goops.c: Also clean up.
* module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset
index.
Ludovic Courtès [Wed, 25 Nov 2009 22:46:17 +0000 (23:46 +0100)]
Remove uses of discouraged constructs.
* libguile/vm-i-scheme.c, libguile/vm-i-system.c, libguile/vm.c: Replace
uses of discouraged constructs by their current counterparts.
Ludovic Courtès [Wed, 25 Nov 2009 22:44:14 +0000 (23:44 +0100)]
Don't build `inet-aton' and `inet-ntoa' when --disable-networking.
* libguile/deprecated.c (scm_inet_aton, scm_inet_ntoa): Conditionalize
on `HAVE_NETWORKING'.
Ludovic Courtès [Tue, 24 Nov 2009 22:43:27 +0000 (23:43 +0100)]
Use $(PATH_SEPARATOR) where appropriate.
* examples/Makefile.am (AM_CFLAGS, AM_LIBS): Use $(PATH_SEPARATOR)
instead of `:'.
(installcheck): Likewise.
Ludovic Courtès [Tue, 24 Nov 2009 22:39:10 +0000 (23:39 +0100)]
Fix makefile indentation.
* benchmark-suite/Makefile.am, libguile/Makefile.am, meta/Makefile.am:
Use TAB instead of 8 spaces...
* .x-sc_makefile_check: New file.
Ludovic Courtès [Tue, 24 Nov 2009 22:34:37 +0000 (23:34 +0100)]
Properly quote the first argument to `AC_DEFINE{,_UNQUOTED}'.
* acinclude.m4, configure.ac, examples/compat/acinclude.m4: Properly
quote the first argument for `AC_DEFINE' and `AC_DEFINE_UNQUOTED'.
* .x-sc_m4_quote_check: New file.
Ludovic Courtès [Tue, 24 Nov 2009 22:23:28 +0000 (23:23 +0100)]
Add `cfg.mk', for use by the top-level GNUmakefile.
* cfg.mk: New file, with 1.9.5 `NEWS' hash.
Ludovic Courtès [Tue, 24 Nov 2009 22:16:08 +0000 (23:16 +0100)]
"filesystem" -> "file system"
* doc/ref/misc-modules.texi, doc/sources/unix.texi,
module/ice-9/ftw.scm: Replace "filesystem" by "file system".
Ludovic Courtès [Tue, 24 Nov 2009 22:12:03 +0000 (23:12 +0100)]
Don't rely on `HAVE_' macros in public header "tags.h".
* configure.ac: Check for `intptr_t' and `uintptr_t'. Substitute
`SCM_I_GSC_T_INTPTR' and `SCM_I_GSC_T_UINPTR'.
* libguile/__scm.h (SCM_T_UINTPTR_MAX, SCM_T_INTPTR_MIN,
SCM_T_INTPTR_MAX): New macros.
* libguile/_scm.h (SIZEOF_SCM_T_BITS): New macro.
* libguile/gen-scmconfig.c (main): Produce typedefs for `scm_t_intptr'
and `scm_t_uintptr'.
* libguile/gen-scmconfig.h.in (SCM_I_GSC_T_INTPTR, SCM_I_GSC_T_UINPTR):
New macros.
* libguile/tags.h: Don't check for `HAVE_INTTYPES_H' and
`HAVE_STDINT_H'; don't include <inttypes.h> nor <stdint.h>.
(scm_t_signed_bits, scm_t_bits): Define unconditionally as aliases for
`scm_t_intptr' and `scm_t_uintptr', respectively.
(SCM_T_SIGNED_BITS_MAX, SCM_T_SIGNED_BITS_MIN, SCM_T_BITS_MAX):
Likewise.
(SIZEOF_SCM_T_BITS): Remove.
Ludovic Courtès [Tue, 24 Nov 2009 21:25:49 +0000 (22:25 +0100)]
Remove unused, non-prefixed macros.
* libguile/__scm.h (BIGNUMS, TICKS): Remove.
Ludovic Courtès [Tue, 24 Nov 2009 21:11:28 +0000 (22:11 +0100)]
Update to Gnulib
v0.0-2923-g6575ab5.
Ludovic Courtès [Tue, 24 Nov 2009 21:07:16 +0000 (22:07 +0100)]
Really disable thread-local storage on NetBSD 5.0.
* acinclude.m4 (GUILE_THREAD_LOCAL_STORAGE): Adjust to match actual
NetBSD 5 triplet, `x86_64-unknown-netbsd5.0.' (note the final dot).
Ludovic Courtès [Tue, 24 Nov 2009 21:06:08 +0000 (22:06 +0100)]
Fix compilation `--without-threads'.
* configure.ac: For `--without-threads' and `--with-threads=null', set
`SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS=0'. This fixes compilation of
`gen-scmconfig.c' in these cases.
Ludovic Courtès [Mon, 23 Nov 2009 22:47:20 +0000 (23:47 +0100)]
Use Gnulib's `duplocale' module.
* libguile/i18n.c (scm_make_locale): Simplify global locale handling,
using duplocale(3) for all kinds of locales.
(scm_init_i18n): Comment on why we don't just use `LC_GLOBAL_LOCALE'
for `global_locale_smob'.
* m4/gnulib-cache.m4: Add `duplocale'.
Ludovic Courtès [Mon, 23 Nov 2009 21:50:34 +0000 (22:50 +0100)]
Use Gnulib's `locale' module.
* configure.ac: Remove test for <xlocale.h>.
* libguile/i18n.c: Remove conditional <xlocale.h> inclusion on
`HAVE_XLOCALE_H'.
* m4/gnulib-cache.m4: Add `locale' module.
Ludovic Courtès [Mon, 23 Nov 2009 17:51:25 +0000 (18:51 +0100)]
Correct manual wrt. encoding names.
* doc/ref/api-evaluation.texi (Character Encoding of Source Files):
Don't suggest `latin1' as a good encoding name since Emacs cannot deal
with it.
* libguile/read.c (scm_file_encoding): Fix "Emacs" spelling.
Andy Wingo [Fri, 20 Nov 2009 12:12:44 +0000 (13:12 +0100)]
better printing of procedures with keyword arguments
* module/system/vm/program.scm (arguments->lambda-list): Print keyword
arguments more sensibly.
Andy Wingo [Fri, 20 Nov 2009 16:24:40 +0000 (17:24 +0100)]
fix version-etc for older autoconf
* lib/version-etc.c: Don't reference the undefined PACKAGE if
PACKAGE_URL is undefined. Probably should go upstream.
Ludovic Courtès [Wed, 18 Nov 2009 14:32:03 +0000 (15:32 +0100)]
autogen.sh: Don't presume /usr/bin/m4.
* autogen.sh: Don't presume /usr/bin/m4.