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

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

Issue 2531973002: Simple BlinkGC heap compaction. (Closed)
Patch Set: Clear unused pages before decommitting Created 4 years 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/heap/Visitor.h" 5 #include "platform/heap/Visitor.h"
6 6
7 #include "platform/heap/BlinkGC.h" 7 #include "platform/heap/BlinkGC.h"
8 #include "platform/heap/MarkingVisitor.h" 8 #include "platform/heap/MarkingVisitor.h"
9 #include "platform/heap/ThreadState.h" 9 #include "platform/heap/ThreadState.h"
10 #include "wtf/PtrUtil.h" 10 #include "wtf/PtrUtil.h"
11 #include <memory> 11 #include <memory>
12 12
13 namespace blink { 13 namespace blink {
14 14
15 std::unique_ptr<Visitor> Visitor::create(ThreadState* state, 15 std::unique_ptr<Visitor> Visitor::create(ThreadState* state,
16 BlinkGC::GCType gcType) { 16 BlinkGC::GCType gcType) {
17 switch (gcType) { 17 switch (gcType) {
18 case BlinkGC::GCWithSweep: 18 case BlinkGC::GCWithSweep:
19 case BlinkGC::GCWithoutSweep: 19 case BlinkGC::GCWithoutSweep:
20 return WTF::makeUnique<MarkingVisitor<Visitor::GlobalMarking>>(state); 20 return WTF::makeUnique<MarkingVisitor<Visitor::GlobalMarking>>(state);
21 case BlinkGC::GCWithSweepCompaction:
22 return WTF::makeUnique<
23 MarkingVisitor<Visitor::GlobalMarkingWithCompaction>>(state);
21 case BlinkGC::TakeSnapshot: 24 case BlinkGC::TakeSnapshot:
22 return WTF::makeUnique<MarkingVisitor<Visitor::SnapshotMarking>>(state); 25 return WTF::makeUnique<MarkingVisitor<Visitor::SnapshotMarking>>(state);
23 case BlinkGC::ThreadTerminationGC: 26 case BlinkGC::ThreadTerminationGC:
24 return WTF::makeUnique<MarkingVisitor<Visitor::ThreadLocalMarking>>( 27 return WTF::makeUnique<MarkingVisitor<Visitor::ThreadLocalMarking>>(
25 state); 28 state);
26 case BlinkGC::ThreadLocalWeakProcessing: 29 case BlinkGC::ThreadLocalWeakProcessing:
27 return WTF::makeUnique<MarkingVisitor<Visitor::WeakProcessing>>(state); 30 return WTF::makeUnique<MarkingVisitor<Visitor::WeakProcessing>>(state);
28 default: 31 default:
29 ASSERT_NOT_REACHED(); 32 ASSERT_NOT_REACHED();
30 } 33 }
31 return nullptr; 34 return nullptr;
32 } 35 }
33 36
34 Visitor::Visitor(ThreadState* state, MarkingMode markingMode) 37 Visitor::Visitor(ThreadState* state, MarkingMode markingMode)
35 : VisitorHelper(state), m_markingMode(markingMode) { 38 : VisitorHelper(state), m_markingMode(markingMode) {
36 // See ThreadState::runScheduledGC() why we need to already be in a 39 // See ThreadState::runScheduledGC() why we need to already be in a
37 // GCForbiddenScope before any safe point is entered. 40 // GCForbiddenScope before any safe point is entered.
38 state->enterGCForbiddenScope(); 41 DCHECK(state->isGCForbidden());
39 42 #if ENABLE(ASSERT)
40 ASSERT(state->checkThread()); 43 DCHECK(state->checkThread());
44 #endif
41 } 45 }
42 46
43 Visitor::~Visitor() { 47 Visitor::~Visitor() {}
44 state()->leaveGCForbiddenScope();
45 }
46 48
47 } // namespace blink 49 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698