<br><br><div class="gmail_quote">On Thu, Jul 3, 2008 at 6:19 PM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="Wj3C7c">2008/7/4 Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt;:<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Jul 3, 2008 at 5:48 PM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; 2008/7/4 Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt;:<br>
&gt;&gt; &gt; Hi All,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; &nbsp; &nbsp; does anyone know (or even better has anyone fixed it) how hard it is<br>
&gt;&gt; &gt; to<br>
&gt;&gt; &gt; make Slang inline methods that contain simple type declarations?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I would like to eliminate compile-time integer/pointer mismatch errors<br>
&gt;&gt; &gt; in<br>
&gt;&gt; &gt; the new StackInterpreter I&#39;m writing. &nbsp;I&#39;d like to say things like:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; callerSPOf: theFP<br>
&gt;&gt; &gt; &quot;Answer the SP of the caller provided theFP is not a base frame.<br>
&gt;&gt; &gt; This points to the hottest item on the frame&#39;s stack.&quot;<br>
&gt;&gt; &gt; self var: #theFP type: &#39;char *&#39;.<br>
&gt;&gt; &gt; self returnTypeC: &#39;char *&#39;.<br>
&gt;&gt; &gt; self assert: (self isBaseFrame: theFP) not.<br>
&gt;&gt; &gt; ^theFP + FoxCallerSavedIP + ((self frameNumArgs: theFP) + 2 *<br>
&gt;&gt; &gt; BytesPerWord)<br>
&gt;&gt; &gt; but Slang refuses to inline anything that has C declarations. &nbsp;I&#39;m<br>
&gt;&gt; &gt; guessing<br>
&gt;&gt; &gt; that the issue is moving the type information from the method to its<br>
&gt;&gt; &gt; inlined<br>
&gt;&gt; &gt; form. &nbsp;It took me half a day to discover where Slang refuses to inline<br>
&gt;&gt; &gt; (should have looked in the obvious place<br>
&gt;&gt; &gt; CCodeGenerator&gt;&gt;collectInlineList,<br>
&gt;&gt; &gt; instead of in the inlining code :/ ). &nbsp;So I&#39;m afraid to waste the time<br>
&gt;&gt; &gt; trying to find out where the restriction bites. &nbsp;Anyone know how to fix<br>
&gt;&gt; &gt; this<br>
&gt;&gt; &gt; or better still have a fix?<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; Doesn&#39;t &#39;self inline: true&#39; helps?<br>
&gt;<br>
&gt; No. &nbsp;Slang refuses to inline anything containing a C declaration<br>
&gt; (retrnTypeC:, var:type: cCode:inSmalltalk: etc)<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; Or, can&#39;t you circumvent that by coercing a value to corresponding<br>
&gt;&gt; type at call site? Like:<br>
&gt;&gt;<br>
&gt;&gt; newSP := self cCoerce: (self callerSPOf: blabla) to: &#39;char *&#39;.<br>
&gt;<br>
&gt; That&#39;s worse than the disease :) &nbsp;There are many more uses than definitions.<br>
&gt; &nbsp;So I want the uses to look clean and I&#39;ll tolerate noisy definition. &nbsp;There<br>
&gt; are also argument types to consider. &nbsp;localIP has type char * for example,<br>
&gt; so where it is used as an argument I want the argument type to be char * or<br>
&gt; void *, etc.<br>
&gt;<br>
&gt;<br>
</div></div>I guess i know why it refusing to inline methods with declarations,<br>
because you may write like:<br>
<br>
method: arg1<br>
<br>
| foo |<br>
self var: #foo declareInC: &#39;void **foo = malloc(arg1)&#39;.<br>
<br>
^ foo.<br>
<br>
inliner simply moving any temps into enclosing method.<br>
But here, a situation, where you have a C style declaration and<br>
assignment both.<br>
And ANSI C prohibits declaring vars not in the first lines of function<br>
body. C++ allows it :)<br>
<br>
Try comment a line of code in &nbsp;collectInlineList.<br>
<br>
hasCCode := false. &quot;m declarations size &gt; 0.&quot;<br>
<br>
Its not safe, and you&#39;ll get a lot of compiler errors.</blockquote><div><br><br>I did that. &nbsp;I got lots of errors :)<br>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
GCC will inline your method anyways, so why bother?</blockquote><div><br>The current sources use the localIP localSP localHomeContext localReturnContext localReturnValue scheme to get important variables in registers. &nbsp;The translator rips out methods it can&#39;t inline that refer to these. &nbsp;So lots of methods end up getting deleted unless they&#39;re inlined.<br>
<br>The localFoo scheme may or may not be important for performance. &nbsp;I don&#39;t want to rip it out until I can measure in a working VM whether it has any effect or not. &nbsp;I want to measure my new VM not the old one &nbsp;The benefit of having localFP (the frame pointer) in a register in my VM is likely to be quite high.<br>
<br>I only want the type declarations to eliminate warnings. &nbsp;So its easier to do without the declarations. &nbsp;But I&#39;d like my cake and eat it too, dammit :)<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
<font color="#888888"><br>
--<br>
</font><div><div></div><div class="Wj3C7c">Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</div></div></blockquote></div><br>best<br>Eliot<br>