Closed Bug 503157 Opened 15 years ago Closed 15 years ago

TM: avoid integer division in NewGCThing path

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: gal, Assigned: gal)

References

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 3 obsolete files)

      No description provided.
Attached patch patch (obsolete) — Splinter Review
This was originally discovered by Gregor.
Assignee: general → gal
Blocks: 503141
This patch specializes NewGCThing for JSObject, JSFunction, JSString and JSXML. We always allocate for sizeof(T), and don't try to save a few trailing words for cloned JSFunctions and certain JSXML objects.
Attachment #387510 - Attachment is obsolete: true
Attachment #387767 - Flags: review?(brendan)
Attachment #387767 - Flags: review?(igor)
Comment on attachment 387767 [details] [diff] [review]
specialize NewGCThing to avoid integer mul/div in the allocator path

Brendan indicated his preference for adding back another size class for cloned Functions. I am a bit reluctant on that. I can't imagine it makes a big enough difference but I will go ahead and measure it.
Attachment #387767 - Flags: review?(brendan) → review?(jorendorff)
Attached patch patch (obsolete) — Splinter Review
This addresses an offline-nit by Brendan to restore the previous behavior of not over-allocating cloned Functions. JSXML objects still potentially waste a few bytes, but W.
Attachment #387767 - Attachment is obsolete: true
Attachment #388141 - Flags: review?(jorendorff)
Attachment #387767 - Flags: review?(jorendorff)
Attachment #387767 - Flags: review?(igor)
(In reply to comment #4)
> Created an attachment (id=388141) [details]
> patch

What about passing flindex to NewGCThing with helper inline functions calculating the index statically? This will avoid the useless code duplication in jsgc.cpp.
The path seems very sensitive to the generated code. I don't think there is a way to guess it. Do you want to sketch up a patch and we measure it?
Btw, its not flindex thats the issue here. Its the individual THING_TO_FLAGP and FLAGP_TO_THING macro calculations, which result in simple shift if we specialize, but actual heavy-weight idiv/imul if we don't. Let me know if you want to do an alternative patch.
(In reply to comment #7)
> Btw, its not flindex thats the issue here. Its the individual THING_TO_FLAGP
> and FLAGP_TO_THING macro calculations, which result in simple shift if we
> specialize, but actual heavy-weight idiv/imul if we don't. Let me know if you
> want to do an alternative patch.

You are right, it seems that the template function is a good way to optimize this.
Attached patch patchSplinter Review
Attachment #388141 - Attachment is obsolete: true
Attachment #388377 - Flags: review?(jwalden+bmo)
Attachment #388141 - Flags: review?(jorendorff)
Attachment #388377 - Flags: review?(jwalden+bmo) → review+
http://hg.mozilla.org/tracemonkey/rev/b0f849609c10
Whiteboard: fixed-in-tracemonkey
http://hg.mozilla.org/mozilla-central/rev/b0f849609c10
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: