Closed Bug 1576885 Opened 5 years ago Closed 3 years ago

Reduce size of Maybe<SharedImmutableString>

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: tcampbell, Assigned: cOde.A4sh, Mentored)

References

Details

Attachments

(1 file)

In Bug 1575077 we start making more use of the SharedImmutableStringsCache and should reduce the size of references to shrink ScriptSource by 10 words per top-level script.

It should be possible to move the cache pointer from SharedImmutableString into the StringBox itself, and then allowing this to be a nullable type to replace the use of Maybe.

Assignee: tcampbell → nobody
Status: ASSIGNED → NEW

The first step would be to understand the relation between

  • SharedImmutableString
  • SharedImmutableStringCache
  • SharedImmutableStringCache::Inner
  • SharedImmutableStringCache::StringBox

Since multiple SharedImmutableString may point to the same StringBox, moving the cache_ field from SharedImmutableString to StringBox should save us memory in general.

Part 2 of this bug would be to to have SharedImmutableString support null strings (eg, box_ being nullptr). If we did that, we could replace uses of Maybe<SharedImmutableString> and save more memory.

Assignee: nobody → cOde.A4sh
Mentor: tcampbell

For Part 2 there are probably a few steps:

  • Add a new Constructor to SharedImmutableString that takes no arguments and sets box_ to nullptr. This will represent a missing string. Today we use Maybe<SharedImmutableString> set to Nothing to represent that. See here for documents on Maybe.
  • Use that new constructor in a dummy place and fix crashes. For example, add SharedImmutableString _dummy; after this. When you try to run the jsshell, you will see assertion failures such as here. We need to teach the code how to deal with box_ being null and add an "if (box)" around certain code.
  • Add an "operator bool" to SharedImmutableString similar to here. This will let us write more natural code later.
  • Replace uses of Maybe<SharedImmutableString> with just SharedImmutableString (and the same for SharedImmutableTwoByteString) here. You will also need to change our getOrCreate function we have been working on to stop returning a Maybe type.

(Once again, I recommend doing one step at a time and trying to get it to compile)

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: