mark_sweep-inl.h revision f85c2fb317399ab540854cd7551ac47690366543
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
28namespace art {
29namespace gc {
30namespace collector {
31
32template<typename MarkVisitor, typename ReferenceVisitor>
33inline void MarkSweep::ScanObjectVisit(mirror::Object* obj, const MarkVisitor& visitor,
34                                       const ReferenceVisitor& ref_visitor) {
35  if (kIsDebugBuild && !IsMarked(obj)) {
36    heap_->DumpSpaces();
37    LOG(FATAL) << "Scanning unmarked object " << obj;
38  }
39  obj->VisitReferences<false>(visitor, ref_visitor);
40  if (kCountScannedTypes) {
41    mirror::Class* klass = obj->GetClass<kVerifyNone>();
42    if (UNLIKELY(klass == mirror::Class::GetJavaLangClass())) {
43      ++class_count_;
44    } else if (UNLIKELY(klass->IsArrayClass<kVerifyNone>())) {
45      ++array_count_;
46    } else {
47      ++other_count_;
48    }
49  }
50}
51
52}  // namespace collector
53}  // namespace gc
54}  // namespace art
55
56#endif  // ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_
57