Closed Bug 1039551 Opened 11 years ago Closed 11 years ago

NewString/NewStringDontDeflate should create inline strings if possible

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla34

People

(Reporter: jandem, Assigned: jandem)

References

Details

(Whiteboard: [Memshrink:P2])

Attachments

(1 file)

Attached patch PatchSplinter Review
Unlike NewStringCopyN, NewString does not attempt to allocate an inline string. I just instrumented the browser and in many cases the length is short enough that we really want an inline string. NewString* is not as hot as NewStringCopy*, but I think it's good to be consistent and to use inline strings as much as possible, to save memory and avoid unnecessary fragmentation.
Attachment #8456919 - Flags: review?(n.nethercote)
Comment on attachment 8456919 [details] [diff] [review] Patch Review of attachment 8456919 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jsstr.cpp @@ +4399,5 @@ > return cx->staticStrings().getUnit(c); > } > } > > + if (JSFatInlineString::lengthFits<CharT>(length) && EnableLatin1Strings) { Hm I thought checking EnableLatin1Strings was necessary (because NewFatInlineString attemps to inflate if latin1 is disabled) but it probably isn't (if EnableLatin1Strings == false, CharT should be != Latin1Char or else the JSFlatString::new_ below would be wrong, so I'll remove it.
Comment on attachment 8456919 [details] [diff] [review] Patch Review of attachment 8456919 [details] [diff] [review]: ----------------------------------------------------------------- Is it worth checking to see if it fits within a non-fat inline string first?
Attachment #8456919 - Flags: review?(n.nethercote) → review+
(In reply to Nicholas Nethercote [:njn] from comment #2) > Is it worth checking to see if it fits within a non-fat inline string first? NewFatInlineString calls AllocateFatInlineString, which will try to use a non-fat inline string if possible. We should really rename NewFatInlineString to NewInlineString, NewInlineOrFatInlineString or something...
> We should really rename NewFatInlineString to NewInlineString, > NewInlineOrFatInlineString or something... I wonder if it's worth renaming "JSInlineString" as "JSSlimInlineString", which would allow us to use "inline" to refer to both kinds.
(In reply to Nicholas Nethercote [:njn] from comment #4) > I wonder if it's worth renaming "JSInlineString" as "JSSlimInlineString", > which would allow us to use "inline" to refer to both kinds. Yeah, but JSFatInlineString inherits from JSInlineString and we often use JSInlineString* for both kinds. Changing it to JSSlimInlineString* would also be confusing there.
(In reply to Ryan VanderMeulen [:RyanVM UTC-4] from comment #7) > Backed out for Windows debug mochitest-4 crashes. Hm, sorry for that. I doubt it's directly caused by this patch though; it's pretty simple and it works fine everywhere else. Maybe it exposed another issue somewhere, will investigate.
Whiteboard: [Memshrink] → [Memshrink:P2]
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: