summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* linenoise: Ctrl-X Ctrl-P missing from cheatsheet.Kaz Kylheku2019-02-211-4/+4
| | | | | | | * linenoise/linenoise.c (show_help): Rearrange contents. ^X+Tab moves from page 3 to page 2, to a spot where there is just enough room. That gives us room to place ^X^P on page 3.
* listener: fix hang when stringifying output.Kaz Kylheku2019-02-211-1/+2
| | | | | | | | | | | | | | | | | | The issue is that when *listener-pprint-p* is set, then the evaluation is printed using pprinl. The user may have arranged for that to safely work when there are circular objects in the print. But then the listener ignores *listener-pprint-p* when saving the output object as a string (which is done for the sake of the Ctrl-X Ctrl-P paste-previous-output feature). The tostring function is used which can blow up on an object containing circular structure, even though the object was successfully printed. The user is puzzled: why was the result of the evaluation printed completely and perfectly, yet the image has hanged? * parser.c (repl): Do not use tostring for converting the evaluated output to a string. Choose between tostring and tostringp based on the *listener-pprint-p* variable.
* doc: clarification in cptr-int.Kaz Kylheku2019-02-201-2/+2
| | | | | * txr.1: Remove unclear pronoun in remark about addressing structure.
* doc: wrong word under cptr.Kaz Kylheku2019-02-201-1/+1
| | | | * txr.1: Fix "an" that should be "and".
* pprof: generate much smaller expansion.Kaz Kylheku2019-02-191-17/+21
| | | | | | | | | * eval.c (me_pprof): Instead of emitting open code which destructures the output of pprof and prints a diagnostic, let's do that inside a run-time support function called sys:rt-pprof, so (pprof x) now expands to (rt:pprof (prof x)). (rt_pprof): New function. (eval_init): Register sys:rt-pprof intrinsic.
* compiler: prof instruction tries to modify t0.Kaz Kylheku2019-02-191-2/+2
| | | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-prof): We must use the incoming oreg as the destination for prof, and not try to use output register indicated by the compiled fragment. That fragment may indicate nil as its output, which we may not clobber. Since we are telling the sub-compile to try to put the fragment's output into our oreg, in most cases they still get merged so a single register is re-used.
* struct: optimizations in new operator.Kaz Kylheku2019-02-191-2/+4
| | | | | | | | | | * share/txr/stdlib/struct.tl (new): Use struct-from-args and struct-from-plist whenever possible; don't use make-struct unless the syntax specifies both BOA and plist arguments. Using struct-from-plist instead of make-struct means we can now entirely avoid consing a list in compiled code. Code like (new point x 0 y 0) now allocates nothing but the struct.
* structs: optimize struct creating functions.Kaz Kylheku2019-02-191-7/+19
| | | | | | | | | | | | | | | | We reduce consing in the structure instantiating API. * struct.c (make_struct_impl): New static function, formed from make_struct. This takes two "struct args *" arguments, for both the slot/pair property list and the BOA list. (make_struct): Now a wrapper for make_struct_impl. (struct_from_plist): Call make_struct_impl instead of make_struct, avoiding the args_get_list operation that potentially conses args on the stack into a list. Diagnosis is improved because make_struct_impl takes a self argument. (struct_from_args): Call make_struct_impl instead of make_struct.
* mpi/arith: optimize "highest bit" with GCC builtins.Kaz Kylheku2019-02-192-2/+14
| | | | | | * arith.c (highest_bit): On GCC, use __builtin_clz. * mpi/mpi.c (s_highest_bit): Likewise.
* Version 211.txr-211Kaz Kylheku2019-02-186-909/+949
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* structs: bugfix: slot_cache null check.Kaz Kylheku2019-02-181-6/+7
| | | | | | * struct.c (struct_type_finalize): We must check slot_cache for null. The slot symbols of a struct type being finalized might not have slot caches.
* RELNOTES: repair bad dates.Kaz Kylheku2019-02-181-1/+2
| | | | | * RELNOTES: Restore correct date under TXR 209. Add missing date under 210.
* gc: bug: finalized objects not reclaimed.Kaz Kylheku2019-02-181-1/+11
| | | | | | | | | | | | | | | | | The problem: in an incremental GC run, when an generation 0 object is determined to be unreachable and has a registered finalizer, it ends up hanging around until a full GC. This is because it is marked as if it were reachable (just in case the finalizer re-introduces it into the object graph) and left to be processed at the next GC. However, what's missing is that the object is not in the freshobj array any more, and so it is not reclaimed by the sweep function. Effectively, it's as if the object had been promoted to gen 1. * gc.c (call_finalizers_impl): After invoking a finalizer, if the object is still in gen 0, add it to the freshobj array as if it had just been allocated. If there is no room in the freshobj array, set the full_gc flag, as usual.
* doc: clarify that ftw takes a list or path.Kaz Kylheku2019-02-171-50/+46
| | | | | * txr.1: Make it clearer that ftw operates on a list; that fact was too buried in the documentation.
* save-exe: new function.Kaz Kylheku2019-02-174-80/+86
| | | | | | | | | | | | | | * lisplib.c (save_exe_instantiate, save_exe_set_entries): New static functions. (lisplib_init): Register auto-load of save-exe module, keyed to save-exe symbol. * share/txr/stdlib/save-exe.tl: New file. * txr.1: Removing txr-embedded-arg.txr documentation and documenting save-exe in its place. * txr-embedded-arg.txr: File removed.
* scan-until-match, count-until-match: new functions.Kaz Kylheku2019-02-163-9/+83
| | | | | | | | | | | | | * regex.c (scan_until_common): New static function, made from read_until_match. (read_until_match): Now just wrapper for scan_until_common. (scan_until_match, count_until_match): New functions. (regex_init): Registered new intrinsics scan-until-match and count-until-match. * regex.h (read_until_match, scan_until_match): Declared. * txr.1: Documented.
* fill-buf-adjust: new function.Kaz Kylheku2019-02-163-1/+34
| | | | | | | | | * stream.c (fill_buf_adjust): New function. (stream_init): Register fill-buf-adjust intrinsic. * stream.h (fill_buf_adjust): Declared. * txr.1: Documented.
* buf-alloc-size: new function.Kaz Kylheku2019-02-163-0/+18
| | | | | | | | | * buf.c (buf_alloc_size): New function. (buf_init): buf-alloc-size intrinsic registered. * buf.h (buf_alloc_size): Declared. * txr.1: Documented.
* buf: fix wrong function name string.Kaz Kylheku2019-02-161-1/+1
| | | | * buf.c (length_buf): Replace incorrect name.
* sysrooting: trailing slash needed on directory.Kaz Kylheku2019-02-161-0/+4
| | | | | | | | | * txr.c (sysroot_init): prog_dir is missing a trailing slash, and this breaks the fallback case when we're running a renamed txr executable in the build directory. The presence of the trailing slash had also been documented for the txr-path variable, which is now obsolescent and undocumented. That is hereby fixed.
* txr-exe-path: New variable.Kaz Kylheku2019-02-152-4/+4
| | | | | | | | | * txr.c (sysroot_init): Make prog_path available via the txr-exe-path variable. The txr-path variable becomes obsolescent. * txr.1: Documented txr-exe-path; removed documentation for txr-path.
* linenoise: preserve too-large-to-read file.Kaz Kylheku2019-02-151-2/+11
| | | | | | * linenoise.c (edit_in_editor): If we can't read the file, then preserve the file, and replace the command line buffer with an error message in which the name of that file appears.
* listener: fix buffer overflow reading external file.Kaz Kylheku2019-02-151-6/+1
| | | | | | | | | When an external file is edited, and is longer than the listener's buffer allows, the buffer overflows, trashing the other fields in the linenoise structure, and memory beyond. * parser.c (lino_gets): Decrement nchar in the loop. Also, eliminate useless return case.
* linenoise: bugfix: vertical skip problem.Kaz Kylheku2019-02-141-1/+3
| | | | | | | | | | | | | | | | | | | | | This relates to the optimized insert at the end of the line. The following bug manifests itself. When the cursor is not at the bottom of the screen (e.g. fresh terminal after a clear screen), if blank lines are added to the buffer and then backspace is hit, the cursor strangely jumps down by multiple lines prior to the refresh. In a Windows CMD.EXE window, this shows up even at the bottom of the screen, because the CMD.EXE console responds to a downward movement (ESC[<n>B) beyond the bottom row by scrolling the screen, rather than clipping the movement. * linenoise/linenoise.c (refresh_multiline): When doing the elided refresh (l->need_refresh == 2), we must update not only l->maxrows but also l->oldrow. Otherwise when we do the real update, it will think that the cursor is on the first line, and try to move down to the last line.
* structs: derive type id from pointer.Kaz Kylheku2019-02-151-54/+8
| | | | | | | | | | | | | | | * struct.c (uptopow2_0, uptopow2_1, uptopow2_2, uptopow2_3, uptopow2_4, uptopow2_5, uptopow2): New macros. (struct struct_id_recycle): Declaration removed. (struct_id_counter, struct_id_stack): Static variables removed. (get_struct_id, recycle_struct_id): Static functions removed. (struct_type_finalize): No need to recycle struct ID; don't call removed recycle_struct_id function. (make_struct_type): Don't call removed get_struct_id to allocate ID. Rather, cast the struct_type handle pointer to unsigned integer, and divide by the next smallest power of two.
* structs: fix poorly maintained bitfield size.Kaz Kylheku2019-02-151-1/+1
| | | | | | | | * struct.c (struct struct_inst): When the dirty flag was added, the id field was not decreased by one bit to make space, so the desired packing is not being achieved any more. Let's just use TAG_SHIFT to reserve the maximum bits that will still let us fit a fixnum into id.
* structs: recycle IDs of dead struct types.Kaz Kylheku2019-02-151-7/+71
| | | | | | | | | | | | | * struct.c (nelem): New macro. (struct struct_id_recycle): New struct type. (struct_id_counter): Initialize to 1 instead of zero. (get_struct_id, recycle_struct_id): New static functions. (struct_type_finalize): From each slot symbol, remove the struct type's ID from it slot cache, and finally recycle the struct type ID. (make_struct_type): Use get_struct_id to obtain an ID for the new struct type, rather than directly incrementing the global counter.
* Version 210.txr-210Kaz Kylheku2019-02-146-619/+642
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* linenoise: fix multi-line mode regression.Kaz Kylheku2019-02-141-5/+16
| | | | | | | | | When Enter is input in multi-line mode, a ^M appears instead of advancing to the next line. When the display is refreshed, the ^M's are properly treated as line breaks. * linenoise.c (edit_insert): Let's restructure the conditional ladder here into a switch and handle ENTER by issuing CR-LF.
* Optimize hash operation with unsafe car/cdr.Kaz Kylheku2019-02-147-115/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The associative lists that make up the chains of a hash table are guaranteed to be made of conses. We can use unsafe versions of car, cdr, rplaca and rplacd to speed up hash operations. * eval.c (op_dohash): Use unsafe operations on hash cell. * filter.c (trie_compress, regex_from_trie): Likewise. * hash.c (hash_equal_op, hash_print_op, hash_mark, hash_grow, hash_assoc, hash_assql, copy_hash_chain, gethash, inhash, gethash_n, sethash, remhash, hash_next, maphash, do_weak_tables, group_by, group_reduce, hash_keys_lazy, hash_keys, hash_values_lazy, hash_values, hash_pairs_lazy, hash_pairs, hash_alist_lazy, hash_uni, hash_diff, hash_symdiff, hash_isec, hash_subset, hash_update, hash_update_1, hash_revget): Likewise. * lib.c (us_rplaca, us_rplacd): New functions. (package_local_symbols, package_foreign_symbols, where, populate_obj_hash, obj_hash_merge): Use unsafe operations on hash cell * lib.h (us_rplaca, us_rplacd): Declared. * parser.c (circ_backpatch, get_visible_syms): Use unsafe operations on hash cell. * struct.c (method_name, get_slot_syms): Likewise.
* gethash_c: review uses and improve or replace.Kaz Kylheku2019-02-145-35/+32
| | | | | | | | | | | | | | | | | | | | * eval.c (env_fbind, env_vbind, reg_symacro): Use gethash_l instead of gethash_c to eliminate repeated cdr operations on the same cell. * hash.c (sethash): Since new_p is never used, eliminated it and use nulloc. (group_reduce): Use gethash_l instead of gethash_c. * lib.c (obj_init): Replace rplacd(gethash_c(...)) pattern whose return value is not used with with sethash. We lose some diagnosability here since sethash doesn't take a "self" argument. (obj_print_impl, obj_hash_merge): Use gethash_l instead of gethash_c. * parser.y (ensure_parser, parser_circ_def, get_visible_syms, rlset): Use gethash_l instead of gethash_c.
* gethash_f: removing function.Kaz Kylheku2019-02-143-45/+33
| | | | | | | | | | | | | | | | Uses of gethash_f can be replaced with gethash_e, which returns the hash cell directly rather than through a loc argument. Code that needs the value can call cdr itself. * hash.c (inhash, hash_isec, hash_update_1): Replace gethash_f with gethash_e. (gethash_f): Function removed. * hash.h (gethash_f): Declaration removed. * lib.c (use_sym, unuse_sym, find_symbol, unintern, intern_fallback, in, sel, populate_obj_hash): Replace gethash_f with gethash_e.
* symdiff: new function.Kaz Kylheku2019-02-144-9/+70
| | | | | | | | | | | | * eval.c (eval_init): Register symdiff intrinsic. * lib.c (symdiff): New function. * lib.h (us_car_p, us_cdr_p): New inline functions. (symdiff): Declared. * txr.1: Documented, also fixing issues not related to symdiff doc.
* optimizing diff, isec and uni for non-lists.Kaz Kylheku2019-02-134-41/+109
| | | | | | | | | | | | | | | Also, these functions now support hashes. * eval.c (eval_init): Register only the deprecated set-diff to the set_diff function. The diff intrinsic is now going to the new function named diff. * lib.c (diff): New function. (isec, uni): Rewritten to use seq_iter_t. * lib.h (diff): Declared. * txr.1: Documentation updated.
* num: reduce duplicate code.Kaz Kylheku2019-02-131-3/+1
| | | | | * lib.c (num): Use num_fast instead of an expression that is identical to the body of that inline function.
* Framework for iterating over sequences.Kaz Kylheku2019-02-132-0/+94
| | | | | | | | | | | | | | | | This has been needed for a while. While we have seq_info for classifying sequences to nicely dispatch code into various cases, those cases duplicate code. The code base could benefit from generic traversal. * lib.c (seq_iter_get_nil, seq_iter_get_list, seq_iter_get_vec, set_iter_get_hash): New static functions. (seq_iter_rewind, seq_iter_init): New functions. * lib.h (struct seq_iter, seq_iter_t): New struct type and its typedef name. (seq_iter_init, seq_iter_rewind): Declared. (seq_get): New inline function.
* hash-from-alist: new function.Kaz Kylheku2019-02-133-1/+33
| | | | | | | | | * hash.c (hash_from_alist_v): New function. (hash_init): Register hash-from-alist intrinsic. * hash.h (hash_from_alist_v): Declared. * txr.1: Documented.
* hash-symdiff: new function.Kaz Kylheku2019-02-133-1/+57
| | | | | | | | | * hash.c (hash_symdiff): New function. (hash_init): hash-symdiff intrinsic registered. * hash.h (hash_symdiff): Declared. * txr.1: Documented.
* hash-uni: bugfix.Kaz Kylheku2019-02-131-2/+6
| | | | | | | | * hash.c (hash_uni): The join function must only be called for the values of keys that exist in both hashes. The broken logic here unconditionally calls the join function for all keys in the left hash (using nil as the right join value when the key doesn't exist in the right hash).
* doc: fix reference to nonexistent load-value.Kaz Kylheku2019-02-111-2/+2
| | | | | | * txr.1: In Notes under load-time, the function is once referred to as load-value; also the phrase load-time value is used that can just be load-time.
* Version 209.txr-209Kaz Kylheku2019-02-086-551/+626
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* build: get rid of .tlo2 files.Kaz Kylheku2019-02-081-12/+3
| | | | | | | | | | | | | | | After the defvar bugfix in the previous commit, the only differences between .tlo and .tlo2 files are the names of a few gensyms here and there. In other words, they are identical code; therefore, there is no point in compiling them. * Makefile (STDLIB_TLOS2): Variable removed. (%.tlo2): Implicit rule removed. (stage1 stage2): Phony targets removed. (all): Directly depends on $(STDLIB_TLOS) without stage1 intermediary. (clean-tlo): Don't remove $(STDLIB_TLOS2).
* defvar: spectacular bug causing wrong compile.Kaz Kylheku2019-02-081-2/+6
| | | | | | | | | | | The defvar/defparm macro expander marks symbols special only at macro-expansion time, without actually generating code in the macro expansion to do this. This means that the compiled versions of defvar and defparm forms will code will neglect to create a dynamically scoped variable! * eval.c (me_def_variable): Add code to the output to mark the symbol special, for defvar or defparm.
* ffi: closure: clear stale saved exit point.Kaz Kylheku2019-02-071-0/+2
| | | | | | | | | | | | | | | | | What happens if a FFI closure intercepts an exception, returns to the foreign code, but that caller does not return to Lisp where the exception will continue? Suppose the caller invokes another closure. In that situation, the lingering value of the s_exit_point variable causes problems for FFI calls. An example of this is callbacks from an event dispatching framework such as a GUI. When these callback closures return, control returns to the event loop, which itself doesn't immediately return to Lisp code. Rather, it processes more events and invokes more callbacks. * ffi.c (ffi_closure_dispatch_safe): One thing we can do is clear s_exit_point whenever we dispatch a closure.
* ffi: use padded return size in closure dispatch.Kaz Kylheku2019-02-071-2/+3
| | | | | | | * ffi.c (ffi_closure_dispatch_safe): When initially clearing a return value that has release semantics, use the padded size, not the nominal size. Let's get calculate this once and put it in a local.
* ffi: don't pad void return size to sizeof (ffi_arg).Kaz Kylheku2019-02-071-1/+1
| | | | * ffi.c (pad_retval): If the size is zero, don't pad it.
* bugfix: ffi-make-closure safe-p param.Kaz Kylheku2019-02-061-1/+1
| | | | | | * ffi.c (ffi_make_closure): Fix wrong argument defaulting on safe_p_in parameter, which leaves it always true, preventing unsafely dispatched closures from being created.
* doc: formatting under ffi-make-closure.Kaz Kylheku2019-02-061-2/+2
| | | | * txr.1: Run-on period on identifier; extra words.
* bugfix: deffi-cb-unsafe not autoloaded.Kaz Kylheku2019-02-061-0/+1
| | | | | * lisplib.c (ffi_set_entries): Add missinig autoload entry for deffi-cb-unsafe.
* ffi: make-zstruct must ignore padding slots.Kaz Kylheku2019-02-061-2/+4
| | | | | | | * ffi.c (make_zstruct): Don't convert zeros to a Lisp type and don't try to set the slot, if the slot name is nil. That's a padding slot which doesn't exist in the Lisp type; the slotset will blow up on it.