[Vm-dev] Problem changing primitiveBitOr or primitiveBitAnd

Andreas Raab andreas.raab at gmx.de
Thu Oct 7 07:55:31 UTC 2010


You *really* need to learn how to use the simulator (and read the code 
in the VM). Asking people here to debug your code is an extremely slow 
way to do it.

That said, replacing popStack with stackValue is NOT EQUIVALENT. Thus 
your transformation of popStack -> stackValue is entirely incorrect. 
Where you previously had:

1) popStack
2) popStack
3) test and...
	3a) return result
	3b) unpop 2

with stackValue you need to use

1) stackValue: 0.
2) stackValue: 1.
3) test and ...
	3a) pop 2 and return result
	3b) =do nothing=

I.e., stackValue does NOT POP but rather indexes into the stack.

Cheers,
   - Andreas

On 10/7/2010 12:39 AM, Mariano Martinez Peck wrote:
>
>
>
>
> Hi, I want to change #primitiveBitOr or #primitiveBitAnd and in both
> cases, I compile the VM, I run an image, and the image cannot even start
> and CPU 100%  :(
> I have a loop somewhere.
>
> This is the current implementation of #primitiveBitOr for example:
>
> primitiveBitOr
>      | integerReceiver integerArgument |
>      integerArgument := self popPos32BitInteger.
>      integerReceiver := self popPos32BitInteger.
>      successFlag
>          ifTrue: [self push: (self positive32BitIntegerFor:
>                      (integerReceiver bitOr: integerArgument))]
>          ifFalse: [self unPop: 2]
>
>
> I NEED to have the receiver oop and the argument oop. So, I've change it to:
>
> primitiveBitOr
>      | integerReceiver integerArgument arg rcvr |
>      arg := self popStack.
>      integerArgument := self positive32BitValueOf: arg.
>      rcvr := self popStack.
>      integerReceiver := self positive32BitValueOf: rcvr.
>
>      successFlag
>          ifTrue: [
>              self push: (self positive32BitIntegerFor:
>                      (integerReceiver bitOr: integerArgument))]
>          ifFalse: [self unPop: 2]
>
>
> And then to:
>
> primitiveBitOr
>      | integerReceiver integerArgument arg rcvr |
>      arg := self stackValue: 0.
>      integerArgument := self positive32BitValueOf: arg.
>      rcvr := self stackValue: 1.
>      integerReceiver := self positive32BitValueOf: rcvr.
>
>      successFlag
>          ifTrue: [
>              self push: (self positive32BitIntegerFor:
>                      (integerReceiver bitOr: integerArgument))]
>          ifFalse: [self unPop: 2]
>
> But in both cases, while trying to start an image, I have cpu 100%
> Of course, the same happens if I do this in #primitiveBitAnd
>
> Any ideas what can be happening? because I tried to understand but
> nothing :(
>
> Thanks in advance
>
> Mariano
>
>
>
>
>
>
>
>


More information about the Vm-dev mailing list