Closed Bug 1633468 Opened 1 year ago Closed 1 year ago

Generated bindings code tests jsids against nullptr rather JSID_VOID

Categories

(Core :: DOM: Bindings (WebIDL), task, P3)

task

Tracking

()

RESOLVED FIXED
mozilla77
Tracking Status
firefox77 --- fixed

People

(Reporter: jonco, Assigned: jonco)

Details

Attachments

(1 file)

There's this code in the CycleCollectedJSContext constructor:

  // Reinitialize PerThreadAtomCache because dom/bindings/Codegen.py compares
  // against zero rather than JSID_VOID to detect uninitialized jsid members.
  memset(static_cast<PerThreadAtomCache*>(this), 0, sizeof(PerThreadAtomCache));

As far as I can tell this is unnecessary if we change bindings to compare agains JSID_VOID (jsids have a constructor that initialises them to JSID_VOID).

My guess is that the reason it's like this was to do with avoiding calling jsid constructors, bfore these were constexpr.

I spent some time digging into why it is doing null checks. It looks like that's how this initially landed in bug 903772 part 4. If I'm reading the patch correctly, it always initialized the fields to JSID_VOID (near ClassMember(m.identifier.name + "_id"). I assume INTERNED_STRING_TO_JSID always returns a value that isn't JSID_VOID. So, I have no idea why this ever did this memset stuff. Oh well!

Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d32836d92400
Make dom/bindings/Codegen.py compare against JSID_VOID to detect uninitialized jsid members r=mccr8
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla77
You need to log in before you can comment on or make changes to this bug.