I just implemented something to this effect for our project at Cadence. It works by - an assembler/disassebler that can convert a method into a sequence of messages, one for each of its bytecodes and back - using the disassembler to obtain labels which occur at the start of each basic block - replacing the first bytecode in every basic block with an illegal bytecode, remembering the pc and its correct bytecode in the method properties - implementing a method on MethodContext which receives the unknowBytecode message sent by the VM when it encounters an illegal bytecode - the method replaces the illegal bytecode with the correct bytecode, removing the entry from properties, and continues
The JIT refuses to compile methods that contain illegal bytecodes so this runs at interpreter speed until a method no longer contains illegal bytecodes (has been completely covered). But the illegal bytecode is executed at most once for each basic block, since it is replaced immediately it is executed. The information remaining in properties is that of the basic blocks that have not been executed.
In the Squeak/Pharo bytecode set there are three unknown bytecodes, 126, 127 & 139. I have a Monticello package and tests if you're interested.
Yes please. I am interested! Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.