From 44c8e70f810ad52b0f26f06147d5613ed1271900 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 4 Nov 2018 11:52:03 -0800 Subject: compiler: optimize dwim. * share/txr/stdlib/asm.tl (op-getf): Rename to op-oldgetf. This opcode becomes obsolescent. (op-getf): New opcode. * share/txr/stdlib/compiler.tl (assumed-fun): New global variable. (compiler comp-fun): Use the new getf instruction which takes a function table index instead of a data table index. (compiler comp-lisp1-value): Don't use getl1 opcode any more for dynamic lisp1-style lookup. Instead, we bake the behavior at compile time perform a function lookup if the symbol is completely unbound, a variable lookup if it is bound to a variable (where we decide at compile tie whether it is lexical or dynamic) or else a function if a function binding exists at compile time. Also, if we assume that an unbound symbol is a function, put it on the assumed-fun list. (compiler comp-dwim): If the first argument is a symbol with no lexical binding, and is not bound as a variable, then treat it as a function by transforming the form into a function call form with that symbol in the car position. Put the symbol on the assumed-fun list. (compiler-emit-warnings): New function. (with-compilation-unit): Call compiler-emit-warnings when bailing out of most enclosing compilation unit. (%tlo-ver%): Bump compiled file version to 4, since we added an opcode. * vm.c (vm_execute): Follow rename of GETF to OLDGETF. Implement the new GETF. * parser.c (read_file_common): Extend version range to allow version 4 compiled files. * txr.1: Documented everything. --- vm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'vm.c') diff --git a/vm.c b/vm.c index c0a0d505..26d73304 100644 --- a/vm.c +++ b/vm.c @@ -991,7 +991,7 @@ NOINLINE static val vm_execute(struct vm *vm) case GETV: vm_getsym(vm, insn, lookup_var, lit("variable")); break; - case GETF: + case OLDGETF: vm_getsym(vm, insn, lookup_fun, lit("function")); break; case GETL1: @@ -1024,6 +1024,9 @@ NOINLINE static val vm_execute(struct vm *vm) case SETLX: vm_settab(vm, insn, lookup_var, lit("variable")); break; + case GETF: + vm_gettab(vm, insn, lookup_fun, lit("function")); + break; default: uw_throwf(error_s, lit("invalid opcode ~s"), num_fast(opcode), nao); } -- cgit v1.2.3