Problem changing primitiveBitOr or primitiveBitAnd

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

Problem changing primitiveBitOr or primitiveBitAnd

Mariano Martinez Peck
 
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








Reply | Threaded
Open this post in threaded view
|

Re: Problem changing primitiveBitOr or primitiveBitAnd

Andreas.Raab
 
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
>
>
>
>
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Problem changing primitiveBitOr or primitiveBitAnd

Mariano Martinez Peck
 


On Thu, Oct 7, 2010 at 9:55 AM, Andreas Raab <[hidden email]> wrote:

You *really* need to learn how to use the simulator

Is it working? I've been told it is not working at all and that it should take me time to fix it.
 
(and read the code in the VM).

I am reading the code in the VM as much as possible.
 
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.


Ok, I understand that. But before doing that, I just replced   


integerArgument := self popPos32BitInteger.
integerReceiver := self popPos32BitInteger.

by

arg := self popStack.
integerArgument := self positive32BitValueOf: arg.
rcvr := self popStack.
integerReceiver := self positive32BitValueOf: rcvr.

So....I JUST copy the code of #popPos32BitInteger and put it there.....I didn't change anything else, and I have the same problem.

At the end:

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]


is has CPU100 and

primitiveBitOr
    | integerReceiver integerArgument |
    integerArgument := self popPos32BitInteger.
    integerReceiver := self popPos32BitInteger.
    successFlag
        ifTrue: [self push: (self positive32BitIntegerFor:
                    (integerReceiver bitOr: integerArgument))]
        ifFalse: [self unPop: 2]

works perfect.

And I am not using stackValue.

Anyway, thanks for the explanation about both differences.

Cheers

Mariano

 

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









Reply | Threaded
Open this post in threaded view
|

Re: Problem changing primitiveBitOr or primitiveBitAnd

Eliot Miranda-2
 


On Thu, Oct 7, 2010 at 1:25 AM, Mariano Martinez Peck <[hidden email]> wrote:
 


On Thu, Oct 7, 2010 at 9:55 AM, Andreas Raab <[hidden email]> wrote:

You *really* need to learn how to use the simulator

Is it working? I've been told it is not working at all and that it should take me time to fix it.

Cog works.  If the standard simulator doesn't and you fix it that would be a great contribution to the community /ad/ you would learn a lot in the process.  So you can get two images up side-by-side, try Cog (the simulator expression is in one of the workspaces; use the StackInterpreter) and you can copy across code to your VMMaker until the simulator works, announce it and someone like myself or David can integrate it into the main VMMaker line.

HTH
Eliot


 
(and read the code in the VM).

I am reading the code in the VM as much as possible.
 
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.


Ok, I understand that. But before doing that, I just replced   


integerArgument := self popPos32BitInteger.
integerReceiver := self popPos32BitInteger.

by

arg := self popStack.
integerArgument := self positive32BitValueOf: arg.
rcvr := self popStack.
integerReceiver := self positive32BitValueOf: rcvr.

So....I JUST copy the code of #popPos32BitInteger and put it there.....I didn't change anything else, and I have the same problem.

At the end:

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]


is has CPU100 and

primitiveBitOr
    | integerReceiver integerArgument |
    integerArgument := self popPos32BitInteger.
    integerReceiver := self popPos32BitInteger.
    successFlag
        ifTrue: [self push: (self positive32BitIntegerFor:
                    (integerReceiver bitOr: integerArgument))]
        ifFalse: [self unPop: 2]

works perfect.

And I am not using stackValue.

Anyway, thanks for the explanation about both differences.

Cheers

Mariano

 

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











Reply | Threaded
Open this post in threaded view
|

Problems building VM from latest svn

CdAB63
 
Yesterday I tried to rebuild VM (downloading latest sources from svn repository). Apparently a library is missing:

Scanning dependencies of target squeakvm
[ 65%] Building C object CMakeFiles/squeakvm.dir/gnu-interp.c.o
[ 65%] Building C object CMakeFiles/squeakvm.dir/vm/aio.c.o
[ 66%] Building C object CMakeFiles/squeakvm.dir/vm/debug.c.o
[ 66%] Building C object CMakeFiles/squeakvm.dir/vm/osExports.c.o
[ 66%] Building C object CMakeFiles/squeakvm.dir/vm/sqUnixCharConv.c.o
[ 67%] Building C object CMakeFiles/squeakvm.dir/vm/sqUnixExternalPrims.c.o
[ 67%] Building C object CMakeFiles/squeakvm.dir/vm/sqUnixMain.c.o
[ 68%] Building C object CMakeFiles/squeakvm.dir/vm/sqUnixMemory.c.o
[ 68%] Building C object CMakeFiles/squeakvm.dir/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqNamedPrims.c.o
[ 69%] Building C object CMakeFiles/squeakvm.dir/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c.o
[ 69%] Building C object CMakeFiles/squeakvm.dir/version.c.o
[ 70%] Building C object CMakeFiles/squeakvm.dir/disabledPlugins.c.o
Linking C executable squeakvm
CMakeFiles/squeakvm.dir/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c.o: In function `sqGetInterpreterProxy':
/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:360: undefined reference to `internalIsImmutable'
/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:361: undefined reference to `internalIsMutable'
/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:362: undefined reference to `primitiveFailFor'
/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:363: undefined reference to `classAlien'
/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:364: undefined reference to `getStackPointer'
/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:365: undefined reference to `sendInvokeCallbackStackRegistersJmpbuf'
/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:366: undefined reference to `reestablishContextPriorToCallback'
/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:367: undefined reference to `classUnsafeAlien'

collect2: ld returned 1 exit status
make[2]: ** [squeakvm] Erro 1

make[1]: ** [CMakeFiles/squeakvm.dir/all] Erro 2
make: ** [all] Erro 2


signature.asc (269 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problems building VM from latest svn

Igor Stasenko
 
these functions are available in latest version of VMMaker.
You probably trying to build from outdated VMMaker auto-generated
sources which were saved into SVN repository.
So you need to generate fresh VM sources using VMMaker.

(have i forgot to mention again, that its bad practice to put
autogenerated sources in SVN? ;)

On 8 October 2010 14:30, Casimiro de Almeida Barreto
<[hidden email]> wrote:

>
> Yesterday I tried to rebuild VM (downloading latest sources from svn repository). Apparently a library is missing:
>
> Scanning dependencies of target squeakvm
> [ 65%] Building C object CMakeFiles/squeakvm.dir/gnu-interp.c.o
> [ 65%] Building C object CMakeFiles/squeakvm.dir/vm/aio.c.o
> [ 66%] Building C object CMakeFiles/squeakvm.dir/vm/debug.c.o
> [ 66%] Building C object CMakeFiles/squeakvm.dir/vm/osExports.c.o
> [ 66%] Building C object CMakeFiles/squeakvm.dir/vm/sqUnixCharConv.c.o
> [ 67%] Building C object CMakeFiles/squeakvm.dir/vm/sqUnixExternalPrims.c.o
> [ 67%] Building C object CMakeFiles/squeakvm.dir/vm/sqUnixMain.c.o
> [ 68%] Building C object CMakeFiles/squeakvm.dir/vm/sqUnixMemory.c.o
> [ 68%] Building C object CMakeFiles/squeakvm.dir/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqNamedPrims.c.o
> [ 69%] Building C object CMakeFiles/squeakvm.dir/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c.o
> [ 69%] Building C object CMakeFiles/squeakvm.dir/version.c.o
> [ 70%] Building C object CMakeFiles/squeakvm.dir/disabledPlugins.c.o
> Linking C executable squeakvm
> CMakeFiles/squeakvm.dir/home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c.o: In function `sqGetInterpreterProxy':
> /home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:360: undefined reference to `internalIsImmutable'
> /home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:361: undefined reference to `internalIsMutable'
> /home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:362: undefined reference to `primitiveFailFor'
> /home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:363: undefined reference to `classAlien'
> /home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:364: undefined reference to `getStackPointer'
> /home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:365: undefined reference to `sendInvokeCallbackStackRegistersJmpbuf'
> /home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:366: undefined reference to `reestablishContextPriorToCallback'
> /home/casimiro/Softwares/squeak/squeak/platforms/Cross/vm/sqVirtualMachine.c:367: undefined reference to `classUnsafeAlien'
> collect2: ld returned 1 exit status
> make[2]: ** [squeakvm] Erro 1
> make[1]: ** [CMakeFiles/squeakvm.dir/all] Erro 2
> make: ** [all] Erro 2
>
>
>



--
Best regards,
Igor Stasenko AKA sig.
Reply | Threaded
Open this post in threaded view
|

Re: Problem changing primitiveBitOr or primitiveBitAnd

ccrraaiigg
In reply to this post by Mariano Martinez Peck
 

Hi Mariano and all--

     Andreas writes:

> You *really* need to learn how to use the simulator

     You respond:

> Is it working? I've been told it is not working at all and that it
> should take me time to fix it.

     It'd be worthwhile, truly. I've had to fix it many times over the
years; it's not so bad and always edifying in some way.


     greetings,

-C

--
Craig Latta
www.netjam.org/resume
+ 31 020 894 6247
+  1 415 287 3547



Reply | Threaded
Open this post in threaded view
|

Re: Problem changing primitiveBitOr or primitiveBitAnd

stephane ducasse-2

Sometimes this is not a question of not wanting to do something this is the question of not knowing.


On Nov 7, 2010, at 4:23 PM, Craig Latta wrote:

>
>
> Hi Mariano and all--
>
>     Andreas writes:
>
>> You *really* need to learn how to use the simulator
>
>     You respond:
>
>> Is it working? I've been told it is not working at all and that it
>> should take me time to fix it.
>
>     It'd be worthwhile, truly. I've had to fix it many times over the
> years; it's not so bad and always edifying in some way.
>
>
>     greetings,
>
> -C
>
> --
> Craig Latta
> www.netjam.org/resume
> + 31 020 894 6247
> +  1 415 287 3547
>
>
>

Reply | Threaded
Open this post in threaded view
|

re: Problem changing primitiveBitOr or primitiveBitAnd

ccrraaiigg
 

Hi Stef--

> Sometimes this is not a question of not wanting to do something this
> is the question of not knowing.

     Agreed; here I think he can do it, and I'm encouraging him to try.


-C

--
Craig Latta
www.netjam.org/resume
+ 31 020 894 6247
+  1 415 287 3547