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

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

Issue 2652923002: Devirtualize Visitor and remove inline visitor specialization. (Closed)
Patch Set: Created 3 years, 11 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "platform/heap/Heap.h" 31 #include "platform/heap/Heap.h"
32 32
33 #include "platform/Histogram.h" 33 #include "platform/Histogram.h"
34 #include "platform/RuntimeEnabledFeatures.h" 34 #include "platform/RuntimeEnabledFeatures.h"
35 #include "platform/ScriptForbiddenScope.h" 35 #include "platform/ScriptForbiddenScope.h"
36 #include "platform/heap/BlinkGCMemoryDumpProvider.h" 36 #include "platform/heap/BlinkGCMemoryDumpProvider.h"
37 #include "platform/heap/CallbackStack.h" 37 #include "platform/heap/CallbackStack.h"
38 #include "platform/heap/HeapCompact.h" 38 #include "platform/heap/HeapCompact.h"
39 #include "platform/heap/MarkingVisitor.h"
40 #include "platform/heap/PageMemory.h" 39 #include "platform/heap/PageMemory.h"
41 #include "platform/heap/PagePool.h" 40 #include "platform/heap/PagePool.h"
42 #include "platform/heap/SafePoint.h" 41 #include "platform/heap/SafePoint.h"
43 #include "platform/heap/ThreadState.h" 42 #include "platform/heap/ThreadState.h"
44 #include "platform/instrumentation/tracing/TraceEvent.h" 43 #include "platform/instrumentation/tracing/TraceEvent.h"
45 #include "platform/instrumentation/tracing/web_memory_allocator_dump.h" 44 #include "platform/instrumentation/tracing/web_memory_allocator_dump.h"
46 #include "platform/instrumentation/tracing/web_process_memory_dump.h" 45 #include "platform/instrumentation/tracing/web_process_memory_dump.h"
47 #include "public/platform/Platform.h" 46 #include "public/platform/Platform.h"
48 #include "wtf/Assertions.h" 47 #include "wtf/Assertions.h"
49 #include "wtf/CurrentTime.h" 48 #include "wtf/CurrentTime.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 308
310 #if !DCHECK_IS_ON() 309 #if !DCHECK_IS_ON()
311 m_heapDoesNotContainCache->addEntry(address); 310 m_heapDoesNotContainCache->addEntry(address);
312 #else 311 #else
313 if (!m_heapDoesNotContainCache->lookup(address)) 312 if (!m_heapDoesNotContainCache->lookup(address))
314 m_heapDoesNotContainCache->addEntry(address); 313 m_heapDoesNotContainCache->addEntry(address);
315 #endif 314 #endif
316 return nullptr; 315 return nullptr;
317 } 316 }
318 317
318 #if DCHECK_IS_ON()
319 // To support unit testing of the marking of off-heap root references
320 // into the heap, provide a checkAndMarkPointer() version with an
321 // extra notification argument.
322 Address ThreadHeap::checkAndMarkPointer(Visitor* visitor,
323 Address address,
324 MarkedPointerCallback callback) {
325 DCHECK(ThreadState::current()->isInGC());
326
327 if (BasePage* page = lookupPageForAddress(address)) {
328 DCHECK(page->contains(address));
329 DCHECK(!page->orphaned());
330 DCHECK(!m_heapDoesNotContainCache->lookup(address));
331 DCHECK(&visitor->heap() == &page->arena()->getThreadState()->heap());
332 page->checkAndMarkPointer(visitor, address, callback);
333 return address;
334 }
335 if (!m_heapDoesNotContainCache->lookup(address))
336 m_heapDoesNotContainCache->addEntry(address);
337 return nullptr;
338 }
339 #endif
340
319 void ThreadHeap::pushTraceCallback(void* object, TraceCallback callback) { 341 void ThreadHeap::pushTraceCallback(void* object, TraceCallback callback) {
320 ASSERT(ThreadState::current()->isInGC()); 342 ASSERT(ThreadState::current()->isInGC());
321 343
322 // Trace should never reach an orphaned page. 344 // Trace should never reach an orphaned page.
323 ASSERT(!getOrphanedPagePool()->contains(object)); 345 ASSERT(!getOrphanedPagePool()->contains(object));
324 CallbackStack::Item* slot = m_markingStack->allocateEntry(); 346 CallbackStack::Item* slot = m_markingStack->allocateEntry();
325 *slot = CallbackStack::Item(object, callback); 347 *slot = CallbackStack::Item(object, callback);
326 } 348 }
327 349
328 bool ThreadHeap::popAndInvokeTraceCallback(Visitor* visitor) { 350 bool ThreadHeap::popAndInvokeTraceCallback(Visitor* visitor) {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); 676 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize());
655 677
656 m_stats.reset(); 678 m_stats.reset();
657 for (ThreadState* state : m_threads) 679 for (ThreadState* state : m_threads)
658 state->resetHeapCounters(); 680 state->resetHeapCounters();
659 } 681 }
660 682
661 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; 683 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr;
662 684
663 } // namespace blink 685 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698