| 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 #include "wtf/PtrUtil.h" | |
| 11 #include <memory> | |
| 12 | 10 |
| 13 namespace blink { | 11 namespace blink { |
| 14 | 12 |
| 15 std::unique_ptr<Visitor> Visitor::create(ThreadState* state, BlinkGC::GCType gcT
ype) | 13 PassOwnPtr<Visitor> Visitor::create(ThreadState* state, BlinkGC::GCType gcType) |
| 16 { | 14 { |
| 17 switch (gcType) { | 15 switch (gcType) { |
| 18 case BlinkGC::GCWithSweep: | 16 case BlinkGC::GCWithSweep: |
| 19 case BlinkGC::GCWithoutSweep: | 17 case BlinkGC::GCWithoutSweep: |
| 20 return wrapUnique(new MarkingVisitor<Visitor::GlobalMarking>(state)); | 18 return adoptPtr(new MarkingVisitor<Visitor::GlobalMarking>(state)); |
| 21 case BlinkGC::TakeSnapshot: | 19 case BlinkGC::TakeSnapshot: |
| 22 return wrapUnique(new MarkingVisitor<Visitor::SnapshotMarking>(state)); | 20 return adoptPtr(new MarkingVisitor<Visitor::SnapshotMarking>(state)); |
| 23 case BlinkGC::ThreadTerminationGC: | 21 case BlinkGC::ThreadTerminationGC: |
| 24 return wrapUnique(new MarkingVisitor<Visitor::ThreadLocalMarking>(state)
); | 22 return adoptPtr(new MarkingVisitor<Visitor::ThreadLocalMarking>(state)); |
| 25 case BlinkGC::ThreadLocalWeakProcessing: | 23 case BlinkGC::ThreadLocalWeakProcessing: |
| 26 return wrapUnique(new MarkingVisitor<Visitor::WeakProcessing>(state)); | 24 return adoptPtr(new MarkingVisitor<Visitor::WeakProcessing>(state)); |
| 27 default: | 25 default: |
| 28 ASSERT_NOT_REACHED(); | 26 ASSERT_NOT_REACHED(); |
| 29 } | 27 } |
| 30 return nullptr; | 28 return nullptr; |
| 31 } | 29 } |
| 32 | 30 |
| 33 Visitor::Visitor(ThreadState* state, MarkingMode markingMode) | 31 Visitor::Visitor(ThreadState* state, MarkingMode markingMode) |
| 34 : VisitorHelper(state) | 32 : VisitorHelper(state) |
| 35 , m_markingMode(markingMode) | 33 , m_markingMode(markingMode) |
| 36 { | 34 { |
| 37 // See ThreadState::runScheduledGC() why we need to already be in a | 35 // See ThreadState::runScheduledGC() why we need to already be in a |
| 38 // GCForbiddenScope before any safe point is entered. | 36 // GCForbiddenScope before any safe point is entered. |
| 39 state->enterGCForbiddenScope(); | 37 state->enterGCForbiddenScope(); |
| 40 | 38 |
| 41 ASSERT(state->checkThread()); | 39 ASSERT(state->checkThread()); |
| 42 } | 40 } |
| 43 | 41 |
| 44 Visitor::~Visitor() | 42 Visitor::~Visitor() |
| 45 { | 43 { |
| 46 state()->leaveGCForbiddenScope(); | 44 state()->leaveGCForbiddenScope(); |
| 47 } | 45 } |
| 48 | 46 |
| 49 } // namespace blink | 47 } // namespace blink |
| OLD | NEW |