| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 263 } |
| 264 | 264 |
| 265 bool ThreadHeap::park() { | 265 bool ThreadHeap::park() { |
| 266 return m_safePointBarrier->parkOthers(); | 266 return m_safePointBarrier->parkOthers(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void ThreadHeap::resume() { | 269 void ThreadHeap::resume() { |
| 270 m_safePointBarrier->resumeOthers(); | 270 m_safePointBarrier->resumeOthers(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 #if ENABLE(ASSERT) | 273 #if DCHECK_IS_ON() |
| 274 BasePage* ThreadHeap::findPageFromAddress(Address address) { | 274 BasePage* ThreadHeap::findPageFromAddress(Address address) { |
| 275 MutexLocker locker(m_threadAttachMutex); | 275 MutexLocker locker(m_threadAttachMutex); |
| 276 for (ThreadState* state : m_threads) { | 276 for (ThreadState* state : m_threads) { |
| 277 if (BasePage* page = state->findPageFromAddress(address)) | 277 if (BasePage* page = state->findPageFromAddress(address)) |
| 278 return page; | 278 return page; |
| 279 } | 279 } |
| 280 return nullptr; | 280 return nullptr; |
| 281 } | 281 } |
| 282 | 282 |
| 283 bool ThreadHeap::isAtSafePoint() { | 283 bool ThreadHeap::isAtSafePoint() { |
| 284 MutexLocker locker(m_threadAttachMutex); | 284 MutexLocker locker(m_threadAttachMutex); |
| 285 for (ThreadState* state : m_threads) { | 285 for (ThreadState* state : m_threads) { |
| 286 if (!state->isAtSafePoint()) | 286 if (!state->isAtSafePoint()) |
| 287 return false; | 287 return false; |
| 288 } | 288 } |
| 289 return true; | 289 return true; |
| 290 } | 290 } |
| 291 #endif | 291 #endif |
| 292 | 292 |
| 293 Address ThreadHeap::checkAndMarkPointer(Visitor* visitor, Address address) { | 293 Address ThreadHeap::checkAndMarkPointer(Visitor* visitor, Address address) { |
| 294 ASSERT(ThreadState::current()->isInGC()); | 294 ASSERT(ThreadState::current()->isInGC()); |
| 295 | 295 |
| 296 #if !ENABLE(ASSERT) | 296 #if !DCHECK_IS_ON() |
| 297 if (m_heapDoesNotContainCache->lookup(address)) | 297 if (m_heapDoesNotContainCache->lookup(address)) |
| 298 return nullptr; | 298 return nullptr; |
| 299 #endif | 299 #endif |
| 300 | 300 |
| 301 if (BasePage* page = lookupPageForAddress(address)) { | 301 if (BasePage* page = lookupPageForAddress(address)) { |
| 302 ASSERT(page->contains(address)); | 302 ASSERT(page->contains(address)); |
| 303 ASSERT(!page->orphaned()); | 303 ASSERT(!page->orphaned()); |
| 304 ASSERT(!m_heapDoesNotContainCache->lookup(address)); | 304 ASSERT(!m_heapDoesNotContainCache->lookup(address)); |
| 305 DCHECK(&visitor->heap() == &page->arena()->getThreadState()->heap()); | 305 DCHECK(&visitor->heap() == &page->arena()->getThreadState()->heap()); |
| 306 page->checkAndMarkPointer(visitor, address); | 306 page->checkAndMarkPointer(visitor, address); |
| 307 return address; | 307 return address; |
| 308 } | 308 } |
| 309 | 309 |
| 310 #if !ENABLE(ASSERT) | 310 #if !DCHECK_IS_ON() |
| 311 m_heapDoesNotContainCache->addEntry(address); | 311 m_heapDoesNotContainCache->addEntry(address); |
| 312 #else | 312 #else |
| 313 if (!m_heapDoesNotContainCache->lookup(address)) | 313 if (!m_heapDoesNotContainCache->lookup(address)) |
| 314 m_heapDoesNotContainCache->addEntry(address); | 314 m_heapDoesNotContainCache->addEntry(address); |
| 315 #endif | 315 #endif |
| 316 return nullptr; | 316 return nullptr; |
| 317 } | 317 } |
| 318 | 318 |
| 319 void ThreadHeap::pushTraceCallback(void* object, TraceCallback callback) { | 319 void ThreadHeap::pushTraceCallback(void* object, TraceCallback callback) { |
| 320 ASSERT(ThreadState::current()->isInGC()); | 320 ASSERT(ThreadState::current()->isInGC()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // Trace should never reach an orphaned page. | 386 // Trace should never reach an orphaned page. |
| 387 ASSERT(!getOrphanedPagePool()->contains(table)); | 387 ASSERT(!getOrphanedPagePool()->contains(table)); |
| 388 CallbackStack::Item* slot = m_ephemeronStack->allocateEntry(); | 388 CallbackStack::Item* slot = m_ephemeronStack->allocateEntry(); |
| 389 *slot = CallbackStack::Item(table, iterationCallback); | 389 *slot = CallbackStack::Item(table, iterationCallback); |
| 390 | 390 |
| 391 // Register a post-marking callback to tell the tables that | 391 // Register a post-marking callback to tell the tables that |
| 392 // ephemeron iteration is complete. | 392 // ephemeron iteration is complete. |
| 393 pushPostMarkingCallback(table, iterationDoneCallback); | 393 pushPostMarkingCallback(table, iterationDoneCallback); |
| 394 } | 394 } |
| 395 | 395 |
| 396 #if ENABLE(ASSERT) | 396 #if DCHECK_IS_ON() |
| 397 bool ThreadHeap::weakTableRegistered(const void* table) { | 397 bool ThreadHeap::weakTableRegistered(const void* table) { |
| 398 ASSERT(m_ephemeronStack); | 398 ASSERT(m_ephemeronStack); |
| 399 return m_ephemeronStack->hasCallbackForObject(table); | 399 return m_ephemeronStack->hasCallbackForObject(table); |
| 400 } | 400 } |
| 401 #endif | 401 #endif |
| 402 | 402 |
| 403 void ThreadHeap::commitCallbackStacks() { | 403 void ThreadHeap::commitCallbackStacks() { |
| 404 m_markingStack->commit(); | 404 m_markingStack->commit(); |
| 405 m_postMarkingCallbackStack->commit(); | 405 m_postMarkingCallbackStack->commit(); |
| 406 m_globalWeakCallbackStack->commit(); | 406 m_globalWeakCallbackStack->commit(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); | 654 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); |
| 655 | 655 |
| 656 m_stats.reset(); | 656 m_stats.reset(); |
| 657 for (ThreadState* state : m_threads) | 657 for (ThreadState* state : m_threads) |
| 658 state->resetHeapCounters(); | 658 state->resetHeapCounters(); |
| 659 } | 659 } |
| 660 | 660 |
| 661 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; | 661 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; |
| 662 | 662 |
| 663 } // namespace blink | 663 } // namespace blink |
| OLD | NEW |