[Vm-dev] Primitive 40 (asFloat) fails for me

Eliot Miranda eliot.miranda at gmail.com
Tue Feb 19 17:17:47 UTC 2019


Hi Christian,

On Tue, Feb 19, 2019 at 8:05 AM Christian Kellermann <ckeen at pestilenz.org>
wrote:

>  * Tobias Pape <Das.Linux at gmx.de> [190219 17:02]:
> >
>
> > Hi,
> >
> > > On 19.02.2019, at 12:25, Christian Kellermann <ckeen at pestilenz.org>
> wrote:
> > >
> > > Hi,
> > >
> > > I am currently using the latest VM with commit
> > > f9ae4a1479122b448fcfdc80bb2caa09b53aa474
> > >
> > > On a Squeak image:
> > >
> > > -----
> > > /home/ckeen/Sync/src/Muffin/Squeak5.2-18225-64bit.dependents.image
> > > Squeak5.2
> > > latest update: #18231
> > > Current Change Set: Unnamed1
> > > Image format 68021 (64 bit)
> > >
> > > Virtual Machine
> > > ---------------
> > >
> /home/ckeen/src/playground/opensmalltalk-vm/products/sqcogspur64linuxht/lib/squeak/5.0-201902181742/squeak
> > > Croquet Closure Cog[Spur] VM [CoInterpreterPrimitives
> VMMaker.oscog-eem.2509]
> > > Unix built on Feb 19 2019 08:58:47 Compiler: 8.2.1 20181127
> > > platform sources revision VM: 201902181742 ckeen at blackbeard:src/playground/opensmalltalk-vm
> Date: Mon Feb 18 09:42:23 2019 CommitHash: f9ae4a147 Plugins: 201902181742
> ckeen at blackbeard:src/playground/opensmalltalk-vm
> > > CoInterpreter VMMaker.oscog-eem.2509 uuid:
> 91e81f64-95de-4914-a960-8f842be3a194 Feb 19 2019
> > > StackToRegisterMappingCogit VMMaker.oscog-eem.2509 uuid:
> 91e81f64-95de-4914-a960-8f842be3a194 Feb 19 2019
> >
> > What Platform [os/cpu] is this  on?
>
>
> Linux/amd64 sorry for omitting this...
>

and you report that -100 asFloat answers 100.0.

Can you please try the following experiments?

First what is the result of

    | floats |
    floats := Array new: 30.
    1 to: floats size do: [:i| floats at: i put: -100 asFloat].
    floats

?

If the result has the first several floats as 100.0 and the last few as
-100.0 then...

Edit spur64src/vm/gcc3x-cointerp.c so that

static void
primitiveAsFloat(void)
{   DECL_MAYBE_SQ_GLOBAL_STRUCT
    sqInt rcvr;
    char *sp;

    rcvr = longAt(GIV(stackPointer));
    assert((((rcvr) & 7) == 1));
    /* begin pop:thenPushFloat: */
    longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)),
floatObjectOf(((double) ((rcvr >> 3)) )));
    GIV(stackPointer) = sp;
}

reads

static void
primitiveAsFloat(void)
{   DECL_MAYBE_SQ_GLOBAL_STRUCT
    sqInt rcvr;
    char *sp;

    rcvr = longAt(GIV(stackPointer));
    assert((((rcvr) & 7) == 1));
    /* begin pop:thenPushFloat: */
    longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)),
floatObjectOf(((double) ((sqInt)(rcvr >> 3)) )));
    GIV(stackPointer) = sp;
}

and test -100 asFloat.  Does this fix it?

And does this rewrite fix it?

static void
primitiveAsFloat(void)
{   DECL_MAYBE_SQ_GLOBAL_STRUCT
    sqInt rcvr;
    char *sp;

    rcvr = longAt(GIV(stackPointer));
    assert((((rcvr) & 7) == 1));
    /* begin pop:thenPushFloat: */
    longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)),
floatObjectOf(((double) (((sqInt)rcvr >> 3)) )));
    GIV(stackPointer) = sp;
}

(I would expect not)

_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20190219/5f7c86fa/attachment.html>


More information about the Vm-dev mailing list