Closed Bug 907508 Opened 11 years ago Closed 11 years ago

Remove unused reserved slots on globals and simplify invariants

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: bholley, Assigned: bholley)

References

Details

Attachments

(4 files)

bz and I just dug into this, and it looks like we've been sloppy over the past year with the slots we use on globals. I'm going to clean this up - patches coming.
In the old world, XPConnect globals had one reserved slot, which was used to
store a private pointer to the XPCWrappedNativeScope.

Then, in the new DOM bindings landing (bug 740069), we added two slots, one
for DOM_GLOBAL_OBJECT_SLOT, and one for DOM_PROTOTYPE_SLOT.

Then, in bug 761707, we removed DOM_GLOBAL_OBJECT_SLOT, but the slot count
remained at 3.

Then, in bug 797821, we stopped storing the XPCWrappedNativeScope in the slot
on the global, and dropped the XPConnect global count from 3 to 2.

Given the above, we can safely drop it to 1, here. It's easy to check that
this is correct, because reserved slots for globals have a different offset,
which is JSCLASS_GLOBAL_SLOT_COUNT. And according to mxr, the only thing
defined in terms of that is DOM_PROTOTYPE_SLOT (which takes the same value).
This means that all subsequent slots on the global are unused.
Attachment #793254 - Flags: review?(bzbarsky)
Continuing the analysis of the previous patch, we actually have two free slots.

The first comes from the removal of DOM_GLOBAL_OBJECT_SLOT, as in the previous
patch.

The second comes from the fact that we mirrored the XPConnect slot for the
XPCWrappedNativeScope (so that slot offsets would be the same for workers and
non-workers), but didn't drop the slot count in bug 797821.
Attachment #793255 - Flags: review?(bzbarsky)
Comment on attachment 793254 [details] [diff] [review]
Part 1 - Drop the number of slots on XPConnect globals from 2 to 1. v1

r=me
Attachment #793254 - Flags: review?(bzbarsky) → review+
Comment on attachment 793255 [details] [diff] [review]
Part 2 - Drop the slot count for worker globals from 3 to 1. v1

r=me
Attachment #793255 - Flags: review?(bzbarsky) → review+
Comment on attachment 793257 [details] [diff] [review]
Part 3 - Define the slot count for xpconnect and worker globals in terms of the slots defined in DOMJSClass.h. v1

r=me
Attachment #793257 - Flags: review?(bzbarsky) → review+
Comment on attachment 793258 [details] [diff] [review]
Part 4 - Provide a mechanism for adding extra slots for XPConnect globals. v1

r=me
Attachment #793258 - Flags: review?(bzbarsky) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: