1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_
18 #define ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_
19 
20 #include "gc/collector/mark_sweep.h"
21 
22 #include "gc/heap.h"
23 #include "mirror/art_field.h"
24 #include "mirror/class-inl.h"
25 #include "mirror/object_array-inl.h"
26 #include "mirror/reference.h"
27 
28 namespace art {
29 namespace gc {
30 namespace collector {
31 
32 template<typename MarkVisitor, typename ReferenceVisitor>
ScanObjectVisit(mirror::Object * obj,const MarkVisitor & visitor,const ReferenceVisitor & ref_visitor)33 inline void MarkSweep::ScanObjectVisit(mirror::Object* obj, const MarkVisitor& visitor,
34                                        const ReferenceVisitor& ref_visitor) {
35   DCHECK(IsMarked(obj)) << "Scanning unmarked object " << obj << "\n" << heap_->DumpSpaces();
36   obj->VisitReferences<false>(visitor, ref_visitor);
37   if (kCountScannedTypes) {
38     mirror::Class* klass = obj->GetClass<kVerifyNone>();
39     if (UNLIKELY(klass == mirror::Class::GetJavaLangClass())) {
40       ++class_count_;
41     } else if (UNLIKELY(klass->IsArrayClass<kVerifyNone>())) {
42       ++array_count_;
43     } else {
44       ++other_count_;
45     }
46   }
47 }
48 
49 }  // namespace collector
50 }  // namespace gc
51 }  // namespace art
52 
53 #endif  // ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_
54