
Arunkumar S Jadhav
Along the similar lines, if someone who has already worked and knows the semantics of other G-codes can explain it, it'll save really lot of time and effort and will speed up the native code generation process. Some are self explanatory, but others will take looking into most of the runtime system sources (mainly mutator and related) to figure out their purpose
Yes. I assume you have already looked at http://haskell.org/nhc98/implementation-notes/index.html especially the introduction to the byte coding scheme.
(like TABLESWITCH, LOOKUPSWITCH etc..).
I think you should be able to work out most of the bytecodes just by inspecting the mutator (src/runtime/Kernel/mutator.c). Here is a basic summary of the two you specifically asked about: TABLESWITCH is followed by an aligned table of 16-bit relative jumps. The constructor from the value on the top of stack is used to index into the table. For instance, to distinguish Nothing and (Just a), you might have TABLESWITCH (04) (08), and if the TOS value is a Nothing, you jump 4 forward, but for a Just constructor, jump 8 forward. LOOKUPSWITCH i is similar to TABLESWITCH, except that the TOS is interpreted as a 16-bit Int, and each jump address is paired with a 16-bit Int key. The argument i says how big the table is, and the mutator searches linearly through the table comparing with keys until a match is found, then it selects that jump. Regards, Malcolm