Closed Bug 1874373 Opened 2 years ago Closed 2 years ago

Mark String.prototype.{codePointAt,at} and StringIterator.prototype.next as always inlinable

Categories

(Core :: JavaScript Engine: JIT, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
124 Branch
Tracking Status
firefox124 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(3 files, 1 obsolete file)

  • String.prototype.codePointAt and String.prototype.at are slightly too large to be inlinable, so they're noticeably slower when compared to String.prototype.charCodeAt resp. String.prototype.charAt.
  • StringIteratorNext is also too large to be inlined by default, which means scalar replacement of the iterator and the result object doesn't work.
  • String.prototype.codePointAt and String.prototype.at are slightly too large
    to be inlinable, so they're noticeably slower when compared to
    String.prototype.charCodeAt resp. String.prototype.charAt.
  • StringIteratorNext is also too large to be inlined by default, which means
    scalar replacement of the iterator and the result object doesn't work.

Reorder the operations to match js::unicode::UTF16Decode, which allows the
frontend to constant fold the right most operand into a single constant. This
also saves two subtractions:

  (first - 0xd800) * 0x400 + (second - 0xdc00) + 0x10000
= (first * 0x400) - (0xd800 * 0x400) + (second - 0xdc00) + 0x10000
= (first * 0x400) + second - (0xd800 * 0x400) - 0xdc00 + 0x10000
= (first << 10) + second + (0x10000 - (0xd800 << 10) - 0xdc00)

Depends on D198360

Severity: -- → N/A
Priority: -- → P1
Attachment #9372438 - Attachment is obsolete: true
Attachment #9372437 - Attachment description: Bug 1874373 - Part 1: Mark String.p.{codePointAt,at} and StringIterator.p.next as inlinable. r=jandem! → Bug 1874373 - Part 1: Mark StringIterator.p.next as inlinable. r=jandem!

Directly call String.p.codePointAt instead of manually computing the code
point in StringIteratorNext.

Depends on D198360

Directly call String.p.codePointAt instead of manually computing the code
point in AdvanceStringIndex. This also makes AdvanceStringIndex small
enough to be inlined by default.

Depends on D199350

Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/26beade9b70b Part 1: Mark StringIterator.p.next as inlinable. r=jandem https://hg.mozilla.org/integration/autoland/rev/43b98212a7d0 Part 2: Call String.p.codePointAt in StringIteratorNext. r=jandem https://hg.mozilla.org/integration/autoland/rev/e48b625ffa25 Part 3: Call String.p.codePointAt in AdvanceStringIndex. r=jandem
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 124 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: