Chromium Code Reviews| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 void ThreadHeap::detach(ThreadState* thread) { | 184 void ThreadHeap::detach(ThreadState* thread) { |
| 185 ASSERT(ThreadState::current() == thread); | 185 ASSERT(ThreadState::current() == thread); |
| 186 bool isLastThread = false; | 186 bool isLastThread = false; |
| 187 { | 187 { |
| 188 // Grab the threadAttachMutex to ensure only one thread can shutdown at | 188 // Grab the threadAttachMutex to ensure only one thread can shutdown at |
| 189 // a time and that no other thread can do a global GC. It also allows | 189 // a time and that no other thread can do a global GC. It also allows |
| 190 // safe iteration of the m_threads set which happens as part of | 190 // safe iteration of the m_threads set which happens as part of |
| 191 // thread local GC asserts. We enter a safepoint while waiting for the | 191 // thread local GC asserts. We enter a safepoint while waiting for the |
| 192 // lock to avoid a dead-lock where another thread has already requested | 192 // lock to avoid a dead-lock where another thread has already requested |
| 193 // GC. | 193 // GC. |
| 194 SafePointAwareMutexLocker locker(m_threadAttachMutex, | 194 MutexLocker locker(m_threadAttachMutex); |
| 195 BlinkGC::NoHeapPointersOnStack); | |
| 196 thread->runTerminationGC(); | 195 thread->runTerminationGC(); |
| 197 ASSERT(m_threads.contains(thread)); | 196 ASSERT(m_threads.contains(thread)); |
| 198 m_threads.remove(thread); | 197 m_threads.remove(thread); |
| 199 isLastThread = m_threads.isEmpty(); | 198 isLastThread = m_threads.isEmpty(); |
| 200 } | 199 } |
| 201 if (thread->isMainThread()) | 200 if (thread->isMainThread()) |
| 202 DCHECK_EQ(heapStats().allocatedSpace(), 0u); | 201 DCHECK_EQ(heapStats().allocatedSpace(), 0u); |
| 203 if (isLastThread) | 202 if (isLastThread) |
| 204 delete this; | 203 delete this; |
| 205 } | 204 } |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 ASSERT(ThreadState::current()->isInGC()); | 569 ASSERT(ThreadState::current()->isInGC()); |
| 571 TRACE_EVENT0("blink_gc", "ThreadHeap::visitStackRoots"); | 570 TRACE_EVENT0("blink_gc", "ThreadHeap::visitStackRoots"); |
| 572 for (ThreadState* state : m_threads) | 571 for (ThreadState* state : m_threads) |
| 573 state->visitStack(visitor); | 572 state->visitStack(visitor); |
| 574 } | 573 } |
| 575 | 574 |
| 576 void ThreadHeap::enterSafePoint(ThreadState* threadState) { | 575 void ThreadHeap::enterSafePoint(ThreadState* threadState) { |
| 577 m_safePointBarrier->enterSafePoint(threadState); | 576 m_safePointBarrier->enterSafePoint(threadState); |
| 578 } | 577 } |
| 579 | 578 |
| 580 void ThreadHeap::leaveSafePoint(ThreadState* threadState, | 579 void ThreadHeap::leaveSafePoint() { |
|
sof
2017/02/14 08:31:38
we can just remove this altogether.
haraken
2017/02/14 08:50:49
Yeah, I want to do that in a follow-up where I'll
| |
| 581 SafePointAwareMutexLocker* locker) { | 580 m_safePointBarrier->leaveSafePoint(); |
| 582 m_safePointBarrier->leaveSafePoint(threadState, locker); | |
| 583 } | 581 } |
| 584 | 582 |
| 585 BasePage* ThreadHeap::lookupPageForAddress(Address address) { | 583 BasePage* ThreadHeap::lookupPageForAddress(Address address) { |
| 586 ASSERT(ThreadState::current()->isInGC()); | 584 ASSERT(ThreadState::current()->isInGC()); |
| 587 if (PageMemoryRegion* region = m_regionTree->lookup(address)) { | 585 if (PageMemoryRegion* region = m_regionTree->lookup(address)) { |
| 588 return region->pageFromAddress(address); | 586 return region->pageFromAddress(address); |
| 589 } | 587 } |
| 590 return nullptr; | 588 return nullptr; |
| 591 } | 589 } |
| 592 | 590 |
| 593 void ThreadHeap::resetHeapCounters() { | 591 void ThreadHeap::resetHeapCounters() { |
| 594 ASSERT(ThreadState::current()->isInGC()); | 592 ASSERT(ThreadState::current()->isInGC()); |
| 595 | 593 |
| 596 ThreadHeap::reportMemoryUsageForTracing(); | 594 ThreadHeap::reportMemoryUsageForTracing(); |
| 597 | 595 |
| 598 ProcessHeap::decreaseTotalAllocatedObjectSize(m_stats.allocatedObjectSize()); | 596 ProcessHeap::decreaseTotalAllocatedObjectSize(m_stats.allocatedObjectSize()); |
| 599 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); | 597 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); |
| 600 | 598 |
| 601 m_stats.reset(); | 599 m_stats.reset(); |
| 602 for (ThreadState* state : m_threads) | 600 for (ThreadState* state : m_threads) |
| 603 state->resetHeapCounters(); | 601 state->resetHeapCounters(); |
| 604 } | 602 } |
| 605 | 603 |
| 606 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; | 604 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; |
| 607 | 605 |
| 608 } // namespace blink | 606 } // namespace blink |
| OLD | NEW |