<br><br><div class="gmail_quote">On Thu, Jul 3, 2008 at 6:19 PM, Igor Stasenko <<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>> 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 <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>>:<br>
><br>
><br>
> On Thu, Jul 3, 2008 at 5:48 PM, Igor Stasenko <<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>> wrote:<br>
>><br>
>> 2008/7/4 Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>>:<br>
>> > Hi All,<br>
>> ><br>
>> > does anyone know (or even better has anyone fixed it) how hard it is<br>
>> > to<br>
>> > make Slang inline methods that contain simple type declarations?<br>
>> ><br>
>> > I would like to eliminate compile-time integer/pointer mismatch errors<br>
>> > in<br>
>> > the new StackInterpreter I'm writing. I'd like to say things like:<br>
>> ><br>
>> > callerSPOf: theFP<br>
>> > "Answer the SP of the caller provided theFP is not a base frame.<br>
>> > This points to the hottest item on the frame's stack."<br>
>> > self var: #theFP type: 'char *'.<br>
>> > self returnTypeC: 'char *'.<br>
>> > self assert: (self isBaseFrame: theFP) not.<br>
>> > ^theFP + FoxCallerSavedIP + ((self frameNumArgs: theFP) + 2 *<br>
>> > BytesPerWord)<br>
>> > but Slang refuses to inline anything that has C declarations. I'm<br>
>> > guessing<br>
>> > that the issue is moving the type information from the method to its<br>
>> > inlined<br>
>> > form. It took me half a day to discover where Slang refuses to inline<br>
>> > (should have looked in the obvious place<br>
>> > CCodeGenerator>>collectInlineList,<br>
>> > instead of in the inlining code :/ ). So I'm afraid to waste the time<br>
>> > trying to find out where the restriction bites. Anyone know how to fix<br>
>> > this<br>
>> > or better still have a fix?<br>
>> ><br>
>><br>
>> Doesn't 'self inline: true' helps?<br>
><br>
> No. Slang refuses to inline anything containing a C declaration<br>
> (retrnTypeC:, var:type: cCode:inSmalltalk: etc)<br>
><br>
>><br>
>> Or, can't you circumvent that by coercing a value to corresponding<br>
>> type at call site? Like:<br>
>><br>
>> newSP := self cCoerce: (self callerSPOf: blabla) to: 'char *'.<br>
><br>
> That's worse than the disease :) There are many more uses than definitions.<br>
> So I want the uses to look clean and I'll tolerate noisy definition. There<br>
> are also argument types to consider. localIP has type char * for example,<br>
> so where it is used as an argument I want the argument type to be char * or<br>
> void *, etc.<br>
><br>
><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: 'void **foo = malloc(arg1)'.<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 collectInlineList.<br>
<br>
hasCCode := false. "m declarations size > 0."<br>
<br>
Its not safe, and you'll get a lot of compiler errors.</blockquote><div><br><br>I did that. I got lots of errors :)<br> </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. The translator rips out methods it can't inline that refer to these. So lots of methods end up getting deleted unless they're inlined.<br>
<br>The localFoo scheme may or may not be important for performance. I don't want to rip it out until I can measure in a working VM whether it has any effect or not. I want to measure my new VM not the old one 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. So its easier to do without the declarations. But I'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>