Closed Bug 413104 Opened 15 years ago Closed 15 years ago

Avoid accessing JSString.length and JSString.u.chars directly

Categories

(Core :: JavaScript Engine, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED

People

(Reporter: igor, Assigned: igor)

References

Details

Attachments

(1 file)

[This is a spin-off of bug 412340].

Currently the SpiderMonkey code accesses directly the length and u.chars fields of JSString when it is known that the string is flat. But that make it hard to store in the fields extra flags to implement various optimizations/feature. For example, bug 412340 proposes to add a flag indicating the atomized status of the string.

It would be nice to hide the access to the fields behind a special-purpose flat string macros.
Asking for blocking1.9 flag as the bug 412340 is blocking1.9+ and depends on this bug.
Flags: blocking1.9?
Attached patch v1Splinter Review
The patch is essentially the part of the patch from bug 412340 comment 34 that adds JSFLAT_CHARS macros with the following extras:

1. JSSTRING_(INIT|SET_MUTABLE|CLEAR_MUTABLE) macros are only to flat strings. I renamed them as JSFLATSTR_(INIT|SET_MUTABLE|CLEAR_MUTABLE).

2. I added JSSTRING_IS_FLAT(str) for brevity.

3. I removed FRIEND declarations from atomized functions as they are not used outside the SpiderMonkey.
Attachment #297969 - Flags: review?(brendan)
blocking+ for sure
Flags: blocking1.9? → blocking1.9+
Priority: -- → P1
Comment on attachment 297969 [details] [diff] [review]
v1

Ok by me -- whole patch for the blocked bug could go back in too, but I guess this has more changes than were reviewed in that bug's patch?

/be
Attachment #297969 - Flags: review?(brendan)
Attachment #297969 - Flags: review+
Attachment #297969 - Flags: approval1.9+
(In reply to comment #4)
> (From update of attachment 297969 [details] [diff] [review])
> Ok by me -- whole patch for the blocked bug could go back in too, but I guess
> this has more changes than were reviewed in that bug's patch?

Yes, this is the case.
I checked in the patch from comment 2 to the trunk:

http://bonsai.mozilla.org/cvsquery.cgi?module=PhoenixTinderbox&branch=HEAD&cvsroot=%252Fcvsroot&date=explicit&mindate=1200777240&maxdate=1200777542&who=igor%25mir2.org
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Depends on: 413793
Flags: in-testsuite-
Flags: in-litmus-
You need to log in before you can comment on or make changes to this bug.