<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 20.04.2011 15:52, Mariano Martinez Peck wrote:
    <blockquote
      cite="mid:BANLkTi=LJacoaQzM0EPNk4C2rTNBaMM59g@mail.gmail.com"
      type="cite">
      <pre wrap=""> </pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      I cannot believe it but it seems to work. I would really
      appreaciate if someone can take a look, and consider to integrate
      it. <br>
      Having no way to execute a method on a receveir WITHOUT sending a
      message to the object, is really a problem. I am implementing
      proxies, which understand NOTHING (their class has method
      dictionary in nil and I use the cannotInterpret trick) and so I
      CANNOT send a message because I will be in loop. I have a similar
      problem with primitiveChangeClassTo:&nbsp; but fortunately, Eliot did
      #adoptInstance: which receiver is the class and not the object. <br>
      <br>
      Anyway, this is the method <br>
      <br>
      CompiledMethod &gt;&gt; executeWithReceiver: aReceiver arguments:
      anArray <br>
      &nbsp;"Execute the compiledMethod against the aReceiver and args in
      argArray."<br>
      <br>
      &lt;primitive: 190&gt;<br>
      &nbsp;&nbsp; self primitiveFailed<br>
      <br>
      <br>
      And this is the primitive. <br>
      <br>
      <br>
      StackInterpreterPrimitives &gt;&gt;
      primitiveExecuteWithReceiverArguments<br>
      &nbsp;&nbsp;&nbsp; "method, recevier, and the array of arguments are on top of
      stack.&nbsp; Execute method against receiver and args.<br>
      &nbsp;&nbsp;&nbsp; &nbsp;Set primitiveFunctionPointer because no cache lookup has been
      done for the method, and<br>
      &nbsp;&nbsp;&nbsp; &nbsp;hence primitiveFunctionPointer is stale."<br>
      &nbsp;&nbsp;&nbsp; | receiverMethod argCnt argumentArray primitiveIndex
      receiverObject |<br>
      &nbsp;&nbsp;&nbsp; receiverMethod := self stackValue: 2.<br>
      &nbsp;&nbsp;&nbsp; receiverObject := self stackValue: 1.<br>
      &nbsp;&nbsp;&nbsp; argumentArray := self stackTop.<br>
      &nbsp;&nbsp;&nbsp; ((objectMemory isOopCompiledMethod: receiverMethod)<br>
      &nbsp;&nbsp;&nbsp; &nbsp;and: [objectMemory isArray: argumentArray]) ifFalse:<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [^self primitiveFailFor: PrimErrBadArgument].<br>
      &nbsp;&nbsp;&nbsp; argCnt := self argumentCountOf: receiverMethod.<br>
      &nbsp;&nbsp;&nbsp; argCnt = (objectMemory fetchWordLengthOf: argumentArray)
      ifFalse:<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [^self primitiveFailFor: PrimErrBadNumArgs].<br>
      &nbsp;&nbsp;&nbsp; self pop: 3.<br>
      &nbsp;&nbsp;&nbsp; self push: receiverObject.<br>
      &nbsp;&nbsp;&nbsp; 0 to: argCnt - 1 do:<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [:i|<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self push: (objectMemory fetchPointer: i ofObject:
      argumentArray)].<br>
      &nbsp;&nbsp;&nbsp; newMethod := receiverMethod.<br>
      &nbsp;&nbsp;&nbsp; primitiveIndex := self primitiveIndexOf: newMethod.<br>
      &nbsp;&nbsp;&nbsp; primitiveFunctionPointer := self functionPointerFor:
      primitiveIndex inClass: nil.<br>
      &nbsp;&nbsp;&nbsp; argumentCount := argCnt.<br>
      &nbsp;&nbsp;&nbsp; "We set the messageSelector for executeMethod below since
      things<br>
      &nbsp;&nbsp;&nbsp; &nbsp;like the at cache read messageSelector and so it cannot be
      left stale."<br>
      &nbsp;&nbsp;&nbsp; messageSelector := objectMemory nilObject.<br>
      &nbsp;&nbsp;&nbsp; self executeNewMethod.<br>
      &nbsp;&nbsp;&nbsp; "Recursive xeq affects primErrorCode"<br>
      &nbsp;&nbsp;&nbsp; self initPrimCall<br>
      <br>
      <br>
      Thanks for taking a look and hopefully integrate this or something
      better,<br>
      <br>
      Mariano<br>
    </blockquote>
    Wouldn't you want to do a class check on the object vs installed
    class of the CompiledMethod as part of PrimErrBadArgument checks?<br>
    Otherwise you'd probably end up insilly situations with
    CompiledMethods which accesses/stores to instvars :)<br>
    <br>
    Cheers,<br>
    Henry<br>
  </body>
</html>