From: Sam S. <sd...@gn...> - 2004-10-21 19:52:52
|
> * Bruno Haible <oe...@py...t> [2004-10-21 21:05:22 +0200]: > >> Alas, it works only for flet/labels that are not really closures. >> that's because compiled closures access STACK in a pre-computed way >> which is not correct for the traced closures, so they do not find the >> right values where they are looking for them. > > I don't understand this. The closures are compiled before the outer > function, therefore they cannot know the STACK offsets of the outer > function. The only problem I can see with tracing flet/labels is that > the bytecode operation COPY-CLOSURE needs to be aware of traced closures. (defun foo (x) (flet ((bar (y) (+ x y))) (bar x))) (compile 'foo) (disassemble 'foo) Disassembly of function FOO (CONST 0) = #<COMPILED-CLOSURE FOO-BAR> 1 required argument 0 optional arguments No rest parameter No keyword parameters 9 byte-code instructions: 0 (NIL) 1 (MAKE-VECTOR1&PUSH 1) 3 (LOAD&STOREC 2 0 0) 7 (LOAD&PUSH 0) 8 (COPY-CLOSURE&PUSH 0 1) ; #<COMPILED-CLOSURE FOO-BAR> 11 (LOADC&PUSH 1 0) 14 (LOAD 1) 15 (CALLC) 16 (SKIP&RET 4) NIL (disassemble (ext:local foo bar)) Disassembly of function FOO-BAR (CONST 0) = NIL 1 required argument 0 optional arguments No rest parameter No keyword parameters 4 byte-code instructions: 0 (LOADV&PUSH 0 1) 3 (LOAD&PUSH 2) 4 (CALLSR 2 53) ; + 7 (SKIP&RET 2) NIL (trace (ext:local foo bar)) ;; Tracing function (EXT:LOCAL FOO BAR). ((EXT:LOCAL FOO BAR)) (foo 10) 1. Trace: ((EXT:LOCAL FOO BAR) '10) *** - +: #<UNBOUND> is not a NUMBER The following restarts are available: USE-VALUE :R1 You may input a value to be used instead. (untrace (ext:local foo bar)) ((EXT:LOCAL FOO BAR)) (foo 10) 20 -- Sam Steingold (http://www.podval.org/~sds) running w2k <http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/> <http://www.mideasttruth.com/> <http://www.honestreporting.com> Ernqvat guvf ivbyngrf QZPN. |