Closed Bug 1451658 Opened 2 years ago Closed 2 years ago

Add MOZ_STATIC_CLASS annotation

Categories

(Core :: MFBT, enhancement)

enhancement
Not set

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: njn, Assigned: njn)

Details

Attachments

(2 files)

It would be nice to have a MOZ_STATIC_CLASS annotation, indicating that objects of a class should only be instantiated in static memory.

Nika says:

> there is an attribute which requires that a class is used only in statics,
> which is __attribute__((annotate("moz_global_class")))
> 
> This is currently exposed with a macro as MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS:
> https://searchfox.org/mozilla-central/rev/57bbc1ac58816dc054df242948f3ecf75e12df5f/mfbt/Attributes.h#675-681,
> though we should probably also have a MOZ_STATIC_CLASS alias.

Once that's done, this XXX item should be fixed:
https://searchfox.org/mozilla-central/rev/57bbc1ac58816dc054df242948f3ecf75e12df5f/js/public/Class.h#617
Comment on attachment 8966513 [details]
Bug 1451658 - Add MOZ_STATIC_CLASS.

https://reviewboard.mozilla.org/r/235236/#review241008
Attachment #8966513 - Flags: review?(nika) → review+
Comment on attachment 8966514 [details]
Bug 1451658 - Remove JS_STATIC_CLASS in favour of MOZ_STATIC_CLASS.

https://reviewboard.mozilla.org/r/235238/#review241010
Attachment #8966514 - Flags: review?(nika) → review+
Pushed by nnethercote@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/4ce7bb67eab9
Add MOZ_STATIC_CLASS. r=mystor
https://hg.mozilla.org/integration/mozilla-inbound/rev/8c6cf2dab2ae
Remove JS_STATIC_CLASS in favour of MOZ_STATIC_CLASS. r=mystor
BTW, I did a try push where I used a MOZ_STATIC_CLASS as a heap class and a stack class and it successfully complained about both.
https://hg.mozilla.org/mozilla-central/rev/4ce7bb67eab9
https://hg.mozilla.org/mozilla-central/rev/8c6cf2dab2ae
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
Assignee: nobody → n.nethercote
You need to log in before you can comment on or make changes to this bug.