A short history: In bug 15861, we concluded that, for compatibility with Firefox and ECMA3, we should create a single, persistent RegExpImp (JS wrapper) per regular expression literal in the AST. However, IE6 creates a new JS wrapper each time the regular expression literal is evaluated. Also, Firefox's behavior has caused many compatibility problems. (See https://bugzilla.mozilla.org/show_bug.cgi?id=98409.) And, as a result of these facts, the current draft of ECMA4 contradicts ECMA3 and specifies the IE6 behavior. (See http://www.ecmascript.org/es4/spec/incompatibilities.pdf.) So, I don't think we should create a single, persistent RegExpImp (JS wrapper) per regular expression literal in the AST. However, building on the work in bug 15861, I think we can store a compiled RegExp in the AST, for a performance win.
I think perhaps we should dup bug 15900 to this one :) Got to love web compatibility!
*** Bug 15900 has been marked as a duplicate of this bug. ***
Created attachment 17159 [details] Patch
Committed revision 27702.