Closed Bug 1669942 Opened 4 years ago Closed 1 year ago

Optimize charCodeAt/charAt on ropes

Categories

(Core :: JavaScript Engine: JIT, task, P2)

task

Tracking

()

RESOLVED FIXED
109 Branch
Tracking Status
firefox109 --- fixed

People

(Reporter: jandem, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

This affects the crypto-sha1 test in JetStream 2 (test originally from SunSpider). We spend time in str_charCodeAt because the string here is a rope initially:

  for(var i = 0; i < str.length * chrsz; i += chrsz) {
    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
  }

This is probably quite common.

The crypto-md5 test has the same issue.

charCodeAt() should normally flatten ropes - unless we're hitting bug 1382639 here?

(In reply to André Bargull [:anba] from comment #2)

charCodeAt() should normally flatten ropes

But if we fail to inline charCodeAt we attach a CallNative stub so we'll never try optimizing charCodeAt again..

Blocks: jetstream2

We can't inline String.prototype.charAt and String.prototype.charCodeAt in a
couple of JetStream tests because the input is a nested rope.

Before this change, we can observe the following number of non-inlined calls to
these functions:

crypto
String.prototype.charCodeAt 360'000

pdfjs
String.prototype.charCodeAt 21'910'000

typescript
String.prototype.charCodeAt 17'840'000

base64-SP
String.prototype.charCodeAt 39'300'000

crypto-md5-SP
String.prototype.charCodeAt 41'750'000

crypto-sha1-SP
String.prototype.charCodeAt 30'180'000

acorn-wtb
String.prototype.charCodeAt 3'370'000

jshint-wtb
String.prototype.charAt 2'450'000
String.prototype.charCodeAt 200'000

uglify-js-wtb
String.prototype.charAt 450'000

After this change, only the WBT sub-benchmarks still have non-inlined calls:

acorn-wtb
String.prototype.charCodeAt 1'150'000

jshint-wtb
String.prototype.charAt 2'450'000
String.prototype.charCodeAt 200'000

uglify-js-wtb
String.prototype.charAt 450'000

Depends on D162725

Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Pushed by andre.bargull@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/6810bbf2119c
Add CacheIR op to linearise strings for char-accesses. r=jandem
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: