[Yhc] What constitutes an 'evaluated node'?

Stefan O'Rear stefanor at cox.net
Wed Feb 28 18:43:12 EST 2007


Hello.  I am writing my own Yhi-Bytecode backend.  I wish to minimize
the number of indirection checks, and the bytecode.xml is not clear on
the subject. 

Some of the bytecodes, eg INT_SWITCH, require the node they are
applied to, to be 'evaluated'.  EVAL takes a node and returns an
equivalent evaluated node.  However in the current implementation
(Yhi) EVAL has the side-effect of making any other reference to the
original node become evaluated.  For instance, this is "legal":

not:
 PUSH_ARG_0
 EVAL
 POP_1
 PUSH_ZAP_ARG_0
 JUMP_FALSE L2
 POP_1
 PUSH_CON_0
 RETURN
L2:
 POP_1
 PUSH_CON_1
 RETURN
{ Prelude.False, Prelude.True }

Specifically, I have in mind an implementation where indirections are
NEVER automatically followed, and only EVAL and RETURN_EVAL (and for
efficiency perhaps APPLY) check for them, returning the targets as the
evaluated nodes.  Thus in the above example, the value pushed by
PUSH_ZAP_ARG_0 would be an indirection node, not False in any case, so
our 'not' would mis-behave as 'const False'.  Does any yhc generated
code rely on this (mis?) feature?  Does anyone (note that I do NOT say
'else') think this is a misfeature? 

Stefan


More information about the Yhc mailing list