I see this in SqueakVM souce, interp.c.
sqInt dummyReferToProxy(void) { interpreterProxy = interpreterProxy; }
It looks strange to me. Can someone give me a clue?
Thanks.
Ang Beepeng
2009/7/30 Ang Beepeng beepeng86@yahoo.com:
I see this in SqueakVM souce, interp.c.
sqInt dummyReferToProxy(void) { interpreterProxy = interpreterProxy; }
It looks strange to me. Can someone give me a clue?
it is a dummy function, referring to proxy :) It is done on purpose, because otherwise Code generator could decide to not declare the interpreterProxy variable, because it is not used anywhere. Of course, it would be better if we could tell this explicitly to codegen.. but dummy fn does the same..
Thanks.
Ang Beepeng
View this message in context: http://www.nabble.com/dummyReferToProxy-tp24733239p24733239.html Sent from the Squeak - Dev mailing list archive at Nabble.com.
There is also a SLANG optimization step involved. It's exploited by the GC code.
The smalltalk code for the GC logic consists of a number of methods, mark & sweep for example. Normally these would be translated into individual C procedure calls, but the first optimization the SLANG translator does is fold small methods that follow certain rules into the caller, and deletes the method in question. There is a method in the image that notes methods it should not delete since an outside caller would use them. So most of the GC logic which is spread over a few methods in Smalltalk get nicely folded into a single C procedure. By doing this C optimizing compiler are more happy about you.
Now the 2nd optimization is that after folding all these smaller methods into a particular caller and we find that the scope of variables that would be global actually are *ONLY* used by this method then we make the variables local versus global in scope. As a side effect this would make a global variable then become a local variable used in a particular method. Of course if you are depending on this variable to actually be global in scope you now have a problem
To defeat that optimization you need a dummy method that refers to the variable so that SLANG then thinks the global variable is used in two different methods, thus it cann't be made into a local.
On 30-Jul-09, at 3:07 AM, Igor Stasenko wrote:
2009/7/30 Ang Beepeng beepeng86@yahoo.com:
I see this in SqueakVM souce, interp.c.
sqInt dummyReferToProxy(void) { interpreterProxy = interpreterProxy; }
It looks strange to me. Can someone give me a clue?
it is a dummy function, referring to proxy :) It is done on purpose, because otherwise Code generator could decide to not declare the interpreterProxy variable, because it is not used anywhere. Of course, it would be better if we could tell this explicitly to codegen.. but dummy fn does the same..
-- = = = ======================================================================== John M. McIntosh johnmci@smalltalkconsulting.com Twitter: squeaker68882 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com = = = ========================================================================
squeak-dev@lists.squeakfoundation.org