[Vm-dev] Funny Floats [WAS OpenSmalltalk current on aarch64]

tesonep at gmail.com tesonep at gmail.com
Wed Dec 11 16:45:32 UTC 2019


Hi Ken,
 this is a problem in an optimization of GCC 8.3 (I am not sure what
other versions are impacted).
Basically it is generating bad a function, removing code that assumes
that is dead code.
Even though this is a bug in GCC, because there is not actual reason
to remove the code.
It is produced because the code is not written in a nice way.

Basically, if someone wants to fix it in the VM code is modifying a
single method:

Spur64BitMemoryManager >> fetchLong32: fieldIndex ofFloatObject: oop
    "index by word size, and return a pointer as long as the word size"

    | bits |
    (self isImmediateFloat: oop) ifFalse:
        [^self fetchLong32: fieldIndex ofObject: oop].
    bits := self smallFloatBitsOf: oop.
    ^ fieldIndex = 0
        ifTrue: [bits bitAnd: 16rFFFFFFFF]
        ifFalse: [bits >> 32]

The old method had a handwritten piece of C code to replace the last if:

(self cCoerceSimple: (self addressOf: bits) to: #'int *') at: fieldIndex

I assume it was done to handle a different kind of endianness, but the
single sender of this message is already doing the handling and having
different behavior depending on the endianness.

With this fix the build can still be executed with -O2 optimization in GCC 8.3

Cheers,

On Sat, Dec 7, 2019 at 4:20 PM <ken.dickey at whidbey.com> wrote:
>
>
> > Have you tried switching off compiler optimisations?
>
> Ah!  I had forgotten that one.  I thought that was changed in mvm.
>
> Image works fine noe (but more slowly!) on aarch64 Alpine Linux
> (musl+busybox).
>
> I am just out the door fir a couple of days but will try fdlib on
> return.
>
> Thanks again to all!
> -KenD



-- 
Pablo Tesone.
tesonep at gmail.com


More information about the Vm-dev mailing list