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

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

Issue 875503003: Allow Oilpan heap objects account for their external allocations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: more minor stuff Created 5 years, 10 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
« no previous file with comments | « Source/core/dom/Text.h ('k') | Source/platform/heap/Heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 24 matching lines...) Expand all
35 #include "core/events/ScopedEventQueue.h" 35 #include "core/events/ScopedEventQueue.h"
36 #include "core/layout/svg/LayoutSVGInlineText.h" 36 #include "core/layout/svg/LayoutSVGInlineText.h"
37 #include "core/rendering/RenderCombineText.h" 37 #include "core/rendering/RenderCombineText.h"
38 #include "core/rendering/RenderText.h" 38 #include "core/rendering/RenderText.h"
39 #include "core/svg/SVGForeignObjectElement.h" 39 #include "core/svg/SVGForeignObjectElement.h"
40 #include "wtf/text/CString.h" 40 #include "wtf/text/CString.h"
41 #include "wtf/text/StringBuilder.h" 41 #include "wtf/text/StringBuilder.h"
42 42
43 namespace blink { 43 namespace blink {
44 44
45 #if ENABLE(OILPAN)
46 namespace {
47 // If the external string kept by a Text node exceed this threshold length,
48 // Oilpan is informed. External allocation amounts owned by heap objects are
49 // taken into account when scheduling urgent Oilpan GCs.
50 //
51 // FIXME: having only Text nodes with strings above an ad-hoc local threshold
52 // influence Oilpan's GC behavior isn't a satisfactory long-term solution.
53 // But code that allocates a lot of Text nodes in tight loops, and not much more ,
54 // we do have to trigger Oilpan GCs to avoid PartitionAlloc OOMs. The accounting
55 // does add overhead on the allocation of every Text node however, so for now, o nly
56 // register those above the given threshold. TBC.
57 const size_t stringLengthThreshold = 256;
58
59 void increaseExternallyAllocatedBytesIfNeeded(size_t length)
60 {
61 if (length > stringLengthThreshold)
62 Heap::increaseExternallyAllocatedBytes(length);
63 }
64
65 void increaseExternallyAllocatedBytesAliveIfNeeded(size_t length)
66 {
67 if (length > stringLengthThreshold)
68 Heap::increaseExternallyAllocatedBytesAlive(length);
69 }
70
71 } // namespace
72 #endif
73
45 PassRefPtrWillBeRawPtr<Text> Text::create(Document& document, const String& data ) 74 PassRefPtrWillBeRawPtr<Text> Text::create(Document& document, const String& data )
46 { 75 {
76 #if ENABLE(OILPAN)
77 increaseExternallyAllocatedBytesIfNeeded(data.length());
78 #endif
47 return adoptRefWillBeNoop(new Text(document, data, CreateText)); 79 return adoptRefWillBeNoop(new Text(document, data, CreateText));
48 } 80 }
49 81
50 PassRefPtrWillBeRawPtr<Text> Text::createEditingText(Document& document, const S tring& data) 82 PassRefPtrWillBeRawPtr<Text> Text::createEditingText(Document& document, const S tring& data)
51 { 83 {
84 #if ENABLE(OILPAN)
85 increaseExternallyAllocatedBytesIfNeeded(data.length());
86 #endif
52 return adoptRefWillBeNoop(new Text(document, data, CreateEditingText)); 87 return adoptRefWillBeNoop(new Text(document, data, CreateEditingText));
53 } 88 }
54 89
55 PassRefPtrWillBeRawPtr<Node> Text::mergeNextSiblingNodesIfPossible() 90 PassRefPtrWillBeRawPtr<Node> Text::mergeNextSiblingNodesIfPossible()
56 { 91 {
57 RefPtrWillBeRawPtr<Node> protect(this); 92 RefPtrWillBeRawPtr<Node> protect(this);
58 93
59 // Remove empty text nodes. 94 // Remove empty text nodes.
60 if (!length()) { 95 if (!length()) {
61 // Care must be taken to get the next node before removing the current n ode. 96 // Care must be taken to get the next node before removing the current n ode.
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 return; 436 return;
402 } 437 }
403 textRenderer->setTextWithOffset(dataImpl(), offsetOfReplacedData, lengthOfRe placedData); 438 textRenderer->setTextWithOffset(dataImpl(), offsetOfReplacedData, lengthOfRe placedData);
404 } 439 }
405 440
406 PassRefPtrWillBeRawPtr<Text> Text::cloneWithData(const String& data) 441 PassRefPtrWillBeRawPtr<Text> Text::cloneWithData(const String& data)
407 { 442 {
408 return create(document(), data); 443 return create(document(), data);
409 } 444 }
410 445
446 void Text::trace(Visitor* visitor)
447 {
448 #if ENABLE(OILPAN)
449 increaseExternallyAllocatedBytesAliveIfNeeded(m_data.length());
450 #endif
451 CharacterData::trace(visitor);
452 }
453
411 #ifndef NDEBUG 454 #ifndef NDEBUG
412 void Text::formatForDebugger(char *buffer, unsigned length) const 455 void Text::formatForDebugger(char *buffer, unsigned length) const
413 { 456 {
414 StringBuilder result; 457 StringBuilder result;
415 String s; 458 String s;
416 459
417 result.append(nodeName()); 460 result.append(nodeName());
418 461
419 s = data(); 462 s = data();
420 if (s.length() > 0) { 463 if (s.length() > 0) {
421 if (result.length()) 464 if (result.length())
422 result.appendLiteral("; "); 465 result.appendLiteral("; ");
423 result.appendLiteral("value="); 466 result.appendLiteral("value=");
424 result.append(s); 467 result.append(s);
425 } 468 }
426 469
427 strncpy(buffer, result.toString().utf8().data(), length - 1); 470 strncpy(buffer, result.toString().utf8().data(), length - 1);
428 } 471 }
429 #endif 472 #endif
430 473
431 } // namespace blink 474 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Text.h ('k') | Source/platform/heap/Heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698