[squeak-dev] Cog+NativeBoost @ Mac OS

John M McIntosh johnmci at smalltalkconsulting.com
Fri Dec 10 19:31:08 UTC 2010


Oh, yes in fact 5? years back I changed the FFI call for this because the Sophie team make a QuickTime FFI call and it was curtains....  Until I too read that "innocent little note".

In fact it's even worst than you can imagine since some bright software engineer said. Oh if the stack is 16 bytes aligned and well we've only 12 bytes here, well hah I'll be clever and use that 4 bytes of padding for working storage...  Unfortunately that just happens to be some Squeak VM local var, but no matter I'm sure the VM will crash *later*.... 


On 2010-12-10, at 10:14 AM, Eliot Miranda wrote:

> 
> 
> On Fri, Dec 10, 2010 at 5:36 AM, Igor Stasenko <siguctua at gmail.com> wrote:
> Yeah, i just found post which confirms my guess :)
> 
> http://blogs.embarcadero.com/eboling/2009/05/20/5607
> 
> <<
> In the Mac OS X ABI Function Call Guide there is an innocent little
> sentence:  "The stack is 16-byte aligned at the point of function
> calls."  We’ve not been able to find out why this is required for the
> IA-32 environment, but they really mean it, and there are deep
> implications.
> >>
> 
> And the reason is to allow the use of sse2 instructions on locals in functions, which requires correct stack alignment because certain sse instructions will trap on unaligned addresses.  In fact this is now a general requirement on common x86 platforms, i.e. current linux variants, as well as Mac OS X.  If you have a look at Cog and the FFI code there-in you'll see it carefully maintains 16-byte stack alignment for calls form machine-code into the interpreter run-time and from the FFI to external code.  See e.g. CogIA32Compiler>>genAlignCStackSavingRegisters:numArgs:wordAlignment: and ReentrantFFIPlugin class>>perambleCCode.
> 
> cheers
> Eliot
> 
>  
> 
> how nice of them, isn't?  :))
> 
> --
> Best regards,
> Igor Stasenko AKA sig.
> 
> 
> 

--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20101210/4ee7297b/attachment.htm


More information about the Squeak-dev mailing list