Closed Bug 1599921 Opened 1 year ago Closed 1 year ago

Make rust atom!() actually generate consts.

Categories

(Core :: CSS Parsing and Computation, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla73
Tracking Status
firefox73 --- fixed

People

(Reporter: emilio, Assigned: emilio)

Details

Attachments

(1 file)

I see atom dropping code generated in release builds for stuff like dropping the class atom here: https://searchfox.org/mozilla-central/rev/4df8821c1b824db5f40f381f48432f219d99ae36/servo/components/style/gecko/wrapper.rs#592

That is silly, and I hope making Atom be able to be used in const context will help the compiler see that yeah, we're not doing anything interesting and the atom shouldn't get dropped.

It also allows us to get rid of a few lazy_static!s, so we should do it anyway.

I see atom dropping code generated in release builds for stuff like dropping the
"class" atom here:

https://searchfox.org/mozilla-central/rev/4df8821c1b824db5f40f381f48432f219d99ae36/servo/components/style/gecko/wrapper.rs#592

That is silly, and I hope making Atom be able to be used in const context will
help the compiler see that yeah, we're not doing anything interesting and the
atom shouldn't get dropped.

It also allows us to get rid of a few lazy_static!s, so we should do it anyway.

In order to accomplish this, compute the offset into gGkAtoms manually instead
of going through the static_atoms() array and then back to the byte offset.

Type: defect → task
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e4813b5e0662
Make Rust static atoms able to be used in const contexts. r=boris
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla73
You need to log in before you can comment on or make changes to this bug.