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. 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? Thanks! Santiago. |
On Fri, May 25, 2012 at 8:46 PM, Santiago Bragagnolo <[hidden email]> wrote: Hi All 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: The rule is that you have to always take care of balance the stack. Be careful to pop according to what you push ;) Thanks! -- Mariano http://marianopeck.wordpress.com |
Thanks Mariano! :) 2012/5/25 Mariano Martinez Peck <[hidden email]>
|
Administrator
|
In reply to this post by Mariano Martinez Peck
plus self is passed implicitly first, right? How did you "browse the image" for the primitive? I ended up searching sources for "<primitive: 249>". Is there a better/faster way? That's what it looked like to me.
Cheers,
Sean |
On Sat, May 26, 2012 at 3:21 AM, Sean P. DeNigris <[hidden email]> wrote:
You see? we start to help us each other :) yes, the receiver is always put in the stack "implicitly"
That's one slow possibily and the hacky and fast one is: CompiledMethod allInstances select: [:each | each primitive = 249]
excellent
-- Mariano http://marianopeck.wordpress.com |
On 26.05.2012, at 10:38, Mariano Martinez Peck wrote:
And and self is put on the stack firs, then the other arguments. So if the primitive only wants to return self, it just pops the 2 arguments off the stack. If it needs to return something else, it also has to pop off self.
Or the less hacky, equally fast SystemNavigation default browseAllSelect: [:m | m primitive = 249] - Bert - |
Administrator
|
Thanks, Bert! I needed that somewhere else, too :)
Cheers,
Sean |
Free forum by Nabble | Edit this page |