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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapCompact.cpp

Issue 2688093002: HeapCompact does not need to look up other threads' states (Closed)
Patch Set: Created 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/heap/HeapCompact.h" 5 #include "platform/heap/HeapCompact.h"
6 6
7 #include "platform/Histogram.h" 7 #include "platform/Histogram.h"
8 #include "platform/RuntimeEnabledFeatures.h" 8 #include "platform/RuntimeEnabledFeatures.h"
9 #include "platform/heap/Heap.h" 9 #include "platform/heap/Heap.h"
10 #include "platform/heap/SparseHeapBitmap.h" 10 #include "platform/heap/SparseHeapBitmap.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 LOG_HEAP_COMPACTION("shouldCompact(): gc=%s count=%zu free=%zu\n", 296 LOG_HEAP_COMPACTION("shouldCompact(): gc=%s count=%zu free=%zu\n",
297 ThreadState::gcReasonString(reason), 297 ThreadState::gcReasonString(reason),
298 m_gcCountSinceLastCompaction, m_freeListSize); 298 m_gcCountSinceLastCompaction, m_freeListSize);
299 m_gcCountSinceLastCompaction++; 299 m_gcCountSinceLastCompaction++;
300 // It is only safe to compact during non-conservative GCs. 300 // It is only safe to compact during non-conservative GCs.
301 // TODO: for the main thread, limit this further to only idle GCs. 301 // TODO: for the main thread, limit this further to only idle GCs.
302 if (reason != BlinkGC::IdleGC && reason != BlinkGC::PreciseGC && 302 if (reason != BlinkGC::IdleGC && reason != BlinkGC::PreciseGC &&
303 reason != BlinkGC::ForcedGC) 303 reason != BlinkGC::ForcedGC)
304 return false; 304 return false;
305 305
306 const ThreadHeap& heap = state->heap(); 306 // If the GCing thread requires a stack scan, do not compact.
307 // If any of the participating threads require a stack scan,
308 // do not compact.
309 //
310 // Why? Should the stack contain an iterator pointing into its 307 // Why? Should the stack contain an iterator pointing into its
311 // associated backing store, its references wouldn't be 308 // associated backing store, its references wouldn't be
312 // correctly relocated. 309 // correctly relocated.
313 for (ThreadState* state : heap.threads()) { 310 if (state->stackState() == BlinkGC::HeapPointersOnStack)
314 if (state->stackState() == BlinkGC::HeapPointersOnStack) { 311 return false;
315 return false;
316 }
317 }
318 312
319 // Compaction enable rules: 313 // Compaction enable rules:
320 // - It's been a while since the last time. 314 // - It's been a while since the last time.
321 // - "Considerable" amount of heap memory is bound up in freelist 315 // - "Considerable" amount of heap memory is bound up in freelist
322 // allocations. For now, use a fixed limit irrespective of heap 316 // allocations. For now, use a fixed limit irrespective of heap
323 // size. 317 // size.
324 // 318 //
325 // As this isn't compacting all arenas, the cost of doing compaction 319 // As this isn't compacting all arenas, the cost of doing compaction
326 // isn't a worry as it will additionally only be done by idle GCs. 320 // isn't a worry as it will additionally only be done by idle GCs.
327 // TODO: add some form of compaction overhead estimate to the marking 321 // TODO: add some form of compaction overhead estimate to the marking
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 fixups().addCompactingPage(page); 454 fixups().addCompactingPage(page);
461 } 455 }
462 456
463 bool HeapCompact::scheduleCompactionGCForTesting(bool value) { 457 bool HeapCompact::scheduleCompactionGCForTesting(bool value) {
464 bool current = s_forceCompactionGC; 458 bool current = s_forceCompactionGC;
465 s_forceCompactionGC = value; 459 s_forceCompactionGC = value;
466 return current; 460 return current;
467 } 461 }
468 462
469 } // namespace blink 463 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698