[Vm-dev] Fwd: squeak 32bit clean, no? yes?

Eliot Miranda eliot.miranda at gmail.com
Wed Sep 8 21:19:15 UTC 2010


On Wed, Sep 8, 2010 at 1:48 PM, John M McIntosh <
johnmci at smalltalkconsulting.com> wrote:

>
> Let me try that with the correct email address...
>
> Begin forwarded message:
>
> > From: John M McIntosh <johnmci at smalltalkconsulting.com>
> > Date: September 8, 2010 2:20:29 AM PDT
> > To: Squeak VM Developers <squeak-vmdev at lists.sourceforge.net>
> > Subject: squeak 32bit clean, no? yes?
> > Reply-To: johnmci at smalltalkconsulting.com
> >
> > It's 2:05am I should be in bed but I'm confused.
> >
> > given BaseHeaderSize is 4
> > foo->newMethod is a usqInt  (unsigned)
> >
> > I see in a interp.c
> > Automatically generated from Squeak on #(27 April 2009 5:35:31 pm)
> >
> > sqInt activateNewMethod(void) {
> > register struct foo * foo = &fum;
> >    sqInt initialIP;
> >    sqInt newContext;
> >    sqInt where;
> >    sqInt methodHeader;
> >    sqInt tempCount;
> >    sqInt i;
> >    sqInt nilOop;
> >    sqInt tmp;
> >
> >       methodHeader = longAt((foo->newMethod + BaseHeaderSize) +
> (HeaderIndex << ShiftForWord));
> >
> >
> > So that is a longAt: ( unsigned sqInt + 4)
> >
> > But in  the interp.c code I generated in July I have
> >       methodPointer (a sqInt) =  foo->newMethod (a usqint)
> >       then
> >       methodHeader = longAt((methodPointer + (BASE_HEADER_SIZE)) +
> (HeaderIndex << (SHIFT_FOR_WORD)));
> >
> > So that is a longAt: (sqInt + 4).
> >
> > Er so if  foo->newMethod is > 0x7FFFFFFF  won't that +4 not do what we
> think it should do?
> > Or should I go to bed now?
>

Go to bed.  In C (and in modulo arithmetic in general) (unsigned)((signed)v
+ N) == (unsigned)v + N.  e.g. 0x80000000 + 4 is indeed (2^32 - 4) negated
but that's also 0x80000004.  i.e. the largest unsigned value is
(unsigned)-1, all ones, and so when adding a positive value to a negative
signed quantity you end up with a larger unsigned quantity.

>
> >
> > /* Automatically generated from Squeak on 8 July 2010 12:32:36 pm
> >   by VMMaker 4.2.6
> > */
> >
> >
> > sqInt activateNewMethod(void) {
> > register struct foo * foo = &fum;
> >    sqInt tempCount;
> >    sqInt nilOop;
> >    sqInt where;
> >    sqInt initialIP;
> >    sqInt i;
> >    sqInt newContext;
> >    sqInt methodHeader;
> >    sqInt methodPointer;
> >    sqInt tmp;
> >    sqInt activeCntx;
> >    sqInt valuePointer;
> >    sqInt valuePointer1;
> >
> >       /* begin headerOf: */
> >       methodPointer = foo->newMethod;
> >       methodHeader = longAt((methodPointer + (BASE_HEADER_SIZE)) +
> (HeaderIndex << (SHIFT_FOR_WORD)));
> >
> >
> > --
> >
> ===========================================================================
> > John M. McIntosh <johnmci at smalltalkconsulting.com>   Twitter:
>  squeaker68882
> > Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> >
> ===========================================================================
> >
> >
> >
> >
>
> --
> ===========================================================================
> 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/vm-dev/attachments/20100908/144ed1f0/attachment.htm


More information about the Vm-dev mailing list