зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1295192 - part 1 - remove CPP_THROW_NEW on layout struct operator new overloads that forward to nsPresShell::AllocateByObjectID; r=dholbert
Structs in our style system use an arena-style allocation system, managed by the presshell to which they belong. All of the relevant overloads that forward allocation requests to the presshell declare themselves as CPP_THROW_NEW, which indicates that they do not throw exceptions. The C++ specification states that operator new overloads that declare themselves to not throw exceptions require a null check on their return value. However, the relevant presshell allocation method, AllocateByObjectID, is infallible and will never return a null pointer. The callers of all of these methods are therefore doing useless (compiler-generated) null checks. Let's get rid of those useless checks by removing the CPP_THROW_NEW annotations. This change declares these methods will return non-null pointers and throw exceptions in case of errors--but as we don't use exceptions, and AllocateByObjectID will abort on OOM, everything works out OK.
This commit is contained in:
Родитель
da3e07b555
Коммит
fa4f709cfd
|
@ -25,7 +25,7 @@ const AlignedFrameListBytes gEmptyFrameListBytes = { 0 };
|
|||
} // namespace mozilla
|
||||
|
||||
void*
|
||||
nsFrameList::operator new(size_t sz, nsIPresShell* aPresShell) CPP_THROW_NEW
|
||||
nsFrameList::operator new(size_t sz, nsIPresShell* aPresShell)
|
||||
{
|
||||
return aPresShell->AllocateByObjectID(eArenaObjectID_nsFrameList, sz);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
/**
|
||||
* Infallibly allocate a nsFrameList from the shell arena.
|
||||
*/
|
||||
void* operator new(size_t sz, nsIPresShell* aPresShell) CPP_THROW_NEW;
|
||||
void* operator new(size_t sz, nsIPresShell* aPresShell);
|
||||
|
||||
/**
|
||||
* Deallocate this list that was allocated from the shell arena.
|
||||
|
|
|
@ -147,7 +147,7 @@ nsLineBox::NoteFramesMovedFrom(nsLineBox* aFromLine)
|
|||
}
|
||||
|
||||
void*
|
||||
nsLineBox::operator new(size_t sz, nsIPresShell* aPresShell) CPP_THROW_NEW
|
||||
nsLineBox::operator new(size_t sz, nsIPresShell* aPresShell)
|
||||
{
|
||||
return aPresShell->AllocateByObjectID(eArenaObjectID_nsLineBox, sz);
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ private:
|
|||
|
||||
// Infallible overloaded new operator. Uses an arena (which comes from the
|
||||
// presShell) to perform the allocation.
|
||||
void* operator new(size_t sz, nsIPresShell* aPresShell) CPP_THROW_NEW;
|
||||
void* operator new(size_t sz, nsIPresShell* aPresShell);
|
||||
void operator delete(void* aPtr, size_t sz) = delete;
|
||||
|
||||
public:
|
||||
|
|
|
@ -980,7 +980,7 @@ public:
|
|||
NS_IMETHOD_(MozExternalRefCountType) AddRef() override;
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release() override;
|
||||
|
||||
void* operator new(size_t sz, nsPresContext* aPresContext) CPP_THROW_NEW
|
||||
void* operator new(size_t sz, nsPresContext* aPresContext)
|
||||
{
|
||||
return aPresContext->PresShell()->AllocateByObjectID(
|
||||
eArenaObjectID_DependentBuiltinCounterStyle, sz);
|
||||
|
@ -1101,7 +1101,7 @@ public:
|
|||
NS_IMETHOD_(MozExternalRefCountType) AddRef() override;
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release() override;
|
||||
|
||||
void* operator new(size_t sz, nsPresContext* aPresContext) CPP_THROW_NEW
|
||||
void* operator new(size_t sz, nsPresContext* aPresContext)
|
||||
{
|
||||
return aPresContext->PresShell()->AllocateByObjectID(
|
||||
eArenaObjectID_CustomCounterStyle, sz);
|
||||
|
|
|
@ -1520,7 +1520,7 @@ SetFactor(const nsCSSValue& aValue, float& aField, RuleNodeCacheConditions& aCon
|
|||
}
|
||||
|
||||
void*
|
||||
nsRuleNode::operator new(size_t sz, nsPresContext* aPresContext) CPP_THROW_NEW
|
||||
nsRuleNode::operator new(size_t sz, nsPresContext* aPresContext)
|
||||
{
|
||||
// Check the recycle list first.
|
||||
return aPresContext->PresShell()->AllocateByObjectID(eArenaObjectID_nsRuleNode, sz);
|
||||
|
|
|
@ -36,7 +36,7 @@ struct nsInheritedStyleData
|
|||
nsStyleStructID_Inherited_Start,
|
||||
nsStyleStructID_Inherited_Count> mStyleStructs;
|
||||
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsInheritedStyleData, sz);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ struct nsResetStyleData
|
|||
}
|
||||
}
|
||||
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsResetStyleData, sz);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ struct nsConditionalResetStyleData
|
|||
Entry* aNext)
|
||||
: mConditions(aConditions), mStyleStruct(aStyleStruct), mNext(aNext) {}
|
||||
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->AllocateByObjectID(
|
||||
mozilla::eArenaObjectID_nsConditionalResetStyleDataEntry, sz);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ struct nsConditionalResetStyleData
|
|||
mConditionalBits = 0;
|
||||
}
|
||||
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->AllocateByObjectID(
|
||||
mozilla::eArenaObjectID_nsConditionalResetStyleData, sz);
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ private:
|
|||
|
||||
public:
|
||||
// Infallible overloaded new operator that allocates from a presShell arena.
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
|
||||
void* operator new(size_t sz, nsPresContext* aContext);
|
||||
void Destroy();
|
||||
|
||||
// Implemented in nsStyleSet.h, since it needs to know about nsStyleSet.
|
||||
|
|
|
@ -1336,7 +1336,7 @@ void nsStyleContext::List(FILE* out, int32_t aIndent, bool aListDescendants)
|
|||
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
|
||||
// (which comes from the presShell) to perform the allocation.
|
||||
void*
|
||||
nsStyleContext::operator new(size_t sz, nsPresContext* aPresContext) CPP_THROW_NEW
|
||||
nsStyleContext::operator new(size_t sz, nsPresContext* aPresContext)
|
||||
{
|
||||
// Check the recycle list first.
|
||||
return aPresContext->PresShell()->
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
already_AddRefed<ServoComputedValues> aComputedValues,
|
||||
bool aSkipParentDisplayBasedStyleFixup);
|
||||
|
||||
void* operator new(size_t sz, nsPresContext* aPresContext) CPP_THROW_NEW;
|
||||
void* operator new(size_t sz, nsPresContext* aPresContext);
|
||||
void Destroy();
|
||||
|
||||
// These two methods are for use by ArenaRefPtr.
|
||||
|
|
|
@ -181,7 +181,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleFont
|
|||
static already_AddRefed<nsIAtom> GetLanguage(StyleStructContext aPresContext);
|
||||
|
||||
void* operator new(size_t sz, nsStyleFont* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleFont, sz);
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColor
|
|||
}
|
||||
|
||||
void* operator new(size_t sz, nsStyleColor* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleColor, sz);
|
||||
}
|
||||
|
@ -824,7 +824,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBackground {
|
|||
~nsStyleBackground();
|
||||
|
||||
void* operator new(size_t sz, nsStyleBackground* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleBackground, sz);
|
||||
}
|
||||
|
@ -884,7 +884,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleMargin
|
|||
}
|
||||
|
||||
void* operator new(size_t sz, nsStyleMargin* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleMargin, sz);
|
||||
}
|
||||
|
@ -931,7 +931,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePadding
|
|||
}
|
||||
|
||||
void* operator new(size_t sz, nsStylePadding* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStylePadding, sz);
|
||||
}
|
||||
|
@ -1138,7 +1138,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder
|
|||
~nsStyleBorder();
|
||||
|
||||
void* operator new(size_t sz, nsStyleBorder* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleBorder, sz);
|
||||
}
|
||||
|
@ -1371,7 +1371,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleOutline
|
|||
}
|
||||
|
||||
void* operator new(size_t sz, nsStyleOutline* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleOutline, sz);
|
||||
}
|
||||
|
@ -1484,7 +1484,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleList
|
|||
~nsStyleList();
|
||||
|
||||
void* operator new(size_t sz, nsStyleList* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleList, sz);
|
||||
}
|
||||
|
@ -1711,7 +1711,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition
|
|||
~nsStylePosition();
|
||||
|
||||
void* operator new(size_t sz, nsStylePosition* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStylePosition, sz);
|
||||
}
|
||||
|
@ -1962,7 +1962,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTextReset
|
|||
~nsStyleTextReset();
|
||||
|
||||
void* operator new(size_t sz, nsStyleTextReset* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleTextReset, sz);
|
||||
}
|
||||
|
@ -2049,7 +2049,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText
|
|||
~nsStyleText();
|
||||
|
||||
void* operator new(size_t sz, nsStyleText* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleText, sz);
|
||||
}
|
||||
|
@ -2270,7 +2270,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVisibility
|
|||
}
|
||||
|
||||
void* operator new(size_t sz, nsStyleVisibility* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleVisibility, sz);
|
||||
}
|
||||
|
@ -2787,7 +2787,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay
|
|||
}
|
||||
|
||||
void* operator new(size_t sz, nsStyleDisplay* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleDisplay, sz);
|
||||
}
|
||||
|
@ -3065,7 +3065,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTable
|
|||
~nsStyleTable();
|
||||
|
||||
void* operator new(size_t sz, nsStyleTable* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleTable, sz);
|
||||
}
|
||||
|
@ -3096,7 +3096,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTableBorder
|
|||
~nsStyleTableBorder();
|
||||
|
||||
void* operator new(size_t sz, nsStyleTableBorder* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleTableBorder, sz);
|
||||
}
|
||||
|
@ -3197,7 +3197,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleContent
|
|||
~nsStyleContent();
|
||||
|
||||
void* operator new(size_t sz, nsStyleContent* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleContent, sz);
|
||||
}
|
||||
|
@ -3309,7 +3309,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUIReset
|
|||
~nsStyleUIReset();
|
||||
|
||||
void* operator new(size_t sz, nsStyleUIReset* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleUIReset, sz);
|
||||
}
|
||||
|
@ -3378,7 +3378,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUserInterface
|
|||
~nsStyleUserInterface();
|
||||
|
||||
void* operator new(size_t sz, nsStyleUserInterface* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleUserInterface, sz);
|
||||
}
|
||||
|
@ -3430,7 +3430,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleXUL
|
|||
~nsStyleXUL();
|
||||
|
||||
void* operator new(size_t sz, nsStyleXUL* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleXUL, sz);
|
||||
}
|
||||
|
@ -3469,7 +3469,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColumn
|
|||
~nsStyleColumn();
|
||||
|
||||
void* operator new(size_t sz, nsStyleColumn* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleColumn, sz);
|
||||
}
|
||||
|
@ -3567,7 +3567,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVG
|
|||
~nsStyleSVG();
|
||||
|
||||
void* operator new(size_t sz, nsStyleSVG* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleSVG, sz);
|
||||
}
|
||||
|
@ -3758,7 +3758,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVGReset
|
|||
~nsStyleSVGReset();
|
||||
|
||||
void* operator new(size_t sz, nsStyleSVGReset* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleSVGReset, sz);
|
||||
}
|
||||
|
@ -3809,7 +3809,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVariables
|
|||
~nsStyleVariables();
|
||||
|
||||
void* operator new(size_t sz, nsStyleVariables* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleVariables, sz);
|
||||
}
|
||||
|
@ -3839,7 +3839,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleEffects
|
|||
~nsStyleEffects();
|
||||
|
||||
void* operator new(size_t sz, nsStyleEffects* aSelf) CPP_THROW_NEW { return aSelf; }
|
||||
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
||||
void* operator new(size_t sz, nsPresContext* aContext) {
|
||||
return aContext->PresShell()->
|
||||
AllocateByObjectID(mozilla::eArenaObjectID_nsStyleEffects, sz);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче