OLD | NEW |
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 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 PassOwnPtr<Visitor> Visitor::create(ThreadState* state, BlinkGC::GCType gcType) | 13 PassOwnPtr<Visitor> Visitor::create(ThreadState* state, BlinkGC::GCType gcType) |
14 { | 14 { |
15 switch (gcType) { | 15 bool perThreadHeapEnabled = false; |
16 case BlinkGC::GCWithSweep: | 16 if (perThreadHeapEnabled) { |
17 case BlinkGC::GCWithoutSweep: | 17 switch (gcType) { |
18 return adoptPtr(new MarkingVisitor<Visitor::GlobalMarking>(state)); | 18 case BlinkGC::GCWithSweep: |
19 case BlinkGC::TakeSnapshot: | 19 case BlinkGC::GCWithoutSweep: |
20 return adoptPtr(new MarkingVisitor<Visitor::SnapshotMarking>(state)); | 20 // InlinedGlobalMarkingVisitor does not support per thread heap disa
bled heaps. |
21 case BlinkGC::ThreadTerminationGC: | 21 return adoptPtr(new MarkingVisitor<Visitor::ThreadLocalMarking, true
>(state)); |
22 return adoptPtr(new MarkingVisitor<Visitor::ThreadLocalMarking>(state)); | 22 case BlinkGC::TakeSnapshot: |
23 case BlinkGC::ThreadLocalWeakProcessing: | 23 return adoptPtr(new MarkingVisitor<Visitor::SnapshotMarking, true>(s
tate)); |
24 return adoptPtr(new MarkingVisitor<Visitor::WeakProcessing>(state)); | 24 case BlinkGC::ThreadTerminationGC: |
25 default: | 25 return adoptPtr(new MarkingVisitor<Visitor::ThreadTerminationMarking
, true>(state)); |
26 ASSERT_NOT_REACHED(); | 26 case BlinkGC::ThreadLocalWeakProcessing: |
| 27 return adoptPtr(new MarkingVisitor<Visitor::WeakProcessing, true>(st
ate)); |
| 28 default: |
| 29 ASSERT_NOT_REACHED(); |
| 30 } |
| 31 } else { |
| 32 switch (gcType) { |
| 33 case BlinkGC::GCWithSweep: |
| 34 case BlinkGC::GCWithoutSweep: |
| 35 return adoptPtr(new MarkingVisitor<Visitor::GlobalMarking, false>(st
ate)); |
| 36 case BlinkGC::TakeSnapshot: |
| 37 return adoptPtr(new MarkingVisitor<Visitor::SnapshotMarking, false>(
state)); |
| 38 case BlinkGC::ThreadTerminationGC: |
| 39 return adoptPtr(new MarkingVisitor<Visitor::ThreadTerminationMarking
, false>(state)); |
| 40 case BlinkGC::ThreadLocalWeakProcessing: |
| 41 return adoptPtr(new MarkingVisitor<Visitor::WeakProcessing, false>(s
tate)); |
| 42 default: |
| 43 ASSERT_NOT_REACHED(); |
| 44 } |
27 } | 45 } |
28 return nullptr; | 46 return nullptr; |
29 } | 47 } |
30 | 48 |
31 Visitor::Visitor(ThreadState* state, MarkingMode markingMode) | 49 Visitor::Visitor(ThreadState* state, MarkingMode markingMode) |
32 : m_state(state) | 50 : m_state(state) |
33 , m_markingMode(markingMode) | 51 , m_markingMode(markingMode) |
34 { | 52 { |
35 // See ThreadState::runScheduledGC() why we need to already be in a | 53 // See ThreadState::runScheduledGC() why we need to already be in a |
36 // GCForbiddenScope before any safe point is entered. | 54 // GCForbiddenScope before any safe point is entered. |
37 m_state->enterGCForbiddenScope(); | 55 m_state->enterGCForbiddenScope(); |
38 | 56 |
39 ASSERT(m_state->checkThread()); | 57 ASSERT(m_state->checkThread()); |
40 } | 58 } |
41 | 59 |
42 Visitor::~Visitor() | 60 Visitor::~Visitor() |
43 { | 61 { |
44 m_state->leaveGCForbiddenScope(); | 62 m_state->leaveGCForbiddenScope(); |
45 } | 63 } |
46 | 64 |
47 } // namespace blink | 65 } // namespace blink |
OLD | NEW |