[Vm-dev] Re: [Vm-beginners] About Primitives

Mariano Martinez Peck marianopeck at gmail.com
Fri May 25 19:04:07 UTC 2012


On Fri, May 25, 2012 at 8:46 PM, Santiago Bragagnolo <
santiagobragagnolo at gmail.com> wrote:

> Hi All
>
> Im analyzing primtives to use them for the concrete type inference project.
>
> Im currently working with primitiveArrayBecomeOneWayCopyHash
>
>
> primitiveArrayBecomeOneWayCopyHash
>       "Similar to primitiveArrayBecomeOneWay but accepts a third argument
> whether to copy
>       the receiver's identity hash over the argument's identity hash."
>
>       | copyHashFlag arg rcvr |
>       copyHashFlag := self booleanValueOf: (self stackTop).
>       arg := self stackValue: 1.
>       rcvr := self stackValue: 2.
>       self success: (self become: rcvr with: arg twoWay: false copyHash:
> copyHashFlag).
>       successFlag ifTrue: [ self pop: 2 ].
>
>
> Well, i'm seeing that pop:2, in a method which don't receive any argument


yes it receieves! two arguments indeed
if you see #initializePrimitiveTable you see the number of this primitive
is 249. So if you browse your iamge, you find:

Array >> #elementsForwardIdentityTo: otherArray copyHash: copyHash
    "This primitive performs a bulk mutation, causing all pointers to the
elements of this array to be replaced by pointers to the corresponding
elements of otherArray.  The identityHashes remain with the pointers rather
than with the objects so that the objects in this array should still be
properly indexed in any existing hashed structures after the mutation."
    <primitive: 249>
    self primitiveFailed


so poping 2 means you will let "self" in the top, so it will actually be
the return value.
the last time I was hacking in this side of the moon was one year ago...so
some validation from someone else would be nice :)


> . If pop was 1, i could think in self, but is 2, so the questions are:
>
> 1) what is pop:2 in this context
> 2) why? there's any generalization or rules for understand the stack
> manage?
>
>
The rule is that you have to always take care of balance the stack. Be
careful to pop according to what you push ;)



> Thanks!
>
> Santiago.
>
>
>
>
> _______________________________________________
> VM-beginners mailing list
> VM-beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
>
>


-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20120525/85b0b077/attachment.htm


More information about the Vm-dev mailing list