[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.1.1 LOADNIL optimization bug (was: What's wrong here?)
- From: roberto@... (Roberto Ierusalimschy)
- Date: Wed, 21 Mar 2007 16:01:50 -0300
> IMHO the patch is wrong. One needs to check that the assigned
> variable is a new one and not a parameter. Only then can the
> first LOADNILs be omitted. But this requires restructuring ...
What do you mean by "restructuring"? It seems that an "if" (and an
"else" around the old code) is enough, is it not?
void luaK_nil (FuncState *fs, int from, int n) {
Instruction *previous;
if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
if (fs->pc == 0) { /* function start? */
if (from >= fs->nactvar)
return; /* positions are already clean */
}
else {
previous = &fs->f->code[fs->pc-1];
...
(BTW, I agree that we should scrap this optimization in the next
version.)
-- Roberto