| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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( |
| 323 Visitor* visitor, |
| 324 Address address, |
| 325 MarkedPointerCallbackForTesting callback) { |
| 326 DCHECK(ThreadState::current()->isInGC()); |
| 327 |
| 328 if (BasePage* page = lookupPageForAddress(address)) { |
| 329 DCHECK(page->contains(address)); |
| 330 DCHECK(!page->orphaned()); |
| 331 DCHECK(!m_heapDoesNotContainCache->lookup(address)); |
| 332 DCHECK(&visitor->heap() == &page->arena()->getThreadState()->heap()); |
| 333 page->checkAndMarkPointer(visitor, address, callback); |
| 334 return address; |
| 335 } |
| 336 if (!m_heapDoesNotContainCache->lookup(address)) |
| 337 m_heapDoesNotContainCache->addEntry(address); |
| 338 return nullptr; |
| 339 } |
| 340 #endif |
| 341 |
| 319 void ThreadHeap::pushTraceCallback(void* object, TraceCallback callback) { | 342 void ThreadHeap::pushTraceCallback(void* object, TraceCallback callback) { |
| 320 ASSERT(ThreadState::current()->isInGC()); | 343 ASSERT(ThreadState::current()->isInGC()); |
| 321 | 344 |
| 322 // Trace should never reach an orphaned page. | 345 // Trace should never reach an orphaned page. |
| 323 ASSERT(!getOrphanedPagePool()->contains(object)); | 346 ASSERT(!getOrphanedPagePool()->contains(object)); |
| 324 CallbackStack::Item* slot = m_markingStack->allocateEntry(); | 347 CallbackStack::Item* slot = m_markingStack->allocateEntry(); |
| 325 *slot = CallbackStack::Item(object, callback); | 348 *slot = CallbackStack::Item(object, callback); |
| 326 } | 349 } |
| 327 | 350 |
| 328 bool ThreadHeap::popAndInvokeTraceCallback(Visitor* visitor) { | 351 bool ThreadHeap::popAndInvokeTraceCallback(Visitor* visitor) { |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); | 677 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); |
| 655 | 678 |
| 656 m_stats.reset(); | 679 m_stats.reset(); |
| 657 for (ThreadState* state : m_threads) | 680 for (ThreadState* state : m_threads) |
| 658 state->resetHeapCounters(); | 681 state->resetHeapCounters(); |
| 659 } | 682 } |
| 660 | 683 |
| 661 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; | 684 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; |
| 662 | 685 |
| 663 } // namespace blink | 686 } // namespace blink |
| OLD | NEW |