summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Rounding out hash table functionality with lazy lists thatKaz Kylheku2012-04-079-11/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | can walk table content in different ways. * eval.c (op_dohash): Follow interface change of hash_next. (eval_init): hash-keys, hash-values, hash-pairs and hash-alist intrinsics introduced. * filter.c (trie_compress): Follow interface change of hash_next. * hash.c (hash_next): Silly interface which takes a pointer to the iterator has changed to just take the iterator. The function unambiguously returns nil when the iteration ends, so there is no need to set the iterator variable to nil. (maphash): Follows interface change of hash_next. (hash_keys_lazy, hash_values_lazy, hash_pairs_lazy, hash_alist_lazy): New static functions. (hash_keys, hash_values, hash_pairs, hash_alist): New functions. * hash.h (hash_next): Declaration updated. (hash_keys, hash_values, hash_pairs, hash_alist): Declared. * lib.c (make_half_lazy_cons): New way of constructing lazy cons, with the car field specified. It simplifies situations when the previous cons computes the car of the next one. Why hadn't I thought of this before? * lib.h (make_half_lazy_cons): Declared. * txr.1: Doc stubs for new hash functions. * txr.vim: Highlighting for new hash functions.
* Version 64txr-64Kaz Kylheku2012-04-065-4/+43
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES: Updated.
* ChangeLog: fix stray whitespace.Kaz Kylheku2012-04-051-4/+4
|
* Merge branch 'ephemeral-gc'Kaz Kylheku2012-04-0512-159/+654
|\ | | | | | | | | Conflicts: ChangeLog
| * * gc.c (FRESHQ_SIZE): Preprocessor symbol renamed to FRESHOBJ_VEC_SIZE.Kaz Kylheku2012-04-052-4/+9
| | | | | | | | (freshobj, make_obj): Object and function definitions follow rename.
| * * gc.c (mark_obj, sweep_one, gc_is_reachable): Check for gen > 0 ratherKaz Kylheku2012-04-052-3/+15
| | | | | | | | | | | | | | | | | | than gen == 0. This allows gen == -1 objects to be considered the same as gen == 0, and traversed. (gc_set, gc_mutated): When a gen 0 object is added to the checkobj array, set its generation to -1. This prevents duplicates in the checkobj array. Also, it fixes a bug: an vector marked as mutated was not being traversed due to being in generation 1.
| * Code cleanup and tweaking.Kaz Kylheku2012-04-054-24/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (BACKPTR_VEC_SIZE): Preprocessor symbol renamed to CHECKOBJ_VEC_SIZE. (FULL_GC_INTERVAL): Increased to 40 since the modified algorithm now leaves less work for the full gc to do. (backptr, backptr_idx): Static variables renamed to checkobj and checkobj_idx. (mark): Follows rename of backptr and backptr_idx. (gc): Commented out handy printf added. (gc_set): Use in_malloc_range check to avoid adding to the check array pointers which are being stored in non-heap locations, since non-heap locations are already GC roots. (gc_mutated): Follows variable renaming. (gc_push): Just do the push using gc_set. * lib.c (malloc_low_bound, malloc_high_bound): New variables. (chk_malloc, chk_calloc, chk_realloc): Updated malloc_low_bound and malloc_high_bound. (in_malloc_range): New function. * lib.h (in_malloc_range): Declared.
| * The mut macro should only be used for vectors or vector-like objectsKaz Kylheku2012-04-053-12/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | which hold direct references to other objects and must be used each time a mutation takes place. * eval.c (op_dohash): invocations of mut macro removed. Comment rewritten. * lib.c (sort_list): Use set macro for mutating assignment. Do not invoke mut on sorted list; it won't work anyway, because it doesn't mean what the code wants it to mean: that the list will be fully traversed during gc marking.
| * Bunch of fixes.Kaz Kylheku2012-04-057-8/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (gc_mutated): Return the value. * gc.h (gc_mutated): Declaration updated. * hash.c (remhash): Fix unsafe assignment to use set macro. * lib.c (sort): Fix wrong use of mut macro on the list before it is sorted rather than after. * lib.h (mut): Trivial version of macro updated to return argument. * unwind.c (uw_init): The toplevel environment's match_context should be gc_protected. Though this is probably not used, which is why it has not been a problem.
| * * hash.c (hash_grow, gethash_l, gethash, gethash_f): ReplaceKaz Kylheku2012-04-042-4/+9
| | | | | | | | useless use of *vecref_l() with vecref().
| * * configure (gen_gc): Default to off.Kaz Kylheku2012-04-043-1/+23
| | | | | | | | | | | | Help section added for gen_gc variable. * gc.c (gc): Some missing CONFIG_GEN_GC added.
| * Code cleanup.Kaz Kylheku2012-04-042-67/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (backptr_oflow): Static variable removed. (freshq_head, freshq_tail, partial_gc_count): Static variables removed. (freshq): Array renamed to freshobj. (full): Variable renamed to full_gc. (freshobj_idx): New varaible. (make_obj): Add newly born objects to freshobj array rather than freshq. If freshobj array is full on entry to this function, trigger gc to empty it. make_obj no longer updates the free_tail; the gc routine takes care of restoring this invariant. (mark_obj): Follows rename of full_gc. Some code was not wrapped in #if CONFIG_GEN_GC. (mark, sweep_one): Follow rename of full_gc. (sweep): On entry, restore free_tail invariant in the empty free_list case. Code which processes freshq from tail to head replaced by simple array walk of freshobj. Code wrapped properly in #if CONFIG_GEN_GC. (gc): Logic for triggering full gc simplified. Check added for situations when a partial gc is called when the free list empties, and it doesn't liberate enough memory. This prevents the situation of partial gc being called over and over again by make_obj, squeezing less and less memory each time until finally it returns 0 objects, and more() is called. (gc_is_reachable): Follows rename of full_gc, and #if CONFIG_GEN_GC added. (gc_set, gc_mutated): Simplified. Check if the backptr array is full and trigger gc if so to flush it, then just add to the array.
| * Performance tweaking and fixes.Kaz Kylheku2012-04-032-4/+20
| | | | | | | | | | | | | | | | | | | | | | * gc.c (BACKPTR_VEC_SIZE): Increase greatly, so that we don't trigger gc due to overflow of the backptr array. This is not likely to yield a lot of free objects except in a full GC. (FULL_GC_INTERVAL): From 10 to 20. (gc): Take a not of whether or not gc was entered with free_list being exhausted or not. Call more() only if the free_list was empty, and a full sweep was done. Reset partial_gc_count only when a full gc is triggered.
| * Fix failing test case tests/006/freeform-1.txr.Kaz Kylheku2012-04-032-6/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (lazy_str_force, lazy_str_force_upto): Use set macro when assigning lim. This won't cause a problem unless lim is in the bignum range, however. (acons_new, aconsq_new): When overwriting the cdr value of the existing entry, use set. This is the smoking gun; these functions are used for manipulating bindings. (sort): After sorting a list, we must mark it as having been mutated. If a list contains only mature conses or only fresh conses, there is no problem. But if it contains a mixture, then sorting could reverse their relationship, causing mature conses to backpoint to the fresh ones. (obj_init): Use set when installing the t symbol into the user package.
| * Generational GC showing signs of working. One test case inKaz Kylheku2012-04-034-82/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test suite fails. * gc.c (FRESHQ_SIZE): New preprocessor symbol. (backptr_oflow, freshq, freshq_head, freshq_tail): New static variables. (make_obj): Place newly allocated generation 0 object into freshq. If freshq becomes full, transfer oldest item into generation 1. (mark_obj): If doing only a partial gc, then do not mark objects which are not generation 0. (mark_mem_region): Valgrind support: cannot mark t.type field undefined because it is a bitfield. Just mark the first SIZEOF_PTR bytes of the object defined. (mark): Under partial gc, mark the table of back pointers. (sweep_one): New static function from the prior guts of sweep. Reachable objects now get promoted to generation 1. (sweep): Under partial gc, sweep just the freshq which identifies the generation 0 objects, rather than the entire linked list of all the heaps. (gc): Trigger full gc also if the backptr list has overflowed due to gc having been disabled. Under generational gc, reset the static variables afterward: clear the list of backpointers, and the freshq. (gc_is_reachable): Under partial gc, report any mature object as reachable. (gc_set, gc_mutated): Handle backptr array overflow situation when gc is disabled. (gc_push): Bugfix: it is the newly pushed cons cell that has to be marked as a root, not the value being pushed. * hash.c (sethash): Use set macro for storing value. * lib.h (set, mut, mpush): Fix wrong-way #if test for these macros. The trivial versions were being defined uner CONFIG_GEN_GC and vice versa!
| * * eval.c (op_modplace): push replaced with mpush (mutating push).Kaz Kylheku2012-04-037-7/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (gc_push): New function. * gc.h (gc_push): Declared. * hash.c (pushhash): Use mpush. * lib.c (push): Reverted to unsafe operation. TODO comment replaced with warning. (lazy_flatten_scan): push occurence commented as safe. (lazy_stream_func): Unsafe push replaced with mpush. * lib.h (mpush): New macro.
| * * configure: Support a gen-gc configuration variable whichKaz Kylheku2012-04-0312-58/+195
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | causes CONFIG_GEN_GC to be defined as 1 in config.h. * eval.c (op_defvar, dwim_loc, op_modplace, transform_op): Handle mutating assignments via set macro. (op_dohash): Inform gc about mutated variables. TODO here. * filter.c (trie_add, trie_compress): Handle mutating assignments via set macro. * gc.c (BACKPTR_VEC_SIZE, FULL_GC_INTERVAL): New preprocessor symbols. (backptr, backptr_idx, partial_gc_count, full): New static variables. (make_obj): Initialize generation to zero. (gc): Added logic for deciding between full and partial gc. (gc_set, gc_mutated): New functions. * gc.h (gc_set, gc_mutated): Declared. * hash.c (hash_mark): Changed useless use of vecref_l to vecref. (gethash_f): Use set when assigning through *found since it is a possible mutation. * lib.c (car_l, cdr_l, vecref_l): Got rid of loc macro uses. Using the value properly is going to be the caller's responsibility. (push): push may be a mutation, so use set. (intern): Uset set to mutate a hash entry. (acons_new_l, aconsq_new_l): Use set when replacing *list. * lib.h (PTR_BIT): New preprocessor symbol. (obj_common): New macro for defining common object fields. type_t is split into two bitfields, half a pointer wide, allowing for generation to be represented. (struct any, struct cons, struct string, struct sym, struct package, struct func, struct vec, struct lazy_cons, struct cobj, struct env, struct bignum, struct flonum): Use obj_common macro to defined common fields. (loc): Macro removed. (set, mut): Macros conditionally defined for real functionality. (list_collect, list_collect_nconc, list_collect_append): Replace mutating operations with set. * match.c (dest_set, v_cat, v_output, v_filter): Replace mutating operations with set. * stream.c (string_in_get_line, string_in_get_char, strlist_out_put_string, strlist_out_put_char): Replace mutating operations with set. * unwind.c (uw_register_subtype): Replace mutating operation with set.
| * * lib.c (vec_set_length): Use set instead of assignment.Kaz Kylheku2012-04-023-3/+15
| | | | | | | | | | | | | | | | (vecref_l): Use loc to lift address of cell. (replace_vec): Use macro mut to indicate the object is being mutated. * lib.h (mut): New macro.
| * Start of ground-work for ephemeral GC. We must add some abstractionKaz Kylheku2012-04-015-30/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to places where we potentially assign a reference to a younger object inside a field located in an older object (chronological backreference) and also where we take the address of an object field, making it possible that the user of the address will do so. This patch does not take care of vectors. No, this is not an April Fool's joke. * eval.c (env_fbind, env_vbind, env_replace_vbind, lookup_var, lookup_sym_lisp1): Use set macro instead of assignment. * hash.c (hash_grow, set_hash_userdata, hash_next): Use set macro instead of assignment. * lib.c (rplaca, rplacd, string_extend, length_str, replace_str, rehome_sym, lazy_stream_func, lazy_str, lazy_str_force, lazy_str_force_upto, obj_init): Use set macro instead of assignment. (car_l, cdr_l): Use loc instead of address-of operator. * lib.h (set, loc): New macros.
* | * txr.vim: @[...] syntax not marked as "contained" because itKaz Kylheku2012-04-052-1/+6
|/ | | | can freely occur, and is useful in @(output).
* * hash.c (last_equal_key, last_equal_hash): New static variables.Kaz Kylheku2012-03-312-23/+58
| | | | | | | (equal_hash): Caching optimization implemented. (eql_hash): Optimization extended to those objects that have equal semantics. (hash_process_weak): Clear the cached hash during gc.
* If one of the blocks which are subordinate to a @(trailer)Kaz Kylheku2012-03-315-11/+100
| | | | | | | | | | | | | | | | | | | | | happen to request a successful termination by invoking @(accept) the position must not advance into the trailer material. * match.c (v_trailer): Added an unwind protect which detects that an accept is taking place and adjusts the return value to restrict the input position at the point given to trailer. (accept_fail): Use uw_block_return_proto instead of uw_block_return and pass the symbol as the protocol identifier. * unwind.c (uw_current_exit_point): New function. (uw_block_return): Function renamed to uw_block_return_proto; takes new parameter which is stored in the block structure. * unwind.h (struct uw_block): New member, protocol. (uw_block_return): Becomes an inline wrapper for uw_block_return_proto. (uw_block_return_proto, uw_current_exit_point): Declared. * txr.1: Interaction between @(trailer) and @(accept) documented.
* * match.c (h_var): Disallow the variable named by the symbol tKaz Kylheku2012-03-303-10/+45
| | | | | | | | by throwing an exception. Allow nil, but wherever nil occurs, do not produce a binding. * txr.1: State the restrictions against using t in the section on Variables and also describe the nil ignore feature.
* * txr.1: Correction: backtracking does NOT take place into a blockKaz Kylheku2012-03-302-3/+8
| | | | which completed.
* * txr.1: Documenting the debugger with an example session.Kaz Kylheku2012-03-302-0/+196
|
* Version 63txr-63Kaz Kylheku2012-03-305-4/+59
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES: Updated.
* * lib.c (num_str): Much more accurate test for deciding whetherKaz Kylheku2012-03-303-7/+57
| | | | | | | | | to treat the number as floating or integer. We can't just look for the presence of E, e or . because these coudl be part of trailing junk for instance "123XYZE." should convert to the integer 123, where "XYZE." is trailing junk. * txr.1: Documented int-str, flo-str and num-str.
* * arith.c (numeq): Fix misplaced parenthesis.Kaz Kylheku2012-03-292-1/+5
|
* * lib.c (min2, max2): Semantics tweak. If the numbers are equal,Kaz Kylheku2012-03-293-2/+34
| | | | | | favor the left one. * txr.1: Documented min and max.
* * arith.c (numeq): New function.Kaz Kylheku2012-03-297-8/+208
| | | | | | | | | | | | | | | | | (exptmod): Bugfix: was no normalizing the bignum, ouch. Also was reporting "non-integral operands" for other errors. * eval.c (eval_init): Registered = intrinsic function. * lib.c (numeqv): New function. * lib.h (numeq, numeqv): Declared. * txr.1: Documented expt, sqrt, isqrt, exptmod, fixnump, bignump, integerp, floatp, numberp, zerop, evenp, oddp, >, <, >=, <= and =. * txr.vim: Highlight =
* * arith.c (gcd): Allow zeros. Don't issue "non-integral"Kaz Kylheku2012-03-296-3/+141
| | | | | | | | | | | | | | | exception if MPI fails. (floorf, ceili): Map integer argument to itself. (tang, asine, acosi): New functions. * eval.c (eval_init): New intrinsics: tan, asin, acos. * lib.h (tang, asine, acosi): Declared. * txr.1: Documented gcd, abs, floor, ceil, sin, cos, tan asin, acos, atan, log, and exp. * txr.vim: Highlighting for tang, asine, acosi.
* * arith.c (dmod): New static function.Kaz Kylheku2012-03-293-7/+57
| | | | | | | | (mod): Use dmod instead of fmod directly, to calculate the correct semantics for combinations of negative operands in the floating point domain also. * txr.1: Documented /, trunc and mod.
* * txr.1: Documented +, - and *.Kaz Kylheku2012-03-292-1/+73
|
* * txr.1: num-str added to doc stub.Kaz Kylheku2012-03-293-2/+8
| | | | * txr.vim: num-str added.
* * lib.c (obj_print, obj_pprint): Do not use the #<lazy-string ..>Kaz Kylheku2012-03-282-2/+15
| | | | notation for lazy strings that have been forced.
* * stream.c (vformat): Compensate for differences in printfKaz Kylheku2012-03-273-6/+58
| | | | | | | implementations with regard to printing floating point exponents. by deleting any plus sign and leading zeros after the 'e'. * tests/009/json.expected: Regenerated.
* Filtering on lists and nested lists is hereby made to work.Kaz Kylheku2012-03-264-21/+48
| | | | | | | | | | | | | | | | | | For instance given @(bind a ("a" "b" "c")) it is now possible to do @(filter :upcase a) whereby a promptly takes on the value ("A" "B" "C"). * filter.c (string_filter): Function renamed to string_tree_filter. (compound_filter): Follows rename. (filter_string): Function renamed to filter string tree. Can filter tree of strings, or possibly other objects, if the filter function allows. (filter_equal): No special case test for objects that are strings. Just put them through the filter. * filter.h (filter_string): Declaration updated. * match.c (format_field, subst_vars, v_filter): Follow rename.
* * match.c (v_output): Bugfix: we should flush the streamKaz Kylheku2012-03-262-0/+10
| | | | | | | after each @(output) block. Otherwise if output blocks that go to standard output are interleaved with output blocks which pipe to some command which then goes to standard out, the output won't be in the proper order.
* * eval.c (eval_init): New intrinsic num-str registered.Kaz Kylheku2012-03-267-5/+71
| | | | | | | | | | | | | | | * filter.c (tonumber_k, tointeger_k, tofloat_k, hextoint_k): New keyword variables. (filter_init): New variables initialized; new filters registered. * filter.h (tonumber_k, tointeger_k, tofloat_k, hextoint_k): Declared. * lib.c (num_str): New function. * lib.h (num_str): Declared. * txr.1: New filters documented.
* * arith.c (to_float): Fix unterminated argument list in throwf.Kaz Kylheku2012-03-263-2/+8
| | | | * lib.c (funcall): Likewise.
* * lib.c (rebind_s): New symbol variable.Kaz Kylheku2012-03-245-5/+69
| | | | | | | | | | * lib.h (rebind_s): Declared. * match.c (v_rebind): New static function. (dir_tables_init): Registered rebind_s to v_rebind, and also to hv_trampoline in the horizontal directive table. * txr.1: Documented it.
* Bug #35989Kaz Kylheku2012-03-242-1/+8
| | | | | * match.c (syms_init): text_s must be in the system package because it's not a user-visible operator.
* Performance improvement in the GC: keep at least one heap's worthKaz Kylheku2012-03-242-4/+23
| | | | | | | | | | | | | of free space, so programs close to exhausting a heap do not waste cycles frequently calling the collector. * gc.c (more): Do not assert that free_list is null; this will not be the case any more. (make_obj): Comment added regarding why we the free_tail variable is fixed up. (sweep): Now returns a count of the objects that are free. (gc): If sweep reports that less than 75% of the objects are free then let us add another heap.
* * eval.c (eval_init): Register match-str and match-str-treeKaz Kylheku2012-03-245-0/+24
| | | | | | | | | | intrinsics. * lib.c (match_str, match_str_tree): Default position to zero. * txr.1: Doc stubs created. * txr.vim: Highlighting for match-str and match-str-tree.
* Bugfix: code like @(skip)@{var /partial/} whereKaz Kylheku2012-03-242-11/+34
| | | | | | | | | | | | | | | | the regular expression does not match all the way to the end of the line was getting by the check for a complete match. * match.c (do_match_line): Loses the second parameter named completely. The check whether the line was matched completely is done higher up, in match_line_completely. This is needed because do_match_line has some early successful return cases which bypass the check. (match_line): Remove second paramter in call to do_match_line. (match_line_completely): Do the check here that the line was matched completely. Nothing can get by this. (v_freeform): Do notpass second nil argument to do_match_line.
* * lib.c (search_str): If start_num is nil, default it to zero.Kaz Kylheku2012-03-242-0/+9
| | | | This is needed for this to work right as an optional argument.
* Version 62txr-62Kaz Kylheku2012-03-234-4/+14
| | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped.
* * RELNOTES: Updated.Kaz Kylheku2012-03-233-2/+90
| | | | * txr.1: Describe floating-point constants.
* * Makefile (TXR_ARGS): Pass new file to tests/009/json.txr test.Kaz Kylheku2012-03-235-18/+130
| | | | | | | | | | * tests/009/json.expected: Updated. * tests/009/json.txr: Updated source. Translates to a more native representation with vectors and hash tables. Numbers go to floating point instead of remaining as strings. * tests/009/pass1.json: New file: a test case from json.org.
* Merge branch 'float-support'Kaz Kylheku2012-03-2216-424/+1322
|\ | | | | | | | | Conflicts: ChangeLog