Fwd: squeak 32bit clean, no? yes?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: squeak 32bit clean, no? yes?

johnmci
 
Let me try that with the correct email address...

Begin forwarded message:

> From: John M McIntosh <[hidden email]>
> Date: September 8, 2010 2:20:29 AM PDT
> To: Squeak VM Developers <[hidden email]>
> Subject: squeak 32bit clean, no? yes?
> Reply-To: [hidden email]
>
> 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?
>
>
> /* 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 <[hidden email]>   Twitter:  squeaker68882
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ===========================================================================
>
>
>
>
--
===========================================================================
John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================





smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: squeak 32bit clean, no? yes?

Eliot Miranda-2
 


On Wed, Sep 8, 2010 at 1:48 PM, John M McIntosh <[hidden email]> wrote:
 
Let me try that with the correct email address...

Begin forwarded message:

> From: John M McIntosh <[hidden email]>
> Date: September 8, 2010 2:20:29 AM PDT
> To: Squeak VM Developers <[hidden email]>
> Subject: squeak 32bit clean, no? yes?
> Reply-To: [hidden email]
>
> 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 <[hidden email]>   Twitter:  squeaker68882
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ===========================================================================
>
>
>
>

--
===========================================================================
John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================