Commit 61101232 authored by ulan's avatar ulan Committed by Commit bot

[heap] Synchronize young generation GC with concurrent marking.

BUG=chromium:694255

Review-Url: https://codereview.chromium.org/2872263002
Cr-Commit-Position: refs/heads/master@{#45230}
parent 69c6970f
......@@ -222,7 +222,7 @@ void HEnvironmentLivenessAnalysisPhase::Run() {
#ifdef DEBUG
bool HEnvironmentLivenessAnalysisPhase::VerifyClosures(
Handle<JSFunction> a, Handle<JSFunction> b) {
Heap::RelocationLock for_heap_access(isolate()->heap());
base::LockGuard<base::Mutex> guard(isolate()->heap()->relocation_mutex());
AllowHandleDereference for_verification;
return a.is_identical_to(b);
}
......
......@@ -738,7 +738,7 @@ class ReachabilityAnalyzer BASE_EMBEDDED {
void HGraph::Verify(bool do_full_verify) const {
Heap::RelocationLock relocation_lock(isolate()->heap());
base::LockGuard<base::Mutex> guard(isolate()->heap()->relocation_mutex());
AllowHandleDereference allow_deref;
AllowDeferredHandleDereference allow_deferred_deref;
for (int i = 0; i < blocks_.length(); i++) {
......
......@@ -185,10 +185,12 @@ ConcurrentMarking::~ConcurrentMarking() { delete visitor_; }
void ConcurrentMarking::Run() {
double time_ms = heap_->MonotonicallyIncreasingTimeInMs();
size_t bytes_marked = 0;
base::Mutex* relocation_mutex = heap_->relocation_mutex();
{
TimedScope scope(&time_ms);
HeapObject* object;
while ((object = deque_->Pop(MarkingThread::kConcurrent)) != nullptr) {
base::LockGuard<base::Mutex> guard(relocation_mutex);
bytes_marked += visitor_->Visit(object);
}
}
......
......@@ -1356,8 +1356,7 @@ bool Heap::PerformGarbageCollection(
break;
case SCAVENGER:
if ((fast_promotion_mode_ &&
CanExpandOldGeneration(new_space()->Size())) ||
concurrent_marking_->IsTaskPending()) {
CanExpandOldGeneration(new_space()->Size()))) {
tracer()->NotifyYoungGenerationHandling(
YoungGenerationHandling::kFastPromotionDuringScavenge);
EvacuateYoungGeneration();
......@@ -1633,6 +1632,7 @@ class ScavengeWeakObjectRetainer : public WeakObjectRetainer {
void Heap::EvacuateYoungGeneration() {
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_EVACUATE);
base::LockGuard<base::Mutex> guard(relocation_mutex());
if (!FLAG_concurrent_marking) {
DCHECK(fast_promotion_mode_);
DCHECK(CanExpandOldGeneration(new_space()->Size()));
......@@ -1674,7 +1674,7 @@ void Heap::EvacuateYoungGeneration() {
void Heap::Scavenge() {
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_SCAVENGE);
RelocationLock relocation_lock(this);
base::LockGuard<base::Mutex> guard(relocation_mutex());
// There are soft limits in the allocation code, designed to trigger a mark
// sweep collection by failing allocations. There is no sense in trying to
// trigger one during scavenge: scavenges allocation should always succeed.
......
......@@ -590,19 +590,9 @@ class Heap {
enum UpdateAllocationSiteMode { kGlobal, kCached };
// Taking this lock prevents the GC from entering a phase that relocates
// Taking this mutex prevents the GC from entering a phase that relocates
// object references.
class RelocationLock {
public:
explicit RelocationLock(Heap* heap) : heap_(heap) {
heap_->relocation_mutex_.Lock();
}
~RelocationLock() { heap_->relocation_mutex_.Unlock(); }
private:
Heap* heap_;
};
base::Mutex* relocation_mutex() { return &relocation_mutex_; }
// Support for partial snapshots. After calling this we have a linear
// space to write objects in each space.
......
......@@ -2719,7 +2719,7 @@ void MinorMarkCompactCollector::EvacuateEpilogue() {
void MinorMarkCompactCollector::Evacuate() {
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE);
Heap::RelocationLock relocation_lock(heap());
base::LockGuard<base::Mutex> guard(heap()->relocation_mutex());
{
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE_PROLOGUE);
......@@ -4085,7 +4085,7 @@ void MarkCompactCollector::Sweeper::AddSweptPageSafe(PagedSpace* space,
void MarkCompactCollector::Evacuate() {
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE);
Heap::RelocationLock relocation_lock(heap());
base::LockGuard<base::Mutex> guard(heap()->relocation_mutex());
{
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE_PROLOGUE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment