summaryrefslogtreecommitdiffstats
path: root/share
Commit message (Collapse)AuthorAgeFilesLines
...
* vm/asm/compiler: parametrize display parameters.Kaz Kylheku2018-04-163-45/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this patch we replace some hard-coded constants related to the dimensions of the frame display, which will make it easier to experiment with changes to the configuration: to set up wider frames at the cost of max display depth. The encoding of small operands needs to be abstracted because games can be played here. A 10 bit small operand can be configured in various ways: for instance a 5:5 split would mean that the first 32 entries in the first 32 levels can be small operands. That's independent of the display configuration. * share/txr/stdlib/asm.tl: Load vm-param to get some fundamental constants. (small-op-p): New macro. (assembler parse-args, parse-compound-operand, parse-operand, operand-to-sym): Use constants. (enc-small-oip, small-op-to-sym): New macros. (op-frame asm): Use constants. Small range check problem fixed here: a frame level of 1 mustn't be allowed. (op-movrs, op-movsr, op-mov-pseudo, op-movsmi, op-movrbi, op-movi-pseudo, op-retsr, op-retrs, op-retrr, op-ret-pseudo, op-getv, op-setv): Deal with small operand via functions. (op-close): Use constants. Off-by-one problem: frame size of 256 must be allowed. * share/txr/stdlib/compiler.tl: Load vm-param to get constants. (compiler get-dreg, compiler get-funvec): Use constant for max frame size. (compiler new-env): Check for maximum levels being exceeded. (compiler comp-atom): Use constant for maximum immediate integer operand width. * share/txr/stdlib/vm-param.tl: New file. * vm.c (vm_insn_extra_dec_small): New macro. (VM_LEV_BITS, VM_LEV_MASK, VM_SM_LEV_BITS, VM_SM_LEV_MASK): New preprocessor constants. (vm_lev, vm_idx, vm_sm_lev, vm_sm_idx): New macros. (vm_get, vm_set): Use macros instead of literals. (vm_sm_get, vm_sm_set): New inline functions. (vm_movrs, vm_movsr, vm_movsmi, vm_retsr, vm_retrs, vm_abscsr, vm_get_binding, vm_bindv): Use vm_sm_get or vm_sm_set to access the display using the small operand. (vm_close): Use preprocessor symbols instead of hard-coded literals.
* compiler: lambda call to let optimization.Kaz Kylheku2018-04-152-6/+79
| | | | | | | | | | | | | | | | | | | Normalize ((lambda ...) args) to (call (lambda ...) args). Reduce (apply (lambda ...) args) and (call (lambda ...) args) to let (let (vars-inited-from-args ...) ...). * lisplib.c (error_set_entries): Autoload for new error functions lambda-too-many-args, lambda-too-few-args, lambda-short-apply-list. * share/txr/stdlib/compiler.tl (comp-fun-form): Restructure to recognize lambda and handle via comp-inline-lambda. (compiler comp-inline-lambda): New method. (lambda-apply-transform): New function. * share/txr/stdlib/error.tl (lambda-too-many-args, lambda-too-few-args, lambda-short-apply-list): New functions.
* compiler: use new parser for macro params.Kaz Kylheku2018-04-151-100/+80
| | | | | | * share/txr/stdlib/compiler.tl (expand-bind-mac-parse-params): Function removed. (expand-bind-mac-params): Use mac-param-parser struct.
* compiler: move lambda param parsing into struct.Kaz Kylheku2018-04-141-85/+116
| | | | | | | | * share/txr/stdlib/compiler.tl (param-parser-base, fun-param-parser, mac-param-parser): New structs. (compiler comp-lambda): Construct a fun-param-parser object using parameter syntax. Then just extract the parsed pieces for further processing.
* compiler: lambda: accurate determination of need-frame.Kaz Kylheku2018-04-141-3/+3
| | | | | | | | | | | | | * share/txr/stdlib/compiler.tl (comp-lambda): The local variable need-frame is supposed to indicate whether the lambda needs a frame for its arguments: i.e. whether it has any parameters. However the way it is calculated is poor: the fixed-pars list potentially includes the semicolon symbol : which separates the required parameters from optionals. Hence the parameter list syntax (:) will be treated as "needs frame", even though it denotes an empty parameter list, just like the syntax (). This slight flaw is now tightened up.
* compiler: bugfix: handle lambda call form.Kaz Kylheku2018-04-131-0/+2
| | | | | | | | | Looks like the compiler neglects to handle the syntax ((lambda (params ...) body ...) args ...). * share/txr/stdlib/compiler.tl (compiler compile): Check for a lambda expression in the car position of a form; if it's present then ((lambda ...) ...) -> (call (lambda ...) ...).
* compile-file: need endian mark in .tlo files.Kaz Kylheku2018-04-121-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | VM machine code is endian-specific: it consists of 32 bit instruction words which are 32 bit in the local byte order. Thus code assembled on a little-endian machine won't run on a big endian-machine, or vice versa: unless we identify the situation and byte-swap the code when we load it. * buf.c (buf_swap32): New function. * buf.h (buf_swap32): Declared. * parser.c (read_file_common): Decode the third element from the version: a Boolean indicating big endian, if true. If the object file's endian is opposite from our endian, then byte swap the code. * itypes.c (itypes_init): Oops, calculation of itypes_little_endian was broken due to classic C =/== typo. Luckily, nothing has used this flag so far; it's been waiting for this first use. I caught this due to testing on a PPC64 box. * share/txr/stdlib/compiler.tl (%big-endian%, %tlo-ver%): New variables. (usr:compile-file): The file version comes from %tlo-ver% now, which includes the big-endian flag.
* Version 191.txr-191Kaz Kylheku2018-04-101-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* defpackage: bugfix: symbol clash.Kaz Kylheku2018-04-101-3/+3
| | | | | | | | * share/txr/stdlib/package.tl (defpackage): Now that library file are read in the sys package, this macro's name-str local variable is the same symbol as sys:name-str, the function it uses. They clash in the (op sys:name-str ...) syntax. Let's rename the local.
* compiler: implement with-compilation-unit macro.Kaz Kylheku2018-04-091-36/+46
| | | | | | | | | | | | * lisp.c (compiler_set_entries): Add with-compilation-unit to autoload symbols for compile module. * share/txr/stdlib/compiler.tl (usr:with-compilation-unit): New macro. (usr:compile-file): Use with-compilation-unit macro to dump warnings if a file is processed alone. * txr.1: Documented.
* compiler: record source loc when reading.Kaz Kylheku2018-04-091-0/+1
| | | | | | | * share/txr/stdlib/compiler.tl (usr:compile-file): Bind *rec-source-loc* to t, otherwise the read function doesn't record source loc info and we don't get warnings reported against line numbers in the processed source files.
* compiler: improve and & or.Kaz Kylheku2018-04-091-27/+30
| | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-and-or): Handle the trivial zero and one argument cases separately. In particular, the one-argument case results in better code because it eliminates a temporary register. We don't have to test for the zero-arg case any more in the general case, so it is simplified in a few cases.
* awk/struct: fix breakage under interpreted mode.Kaz Kylheku2018-04-092-8/+8
| | | | | | | | | | | | | | References to rslot must be usr:rslot because there is a sys:rslot. Some difference in loading order causes this not to be a problem when runing compiled "make tests", but if the .tlo files are removed, the awk test case fails. * share/txr/stdlib/awk.tl (sys:awk-mac-let): Replace rslot with usr:rslot. * share/txr/stdlib/struct.tl (rslot): Replace rslot symbol token with usr:rslot in definitions of rslot macro and rslot place macro.
* compiler: fix broken prog1.Kaz Kylheku2018-04-081-3/+3
| | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-prog1): The output of the frag should be fireg, not oreg. We need to move into fireg before re-frag.code is executed, because the data source in fi-frag may be clobbered by re-frag.
* trace: refer usr:catch operator rather than sys:catch.Kaz Kylheku2018-04-081-3/+3
| | | | | | * share/txr/stdlib/trace.tl (sys:trace, sys:untrace): Now that library code is being read in the sys package, catch refers to the sys:catch special form; we want the usr:catch macro here.
* trace: bugfix: redefine check mustn't throw exceptions.Kaz Kylheku2018-04-081-6/+10
| | | | | | | | | * share/txr/stdlib/trace.tl (sys:trace-canonicalize-name): Don't call static-slot-home on something that might not be a struct type symbol. Otherwise the trace module will throw whenever some lookup is performed for a non-existent method. That means that when trace is loaded, it is impossible to define a method with defun.
* compiler: fix overestimated register count.Kaz Kylheku2018-04-072-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The compiler internally allocates registers that are never inserted into code (but correctly recycled). Thus the treg bump counter overestimates the actual number of registers that a VM requires; but that's how we use it! That causes wasted stack space. What we can do to get a tightly clamped register count is simply to let the assembler report the highest-numbered treg operand that it finds in the code. (In the future we will need something better to optimize the register allocation. Why: because closures have their own VM instance with its own registers. If an overall VM uses registers t00 through t09, but a certain closure uses only t02 through t06, that closure's frame only needs to allocate seven registers.) * share/txr/stdlib/asm.tl (assembler): New slot, max-treg. (assembler parse-args): Whenever a register operand is parsed, if it is a t register, update max-treg. * share/txr/stdlib/compiler.tl (usr:compile-toplevel): When creating the vm-desc, determine the nreg parameter from the assembler's max-treg value, rather than from the compiler's treg allocation bump counter.
* new function: compile.Kaz Kylheku2018-04-071-0/+15
| | | | | | * lisplib.c (compiler_set_entries): Add compile to autoloads. * share/txr/stdlib/compiler.tl (usr:compile): New function.
* asm: support disassembly on functions.Kaz Kylheku2018-04-071-8/+19
| | | | | | | | | | * share/txr/stdlib/asm.tl (disassemble): Drop usr: prefix since symbol is interned already in usr package. Handle vm functions by obtaining their vm desc and entry point. Disassemble whole desc, then indicate entry point. The fallback case tries the object as a potential function name and recurses, so (disassemble '(meth struct slot)) and (disassemble 'name) will work.
* asm: rename disassembly helper function.Kaz Kylheku2018-04-061-2/+2
| | | | | | | | * share/txr/stdlib/asm.tl (disassemble-c-d): Rename to disassemble-cdf. These letters stand for code, data vector, function vector. The name had been was chosen before the VM had function vectors. (usr:disassemble): Follow rename.
* stdlib: all code read under sys package.Kaz Kylheku2018-04-0614-51/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Another part of the preparation for an upcoming change. All library code is now read in the sys package, so any symbols that are interned (local variables and whatnot) are in sys and will not be exposed to user code. We have to overcome some annoyances to achieve this: - We have to stay away from the symbols exp or var, because they are now sys:exp and sys:var with their special meaning. - Instances in which a symbol of the same name exists in both sys and usr present a problem; the plain symbol now is the usr one. For instance rplaca will refer to sys:rplaca, so a small amount of code has to explicitly use usr:rplaca. * Makefile (COMPILE_TL): Change to the sys package before compiling library code. * lisplib.c (lisplib_try_load): Bind *package* to the system package. * share/txr/stdlib/asm.tl, share/txr/stdlib/compiler.tl: Remove in-package macro invocation; we don't need this since all files are loaded or compiled in the sys package. * share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl, share/txr/stdlib/error.tl, share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl, share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/trace.tl share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/ver.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl: Deal with the various usr versus sys symbol issues.
* structs: get rid of sys:slot and sys:static-slot.Kaz Kylheku2018-04-061-4/+4
| | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (defstruct, sys:check-slot, defmeth): Use slot rather than sys:slot as indicator in tentative defs. * struct.c (static_slot_s): Variable removed. (struct_init): slot_s initialized with symbol in user package, rather than system package. Initialization of static_slot_s removed. Existing slot function now registered using slot_s. (static_slot_type_reg): Remove reference to static_slot_s. This was a dud all along; nothing publishes deferred warnings against this symbol. * protsym.c (protected_sym): Remove static_slot_s.
* trace: add missing copyright header.Kaz Kylheku2018-04-051-0/+26
| | | | * trace.tl: File was introduced in 2016, so 2016-2018.
* compile-file: handle gensyms and such.Kaz Kylheku2018-04-051-6/+13
| | | | | | | | | | | | | | | | | | | * parser.c (read_file_common): The entire compiled representation is now one big list. We must walk the list to visit the individual compiled top-level forms. * share/txr/stdlib/compiler.tl (compile-file): Collect all the compiled top-level forms into one list, and emit it as one object. This way, gensym references among the items will resolve; for instance tests/012/man-or-boy.tl now compiles. That file defines a function named by a gensym, and a macro which expands to calls to that function. These end up in separate top-level forms and have to resolve. Because we are emitting everything as one big object, we cannot rely on (in-package ...) forms influencing the reading of the symbols. So we create a dummy package and switch to that during the writing, which forces all symbols to be fully qualified.
* compile-file/load: add version to files.Kaz Kylheku2018-04-051-0/+1
| | | | | | | | | | * parser.c (read_file_common): Treat first form in file as a version number of the form (major minor), where major nad minor are non-negative integers. If the major number is greater than zero, reject the file as incompatible. * share/txr/stdlib/compiler.tl (usr:compile-file): Emit version number (0 0) as the first item in a compiled file.
* compiler: bugfix: quasilit cannot use append.Kaz Kylheku2018-04-041-1/+1
| | | | | | | | | | | append is too generic, and produces nil sometimes. Let's use a custom run-time support function sys:fmt-join. * eval.c (fmt_join): New function. (eval_init): Intern sys:fmt-join. * share/txr/stdlib/compiler.tl (expand-quasi): Generate a sys:fmt-join call to combine the pieces rather than append.
* hash: with-hash-iter bug found by new compiler.Kaz Kylheku2018-04-041-2/+2
| | | | | | | | The compiler barfed on hash.tl, reporting an if form with too many arguments in the with-hash-iter macro, indicating that it's basically broken. * share/txr/stdlib/hash.tl (with-hash-iter): Repair the macro.
* compiler: bugfix: broken Lisp forms in quasiquote.Kaz Kylheku2018-04-041-1/+1
| | | | | | | | * share/txr/stdlib/compiler.tl (expand-quasi-args): When the element of the quasiquote is a compound form, we can't just return it. Firstly, because we are appending, we must wrap each returned item in a list. Secondly, we must wrap the form in code which formats it into a string consistently.
* stdlib: remove macro-time.Kaz Kylheku2018-04-043-22/+19
| | | | | | | | | | | | | | These top-level macro-time forms are preventing code from being compiled. * share/txr/stdlib/ifa.tl: Remove macro-time around sys:if-to-cond function. * share/txr/stdlib/package.tl: Remove macro-time around sys:name-str. * share/txr/stdlib/struct.tl: Remove macro-time around sys:bad-slot-syntax and sys:prune-missing-inits.
* compiler: move sys:bind-mac-error to error.tl.Kaz Kylheku2018-04-042-7/+7
| | | | | | | | | | | | | | | | | | | | | | | The sys:bind-mac-error function is a run-time support function for the compiler-generated code for destructuring. But the compiler.tl source file is a bad place for it. It means that compiled modules which need sys:bind-mac-error auto-load the entire compiler. That easily creates an irresolveable cycle, because the compiler is on top of the foodchain. No, sys:bind-mac-error belongs in error.tl; the light-weight module of low-dependency run-time support routines for error reporting. * lisplib.c (error_set_entries): Add sys:bind-mac-error symbol here. (compiler_set_entries): Remove it from here. * share/txr/stdlib/compiler.tl (sys:bind-mac-error): Function removed. * share/txr/stdlib/error.tl (sys:bind-mac-error): Function moved here.
* asm: changes for compiling.Kaz Kylheku2018-04-041-19/+20
| | | | | | | | | * share/txr/stdlib/asm.tl (assembler): Wrap with compile-only so we don't redefine this struct while we are compiling the assembler. (%oc-code%): Use defparml so this is reset to zero, so that the opcodes are numbered from zero instead of the most recent value left in the variable.
* compile-file: don't compile constants.Kaz Kylheku2018-04-041-1/+2
| | | | | | * share/txr/stdlib/compiler.tl: Skip top-level forms which are just constants. Their value is discarded and they have no effect.
* compiler: don't add compile-time gensym into env.Kaz Kylheku2018-04-041-3/+3
| | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-tree-case): The block name isn't a lexical variable; do not add it to nenv via extend-var. Just bind to gensym directly and insert where needed. This reduces the run-time frame size by one entry.
* macro param lists: remove colon hack.Kaz Kylheku2018-04-041-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Going forward, when : appears as the argument of an optional parameter in destructuring, it is treated as an ordinary object, and not as "this argument is missing". That is now a feature of function calls only. Rationale: interferes with macros. For instance, the pattern (test : then else) doesn't correctly express the arguments of if, because (if x y :) eats the semicolon. The defaulting behavior is not useful because usually there is no default value for optional structure, other than nil. * eval.c (bind_macro_params): Only implement the colon hack under compatibility with 190. * share/txr/stdlib/place.tl (defplace gethash, defplace fun, defplace symbol-function, defplace symbol-macro, defplace symbol-value): Remove uses of : for defaulting the ssetter argument. This illustrates how useless the feature is for macro destructuring; all these just replace with nil. * txr.1: Clarify that macro parameter lists don't implement the colon trick. It was never explicitly specified that this is the case, but could have been inferred from the statements which indicate that macro parameter lists copy the features of function parameter lists. Added compat notes.
* places: remove macro-time.Kaz Kylheku2018-04-031-129/+126
| | | | | | | | | | | | Uses of the macro-time form are not useful in this module, and will hinder compilation, since forms evaluated by macro-time are not seen by the compiler and thus cannot be emitted in compiled form into a compiled file. * share/txr/stdlib/place.tl: Remove all top-level occurrences of macro-time. (defplace): Remove macro-time emitted in expansion, replacing it by progn.
* compiler: rewrite incorrect defmacro expander.Kaz Kylheku2018-04-031-6/+8
| | | | | | | | | | * share/txr/stdlib/compiler.tl (expand-defmacro): We cannot simply generate a mac-param-bind form because that has no means to pass through the all-important macro environment parameter; its expansion is carried out by expand-bind-mac-params with an nil environment parameter. Instead, we retarget to use expand-bind-mac-params directly, and supply the parameter gensym.
* compiler: first cut compile-file implementation.Kaz Kylheku2018-04-031-12/+88
| | | | | | | | | | | | | | | | | | | | | | * lisplib.c (compiler_set_entries): Autoload on compile-file. * parser.c (parse_init): Expose get-parser, parser-errors and parser-eof intrinsics in system package. * share/txr/stdlib/compiler.tl (compiler): Wrap defstruct form in compile-only. What this means is that when we invoke comile-file on compiler.tl, the compiler will only compile this defstruct and not evaluate it. I.e. it will not try to redefine the structure. Redefining the core structure of the compiler while it is compiling itself wreaks havoc on the compilation. (%fille-suff-rx%, *emit*, *eval*): New variables. (open-compile-streams, list-from-vm-desc, usr:compile-file): New functions. * vm.c (vm_desc_nlevels, vm_desc_nregs): New static functions. (vm_init): Register new intrinsics vm-desc-nlevels and vn-desc-nregs in system package.
* asm/compiler: use unadorned sym in in-package.Kaz Kylheku2018-04-032-2/+2
| | | | | * share/txr/stdlib/asm.tl, share/txr/stdlib/compiler.tl: Just use (in-package sys) rather than (in-package :sys).
* eval/compile: special ops compile-only & eval-only.Kaz Kylheku2018-04-031-1/+1
| | | | | | | | | | | | | | | | These forms will be specially recognized by the file compiler when they appear as top-level forms. eval-only will mean this: only execute this form (possibly after compiling it); do not emit any compiled code into the output file. compile-only will mean: only emit the compiled code into the output file; do not execute it. * eval.c (eval_init): Register special operators compile-only and eval-only. In the interpreter, these are equivalent to progn and so route to op_progn. * share/txr/stdlib/compiler.tl (compiler compile): Similarly to interpreter, handle compile-only and eval-only as progn.
* compiler: bugfix: missing case in cond.Kaz Kylheku2018-04-021-0/+1
| | | | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-cond): Add handling for the case when the cond clause contains only a test form, and no additional forms. In that case, if the value is true, then cond terminates with that value. We can nicely achieve this by using or. This was uncovered while compiling share/txr/stdlib/awk.tl, which contains such a case in (sys:awk-state loop) that handles opening the input source.
* compiler: bugfix: block: missing mov to oreg.Kaz Kylheku2018-04-021-1/+2
| | | | | | | | | | * share/txr/stdlib/compiler.tl (comp-block): Our output frag indicates that oreg is the output register, and in the case when the block is terminated by the dynamic return, that's where it stores the result value before branching to the skip address. In the ordinary termination case, we have neglected to move the output of the block's code from bfrag.oreg to the output register oreg.
* compiler: unwind-protect bug: wrong output reg.Kaz Kylheku2018-04-021-1/+1
| | | | | | | * share/txr/stdlib/compiler.tl (comp-unwind-protect): The output register of the compiled unwind-protect is that of the protected forms compiled in pfrag, not of the compiled code for the cleanup forms in cfrag.
* compiler: switch: bugfix: missing mov to oreg.Kaz Kylheku2018-04-021-0/+5
| | | | | | | * share/txr/stdlib/compiler.tl (comp-switch): When compiling the shared case of switch (generated by tagbody), we must identify the last fragment's output register and move that to oreg.
* compiler: switch bugfix: missing index code.Kaz Kylheku2018-04-021-1/+2
| | | | | | | | * share/txr/stdlib/compiler.tl (comp-switch): Emit the code for evaluating the switch index. This has been working by fluke, because when the index is a variable, the assembly code for ifrag is nil; the swtch instruction accesses the variable directly and all is cool.
* compiler: big oreg-related bugfixKaz Kylheku2018-04-011-40/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | There is a smattering of incorrect logic affecting a number of the compiler's special form sub-compilers. Basically the issue is that a compiler routine cannot arbitrarily use the oreg that it is given. If it generates multiple instructions which clobber a destination, only the last clobber may target oreg. The reason is that oreg is not necessarily a fresh temporary that can be used arbitrarily. It can be a variable which is evaluated by the forms that are compiled by the sub-compiler. Prematurely storing a value into oreg can affect the behavior and result value of not-yet executed code. The recent "indirect function calls" fix addressed just one case of this; the problem is more wide-spread. * share/txr/stdlib/compiler.tl (compiler (maybe-alloc-treg, maybe-free-treg)): New methods. (compiler (comp-if, comp-switch, comp-unwind-protect, comp-block, comp-handler-bind, comp-catch, comp-let, comp-progn, comp-and-or, comp-prog1, comp-for, comp-call, comp-tree-case): Do not carelessly use oreg for intermediate computations; allocate one or more temporary registers for that purpose, and either only move the final value into oreg, or else indicate a temporary register as the returned frag's output register.
* compiler: bugfix: wrong lambda frame size.Kaz Kylheku2018-04-011-1/+1
| | | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-lambda): We must not deduce the frame size from the nenv v-counter, because in the case when no frame is needed (the function has no arguments), nenv is just env. Our need-frame variable indicates whether or not a frame is needed; if not, we must use size zero. This is crucial because the VM otherwise ends up throwing an exception due to the frame level mismatch.
* compiler: bugfix: return value optionalKaz Kylheku2018-04-011-2/+2
| | | | | | * share/txr/stdlib/compiler.tl (comp-return-from, comp-return): The value expression is optional in all the return operators.
* compiler: bug: indirect function calls.Kaz Kylheku2018-04-011-1/+3
| | | | | | | | * share/txr/stdlib/compiler.tl (comp-call): We must not use the output register oreg for compiling the expression which calculates the function because it could be one of the arguments. In that case, we clobber an argument before we have called the function.
* compiler: bugfix: bad len check for tree-case.Kaz Kylheku2018-04-011-3/+5
| | | | | | | | | * share/txr/stdlib/compiler.tl (expand-bind-mac-params): When the strict parameter is the keyword symbol : we are mis-translating the length check. We are ignoring the presence of the rest-par, and checking for an exact length. When rest-par is present, we must check only for a minimum number of fixed parameters.
* compiler: bugfix: incorrect jmp in catch.Kaz Kylheku2018-04-011-3/+1
| | | | | | | | | | * share/txr/stdlib/compiler.tl (comp-catch): The emitted code doesn't handle the normal non-exception path. It assumes that only the frame established with the earlier frame instruction needs to be terminated; but in fact the catch intruction's frame has to be ended also. Thus we don't need the frame-end label; all exit cases jump too the handler-end label in front of the two end instructions.