Closed Bug 1632439 Opened 4 months ago Closed 3 months ago

Make CallbackObject methods return JSObject pointers rather than handles

Categories

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

task

Tracking

()

RESOLVED FIXED
mozilla78
Tracking Status
firefox78 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

In general methods that return pointers to GC things do so by returning a raw pointer, which must be rooted before being passed into any JS APIs.

Returning JS::Handle<JSObject*> is undesirable because:

  • it requires enforcing invariants about not mutating the original member while the handle is in use
  • it requires use of Handle::fromMarkedLocation which is a footgun and can cause security vulerabilities if used incorrectly

The advantage of doing it this was is that it saves rooting the value in some places, but I think the difference is negligable.

This turned out to be simpler than expected. Apart from generated bindings, a lot of the callers didn't make use of the fact that the return value was a handle.

Blocks: 1632459
Severity: -- → N/A
Priority: -- → P2
Attachment #9142662 - Attachment description: Bug 1632439 - Make CallbackObject methods return JSObject pointers rather than handles r?mccr8 → Bug 1632439 - Make CallbackObject methods return JSObject pointers rather than handles r?peterv
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2a2f55e482c1
Make CallbackObject methods return JSObject pointers rather than handles r=peterv
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla78
You need to log in before you can comment on or make changes to this bug.