Use MFBT Result<T, E> in MInstruction::New.

NEW
Unassigned

Status

()

Core
JavaScript Engine: JIT
P3
normal
a year ago
a year ago

People

(Reporter: nbp, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

a year ago
Today, our MIR Instructions have 2 different New static functions:

    static MThisOpcode* New(TempAllocator& alloc, ...)
    static MThisOpcode* New(TempAllocator::Fallible alloc, ...)

Ideally the type of the argument should be enough to know if we should check for failures or not, but unfortunately, we still have tens of legacy New function taking the infallible Allocator and returning either null or a valid pointer.

I suggest we rewrite the signature of the above to:

    static NotNull<MThisOpcode*> New(TempAllocator& alloc, ...)
    static AbortReasonOr<NotNull<MThisOpcode*>> New(TempAllocator::Fallible alloc, ...)

This would have the benefit of forcing any function using these New functions to forward the error code, and also to prevent useless checks for null pointers from Ion code base (mozilla::NotNull::operator bool() = delete).
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.