• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-refvisitor-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,
34                                        const MarkVisitor& visitor,
35                                        const ReferenceVisitor& ref_visitor) {
36   DCHECK(IsMarked(obj)) << "Scanning unmarked object " << obj << "\n" << heap_->DumpSpaces();
37   obj->VisitReferences(visitor, ref_visitor);
38   if (kCountScannedTypes) {
39     mirror::Class* klass = obj->GetClass<kVerifyNone>();
40     uint32_t class_flags = klass->GetClassFlags();
41     if ((class_flags & mirror::kClassFlagNoReferenceFields) != 0) {
42       ++no_reference_class_count_;
43     } else if (class_flags == mirror::kClassFlagNormal) {
44       ++normal_count_;
45     } else if (class_flags == mirror::kClassFlagObjectArray) {
46       ++object_array_count_;
47     } else if (class_flags == mirror::kClassFlagClass) {
48       ++class_count_;
49     } else if ((class_flags & mirror::kClassFlagReference) != 0) {
50       ++reference_count_;
51     } else {
52       ++other_count_;
53     }
54   }
55 }
56 
57 }  // namespace collector
58 }  // namespace gc
59 }  // namespace art
60 
61 #endif  // ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_
62