LayoutTests:
Layout test for <rdar://problem/
4661982> (crash in KHTMLParser::popBlock)
* fast/parser/remove-node-stack-expected.txt: Added.
* fast/parser/remove-node-stack.html: Added.
WebCore:
Reviewed by Darin.
- This patch reworks a previous fix for <rdar://problem/
3524912> repro
crash in KHTMLParser::parseToken, due to parser's current element being
destroyed (www.gnnetcom.dk), along with subsequent adjustments to fix
leaks.
The previous solutions caused a ~2% performance regression on iBench HTML,
due to RefPtr churn. The optimizations here gain back that ~2% plus ~1% more,
for a total win of ~3% vs current TOT.
We can merge this fix to the branch to fix <rdar://problem/
4661982>
(crash in KHTMLParser::popBlock).
The solution here is:
(1) Don't let the parser ref document nodes -- that causes leaks.
(2) Handle ref/deref manually, to avoid RefPtr churn. Specifically, when
moving a node between stacks or to/from 'current', rather than deref'ing
and then ref'ing again, simply move the node, along with its refcount, to
its new location, and overwrite its old location.
* WebCore.xcodeproj/project.pbxproj:
* html/HTMLParser.cpp:
(WebCore::HTMLStackElem::HTMLStackElem):
(WebCore::HTMLStackElem::derefNode):
(WebCore::HTMLParser::HTMLParser):
(WebCore::HTMLParser::setCurrent):
(WebCore::HTMLParser::insertNode):
(WebCore::HTMLParser::popNestedHeaderTag):
(WebCore::HTMLParser::handleResidualStyleCloseTagAcrossBlocks):
(WebCore::HTMLParser::reopenResidualStyleTags):
(WebCore::HTMLParser::pushBlock):
(WebCore::HTMLParser::popBlock):
(WebCore::HTMLParser::popOneBlockCommon):
(WebCore::HTMLParser::popOneBlock):
(WebCore::HTMLParser::moveOneBlockToStack):
* html/HTMLParser.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15890
268f45cc-cd09-0410-ab3c-
d52691b4dbfc