Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(840)

Side by Side Diff: Source/core/dom/Node.cpp

Issue 265793017: Oilpan: move node/element rare data objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased + assert for Nodes having no renderer on destruction. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 Node::~Node() 259 Node::~Node()
260 { 260 {
261 #ifndef NDEBUG 261 #ifndef NDEBUG
262 nodeCounter.decrement(); 262 nodeCounter.decrement();
263 #endif 263 #endif
264 264
265 #if DUMP_NODE_STATISTICS 265 #if DUMP_NODE_STATISTICS
266 liveNodeSet.remove(this); 266 liveNodeSet.remove(this);
267 #endif 267 #endif
268 268
269 #if !ENABLE(OILPAN)
269 if (hasRareData()) 270 if (hasRareData())
270 clearRareData(); 271 clearRareData();
271 272
272 RELEASE_ASSERT(!renderer()); 273 RELEASE_ASSERT(!renderer());
273 274
274 #if !ENABLE(OILPAN)
275 if (!isContainerNode()) 275 if (!isContainerNode())
276 willBeDeletedFromDocument(); 276 willBeDeletedFromDocument();
277 #else
278 // With Oilpan, the rare data finalizer also asserts for
279 // this condition (we cannot directly access it here.)
280 RELEASE_ASSERT(hasRareData() || !renderer());
277 #endif 281 #endif
278 282
279 if (m_previous) 283 if (m_previous)
280 m_previous->setNextSibling(0); 284 m_previous->setNextSibling(0);
281 if (m_next) 285 if (m_next)
282 m_next->setPreviousSibling(0); 286 m_next->setPreviousSibling(0);
283 287
284 #if !ENABLE(OILPAN) 288 #if !ENABLE(OILPAN)
285 if (m_treeScope) 289 if (m_treeScope)
286 m_treeScope->guardDeref(); 290 m_treeScope->guardDeref();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 { 323 {
320 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData()); 324 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData());
321 return static_cast<NodeRareData*>(m_data.m_rareData); 325 return static_cast<NodeRareData*>(m_data.m_rareData);
322 } 326 }
323 327
324 NodeRareData& Node::ensureRareData() 328 NodeRareData& Node::ensureRareData()
325 { 329 {
326 if (hasRareData()) 330 if (hasRareData())
327 return *rareData(); 331 return *rareData();
328 332
329 NodeRareData* data; 333 OwnPtrWillBeRawPtr<NodeRareData> data;
Erik Corry 2014/05/05 09:31:27 I can't see the point of this OwnPtr. Things woul
sof 2014/05/05 09:41:38 It minimized the #if'ery required, but I'll take a
sof 2014/05/05 13:38:58 Jumped ahead a bit and made the create() return a
330 if (isElementNode()) 334 if (isElementNode())
331 data = ElementRareData::create(m_data.m_renderer).leakPtr(); 335 data = ElementRareData::create(m_data.m_renderer);
332 else 336 else
333 data = NodeRareData::create(m_data.m_renderer).leakPtr(); 337 data = NodeRareData::create(m_data.m_renderer);
338
334 ASSERT(data); 339 ASSERT(data);
335 340
341 #if ENABLE(OILPAN)
336 m_data.m_rareData = data; 342 m_data.m_rareData = data;
343 #else
344 m_data.m_rareData = data.leakPtr();
345 #endif
337 setFlag(HasRareDataFlag); 346 setFlag(HasRareDataFlag);
338 return *data; 347 return *rareData();
339 } 348 }
340 349
350 #if !ENABLE(OILPAN)
341 void Node::clearRareData() 351 void Node::clearRareData()
342 { 352 {
343 ASSERT(hasRareData()); 353 ASSERT(hasRareData());
344 ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegi stry()->isEmpty()); 354 ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegi stry()->isEmpty());
345 355
346 RenderObject* renderer = m_data.m_rareData->renderer(); 356 RenderObject* renderer = m_data.m_rareData->renderer();
347 if (isElementNode()) { 357 if (isElementNode())
348 ElementRareData* rareData = static_cast<ElementRareData*>(m_data.m_rareD ata); 358 delete static_cast<ElementRareData*>(m_data.m_rareData);
349 rareData->dispose(); 359 else
350 delete rareData; 360 delete static_cast<NodeRareData*>(m_data.m_rareData);
351 } else {
352 NodeRareData* rareData = static_cast<NodeRareData*>(m_data.m_rareData);
353 rareData->dispose();
354 delete rareData;
355 }
356 m_data.m_renderer = renderer; 361 m_data.m_renderer = renderer;
357 clearFlag(HasRareDataFlag); 362 clearFlag(HasRareDataFlag);
358 } 363 }
364 #endif
359 365
360 Node* Node::toNode() 366 Node* Node::toNode()
361 { 367 {
362 return this; 368 return this;
363 } 369 }
364 370
365 short Node::tabIndex() const 371 short Node::tabIndex() const
366 { 372 {
367 return 0; 373 return 0;
368 } 374 }
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 ASSERT(isHTMLElement() || isSVGElement()); 2570 ASSERT(isHTMLElement() || isSVGElement());
2565 setFlag(CustomElementFlag); 2571 setFlag(CustomElementFlag);
2566 setFlag(newState == Upgraded, CustomElementUpgradedFlag); 2572 setFlag(newState == Upgraded, CustomElementUpgradedFlag);
2567 2573
2568 if (oldState == NotCustomElement || newState == Upgraded) 2574 if (oldState == NotCustomElement || newState == Upgraded)
2569 setNeedsStyleRecalc(SubtreeStyleChange); // :unresolved has changed 2575 setNeedsStyleRecalc(SubtreeStyleChange); // :unresolved has changed
2570 } 2576 }
2571 2577
2572 void Node::trace(Visitor* visitor) 2578 void Node::trace(Visitor* visitor)
2573 { 2579 {
2580 if (hasRareData())
2581 visitor->trace(rareData());
2582
2574 visitor->trace(m_treeScope); 2583 visitor->trace(m_treeScope);
2575 } 2584 }
2576 2585
2577 } // namespace WebCore 2586 } // namespace WebCore
2578 2587
2579 #ifndef NDEBUG 2588 #ifndef NDEBUG
2580 2589
2581 void showNode(const WebCore::Node* node) 2590 void showNode(const WebCore::Node* node)
2582 { 2591 {
2583 if (node) 2592 if (node)
2584 node->showNode(""); 2593 node->showNode("");
2585 } 2594 }
2586 2595
2587 void showTree(const WebCore::Node* node) 2596 void showTree(const WebCore::Node* node)
2588 { 2597 {
2589 if (node) 2598 if (node)
2590 node->showTreeForThis(); 2599 node->showTreeForThis();
2591 } 2600 }
2592 2601
2593 void showNodePath(const WebCore::Node* node) 2602 void showNodePath(const WebCore::Node* node)
2594 { 2603 {
2595 if (node) 2604 if (node)
2596 node->showNodePathForThis(); 2605 node->showNodePathForThis();
2597 } 2606 }
2598 2607
2599 #endif 2608 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698