Closed Bug 1379461 Opened 2 years ago Closed 2 years ago

Return RegExpShared* instead of using bool + outparam


(Core :: JavaScript Engine, enhancement)

Not set



Tracking Status
firefox56 --- fixed


(Reporter: jandem, Assigned: jandem)



(2 files)

Attached patch PatchSplinter Review
There are a lot of places where we can return RegExpShared* instead of returning bool and using a RegExpShared outparam. This is cleaner and lets us eliminate a bunch of unnecessary roots.

This is a very mechanical patch. I did have to beef up the FORWARD macro in the js/ipc CPOW code to let us return nullptr on failure instead of false.
Attachment #8884624 - Flags: review?(evilpies)
Attachment #8884624 - Flags: review?(evilpies) → review+
Pushed by
Refactor code to return RegExpShared* directly instead of using bool + outparam. r=evilpie
backed out for hazard failure like
Flags: needinfo?(jdemooij)
Backout by
Backed out changeset 3a0a2ffe803b for hazard failure
We use the macro below in the CPOW code.

The analysis thinks that when the return value is a RegExpShared*, it's live across a GC call: AUTO_PROFILER_LABEL macro -> ~AutoProfilerLabel destructor.

This is bogus because ~AutoProfilerLabel has an indirect call but definitely can't GC.

I think the easiest fix is to teach the analysis that ~AutoProfilerLabel cannot GC. Unfortunately this code is in mozglue so I don't think we can use our SuppressGCAnalysis class for this.

This patch adds an annotation and I get a green analysis build with this on Try.

#define FORWARD(call, args, failRetVal)                                 \
    AUTO_PROFILER_LABEL(__func__, JS);                                  \
    WrapperOwner* owner = OwnerOf(proxy);                               \
    if (!owner->active()) {                                             \
        JS_ReportErrorASCII(cx, "cannot use a CPOW whose process is gone"); \
        return failRetVal;                                              \
    }                                                                   \
    if (!owner->allowMessage(cx)) {                                     \
        return failRetVal;                                              \
    }                                                                   \
    {                                                                   \
        CPOWTimer timer(cx);                                            \
        return owner->call args;                                        \
Flags: needinfo?(jdemooij)
Attachment #8885247 - Flags: review?(sphink)
Attachment #8885247 - Flags: review?(sphink) → review+
Pushed by
Refactor code to return RegExpShared* directly instead of using bool + outparam. r=evilpie,sfink
Depends on: 1380134
No longer depends on: 1380134
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in before you can comment on or make changes to this bug.