New primitive to include (please?) Re: [Vm-dev] Method executing
but not sent to the receiver
David T. Lewis
lewis at mail.msen.com
Mon Apr 25 17:07:48 UTC 2011
On Mon, Apr 25, 2011 at 04:59:08PM +0200, Mariano Martinez Peck wrote:
> So...if everybody is happy with this new primitive, can we include it in the
> main distribution of VMMaker and VMMaker-oscog ?
> I mean...I can do it, I have commit access. But I would live to have the
> accept. Andreas and Levente have already agreed. Eliot ? can I commit it to
> VMMaker-oscog ?
> David ? can I commit it to VMMaker ?
If Andreas and Levente like it, then it is fine with me :) When you commit
to VMMaker, can you please also update VMMaker class>>versionString to the
next minor version number? Thanks!
Note that #primitiveFailFor: is not yet available for the standard interpreter,
so you will need to use #primitiveFail. As luck would have it I was just
looking at that last night in hopes of adopting the oscog implementation
into Interpreter, but I think I spotted a slang generation bug that needs
to be addressed first :-/
> is this number 190 okay?
I am away and cannot check right now, but Eliot can probably answer.
> I copy past the code here:
> CompiledMethod >> executeWithReceiver: aReceiver arguments: anArray
> "Execute the compiledMethod against the aReceiver and args in argArray."
> <primitive: 190>
> self primitiveFailed
> And this is the primitive.
> StackInterpreterPrimitives >> primitiveExecuteWithReceiverAr
> "method, recevier, and the array of arguments are on top of stack.
> Execute method against receiver and args.
> Set primitiveFunctionPointer because no cache lookup has been done for
> the method, and
> hence primitiveFunctionPointer is stale."
> | receiverMethod argCnt argumentArray primitiveIndex receiverObject |
> receiverMethod := self stackValue: 2.
> receiverObject := self stackValue: 1.
> argumentArray := self stackTop.
> ((objectMemory isOopCompiledMethod: receiverMethod)
> and: [objectMemory isArray: argumentArray]) ifFalse:
> [^self primitiveFailFor: PrimErrBadArgument].
> argCnt := self argumentCountOf: receiverMethod.
> argCnt = (objectMemory fetchWordLengthOf: argumentArray) ifFalse:
> [^self primitiveFailFor: PrimErrBadNumArgs].
> self pop: 3.
> self push: receiverObject.
> 0 to: argCnt - 1 do:
> self push: (objectMemory fetchPointer: i ofObject: argumentArray)].
> newMethod := receiverMethod.
> primitiveIndex := self primitiveIndexOf: newMethod.
> primitiveFunctionPointer := self functionPointerFor: primitiveIndex
> inClass: nil.
> argumentCount := argCnt.
> "We set the messageSelector for executeMethod below since things
> like the at cache read messageSelector and so it cannot be left stale."
> messageSelector := objectMemory nilObject.
> self executeNewMethod.
> "Recursive xeq affects primErrorCode"
> self initPrimCall
> On Wed, Apr 20, 2011 at 2:42 PM, Andreas Raab <andreas.raab at gmx.de> wrote:
> > On 4/20/2011 14:29, Mariano Martinez Peck wrote:
> >> CompiledMethod >> valueWithReceiver: aReceiver arguments: anArray
> >> "Execute compiledMethod against the receiver and args in argArray. The
> >> receiver is the CompiledMethod"
> >> <primitive: 666>
> >> self primitiveFailed
> >> Where the primitive is send directly, and not a message to the receiver.
> >> Is something like this available or I would need to create a new
> >> primitive?
> > Which by the way, is the primitive that should exist, and
> > Object>>withArgs:executeMethod: should be nuked ASAP. There is no reason to
> > pollute the Object namespace any more than absolutely necessary.
> > Cheers,
> > - Andreas
More information about the Vm-dev