mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 03:05:34 +00:00
Bug 1264948 - Make it possible to use a placement-new with a fallible TempAllocator. r=h4writer
This commit is contained in:
parent
e9b8a82345
commit
0619381333
@ -272,9 +272,7 @@ class LiveRange : public TempObject
|
||||
static LiveRange* FallibleNew(TempAllocator& alloc, uint32_t vreg,
|
||||
CodePosition from, CodePosition to)
|
||||
{
|
||||
if (!alloc.ensureBallast())
|
||||
return nullptr;
|
||||
return new(alloc) LiveRange(vreg, Range(from, to));
|
||||
return new(alloc.fallible()) LiveRange(vreg, Range(from, to));
|
||||
}
|
||||
|
||||
uint32_t vreg() const {
|
||||
@ -422,9 +420,7 @@ class LiveBundle : public TempObject
|
||||
public:
|
||||
static LiveBundle* FallibleNew(TempAllocator& alloc, SpillSet* spill, LiveBundle* spillParent)
|
||||
{
|
||||
if (!alloc.ensureBallast())
|
||||
return nullptr;
|
||||
return new(alloc) LiveBundle(spill, spillParent);
|
||||
return new(alloc.fallible()) LiveBundle(spill, spillParent);
|
||||
}
|
||||
|
||||
SpillSet* spillSet() const {
|
||||
|
@ -60,6 +60,10 @@ class TempAllocator
|
||||
return p;
|
||||
}
|
||||
|
||||
// View this allocator as a fallible allocator.
|
||||
struct Fallible { TempAllocator& alloc; };
|
||||
Fallible fallible() { return { *this }; }
|
||||
|
||||
LifoAlloc* lifoAlloc()
|
||||
{
|
||||
return &lifoScope_.alloc();
|
||||
@ -145,6 +149,9 @@ class AutoJitContextAlloc
|
||||
|
||||
struct TempObject
|
||||
{
|
||||
inline void* operator new(size_t nbytes, TempAllocator::Fallible view) noexcept {
|
||||
return view.alloc.allocate(nbytes);
|
||||
}
|
||||
inline void* operator new(size_t nbytes, TempAllocator& alloc) {
|
||||
return alloc.allocateInfallible(nbytes);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user