Allow to hoist MRegExp when "exec" is called
Categories
(Core :: JavaScript Engine: JIT, enhancement, P1)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox67 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
Details
Attachments
(1 file)
|
2.74 KB,
patch
|
jandem
:
review+
|
Details | Diff | Splinter Review |
It looks like we could easily allow hoisting of MRegExp when RegExp.prototype.exec is called when we handle CallRegExpMethodIfWrapped in IsRegExpHoistableCall.
| Assignee | ||
Comment 1•7 years ago
|
||
CallRegExpMethodIfWrapped is the only function preventing to hoist RegExps when RegExp.prototype.exec is called.
That means we're now able to hoist MRegExp for RegExp.prototype.test (already works without this patch) and RegExp.prototype.exec. The other RegExp/String built-ins seem to be more difficult to handle correctly. For example we can't hoist a RegExp in String.prototype.search (tested with "".search(/./)) because of the calls to
RegExpCreateFlatStringSearchRegExpSearchSlowPath- and
MRegExpInstanceOptimizable
(So we should probably remove this line, shouldn't we?)
Similarly RegExps can't be hoisted in String.prototype.match (tested with "".match(/./)) because of
RegExpCreateFlatStringMatchRegExpMatchSlowPathRegExpGlobalMatchOpt- and
MRegExpInstanceOptimizable.
This change improves the following µ-benchmark from 520ms to 460ms for me:
function f() {
var r = 0;
var t = dateNow()
for (var i = 0; i < 5000000; ++i){
if (/b{2,}/.exec("aaaaabaaabbbaaaa")) {
r++;
}
}
return [dateNow() - t, r];
}
Comment 2•7 years ago
|
||
Updated•7 years ago
|
| Assignee | ||
Comment 3•7 years ago
|
||
(In reply to Jan de Mooij [:jandem] from comment #2)
The idea is that if we have a RegExpObject we never get to
CallRegExpMethodIfWrapped anyway so it doesn't affect behavior, right?
Yes, and because it shouldn't matter when calling CallRegExpMethodIfWrapped if the input is a hoisted or cloned RegExp, because CallRegExpMethodIfWrapped doesn't modify any state.
| Assignee | ||
Comment 4•7 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=04ca7ff567bd11b29445e32b1f88d8b1b4d7a4a1
Pushed by rmaries@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/8cd8d6fd4931
Support hoisting RegExp when "exec" is called. r=jandem
Comment 6•7 years ago
|
||
| bugherder | ||
Description
•