|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
TXR is moving to custom assembly-language routines.
This is mainly motivated by a very dubious thing done in the
GNU C Library setjmp and longjmp in the name of security.
Evidently, glibc's setjmp "mangles" certain pointer values
which are stored into the jmp_buf buffer. It's been that way
since 2005, evidently. This means that, firstly, all along,
the use of setjmp in gc.c to get registers into a buffer so
they can be scanned has not actually worked properly. More
importantly, this pointer mangling in setjmp and longjmp is
very hostile to a stack copying implementation of delimited
continuations. The reason is that continuations contain
jmp_buf buffers, which get relocated in the process of
capturing and reviving a continuation. Any pointers in a
jmp_buf which point into the captured stack segment have to be
fixed up to point into the relocated location. Mangled
pointers make this difficult, requiring hacks which are
specific to glibc and the machine architecture. We might as
well implement a clean, well-behaved setjmp and longjmp.
* Makefile (jmp.o): New object file.
(dbg/%.o, opt/%.o): New rules for .S prerequisites.
* args.c, arith.c, cadr.c, combi.c, cadr.c, combi.c, debug.c,
eval.c, filter.c, glob.c, hash.c, lib.c, match.c, parser.c,
rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c,
syslog.c, txr.c, unwind.c, utf8.c: Removed <setjmp.h>
include.
* gc.c: Switch to struct jmp and jmp_save, instead
of jmp_buf and setjmp.
* jmp.S: New source file.
* signal.h (struct jmp): New struct type.
(jmp_save, jmp_restore): New function declarations
denoting assembly language routines in jmp.S.
(extended_jmp_buf): Uses struct jmp instead of
setjmp.
(extended_setjmp): Use jmp_save instead of setjmp.
(extended_longjmp): Use jmp_restore instead of
longjmp.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Function arguments are now allocated on the stack using alloca,
in conjunction with the struct alloc header structure.
The generic_funcall and apply functions are refactored
for this, as are most functions that take variadic arguments.
* args.c (args_add_list, args_cons_list): Functions removed.
(args_normalize, args_normalize_fill): New functions.
(args_get_checked): Draw arguments from list when array runs out.
(args_copy, args_copy_zap): New functions.
* args.h (ARGS_MAX): Reduced to 32.
(ARGS_MIN): New preprocessor symbol.
(args_init): Call args_init_list.
(args_add2, args_add3, args_add4): New inline functions.
(args_more): Take into account list, which may hold additional arguments.
(args_two_more): New inline function.
(args_normalize, args_normalize_fill): Declared.
(args_get_list): Normalize all arguments into one list and return it.
(args_get_rest, args_at, args_atz): New inline functions.
(args_get): Draw arguments from list when array runs out.
(args_clear): New inline function.
* arith.c (maskv): Convert to new args.
* eval.c (APPLY_ARGS): Preprocessor symbol removed.
(bind_args): Converted to accept struct args.
(apply): Function reduced down to trivial adapter which
converts a list of arguments to args, and calls the new
generic_funcall.
(applyv): New static function: struct args wrapper
around apply_intrinsic.
(iapply): Converted to struct args.
(call): Static function removed. The call intrinsic
function binding now goes directly to generic_funcall.
(list_star_intrinsic, interp_fun): Converted to struct args.
(op_catch): Adjustments for bind_args, which requires
a struct args arglist.
(me_op): Must use the new minl and maxl, since minv and maxv
don't take lists any more.
(mapcarv, mappendv, lazy_mapcarv, lazy_mappendv, mapdov,
weavev, or_fun, and_fun, tf, nilf, do_retf, do_apf,
do_ipf, callf, do_mapf, mapf): Converted.
(mapcarl): New function, like the old mapcarv.
(eval_init): call_f initialized from generic_funcall
rather than call. apply registered to applyv rather than
apply_intrinsic. Registrations for zip, hash_from_pairs, vec,
alist-remove, alist-nremove, and throw similarly updated to
new or renamed functions.
* eval.h (interp_fun, mapcarv): Declarations updated.
(mapcarl): Declard.
* hash.c (hashv): Converted to struct args.
(hashl): New function.
(hash_construct): Use hashl, not hashv.
(hash_from_pairs, hash_list, group_by): Converted.
* hash.h (hashv, hash_construct, hash_from_pairs, hash_list,
group_by): Declarations updated.
(hashl): Declared.
* lib.c (appendv, nconcv, lazy_appendv): Converted to
struct args.
(lazy_appendl): New function.
(multi): Converted.
(listv): New function.
(nary_op, plusv, mulv, logandv, logiorv, gtv, ltv, gev, lev,
numeqv, numneqv, maxv, minv): Converted.
(maxl, minl): New functions, like old maxv and minv.
(exptv, gcdv, lcmv, lessv, greaterv, lequalv, gequalv): Converted.
(func_f0v, func_f1v, func_f2v, func_f3v, func_f4v): Converted.
(func_n0v, func_n1v, func_n2v, func_n3v, func_n4v): Converted.
(func_n0v, func_n1v, func_n2v, func_n3v, func_n4v): Converted.
(func_n1ov, func_n2ov, func_n3ov): Converted.
(generic_funcall): Converted to take struct args.
(funcall, funcall1, funcall2, funcall4): Pass stack-allocated
struct args as trailing arguments to variadic functions, and to
generic_funcall.
(do_curry_12_1_v): New struct-args-based static function,
needed to implement curry_12_1_v now.
(curry_12_1_v): Converted.
(transposev): New function based on previous tranpose.
(transpose): Now a wrapper for transposev.
(do_chain, chainv, do_chand, chandv, do_juxt, juxtv,
do_and, andv, do_or, orv, do_not, do_iff): Converted.
(vectorv): New function. Implementation basis for vec intrinsic function.
(alist_removev, alist_nremovev): New functions.
(multi_sort): Switch from mapcarv to mapcarl.
(unique): Converted.
(uniq): Allocate struct args for calling unique.
(obj_init): list_f function now based on new listv, rather than
identity.
* list.h (varg): New typedef.
(struct func): All variadic function pointers converted to use
struct args.
(appendv, nconcv, lazy_appendv, multi, nary_op, plusv, minusv,
mulv, gtv, ltv, gev, lev, numeqv, numneqv, maxv, minv, exptv,
gcdv, lcmv, logadnv, logiorv, maskv, lessv, greaterv, lequalv,
gequalv, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v,
func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n0v,
func_n1v, func_n2v, func_n3v, func_n4v, func_n1ov, func_n2ov,
func_n3ov, generic_funcall, chainv, chandv, juxtv, adnv, orv,
unique): Declarations updated.
(lazy_appendl, listv, maxl, minl, transposev,
vectorv, alist_removev, alist_nremovev): Declared.
* stream.c (make_catenated_stream_v): New function.
(aformat): Renamed to formatv. The recognition of the nil
and t streams (standard output and string) is done here now.
(vformat): Follow rename of aformat to formatv.
(formatv): Function removed. Nobody calls this anymore.
(stream_init): make-catenated-stream re-registered to new
make_catenated_stream_v function.
* stream.h (formatv): Declaration updated.
(make_catenated_v): Declared.
* syslog.c (syslog_init): syslog registred to syslog_wrapv.
(syslog_wrapv): New function based on syslog_wrap converted to struct
args.
(syslog_wrap): Now wrapper for syslog_wrapv.
* syslog.h (syslog_wrapv): Declared.
* unwind.h (uw_throwv): New function.
(uw_throwfv, uw_errorfv): Converted to struct args.
* unwind.h (uw_throwv): Declared.
(uw_throwfv, uw_errorfv): Declarations updated.
|