| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
* protsym.c: Regenerated.
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/op.tl (sys:*op-ctx*) Move definition before
the make-struct-type call which instantiates the sys:op-ctx
structure type, because the variable is referenced in that
expression and treated as lexical. This situation now
generates a warning.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* parser.c (read_file_common): Allow version three
object files.
* share/txr/stdlib/compiler.tl (compiler comp-var): If a
global variable isn't special, then treat it via the getlx
instruction. The symbol gets added to the symtab, and
referenced by index number.
(compiler comp-setq): Similarly, treat a non-special
global variable using the setlx instruction.
(%tlo-ver%): We bump the major version of .tlo files
from 2 to 3, since old txr executables won't recognize
these new instructions. However, we are backward compatible;
hence read_file_common still allows version 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These instructions can be used for accessing cached global
variable bindings through the symtab of the vm descriptor.
The compiler will use these for optimizing access to global
lexical variables.
* share/txr/stdlib/asm.tl (op-getlx, op-setlx): New opcode
classes.
* vm.c (vm_stab): Take the lookup function as an argument,
so this can be used for variable bindings.
(vm_gcall, vm_gapply): Pass lookup_fun function to vm_stab,
as well as the appropriate string for the unbound error.
(vm_gettab, vm_settab): New static functions.
(vm_execute): Implement GETLX and SETLX using vm_gettab and
vm_settab.
* vmop.h: Regenerated.
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:awk-code-move-check): A symbol
in the sys: package is being used just for the English word
that its name supplies, so print it using ~a so the sys:
prefix doesn't appear.
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (expand-quasi-mods): Fix
misspelled "missing". Small repro test case to trigger
the diagnostic: (compile-toplevel '`@{"" []}`) where,
note, there is nothing between the square brackets.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Harmonizing with the previous change to eval, the
compiler should also handle those situations.
* share/txr/stdlib/compiler.tl (compile-file): do not perform
a full expansion on each object that it reads from the file
before passing it into the top-level walk. Rather, the
raw form is passed into the top-level walk. It is partially
expanded with macro-expand, and this is repated at each
descent of the recursion. Only forms which are not top-level
forms are then fully expanded before compilation, by not
passing the t argument to compile-toplevel.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (opip_s, oand_s, chain_s, chand_s): Variables
removed.
(me_opip): Function removed.
(eval_init): Initializations of removed variables removed.
chain and chand symbols interned at point of function
registration.
* lisplib.c (op_set_entries): Add autoload entries for opip
and oand.
* share/txr/stdlib/op.tl (sys:opip-expand): New function.
(opip, oand): New macros.
* protsym.c: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The op macro is no longer written in C, but the trivial macros
ap, ip, ado, ido, ret and aret are still C. It's silly to
have macros written in C, baked into the TXR executable, which
just produce syntax for a complicated macro written in Lisp
that must be autoloaded when that code is used.
* eval.c (ap_s, apf_s, ipf_s, ret_s, aret_s): Variables removed.
(me_ap, me_ip, me_ado, me_ido, me_ret_aret): Functions removed.
(eval_init): Do not initialize removed variables. Remove
registration for macros ap, ip, ado, ido, ret and aret.
Intern the apf and ipf symbols in the same expression
which registers these functions.
* lisplib.c (op_set_entries): Add autoload entries for ap,
ip, ado, ido, ret and aret.
* share/txr/stdlib/op.tl (ap, ip, ado, ido, ret, aret):
New macros.
* protsym.c: Regenerated.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (usr:compile-file): Check for a
hash bang line in the source file. If so, propagate it
to the compiled file.
* txr.1: Documented existing support for hash bang in .tlo
files, and the translation of hash bang from .tl to .tlo.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The list builder needlessly copies list structure. At
any given moment, the last piece of structure added to
the list can remain shared. We can leave the tail
pointing to that piece and copy it later in a nondestructive
operation.
Also, we would like (build (add 1) (pend 2)) to produce
(1 . 2) rather than an errror. The implementation gives this
to us in the same stroke.
* share/txr/stdlib/build.tl (list-builder :postinit): Just
initialize tail to be head, rather than eagerly chasing to the
last cons.
(list-builder add, list-builder pend, list-builder pend*,
list-builder ncon, list-builder ncon*): Rewrite.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (compiler comp-for): Fix
exception thrown when compiling (for init test step ...)
when test is nil. Firstly, we must distinguish a (nil)
test from (), because the latter means (t). Hence the need for
the test-p Boolean. The list of frags must not contain a
nil, which isn't a frag. The instruction template must not
only omit generating the conditional jump when the test is
absent, but also omit generating the test code (insertion of
tfrag.code) in that case, because tfrag is nil.
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (compiler comp-ift): Fix
incorrect reference to the vec function rather than the
cases-vec local variable. Thus the variable shared is now
correctly calculated, and switch syntax which implements
fall through cases via a single block of shared code is
now translated properly as one block of instructions with
with multiple entry points.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We put the ifql opcode to use for (if (eql ...) ...)
and (if (neql ...) ...) and also constant-fold the constant
cases, like we do for eq.
* share/txr/stdlib/compiler.tl (%test-funs-pos%): Add eql to
list.
(%test-funs-neg%): Add neql to list.
(%test-funs-ops%): New list of corresponding opcodes.
(%test-opcode%): New variable containing a relation function
from equality functions to assembler opcodes.
(compiler comp-ift): Don't hard code the opcode; look it up
from the test function using %test-opcode%.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (%test-inv%): Fix reversed
mapping; the way this is used, it is expected to map the
negative tests to their positive counterparts. This didn't
matter until the previous commit because before that commit,
the value that was computed through this table wasn't used for
anything. It is being used now.
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (copmiler comp-ift): In the
case when both values being compared are constant
expressions, evaluate the comparison statically using the
function, rather than a hard coded eq. Right now, the only
funtion handled is in fact eq.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
* protsym.c: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
| |
This breaks the (next) awk macro, breaking awk expressions
which want to short-circuit to the next record.
* share/txr/stdlib/awk.tl (sys:awk-state loop): The :awk-rec
block is being optimized away by the compiler because it
doesn't contain any direct function calls to functions that
are not in the standard library. We must use block*, which
isn't subject to this optimization.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
| |
Compiling a block* fails with an exception: nil is accessed
as a structure.
* share/txr/stdlib/compiler.tl (comp-block): when compiling
block*, nenv is nil; we must use env when compiling
the name subexpression. Also, we can't use nenv when compiling
the body. We must use nenv when it is available (block case)
or else fall back on env (block* case).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The virtual machine's funvec will be used for global lexical
variables also, so it is being renamed to symvec. Related
structure members, functions and variables are also renamed.
* share/txr/stdlib/asm.tl (disassemble): Print the table
heading as syms: rather than funs:. Follow the rename of
vm-desc-funvec to vm-desc-symvec.
* share/txr/stdlib/compiler.tl (compiler): Slots fidx-cntr
fidx and ftab are renamed to sidx-cntr, sidx and stab, resp.
(compiler get-fidx): Renamed to get-sidx.
(compiler get-funvec): Renamed to get-symvec.
(compiler comp-setqf, compiler comp-catch, compiler
comp-fun-form, usr:compile-toplevel): Follow rename.
(list-from-vm-desc): Follow rename of sys:vm-desc-funvec.
* vm.c (strut vm_desc): Members funvec and ftab renamed to
symvec and stab.
(vm_make_desc): Parameters and local variables renamed.
Follow rename of struct members.
(vm_desc_funvec): Renamed to vm_desc_symvec.
(vm_desc_destroy, vm_desc_mark): Follow rename struct members.
(vm_ftab): Renamed to vm_stab.
(vm_gcall, vm_gapply): Follow rename of vm_ftab.
(vm_init): Register renamed vm_desc_symvec function as
sys:vm-desc-symvec.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Calculation of free symbols emanating out of let, let*, flet
and labels is wrong, not taking into account the differences,
respectively between let and let*, and between flet and
labels. Compilation of lambda also has the same problem;
variable references in initforms are considered free without
regard for shadowing by earlier parameters. Another issue
is the incorrect handling of special variables: special
variable references are incorrectly being considered free
in scopes where they are bound.
* share/txr/stdlib/compiler.tl (compiler comp-let): For
sequential bindings (let*), we must cull the prior variables
from the list of free vars emanating out of each init form;
these references do not emanate out of the binding construct.
We pull the prior vars list out of the environment before
binding the current variable so that it is
not included in the list. Both special and lexical variables
must be considered reference-capturing.
(compiler comp-fbind): If compiling a recursive binding, cull
the newly bound functions from the free references emanating
from the local function bodies. A bug is fixed here that we
were not referring to the correct list of symbols and so not
taking into account the function references inside the local
functions themselves at all.
(compile comp-lambda): Build a correct list of free vars in
relation to the initforms of optional parameters, taking
account the scope, and that special variables capture
references.
|
|
|
|
|
|
|
|
|
|
| |
This makes certain macros cheaper: macros which wrap code
with numerous local functions, not all of which are expected
to be used.
* share/txr/stdlib/compiler.tl (compiler comp-fbind): Detect
functions that are completely unused, and eliminate their
code.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
NB: Accesses to lexical variables are not all marked used yet.
* share/txr/stdlib/compiler.tl (binding): New slot, used.
(sys:env lookup-var, sys:env lookup-fun, sys:env lookup-lisp1,
sys:env lookup-block): Support optional Boolean argument
which, if true, causes the lookup to mark the binding used.
(compiler comp-return-from): Pass t to lookup-block, and
remove code to mark used.
(compiler comp-fun, compiler comp-fun-form): Pass t to
lookup-fun to mark function used.
(compiler comp-lisp1-value): Pass t to lookup-lisp1 to mark
function used.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If code does something like this, we produce a warning:
(let ((var 42))
(load-time (+ var 3)))
A load-time form occurs in an empty lexical environment,
so this code appears right but actually cannot work;
the appearance is a mere trompe d'oeil.
* share/txr/stdlib/compiler.tl (misleading-ref-check): New
function.
(compiler comp-load-time-lit): Apply misleading-ref-check.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The same, correct semantics for special variables in function
arguments get implemented in the compiler.
* share/txr/stdlib/compiler.tl (compiler comp-lambda): We
stick with the strategy that each parameter which is a
special variable is aliased by an anonymous lexical
variable. The difference is that we bind the underlying
special variable from the hidden lexical's value as early as
possible. The overall processing is rearranged. On entry
into the function, if any of the required arguments are
specials, their values are immediately bound to the special
variables in a new environment. Then the optional arguments
are processed, and they bind specials in the dynamic
environment also. Previously, the specials were bound in
one fell swoop after processing the optionals, leading to the
same incorrect semantics that the interpreter code had.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In this patch we eliminate the special operator
sys:with-dyn-rebinds, and implement correct semantics for
dynamically scoped variables that occur in argument
lists.
* eval.c (with_dyn_rebinds_s): Symbol variable removed.
(bind_args): Handle special variables dynamically:
for each symbol that appears, check whether it is a special
and treat accordingly by allocating a new dynamic environment
if necessary, and binding in that environment.
This adds overhead, which is why I moved away from this
approach in the past. But now that there is a compiler,
overhead in the interpreter matters less. Correct semantics
is more important.
(expand_params): Greatly simplified for not having to wrap the
sys:with-dyn-rebinds operator around the body.
(funcall_interp): Since bind_args can now extend the dynamic
environment, it is necessary to save and restore dyn_env
around it. Another call to bind_args occurs in op_catch;
that already saves and restores dyn_env.
(op_with_dyn_rebinds): Static function removed.
(do_expand): with-dyn-rebinds-s case removed.
(eval_init): Removed interning of sys:with-dyn-rebinds
symbol and registration of special op.
* protsym.c: Regenerated.
* compiler.tl (compiler compile): Remove case which handles
sys:with-dyn-rebinds.
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
|
|
|
|
|
|
|
| |
* share/txr/stdlib/error.tl (sys:bind-mac-error,
sys:bind-mac-check): Improve error messages with better
wording. Use ~a for rendering parameter syntax so sys: package
prefixes don't appear.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/asm.tl (assembler immediate-fits-type):
Do not include bignum types as candidates for immediate
operand. We take the sys:bits representation of the object,
and that of course is a pointer. This case actually happens
on 32 bit platforms because the value that is one less than
the most negative fixnum still fits into the fixnum
representational range, due to the way two's complement works,
but is actually a bignum. Concretely, the value #x-20000000
is a bignum, but its width is 29, which falsely suggests that
its representation can fit into 32 bits as a literal.
* share/txr/stdlib/compiler.tl (compiler comp-atom): Test for
fixnum here rather than integerp, so in the above discussed
case, we don't generate a movi instruction.
|
|
|
|
|
| |
* share/txr/stdlib/asm.tl (bits-to-obj): Show the bad
immediate operand in hex.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (compiler comp-atom): The
calculation which determines whether an integer operand fits
into an immediate move instruction is incorrect.
The width function doesn't include a sign bit, so that
must be counted. Also, the immediate operand includes a two
bit type tag: thus we are off by three.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim, protsym.c: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When compile-file writes emits the file, it does so with
*package* bound to a temporary package named "$" so that all
the symbols get fully qualified. Problem is, this is a valid
package name and is added to the package list. While the
package exists, symbols such as $:a could be interned. If such
symbols occur in code being compiled, they get emitted using
unqualified names. Let's introduce an internal interface for
making an anonymous package which isn't on the list of
package, and which has a name that results in bad syntax if it
occurs in print.
* eval.c (eval_init): Register sys:make-anon-package
intrinsic.
* lib.c (make_package_common): New static function.
(make_package): Package construction and initialization
code moved into make_package_common.
(make_anon_package): New function.
* lib.h (make_anon_package): Declared.
* share/txr/stdlib/compiler.tl (usr:compile-file): When
writing out translation, bind *package* to anonymous
package from sys:make-anon-package.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It is time-wasting to have a block in every function. In this
patch we have the compiler eliminate blocks if it is obvious
that they will not be the targets of any exits or continuation
captures through any direct function calls.
If a block contains only calls to library functions,
and doesn't call certain functions, then it is removed.
It is possible for this removal to be strictly wrong
and different from interpreted code. This is true if
the code enclosed in a block invokes a function indirectly or
via a quoted symbol, and that function tries to return from
the block or capture a continuation using that block as
a prompt. Such a call doesn't prevent the block from being
removed.
For instance, this won't work in compiled code
any more:
(defun tricky (fun)
(call fun))
(tricky (lambda () (return-from tricky 42)))
The call function is considered safe; the (call fun)
form doesn't prevent the block inside the tricky
function from being removed.
* share/txr/stdlib/compiler.tl (blockinfo): New struct.
(env): New slot, bb.
(env lookup-block, env extend-block): New methods.
(%block-using-funs%): New global variable.
(compiler comp-block): Implement the elision of the block
based on what free functions are referenced in the body,
and whether the block is referenced lexically.
Also, bind the block in the environment using the bb
member in the env structure.
(comp-return-from): Lookup the block lexically and
mark it as used.
(system-symbol-p): New function.
* txr.1: Document the rules for elision of blocks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The issue is that when load-time forms are present in
top-level forms, the execution of those forms destructively
manipulates the data table. This is bad when we intend to
write out the compiled forms into a file; we need to write
them out in their freshly compiled state before these side
effects took place.
* share/txr/stdlib/compiler.tl (list-from-vm-desc): When
serializing the compiled VM pieces to a list, make a freshly
allocated shallow copy of the data vector. This could be
optimized away if we know that the VM doesn't contain
load-time effects.
|
|
|
|
|
|
|
|
|
| |
When compiling a plain (f x) function call, the
resulting frag must list f as a free function.
* share/txr/stdlib/compiler.tl (comp-fun-form): Compile the
call with comp-call-impl; then pushnew the symbol into the
frag's ffuns set list.
|
|
|
|
|
|
|
|
|
|
| |
Oops; (return x), equivalent to (return-from nil x), is being
miscompiled as if it were (sys:abscond-from nil x).
* share/txr/stdlib/compiler.tl (comp-return): When
short-circuit-recursing into comp-return-from, put return-from
into the operator position, because that function checks for
that symbol.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (error_set_entries): Add sys:bind-mac-check to
autoload list for error.tl
* compiler.tl (expand-bind-mac-params): For strict mode, use
the new sys:bind-mac-check function to do the check and
report the error. For non-strict checks, consolidate the
error check by taking advantage of n-ary nature of <=
function.
* error.tl (sys:bind-mac-check): New function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is similar to the ANSI CL load-time-value.
* eval.c (load_time_s, load_time_lit_s): New symbol variables.
(op_load_time_lit, me_load_time): New static functions.
(eval_init): Intern load-time symbol and sys:load-time-lit.
Register the sys:load-time-lit special operator and load-time
macro.
* share/txr/stdlib/asm.tl (assembler parse-args): We must
now allow the d registers to be the targets of a mov
instruction, because load-time depends on being able to mutate
the data vector, in order to turn the result of a calculation
into a de facto literal.
* share/txr/stdlib/compiler.tl (compiler): New member,
lt-frags.
(compile-in-toplevel): New macro.
(compiler alloc-dreg): New method.
(compiler compile): Handle sys:load-time-lit special form
via comp-load-time-lit method.
(compiler comp-load-time-lit): New method.
(usr:compile-toplevel): Prepend the load-time assembly code
fragments to the compiled assembly code.
* vm.c (vm_set, vm_sm_set): Do not reject an attempt to modify
the static data, since load-time now generates mov
instructions targetting the d registers.
* txr.1: Document load-time.
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (compiler): Remove the nreg
slot. It is not referenced anywhere.
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.t (compiler get-dreg): Replace
"out of registers" message with something more pertinent.
The problem is that the code has too many literals for
the maximum table size.
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (compiler get-dreg): A let*
with just one variable in it is changed to let.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Give the sys:fmt-simple function argument defaulting so the
generated code doesn't have to call it with all five arguments
present, four of them nil being much of the time.
* eval.c (fmt_simple): Default all but the first four
arguments.
(eval_init): Re-register sys:fmt-simple as having only one
required argument.
* parser.c (read_file_common): Load version 1 or 2 files.
We are bumping the object file version to 2 because
now when we compile files, they won't work with older
TXR in which all five arguments to sys:fmt-simple are
required.
* share/txr/stdlib/compiler.tl (expand-quasi-mods):
Generate the sys:fmt-simple call with just enough
arguments to express the modifiers that were decoded.
(sexpand-quasi-args): Reduce the trivial modifier-less
sys:fmt-simple calls to just one argument.
(%tlo-ver%): Bump major version to 2.
|
|
|
|
|
|
| |
share/txr/stdlib/awk.tl (sys:awk-redir): Put the unused gensym
to use: evaluate the path expressio nonce into the gensym
variable. Also move strangely place comma.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim, protsym.c: Regenerated.
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (yield_set_entries): Add hlet and hlet* to
autoload list.
* share/txr/stdlib/yield.tl (hlet-expand): New function
(hlet, hlet*): New macros.
* txr.1: Documented.
|
|
|
|
|
|
|
|
| |
share/txr/stdlib/asm.tl (operand-to-sym): Print t and d
registers with three digits, like is done with the index
portion of v regs already.
(disassemble-cdf): Print three-digit d regs in data table
dump.
|