Closed Bug 1266764 Opened 8 years ago Closed 8 years ago

Make finding sticky "y" from `flags` faster in RegExpSplit.

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
firefox48 --- affected

People

(Reporter: arai, Unassigned)

References

Details

Related to bug 1263490.

We're searching "y" character from `flags` string.

>        if (callFunction(std_String_includes, flags, "y"))

std_String_includes is also not inlinable.

Searching single character should be optimizable more with JS loop or length check or JIT inlining.

Especially, flags string should always be short, at most 5 chars (unless someone introduces extra many flags in their library), so JS loop with charCodeAt could be faster.
About bug 1263340 comment #24, if we could use flags slot instead of flags for all optimizable case, std_String_includes will be used only in non-optimizable case, like subclass or monkey-patched RegExp ctor/prototype.
Now std_String_includes is called only for the following non-optimizable cases:
  * call on subclassed RegExp instance
  * when RegExp prototype is modified

https://dxr.mozilla.org/mozilla-central/rev/c67dc1f9fab86d4f2cf3224307809c44fe3ce820/js/src/builtin/RegExp.js#615
Excellent, let's call this fixed: there will come a time when some framework uses RegExp subclasses for ... something. Until then, there's no need to worry about it at all.
Status: NEW → RESOLVED
Closed: 8 years ago
Depends on: 1263340
Resolution: --- → FIXED
See Also: 1263340
You need to log in before you can comment on or make changes to this bug.