Reduce size of Maybe<SharedImmutableString>
Categories
(Core :: JavaScript Engine, task, P2)
Tracking
()
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.
Reporter | ||
Updated•3 years ago
|
Reporter | ||
Comment 1•3 years ago
|
||
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.
Reporter | ||
Comment 2•3 years ago
|
||
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.
Reporter | ||
Updated•3 years ago
|
Reporter | ||
Comment 4•3 years ago
|
||
For Part 2 there are probably a few steps:
- Add a new Constructor to
SharedImmutableString
that takes no arguments and setsbox_
to nullptr. This will represent a missing string. Today we useMaybe<SharedImmutableString>
set toNothing
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 withbox_
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 justSharedImmutableString
(and the same for SharedImmutableTwoByteString) here. You will also need to change ourgetOrCreate
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)
Comment 5•3 years ago
|
||
bugherder |
Description
•