Closed
Bug 654369
Opened 14 years ago
Closed 14 years ago
Remove OOM checks from layout
Categories
(Core :: Layout, defect)
Core
Layout
Tracking
()
RESOLVED
FIXED
mozilla7
People
(Reporter: craig.topper, Assigned: craig.topper)
Details
Attachments
(7 files, 13 obsolete files)
2.96 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
2.48 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
2.06 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
4.81 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
3.27 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
17.46 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
27.21 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Comment 1•14 years ago
|
||
Assignee | ||
Comment 2•14 years ago
|
||
Assignee | ||
Comment 3•14 years ago
|
||
Assignee | ||
Comment 4•14 years ago
|
||
Assignee | ||
Comment 5•14 years ago
|
||
Assignee | ||
Comment 6•14 years ago
|
||
Assignee | ||
Comment 7•14 years ago
|
||
Assignee | ||
Updated•14 years ago
|
Attachment #529631 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #529632 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #529633 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #529634 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #529635 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #529643 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #529644 -
Flags: review?(bzbarsky)
![]() |
||
Comment 8•14 years ago
|
||
Comment on attachment 529631 [details] [diff] [review]
Part 1: Remove NS_NewCaret
r=me
Attachment #529631 -
Flags: review?(bzbarsky) → review+
![]() |
||
Comment 9•14 years ago
|
||
Comment on attachment 529632 [details] [diff] [review]
Part 2: Remove oom check and outparam from PresShell::CloneStyleSet
r=me
Attachment #529632 -
Flags: review?(bzbarsky) → review+
![]() |
||
Comment 10•14 years ago
|
||
Comment on attachment 529633 [details] [diff] [review]
Part 3: Make nsCSSRendering::Init return void
r=me
Attachment #529633 -
Flags: review?(bzbarsky) → review+
![]() |
||
Comment 11•14 years ago
|
||
Comment on attachment 529634 [details] [diff] [review]
Part 4: Make nsContainerFrame::SetOverflowFrames return void
r=me
Attachment #529634 -
Flags: review?(bzbarsky) → review+
![]() |
||
Comment 12•14 years ago
|
||
Comment on attachment 529635 [details] [diff] [review]
Part 5: Make nsFrameList::Init return void
r=me
Attachment #529635 -
Flags: review?(bzbarsky) → review+
![]() |
||
Comment 13•14 years ago
|
||
Comment on attachment 529643 [details] [diff] [review]
Part 6: Remove OOM checks from nsImageMap
This one I'm not convinced about; the page controls |cnt|, right? These allocations would make more sense being fallible, perhaps.
![]() |
||
Comment 14•14 years ago
|
||
Comment on attachment 529644 [details] [diff] [review]
Part 7: Remove OOM checks from nsTextFrameThebes
r=me
Attachment #529644 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 15•14 years ago
|
||
(In reply to comment #13)
> Comment on attachment 529643 [details] [diff] [review] [review]
> Part 6: Remove OOM checks from nsImageMap
>
> This one I'm not convinced about; the page controls |cnt|, right? These
> allocations would make more sense being fallible, perhaps.
Oops. I missed that that was actually a call to new[] rather than just new. I'll undo that.
![]() |
||
Comment 16•14 years ago
|
||
It's not just the new[]; the other allocation here are under content control too, I think.
We should have a followup bug to make that new[] fallible, at least.
Assignee | ||
Comment 17•14 years ago
|
||
(In reply to comment #16)
> It's not just the new[]; the other allocation here are under content control
> too, I think.
>
> We should have a followup bug to make that new[] fallible, at least.
The only other allocation is for the different kinds of Area. How can that one fail except in the case of the NOT_REACHED path. But since "area" isn't initialized at all before the switch there's no guarantee that it will be null on the NOT_REACHED path anyway. Maybe that was a bug in itself?
![]() |
||
Comment 18•14 years ago
|
||
My point is that the number of calls to AddArea is under content control. We should probably make the |new| in AddArea fallible and just do nothing if it fails.
Assignee | ||
Updated•14 years ago
|
Attachment #529643 -
Attachment is obsolete: true
Attachment #529643 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 19•14 years ago
|
||
Assignee | ||
Updated•14 years ago
|
Attachment #530930 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 20•14 years ago
|
||
Assignee | ||
Updated•14 years ago
|
Attachment #530930 -
Attachment is obsolete: true
Attachment #530930 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #530931 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #530931 -
Attachment is obsolete: true
Attachment #530931 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 21•14 years ago
|
||
Assignee | ||
Comment 22•14 years ago
|
||
Assignee | ||
Comment 23•14 years ago
|
||
Assignee | ||
Comment 24•14 years ago
|
||
Assignee | ||
Updated•14 years ago
|
Attachment #530932 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #530933 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #530934 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #530936 -
Flags: review?(bzbarsky)
Comment 25•14 years ago
|
||
Comment on attachment 530932 [details] [diff] [review]
Part 8: Make nsLineIterator::Init return void
>diff --git a/layout/generic/nsFloatManager.cpp b/layout/generic/nsFloatManager.cpp
>--- a/layout/generic/nsFloatManager.cpp
>+++ b/layout/generic/nsFloatManager.cpp
>@@ -570,17 +570,17 @@
> mOld->List(stdout);
> }
> #endif
>
> delete mNew;
> }
> }
>
>-nsresult
>+void
> nsAutoFloatManager::CreateFloatManager(nsPresContext *aPresContext)
> {
> // Create a new float manager and install it in the reflow
> // state. `Remember' the old float manager so we can restore it
> // later.
> mNew = new nsFloatManager(aPresContext->PresShell());
> if (! mNew)
> return NS_ERROR_OUT_OF_MEMORY;
You should remove that check in this patch, not in part 9.
Comment 26•14 years ago
|
||
Comment on attachment 530933 [details] [diff] [review]
Part 9: Remove OOM checks from layout/generic
>diff --git a/layout/generic/nsFrameUtil.cpp b/layout/generic/nsFrameUtil.cpp
>--- a/layout/generic/nsFrameUtil.cpp
>+++ b/layout/generic/nsFrameUtil.cpp
>@@ -503,31 +498,28 @@
> if (type == openClose) {
> aResult.Append(PRUnichar('/'));
> }
> aResult.Append(PRUnichar('>'));
> }
>
> //----------------------------------------------------------------------
>
>-nsresult NS_NewFrameUtil(nsIFrameUtil** aResult);
> nsresult
> NS_NewFrameUtil(nsIFrameUtil** aResult)
> {
> NS_PRECONDITION(nsnull != aResult, "null pointer");
> if (nsnull == aResult) {
> return NS_ERROR_NULL_POINTER;
> }
>- *aResult = nsnull;
>
> nsFrameUtil* it = new nsFrameUtil();
>- if (nsnull == it) {
>- return NS_ERROR_OUT_OF_MEMORY;
>- }
>- return it->QueryInterface(NS_GET_IID(nsIFrameUtil), (void**) aResult);
>+
>+ NS_ADDREF(*aResult = it);
>+ return NS_OK;
> }
This can just return nsFrameUtil* or already_AddRefed<nsFrameUtil>.
>diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp
>--- a/layout/generic/nsGfxScrollFrame.cpp
>+++ b/layout/generic/nsGfxScrollFrame.cpp
>@@ -1564,22 +1564,20 @@
>
> if (mAsyncScroll) {
> if (mAsyncScroll->mIsSmoothScroll) {
> currentPosition = mAsyncScroll->PositionAt(now);
> currentVelocity = mAsyncScroll->VelocityAt(now);
> }
> } else {
> mAsyncScroll = new AsyncScroll;
>- if (mAsyncScroll) {
>- mAsyncScroll->mScrollTimer = do_CreateInstance("@mozilla.org/timer;1");
>- if (!mAsyncScroll->mScrollTimer) {
>- delete mAsyncScroll;
>- mAsyncScroll = nsnull;
>- }
>+ mAsyncScroll->mScrollTimer = do_CreateInstance("@mozilla.org/timer;1");
>+ if (!mAsyncScroll->mScrollTimer) {
>+ delete mAsyncScroll;
>+ mAsyncScroll = nsnull;
> }
> if (!mAsyncScroll) {
> // some allocation failed. Scroll the normal way.
> ScrollToImpl(mDestination);
> return;
> }
I think this would read more easily as
mAsyncScroll->mScrollTimer = do_CreateInstance("@mozilla.org/timer;1");
if (!mAsyncScroll->mScrollTimer) {
delete mAsyncScroll;
mAsyncScroll = nsnull;
ScrollToImpl(mDestination);
return;
}
>diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp
>--- a/layout/generic/nsSelection.cpp
>+++ b/layout/generic/nsSelection.cpp
>@@ -501,28 +501,24 @@
> PRUint32 mDelay;
> };
>
> NS_IMPL_ISUPPORTS1(nsAutoScrollTimer, nsITimerCallback)
>
> nsresult NS_NewSelection(nsFrameSelection **aFrameSelection)
> {
> nsFrameSelection *rlist = new nsFrameSelection;
>- if (!rlist)
>- return NS_ERROR_OUT_OF_MEMORY;
> *aFrameSelection = rlist;
> NS_ADDREF(rlist);
> return NS_OK;
> }
>
> nsresult NS_NewDomSelection(nsISelection **aDomSelection)
> {
> nsTypedSelection *rlist = new nsTypedSelection;
>- if (!rlist)
>- return NS_ERROR_OUT_OF_MEMORY;
> *aDomSelection = (nsISelection *)rlist;
> NS_ADDREF(rlist);
> return NS_OK;
> }
These two can return the pointer as well.
>@@ -4745,17 +4726,17 @@
> return NS_OK;
> }
>
> NS_IMETHODIMP
> nsTypedSelection::GetEnumerator(nsIEnumerator **aIterator)
> {
> nsresult status = NS_ERROR_OUT_OF_MEMORY;
> nsSelectionIterator *iterator = new nsSelectionIterator(this);
>- if (iterator && NS_FAILED(status = CallQueryInterface(iterator, aIterator)) )
>+ if (NS_FAILED(status = CallQueryInterface(iterator, aIterator)) )
> delete iterator;
> return status;
> }
{
NS_ADDREF(*aIterator = new nsSelectionIterator(this));
return NS_OK;
}
Comment 27•14 years ago
|
||
Comment on attachment 530936 [details] [diff] [review]
Part 11: Remove OOM checks from layout/base
>diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp
>--- a/layout/base/nsDocumentViewer.cpp
>+++ b/layout/base/nsDocumentViewer.cpp
>@@ -517,19 +517,16 @@
> // Class IDs
> static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID);
>
> //------------------------------------------------------------------
> nsresult
> NS_NewDocumentViewer(nsIDocumentViewer** aResult)
> {
> *aResult = new DocumentViewerImpl();
>- if (!*aResult) {
>- return NS_ERROR_OUT_OF_MEMORY;
>- }
>
> NS_ADDREF(*aResult);
>
> return NS_OK;
> }
Can return a pointer.
>diff --git a/layout/base/nsFrameTraversal.cpp b/layout/base/nsFrameTraversal.cpp
>--- a/layout/base/nsFrameTraversal.cpp
>+++ b/layout/base/nsFrameTraversal.cpp
>@@ -146,18 +146,16 @@
> /************IMPLEMENTATIONS**************/
>
> nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult)
> {
> NS_ENSURE_ARG_POINTER(aResult);
> *aResult = nsnull;
>
> nsCOMPtr<nsIFrameTraversal> t(new nsFrameTraversal());
>- if (!t)
>- return NS_ERROR_OUT_OF_MEMORY;
>
> *aResult = t;
> NS_ADDREF(*aResult);
>
> return NS_OK;
> }
>
> nsresult
>@@ -174,18 +172,16 @@
> nsCOMPtr<nsIFrameEnumerator> trav;
> if (aVisual) {
> trav = new nsVisualIterator(aPresContext, aStart, aType,
> aLockInScrollView, aFollowOOFs);
> } else {
> trav = new nsFrameIterator(aPresContext, aStart, aType,
> aLockInScrollView, aFollowOOFs);
> }
>- if (!trav)
>- return NS_ERROR_OUT_OF_MEMORY;
> *aEnumerator = trav;
> NS_ADDREF(trav);
> return NS_OK;
> }
Same for these, but if you don't, can you please do
- *aEnumerator = trav;
- NS_ADDREF(trav);
+ trav.forget(aEnumerator);
>diff --git a/layout/base/nsLayoutDebugger.cpp b/layout/base/nsLayoutDebugger.cpp
>--- a/layout/base/nsLayoutDebugger.cpp
>+++ b/layout/base/nsLayoutDebugger.cpp
>@@ -79,19 +79,16 @@
> nsresult
> NS_NewLayoutDebugger(nsILayoutDebugger** aResult)
> {
> NS_PRECONDITION(aResult, "null OUT ptr");
> if (!aResult) {
> return NS_ERROR_NULL_POINTER;
> }
> nsLayoutDebugger* it = new nsLayoutDebugger();
>- if (!it) {
>- return NS_ERROR_OUT_OF_MEMORY;
>- }
> return it->QueryInterface(NS_GET_IID(nsILayoutDebugger), (void**)aResult);
> }
Here, too.
>diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp
>--- a/layout/base/nsPresShell.cpp
>+++ b/layout/base/nsPresShell.cpp
>@@ -1631,18 +1625,16 @@
> NS_NewPresShell(nsIPresShell** aInstancePtrResult)
> {
> NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
>
> if (!aInstancePtrResult)
> return NS_ERROR_NULL_POINTER;
>
> *aInstancePtrResult = new PresShell();
>- if (!*aInstancePtrResult)
>- return NS_ERROR_OUT_OF_MEMORY;
>
> NS_ADDREF(*aInstancePtrResult);
> return NS_OK;
> }
And here.
Of course, all of these can be done in followup bugs / patches and only apply if bz doesn't disagree.
Assignee | ||
Comment 28•14 years ago
|
||
(In reply to comment #25)
> Comment on attachment 530932 [details] [diff] [review] [review]
> Part 8: Make nsLineIterator::Init return void
>
> >diff --git a/layout/generic/nsFloatManager.cpp b/layout/generic/nsFloatManager.cpp
> >--- a/layout/generic/nsFloatManager.cpp
> >+++ b/layout/generic/nsFloatManager.cpp
> >@@ -570,17 +570,17 @@
> > mOld->List(stdout);
> > }
> > #endif
> >
> > delete mNew;
> > }
> > }
> >
> >-nsresult
> >+void
> > nsAutoFloatManager::CreateFloatManager(nsPresContext *aPresContext)
> > {
> > // Create a new float manager and install it in the reflow
> > // state. `Remember' the old float manager so we can restore it
> > // later.
> > mNew = new nsFloatManager(aPresContext->PresShell());
> > if (! mNew)
> > return NS_ERROR_OUT_OF_MEMORY;
>
> You should remove that check in this patch, not in part 9.
Thanks. That must have happened when I fractured the patches and I didn't build with only a subset applied.
Assignee | ||
Comment 29•14 years ago
|
||
Assignee | ||
Updated•14 years ago
|
Attachment #530932 -
Attachment is obsolete: true
Attachment #530932 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 30•14 years ago
|
||
Assignee | ||
Comment 31•14 years ago
|
||
Assignee | ||
Updated•14 years ago
|
Attachment #530933 -
Attachment is obsolete: true
Attachment #530933 -
Flags: review?(bzbarsky)
Comment 32•14 years ago
|
||
And because I like what you're doing so much:
http://mxr.mozilla.org/mozilla-central/source/layout/style/nsRuleNode.cpp#1934
Assignee | ||
Comment 33•14 years ago
|
||
Assignee | ||
Updated•14 years ago
|
Attachment #530936 -
Attachment is obsolete: true
Attachment #530936 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 34•14 years ago
|
||
(In reply to comment #32)
> And because I like what you're doing so much:
>
> http://mxr.mozilla.org/mozilla-central/source/layout/style/nsRuleNode.
> cpp#1934
Aren't those all Arena allocations? Are those infallible?
Assignee | ||
Updated•14 years ago
|
Attachment #530940 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #530941 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #530944 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #530947 -
Flags: review?(bzbarsky)
![]() |
||
Comment 35•14 years ago
|
||
Rulenode allocations are fallible, last I checked. We can consider fixing that, but not in this bug!
Ms2ger, can I suggest not overquoting? ;)
Craig, I'll try to get to these in the next 2 days. Once we do these, I'd say push the patches and file a followup for any further work just to keep the bugs sane length.
![]() |
||
Comment 36•14 years ago
|
||
Comment on attachment 530940 [details] [diff] [review]
Part 8: Make nsLineIterator::Init return void
Just nix init entirely in favor of constructor arguments.
Attachment #530940 -
Flags: review?(bzbarsky) → review-
![]() |
||
Comment 37•14 years ago
|
||
Comment on attachment 530941 [details] [diff] [review]
Part 8b: Make nsAutoFloatManager::CreateFloatManager return void
r=me
Attachment #530941 -
Flags: review?(bzbarsky) → review+
![]() |
||
Comment 38•14 years ago
|
||
Comment on attachment 530934 [details] [diff] [review]
Part 10: Make nsFloatManager::StoreRegionFor return void
r=me
Attachment #530934 -
Flags: review?(bzbarsky) → review+
![]() |
||
Comment 39•14 years ago
|
||
Comment on attachment 530941 [details] [diff] [review]
Part 8b: Make nsAutoFloatManager::CreateFloatManager return void
Actually, sorry. This operator new doesn't seem to be infallible. Perhaps that should be changed.
Attachment #530941 -
Flags: review+ → review-
![]() |
||
Comment 40•14 years ago
|
||
Comment on attachment 530944 [details] [diff] [review]
Part 9: Remove OOM checks from layout/generic
The frameset frame code should use fallible allocations for all of that stuff since it's under content control.
The rest of the changes here look fine; maybe you want to split out the frameset changes into a separate patch...
Attachment #530944 -
Flags: review?(bzbarsky) → review-
![]() |
||
Comment 41•14 years ago
|
||
For that layout/base patch, there are some more new[] uses that may need to be fallible... Do you want me to review anyway?
Assignee | ||
Updated•14 years ago
|
Attachment #529631 -
Attachment is obsolete: true
Assignee | ||
Updated•14 years ago
|
Attachment #530941 -
Attachment is obsolete: true
Assignee | ||
Comment 42•14 years ago
|
||
Assignee | ||
Updated•14 years ago
|
Attachment #530940 -
Attachment is obsolete: true
Assignee | ||
Comment 43•14 years ago
|
||
Assignee | ||
Updated•14 years ago
|
Attachment #530944 -
Attachment is obsolete: true
Assignee | ||
Comment 44•14 years ago
|
||
Assignee | ||
Updated•14 years ago
|
Attachment #530947 -
Attachment is obsolete: true
Attachment #530947 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #536233 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #536234 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
Attachment #536235 -
Flags: review?(bzbarsky)
![]() |
||
Comment 45•14 years ago
|
||
Comment on attachment 536233 [details] [diff] [review]
Part 8: Remove nsLineIterator::Init by moving code to constructor
Hmm. So I just realized that this is doing an allocation that should probably in fact be fallible. In particular, mLines.....
Attachment #536233 -
Flags: review?(bzbarsky) → review-
![]() |
||
Comment 46•14 years ago
|
||
Comment on attachment 536234 [details] [diff] [review]
Part 9: Remove OOM checks from layout/generic
r=me
Attachment #536234 -
Flags: review?(bzbarsky) → review+
![]() |
||
Comment 47•14 years ago
|
||
Comment on attachment 536235 [details] [diff] [review]
Part 11: Remove OOM checks from layout/base
r=me
Attachment #536235 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Updated•14 years ago
|
Attachment #536233 -
Attachment is obsolete: true
Assignee | ||
Updated•14 years ago
|
Attachment #529633 -
Attachment is obsolete: true
Assignee | ||
Updated•14 years ago
|
Whiteboard: [inbound]
Comment 48•14 years ago
|
||
Pushed:
http://hg.mozilla.org/mozilla-central/rev/bf89d0e1a8d5
http://hg.mozilla.org/mozilla-central/rev/f8abcfe27753
http://hg.mozilla.org/mozilla-central/rev/eb26dea95622
http://hg.mozilla.org/mozilla-central/rev/2ff6a55908af
http://hg.mozilla.org/mozilla-central/rev/605c1bfa4ad2
http://hg.mozilla.org/mozilla-central/rev/acec89b9786b
http://hg.mozilla.org/mozilla-central/rev/8027b37a9b32
That would have been a good idea to rename the parts before pushing them to inbound because now, there are parts 2, 4, 5, 7, 10, 9 and 11 pushed in this order...
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite?
Resolution: --- → FIXED
Whiteboard: [inbound]
Target Milestone: --- → mozilla7
Comment 49•14 years ago
|
||
(In reply to comment #39)
> Comment on attachment 530941 [details] [diff] [review]
> Part 8b: Make nsAutoFloatManager::CreateFloatManager return void
>
> Actually, sorry. This operator new doesn't seem to be infallible. Perhaps
> that should be changed.
What makes this particular operator new fallible?
![]() |
||
Comment 50•14 years ago
|
||
> What makes this particular operator new fallible?
It's a custom operator new that allocates memory via the presshell arena, not via global ::new.
You need to log in
before you can comment on or make changes to this bug.
Description
•