Hi Eliot,
Sorry, I mixed up InterpreterSimulator and InterpreterProxy here. But let me explain what's happening and why I think a primitive would help us.
When the RSqueakVM encounters a named primitive, say 'primitiveCopyBits', and the VMMaker package is loaded in the image, instead of running any primitive behavior, it creates a frame to run 'simulateCopyBits' in place of the primitive behavior. From the point of view of the Smalltalk image that dispatched to 'BitBlt>>copyBits' (where the VM encountered the named primitive), instead of entering that method, the VM entered 'BitBlt>>simulateCopyBits'.
'simulateCopyBits' runs the simulation, but the simulation might fail, for example when it encounters a hibernated form as source or destination. In that case, the simulation will call 'InterpreterProxy>>primitiveFailFor:' or 'InterpreterProxy>>success:'. Both set the primFailCode, and then use a Notification to ask the user if the simulation should stop.
Now, the simulation simply failed because one of the Forms was hibernated - that's what the fallback code is for. But to run the fallback code we need the help of the VM - after all, 'BitBlt>>copyBits' is not even on the stack, and the Smalltalk code doesn't even know the VM replaced a primitive invocation with a message send to 'simulateCopyBits'. Now, if the VM could notice that the primitive fail code was set, it could simply unwind the stack (before the halt is run) and actually run the fallback code. It is hard to notice that, though. The InterpreterProxy is just an object like any other, and the Notification that is used to inform the user isn't visible to the VM -- it is just ordinary Smalltalk code that happens to traverse the senders chain.
Now, if we add a <primitive: 114> to those two methods in InterpreterProxy, 'success:' and 'primitiveFailFor:', the RSqueakVM can use that primitive to notice that we are running the simulation for a primitive, that primitive is about to fail, so we better unwind and start running the fallback code.
-- View this message in context: http://forum.world.st/Need-a-marker-primitive-tp4821675p4822273.html Sent from the Squeak VM mailing list archive at Nabble.com.