[Vm-dev] executing a specified compiled method

Rob Withers reefedjib at yahoo.com
Thu Nov 1 13:52:02 UTC 2007


I am trying to write a primitive that will execute a compiled method, one of 
the arguments.  Does anything nasty jump out at you from this code?


primitiveExecuteCompiledMethodOnReceiverWithArgs

    | argumentArray newReceiver methodToBeExecuted arrayArgumentCount 
cntxSize index |
    self export: true.

    self success: (argumentCount = 3).
    successFlag ifFalse: [^ successFlag].
    argumentArray := self popStack.
    newReceiver := self popStack.
    methodToBeExecuted := self popStack.

    self popStack.    "Pop the old receiver"
    self push: newReceiver.  "Push the new receiver"
    receiverClass := lkupClass := self fetchClassOf: newReceiver.
    newMethod := methodToBeExecuted.
    methodClass := receiverClass.
    index := 1.
    [index <= arrayArgumentCount]
        whileTrue:
            [self push: (self fetchPointer: index - 1 ofObject: 
argumentArray).
            index := index + 1].
    argumentCount := arrayArgumentCount.

    self executeNewMethod.
    successFlag := true.

It is crashing my vm, when I call it.

many thanks,
Rob 



More information about the Vm-dev mailing list