CArray arithmetic methods...

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

CArray arithmetic methods...

Eliot Miranda-2
 
Hi All,

    now I'm successfully simulating the LargeIntegers plugin I'm hitting what I consider a bug in CArray, used to model C pointers in the simulator.  The first problem is that CArray>>#+ & #- return an integer value, not another CArray,  (in C (char *)(exp) + n is still of type (char *), not int) and that the addition/subtraction doesn't scale by the unit size (in C (type *)p + n == (type *)((char *)p + n * sizeof(type))).  The second problem is that << >> * & // are meaningless on C pointers.  Anyone think of a good reason why I shouldn't a) rewrite CArray>>#+ & #- to read

+ n
^ self shallowCopy += (n * unitSize)

- n
^ self shallowCopy -= (n * unitSize)

(since e.g. 
+= increment

ptrOffset := ptrOffset + increment)

and b) delete CArray>>#*, #//, #<<, #>>, #bitAnd:, #bitOr:, #bitShift: & #signedBitShift: ?

best
Eliot
Reply | Threaded
Open this post in threaded view
|

Re: CArray arithmetic methods...

Eliot Miranda-2
 


On Sat, Oct 9, 2010 at 3:01 PM, Eliot Miranda <[hidden email]> wrote:
Hi All,

    now I'm successfully simulating the LargeIntegers plugin I'm hitting what I consider a bug in CArray, used to model C pointers in the simulator.  The first problem is that CArray>>#+ & #- return an integer value, not another CArray,  (in C (char *)(exp) + n is still of type (char *), not int) and that the addition/subtraction doesn't scale by the unit size (in C (type *)p + n == (type *)((char *)p + n * sizeof(type))).  The second problem is that << >> * & // are meaningless on C pointers.  Anyone think of a good reason why I shouldn't a) rewrite CArray>>#+ & #- to read

+ n
^ self shallowCopy += (n * unitSize)

- n
^ self shallowCopy -= (n * unitSize)

(since e.g. 
+= increment

ptrOffset := ptrOffset + increment)

and b) delete CArray>>#*, #//, #<<, #>>, #bitAnd:, #bitOr:, #bitShift: & #signedBitShift: ?

So far so good.  The only thing that broke was the use of BitBltSimulator/BitBltSimulation>>#tableLookup:at: which can be deleted and in BitBltSimulation>>#pickSourcePixels:flags:srcMask:destMask:srcShiftInc:dstShiftInc: rewrite
destPix := self tableLookup: cmLookupTable at: (sourcePix bitAnd: cmMask).
to
destPix := cmLookupTable at: (sourcePix bitAnd: cmMask).


best
Eliot

Reply | Threaded
Open this post in threaded view
|

Re: CArray arithmetic methods...

stephane ducasse-2
In reply to this post by Eliot Miranda-2

Eliot

how do you run the simulator?

Long time ago we had to use an MVC image and after it got broken and we could not use it anymore.
Now in Pharo we do not have MVC so are we talking about the same?

Stef

On Oct 10, 2010, at 12:01 AM, Eliot Miranda wrote:

> Hi All,
>
>     now I'm successfully simulating the LargeIntegers plugin I'm hitting what I consider a bug in CArray, used to model C pointers in the simulator.  The first problem is that CArray>>#+ & #- return an integer value, not another CArray,  (in C (char *)(exp) + n is still of type (char *), not int) and that the addition/subtraction doesn't scale by the unit size (in C (type *)p + n == (type *)((char *)p + n * sizeof(type))).  The second problem is that << >> * & // are meaningless on C pointers.  Anyone think of a good reason why I shouldn't a) rewrite CArray>>#+ & #- to read
>
> + n
> ^ self shallowCopy += (n * unitSize)
>
> - n
> ^ self shallowCopy -= (n * unitSize)
>
> (since e.g.
> += increment
>
> ptrOffset := ptrOffset + increment)
>
> and b) delete CArray>>#*, #//, #<<, #>>, #bitAnd:, #bitOr:, #bitShift: & #signedBitShift: ?
>
> best
> Eliot

Reply | Threaded
Open this post in threaded view
|

Re: CArray arithmetic methods...

Eliot Miranda-2
 


On Sat, Oct 9, 2010 at 11:57 PM, stephane ducasse <[hidden email]> wrote:

Eliot

how do you run the simulator?

See  http://www.squeakvm.org/svn/squeak/branches/Cog/image/VMMaker-Squeak4.1.image and the VM Simulation Workspace there-in.  Substitute StackInterpreterSimulator for CogVMSimulator and you don't need the Bochs plugin.


Long time ago we had to use an MVC image and after it got broken and we could not use it anymore.
Now in Pharo we do not have MVC so are we talking about the same?

One openAsMorph method is all it takes.
 

Stef

On Oct 10, 2010, at 12:01 AM, Eliot Miranda wrote:

> Hi All,
>
>     now I'm successfully simulating the LargeIntegers plugin I'm hitting what I consider a bug in CArray, used to model C pointers in the simulator.  The first problem is that CArray>>#+ & #- return an integer value, not another CArray,  (in C (char *)(exp) + n is still of type (char *), not int) and that the addition/subtraction doesn't scale by the unit size (in C (type *)p + n == (type *)((char *)p + n * sizeof(type))).  The second problem is that << >> * & // are meaningless on C pointers.  Anyone think of a good reason why I shouldn't a) rewrite CArray>>#+ & #- to read
>
> + n
>       ^ self shallowCopy += (n * unitSize)
>
> - n
>       ^ self shallowCopy -= (n * unitSize)
>
> (since e.g.
> += increment
>
>       ptrOffset := ptrOffset + increment)
>
> and b) delete CArray>>#*, #//, #<<, #>>, #bitAnd:, #bitOr:, #bitShift: & #signedBitShift: ?
>
> best
> Eliot


Reply | Threaded
Open this post in threaded view
|

Re: CArray arithmetic methods...

stephane ducasse-2

Thanks we will have a look at that :)
>
> See  http://www.squeakvm.org/svn/squeak/branches/Cog/image/VMMaker-Squeak4.1.image and the VM Simulation Workspace there-in.  Substitute StackInterpreterSimulator for CogVMSimulator and you don't need the Bochs plugin.
>
>
> Long time ago we had to use an MVC image and after it got broken and we could not use it anymore.
> Now in Pharo we do not have MVC so are we talking about the same?
>
> One openAsMorph method is all it takes.
>