[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: byte-code optimizations
From: |
Stefan Monnier |
Subject: |
Re: byte-code optimizations |
Date: |
Tue, 21 Sep 2004 17:05:30 -0400 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux) |
>> Unless I have missed some point here, I think your version of the
>> optimization is the better of the two (all else being equal), because
>> it gets directly to the desired result instead of requiring it to be
>> done in two steps.
> It must also be much simpler (though I never saw what Stefan had).
Yes, it's much simpler. Also my code can break on some bytecode.
More specifically, my code requires that the specpdl stack be unique for any
given point in the byte-code, which is not the case for example if the
bytecode does the equivalent of
if cond
varbind X
endif
...blabla...
if cond
unbind 1
endif
AFAIK, my code works for any bytecode coming out of the current bytecode
compiler (barring bugs), but it might break with some other
bytecode compiler.
>> However, there is still the question of whether we should
>> change the standard defsubst to work the way defsubst* does.
> Maybe we can even use `defmacro' for `caar' and friends. Since
> they evaluate their lone argument only once, there must not be
> any problems, right?
Just think of (mapcar 'caar x)
> If this (or `defsubst*') works, I'll investigate whether this
> byte-code optimization gives any improvement after such a change.
What defsubst* does is treat the argument as a kind of "lexically scoped"
variable, but only in very limited ways. I.e. the
(defsubst* caar (x) (car (car x)))
will expand:
(caar y) => (car (car y))
(caar (f y)) => (let ((x (f y))) ..cl-gunk.. (car (car x)))
[ The cl-gunk is stuff added by CL for CL such as a `catch' statement. ]
If you ignore the nasty cl-gunk, I think the resulting optimization is
similar to what we get, except it works in a few more cases.
E.g. it'll expand
(defsubst* foo (x) (symbol-value x))
(foo y) => (symbol-value y)
whereas our optimization won't be able to do that because it can't assume
a "somewhat lexically scoped" semantics.
Stefan
- byte-code optimizations, Paul Pogonyshev, 2004/09/18
- Re: byte-code optimizations, Stefan, 2004/09/18
- Re: byte-code optimizations, Richard Stallman, 2004/09/19
- Re: byte-code optimizations, Paul Pogonyshev, 2004/09/19
- Re: byte-code optimizations, Richard Stallman, 2004/09/21
- Re: byte-code optimizations, Paul Pogonyshev, 2004/09/21
- Re: byte-code optimizations,
Stefan Monnier <=
- Re: byte-code optimizations, Miles Bader, 2004/09/21
- Re: byte-code optimizations, Paul Pogonyshev, 2004/09/21
- Re: byte-code optimizations, Miles Bader, 2004/09/21
- Re: byte-code optimizations, Paul Pogonyshev, 2004/09/21
- Re: byte-code optimizations, Richard Stallman, 2004/09/22
- Re: byte-code optimizations, Paul Pogonyshev, 2004/09/22
Re: byte-code optimizations, Richard Stallman, 2004/09/18