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> 32 inline void MarkSweep::ScanObjectVisit(mirror::Object* obj, const MarkVisitor& visitor, 33 const ReferenceVisitor& ref_visitor) { 34 DCHECK(IsMarked(obj)) << "Scanning unmarked object " << obj << "\n" << heap_->DumpSpaces(); 35 obj->VisitReferences<false>(visitor, ref_visitor); 36 if (kCountScannedTypes) { 37 mirror::Class* klass = obj->GetClass<kVerifyNone>(); 38 if (UNLIKELY(klass == mirror::Class::GetJavaLangClass())) { 39 ++class_count_; 40 } else if (UNLIKELY(klass->IsArrayClass<kVerifyNone>())) { 41 ++array_count_; 42 } else { 43 ++other_count_; 44 } 45 } 46 } 47 48 } // namespace collector 49 } // namespace gc 50 } // namespace art 51 52 #endif // ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_ 53