<br><br><div class="gmail_quote">2011/1/13 Levente Uzonyi <span dir="ltr"><<a href="mailto:leves@elte.hu">leves@elte.hu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Thu, 13 Jan 2011, Nicolas Cellier wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Follow up on unused temps :<br>
<br>
Wanna play with temps ? Try this :<br>
<br>
testUnusedVariable<br>
self<br>
compiling: 'griffle | goo | ^nil'<br>
shouldRaise: UnusedVariable;<br>
compiling: 'griffle | | ^[ | goo | ]'<br>
shouldRaise: UnusedVariable;<br>
compiling: 'griffle | | [ | goo | goo := nil. goo] yourself. ^[ | goo | ]'<br>
shouldRaise: UnusedVariable;<br>
compiling: 'griffle | | [ | goo | ] yourself. ^[ | goo | goo := nil. goo]'<br>
shouldRaise: UnusedVariable<br>
<br>
What happens is that Parser.scopeTable has a single entry for 'goo'.<br>
Consequently, the last registered goo wins.<br>
In the 3rd case, the last goo is unused, so hasRef = false, so<br>
UnusedVariable is raised.<br>
In the 4th case, the last goo nowHasRef, and we don't get any UnusedVariable.<br>
<br>
Until we get a scopeTable mapping each temp of each block, we gonna<br>
live in trouble.<br>
</blockquote>
<br></div>
Right. I'd probably create a separate class for the Encoder's scopeTable, because it's accessed in various ways from several places and it's hard to see what change will have side effects in the current code. But I'm a total newbie in this area, so I may be wrong.<br>
</blockquote><div><br></div><div>That's a good idea. One goal for anyone who tries to do anything in this area is to collapse optimized temps. e.g. in the following</div><div><br></div><div> 1 to: self size do: [:i| ...].</div>
<div> 1 to: self size do: [:j| ...]</div><div><br></div><div>or</div> 1 to: self size do: [:i| ...].<br> 1 to: self size do: [:i| ...].</div><div class="gmail_quote"><br></div><div class="gmail_quote">the current scope table makes it really hard to use the same temp slot for either i and j or both i's. Since these temps are out of scope after their blocks their temps should be reused. But the compiler keeps the in-scope/out-of-scope info in the temp nodes themselves, so this can't be done.</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">Collapsing temps of different names is probably not feasible because there's no way to add teh necessary scope information to the debugger temp names string and so no way of saying "temp #T is called 'i' from bytecode M to bytecode N but is called 'j' from bytecode O to bytecode P". But collapsing temps with the same name is straight-forward and judging by all the code I've eyeballed in working on the closure compiler I'd say it was worth it, not least because certain large methods would limbo under the 56 slot max temp limit which wouldn't otherwise. remember that GeniePlugin method that couldn't be compiled until it was refactored.</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">2¢</div><div class="gmail_quote">Eliot</div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<font color="#888888">
Levente</font><div><div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Nicolas<br>
<br>
2011/1/12 Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2011/1/12 Levente Uzonyi <<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, 12 Jan 2011, Chris Muller wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I've just posted a new beta image at:<br>
<br>
<a href="ftp://ftp.squeak.org/4.2/" target="_blank">ftp://ftp.squeak.org/4.2/</a><br>
<br>
This one does not have wrecked PackageInfo's, and has most (but not<br>
all) of the aesthetic changes for 4.2.<br>
<br>
The test suite is looking better:<br>
<br>
'CompilerExceptionsTest>>#testUnusedVariable<br>
</blockquote>
<br>
This one is new, I'd be happy if someone could have a look at it.<br>
<br>
</blockquote>
<br>
This is due to latest improvements from Eliot.<br>
Now the BlockNode have their own tempsMark (set by<br>
Parser>>#temporaryBlockVariablesFor:).<br>
The Parser only records top level tempsMark in Parser>>#temporaries.<br>
<br>
If you look at the code in Parser>>#removeUnusedTemps, you see some<br>
defensive programming<br>
((tempsMark between: 1 and: str size)<br>
and: [(str at: tempsMark) = $|]) ifFalse: [^ self].<br>
<br>
But hey, the top level does not have any tempsMark, so the method<br>
prematurely returns without checking for some unused in the blocks.<br>
self<br>
justTriedCompiling: 'griffle | | ^[ | goo | ]'<br>
andItCorrectlyRaised: UnusedVariable.<br>
<br>
Shall we remove the tempsMark protection ?<br>
<br>
Nicolas<br>
<br>
</blockquote>
<br>
</blockquote>
</div></div><br><br>
<br></blockquote></div><br>