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 "mark_sweep.h"
21 
22 #include "gc/heap.h"
23 #include "mirror/class-inl.h"
24 #include "mirror/object_array-inl.h"
25 #include "mirror/reference.h"
26 
27 namespace art {
28 namespace gc {
29 namespace collector {
30 
31 template<typename MarkVisitor, typename ReferenceVisitor>
ScanObjectVisit(mirror::Object * obj,const MarkVisitor & visitor,const ReferenceVisitor & ref_visitor)32 inline void MarkSweep::ScanObjectVisit(mirror::Object* obj,
33                                        const MarkVisitor& visitor,
34                                        const ReferenceVisitor& ref_visitor) {
35   DCHECK(IsMarked(obj)) << "Scanning unmarked object " << obj << "\n" << heap_->DumpSpaces();
36   obj->VisitReferences(visitor, ref_visitor);
37   if (kCountScannedTypes) {
38     mirror::Class* klass = obj->GetClass<kVerifyNone>();
39     uint32_t class_flags = klass->GetClassFlags();
40     if ((class_flags & mirror::kClassFlagNoReferenceFields) != 0) {
41       ++no_reference_class_count_;
42     } else if (class_flags == mirror::kClassFlagNormal) {
43       ++normal_count_;
44     } else if (class_flags == mirror::kClassFlagObjectArray) {
45       ++object_array_count_;
46     } else if (class_flags == mirror::kClassFlagClass) {
47       ++class_count_;
48     } else if ((class_flags & mirror::kClassFlagReference) != 0) {
49       ++reference_count_;
50     } else {
51       ++other_count_;
52     }
53   }
54 }
55 
56 }  // namespace collector
57 }  // namespace gc
58 }  // namespace art
59 
60 #endif  // ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_
61