summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2009-12-01apply goes to the vm, not the interpreterAndy Wingo3-156/+6
* 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.
2009-12-01vm doesn't call the evaluator at all (at least not directly)Andy Wingo1-28/+42
* libguile/vm-i-system.c (goto/args, mv-call): Finish the port to use apply_foreign instead of scm_apply.
2009-12-01first step to make the vm stop calling the interpreterAndy Wingo6-13/+224
* 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.
2009-12-01add new scheme evaluatorAndy Wingo2-0/+212
* 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.
2009-12-01add memoized expression accessors to schemeAndy Wingo3-38/+137
* 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.
2009-12-01export scm_define to scheme as define!Andy Wingo1-4/+10
* libguile/modules.c (scm_define): Export to Scheme as `define!'. The evaluator needs it, and actually it's an OK thing to have around.
2009-12-01wire through the existing vm ops for variable-ref and variable-set!Andy Wingo2-0/+9
* 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.
2009-12-01fixes to variable-ref, variable-set vm opsAndy Wingo1-2/+2
* libguile/vm-i-system.c (variable-ref, variable-set): Fix declared number of pops and pushes.
2009-12-01promises are in their own file nowAndy Wingo7-91/+218
* 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.
2009-12-01new evaluator, y'allAndy Wingo24-5050/+1742
* 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.
2009-12-01goops moving away from evaluator opcodes, and a primitive compilation fixAndy Wingo2-1/+6
* 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.
2009-12-01remove (lang elisp), as it won't work with the new evaluatorAndy Wingo42-2431/+7
* 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.
2009-12-01local-eval will go awayAndy Wingo5-11/+9
* 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.
2009-12-01no special treatment for memoized code in srcprop.cAndy Wingo2-69/+4
* 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.
2009-12-01factor copy-tree and cons-source out of eval.[ch]Andy Wingo11-184/+286
* 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.
2009-12-01remove unused scm_eval_stack varAndy Wingo2-6/+1
* libguile/private-options.h: * libguile/eval.c (scm_eval_stack): Remove declaration and definition of unused scm_eval_stack variable.
2009-12-01remove evaluator-specific code from macros.cAndy Wingo1-10/+0
* libguile/macros.c (macro_print): No special printing for macros whose code is an interpreted procedure.
2009-12-01remove class-environment slot, goops grubs less in the evaluatorAndy Wingo3-101/+43
* 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.
2009-12-01fix to gdb_eval to use newer interfacesAndy Wingo1-3/+2
* libguile/gdbint.c (gdb_eval): Use scm_primitive_eval instead of scm_i_eval_x.
2009-12-01formally deprecate trampolinesAndy Wingo4-156/+120
* 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.
2009-12-01remove uses of trampolines within guile itselfAndy Wingo6-126/+101
* 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.
2009-12-01gut the backtrace implementation for memoized codeAndy Wingo1-68/+8
* 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.
2009-12-01remove some deprecated things, undeprecate scm_the_root_module()Andy Wingo4-62/+6
* 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.
2009-12-01tweak to eval.cAndy Wingo1-3/+3
* libguile/eval.c (eval_letrec_inits): Rename from ceval_letrec_inits. Caller changed.
2009-12-01eval.i.c -> eval.cAndy Wingo3-1494/+1458
* libguile/Makefile.am: * libguile/eval.i.c: Remove eval.i.c. * libguile/eval.c: Fold eval.i.c's contents into eval.c.
2009-12-01more ceval excisionAndy Wingo2-44/+24
* libguile/eval.c: * libguile/eval.i.c: Rename deval to eval. Substitute in some preprocessor macros.
2009-12-01remove code from eval.i.c that was only for CEVAL.Andy Wingo1-241/+0
* libguile/eval.i.c: Remove CEVAL-only code.
2009-12-01Don't double-include eval.i.c -- let's only build deval.Andy Wingo2-48/+37
* 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.
2009-12-01gut trampolinesAndy Wingo4-323/+30
* 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.
2009-12-01expand out named let to letrec in the eval caseAndy Wingo2-6365/+6334
* module/ice-9/psyntax.scm: In the eval case, expand out named let to letrec. * module/ice-9/psyntax-pp.scm: Regenerated.
2009-11-29Make `SCM' type definition acceptable for C++ compilers.Ludovic Courtès1-1/+1
* 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>.
2009-11-28Remove remaining uses of discouraged constructs, really.Ludovic Courtès4-8/+8
* libguile/throw.c, libguile/vm-engine.h, libguile/vm-i-system.c, libguile/vm.c: Replace uses of discouraged constructs by their current counterparts.
2009-11-28Remove remaining uses of discouraged constructs.Ludovic Courtès7-20/+22
* 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.
2009-11-27Disable encoding scanning on non-seekable file ports.Ludovic Courtès1-1/+8
* libguile/read.c (scm_i_scan_for_encoding): Don't attempt to scan non-seekable file ports.
2009-11-26header tidyingsAndy Wingo2-31/+31
* libguile/goops.h: * libguile/struct.h: c-backslash-region some vars.
2009-11-26brace placement fixesAndy Wingo2-2/+4
* libguile/goops.c (scm_sys_allocate_instance): * libguile/vm-i-loader.c (load-wide-string): Fix some brace placements.
2009-11-26push goops compile delay out to 30 invocations, for great justiceAndy Wingo1-1/+1
* module/oop/goops/dispatch.scm (timer-init): Init to 30 for faster goops load time.
2009-11-26generic method cache begoneAndy Wingo2-13/+3
* 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!
2009-11-26remove code that manages the method cacheAndy Wingo5-231/+2
* 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.
2009-11-26remove method cache management code from (oop goops dispatch)Andy Wingo1-219/+7
* module/oop/goops/dispatch.scm: Remove old method cache things.
2009-11-26generics now dispatch as applicable structsAndy Wingo5-106/+101
* 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.
2009-11-26make sure that when equal? is extended, that the generic has a methodAndy Wingo3-1/+23
* 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.
2009-11-26remove cache-mutex slot from genericsAndy Wingo2-18/+7
* libguile/goops.c: * libguile/goops.h: Remove cache-mutex slot from generics, and renumber other slots.
2009-11-26remove locking in method memoizationAndy Wingo1-38/+4
* libguile/goops.c (scm_memoize_method): Don't lock around method memoization, as the new protocol will be reeentrant and lock-free.
2009-11-26limn goops flags, remove foreign objs, rename entity to applicable-structAndy Wingo6-247/+146
* 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.
2009-11-26%invalidate-method-cache invalidates the dispatch procedure tooAndy Wingo1-1/+12
* libguile/goops.c (make_dispatch_procedure, clear_method_cache): Properly reset the dispatch procedure.
2009-11-26generic dispatch protocol in scheme, not yet wired upAndy Wingo1-1/+220
* 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.
2009-11-26eqv? not a generic, equal? dispatches to generic only for objectsAndy Wingo3-24/+15
* 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.
2009-11-26generic tweaks; realizing what the setter slot actually isAndy Wingo2-12/+14
* 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.
2009-11-26more clarity in (oop goops dispatch)Andy Wingo2-10/+24
* 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.