Summary: | Move regex parsing and fallback handling to runtime/RegExp.cpp | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Peter Varga <pvarga> | ||||||
Component: | JavaScriptCore | Assignee: | Peter Varga <pvarga> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | abecsi, barraclough, commit-queue, msaboff, zherczeg | ||||||
Priority: | P2 | ||||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | All | ||||||||
OS: | All | ||||||||
Attachments: |
|
Description
Peter Varga
2010-11-24 04:43:47 PST
Created attachment 74747 [details]
proposed patch
Hi Peter,
A couple of cosmetic things, we should probably remove the compile method (this can now just fold back up into the constructor, since PCRE is gone, and we should probably also remove the following comment from the header:
// FIXME: Just decompile m_regExp instead of storing this.
(not a direction I think we're headed in).
There is one way I think you could improve this patch though, see what you think. Checks like this seem a little over complicated, particularly on a hot path:
> if (!!m_representation->m_regExpJITCode || (m_useInterpreter && m_representation->m_regExpBytecode))
(okay, it's just a couple more branches, but it could be simpler).
I'd suggest instead of adding m_useInterpreter to add an enum to track the state of the regex. At the point of construction the RegExp always goes into one of three states - either (A) it has a parse error, or (B) if the JIT is enabled & the regex is supported it will be JIT compiled, else (C) it will be byte-compiled. In match that if check becomes something like 'if (m_state != ParseError)'
In the longer term, it would be nice to only construct RegExp objects after successfully parsing, and have RegExp::create just return 0 on failure (with an error string as an output parameter). Having duff RegExp objects that can't actually be run seems odd, and I think in all cases, at least within the JS languages use, errors should be reported (an thrown immediately) at construction time anyway, so there is likely no way to get a handle to a JS object that is referencing a RegExp that failed to compile. Anyway, this would be a bigger change & is not important now.
What do you think of adding an enum to explicitly delineate the states?
cheers, G.
Created attachment 75138 [details] proposed patch v2 Hi Gavin, > What do you think of adding an enum to explicitly delineate the states? Adding an enum instead of m_useInterpreter variable is sensible and it mades the code clearer. I updated the patch. > we should probably remove the compile method I didn't remove the compile method. I think it makes the code seperatable and now it makes the logic of handling RegExp states flexible. > we should probably also remove the following comment from the header I removed this comment. At first the solving of the FIXME looked pointless and I didn't modify it. Your suggestion about the modification of RegExp::create needs more investigation because It needs changes in those classes which implement the handling of regular expressions in runtime. Regards, Peter Comment on attachment 75138 [details] proposed patch v2 > > we should probably remove the compile method > I didn't remove the compile method. I think it makes the code seperatable and now it makes > the logic of handling RegExp states flexible. Fine, I'm happy with that decision Peter. Patch looks great, r+. Comment on attachment 75138 [details] proposed patch v2 Rejecting patch 75138 from commit-queue. Failed to run "['./WebKitTools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '--bot-id=abarth-cq-sl', 'build', '--no-clean', '--no-update', '--build-style=both']" exit_code: 2 Last 500 characters of output: .build/Debug/testapi.build/Script-14D857B50A469C100032146C.sh === BUILD AGGREGATE TARGET All OF PROJECT JavaScriptCore WITH CONFIGURATION Debug === Check dependencies ** BUILD FAILED ** The following build commands failed: JavaScriptCore: CompileC /Users/abarth/git/webkit-queue/WebKitBuild/JavaScriptCore.build/Debug/JavaScriptCore.build/Objects-normal/x86_64/RegexJIT.o /Users/abarth/git/webkit-queue/JavaScriptCore/yarr/RegexJIT.cpp normal x86_64 c++ com.apple.compilers.gcc.4_2 (1 failure) Full output: http://queues.webkit.org/results/6779006 Comment on attachment 75138 [details] proposed patch v2 Landed in http://trac.webkit.org/changeset/73124, clearing flags. Closing bug. |