Closed Bug 441416 Opened 16 years ago Closed 12 years ago

banish E4X ops to a sub-interpreter, or desugar to function calls

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX
mozilla1.9.2a1

People

(Reporter: brendan, Unassigned)

References

Details

These bloat js_Interpret needlessly, challenging optimization and trace-recording and so on. Performance can't matter. Simplest thing to do is put them all under a fixed-length JSOP_XMLOP, although the ones that index atoms would need the right atom-based atoms pointer. The ops to target:

OPDEF(JSOP_DEFXMLNS,      161,"defxmlns",   NULL,     1,  1,  0,  0,  JOF_BYTE)
OPDEF(JSOP_ANYNAME,       162,"anyname",    NULL,     1,  0,  1, 19,  JOF_BYTE|JOF_XMLNAME)
OPDEF(JSOP_QNAMEPART,     163,"qnamepart",  NULL,     3,  0,  1, 19,  JOF_ATOM|JOF_XMLNAME)
OPDEF(JSOP_QNAMECONST,    164,"qnameconst", NULL,     3,  1,  1, 19,  JOF_ATOM|JOF_XMLNAME)
OPDEF(JSOP_QNAME,         165,"qname",      NULL,     1,  2,  1,  0,  JOF_BYTE|JOF_XMLNAME)
OPDEF(JSOP_TOATTRNAME,    166,"toattrname", NULL,     1,  1,  1, 19,  JOF_BYTE|JOF_XMLNAME)
OPDEF(JSOP_TOATTRVAL,     167,"toattrval",  NULL,     1,  1,  1, 19,  JOF_BYTE)
OPDEF(JSOP_ADDATTRNAME,   168,"addattrname",NULL,     1,  2,  1, 13,  JOF_BYTE)
OPDEF(JSOP_ADDATTRVAL,    169,"addattrval", NULL,     1,  2,  1, 13,  JOF_BYTE)
OPDEF(JSOP_BINDXMLNAME,   170,"bindxmlname",NULL,     1,  1,  2,  3,  JOF_BYTE|JOF_SET)
OPDEF(JSOP_SETXMLNAME,    171,"setxmlname", NULL,     1,  3,  1,  3,  JOF_BYTE|JOF_SET|JOF_DETECTING)
OPDEF(JSOP_XMLNAME,       172,"xmlname",    NULL,     1,  1,  1, 19,  JOF_BYTE)
OPDEF(JSOP_DESCENDANTS,   173,"descendants",NULL,     1,  2,  1, 18,  JOF_BYTE)
OPDEF(JSOP_FILTER,        174,"filter",     NULL,     3,  1,  1,  0,  JOF_JUMP)
OPDEF(JSOP_ENDFILTER,     175,"endfilter",  NULL,     3,  2,  1, 18,  JOF_JUMP)
OPDEF(JSOP_TOXML,         176,"toxml",      NULL,     1,  1,  1, 19,  JOF_BYTE)
OPDEF(JSOP_TOXMLLIST,     177,"toxmllist",  NULL,     1,  1,  1, 19,  JOF_BYTE)
OPDEF(JSOP_XMLTAGEXPR,    178,"xmltagexpr", NULL,     1,  1,  1,  0,  JOF_BYTE)
OPDEF(JSOP_XMLELTEXPR,    179,"xmleltexpr", NULL,     1,  1,  1,  0,  JOF_BYTE)
OPDEF(JSOP_XMLOBJECT,     180,"xmlobject",  NULL,     3,  0,  1, 19,  JOF_OBJECT)
OPDEF(JSOP_XMLCDATA,      181,"xmlcdata",   NULL,     3,  0,  1, 19,  JOF_ATOM)
OPDEF(JSOP_XMLCOMMENT,    182,"xmlcomment", NULL,     3,  0,  1, 19,  JOF_ATOM)
OPDEF(JSOP_XMLPI,         183,"xmlpi",      NULL,     3,  1,  1, 19,  JOF_ATOM)

Although perhaps the JSOP_QNAME* ones should be kept for ES4.

/be
(In reply to comment #0)
> although the ones that index
> atoms would need the right atom-based atoms pointer.

A simple thing would be to change the emitter to always push the necessary atoms to the stack.
If we're willing to make scripts that want E4X equality and call semantics declare themselves as such, then we could also emit leaner ops for non-XML equality and call, and put the full E4X-semantic versions in the E4X subinterpreter.

Alternately, we could probably tell statically that one of the values is going to be a primitive (and often of what type or even value), and emit leaner-still bytecodes for all scripts.  Maybe that belongs in the jsbcopt bug, though...
Desugaring is better if it can be done without integrity loss.

/be
Summary: banish E4X ops to a sub-interpreter → banish E4X ops to a sub-interpreter, or desugar to function calls
Current plan is to self-host, see bug 485791. Igor, does this bug serve any separate purpose?

One way of self-hosting E4X in JS is to have the parser continue to recognize all the special forms, requiring some hardcoding, and produce ASTs. Then have the emitter not handle the E4X trees in its C++ (hardened) code, instead calling out to a JS code generator, one with severely limited ability to generate constants, expressions, and calls to the rt->builtinFunctions built-in functions.

The rest would entail pseudo-string namespaces as you propose, and decompiling.

Making this bug depend on bug 485791 for now. Feel free to mark this bug INVALID if that bug is the only one needed and this bug's summary is the wrong direction.

Resetting TM, though -- want to get to this soon or punt it otherwise.

/be
Depends on: 485791
Target Milestone: mozilla1.9.1a1 → mozilla1.9.2a1
Assignee: brendan → igor
Assignee: igor → general
e4x is being removed (bug 788293).
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.