blob: 974952d9921d7b5fb41203c10d3ed52fc6bdb891 [file] [log] [blame]
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001/*
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
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_
18#define ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080019
Ian Rogers1d54e732013-05-02 21:10:01 -070020#include "gc/collector/mark_sweep.h"
21
22#include "gc/heap.h"
Brian Carlstromea46f952013-07-30 01:26:50 -070023#include "mirror/art_field.h"
Mathieu Chartier4aeec172014-03-27 16:09:46 -070024#include "mirror/class-inl.h"
Mathieu Chartier407f7022014-02-18 14:37:05 -080025#include "mirror/object_array-inl.h"
26#include "mirror/reference.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080027
28namespace art {
Ian Rogers1d54e732013-05-02 21:10:01 -070029namespace gc {
30namespace collector {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080031
Mathieu Chartier407f7022014-02-18 14:37:05 -080032template<typename MarkVisitor, typename ReferenceVisitor>
33inline void MarkSweep::ScanObjectVisit(mirror::Object* obj, const MarkVisitor& visitor,
34 const ReferenceVisitor& ref_visitor) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080035 if (kIsDebugBuild && !IsMarked(obj)) {
36 heap_->DumpSpaces();
37 LOG(FATAL) << "Scanning unmarked object " << obj;
38 }
Mathieu Chartier407f7022014-02-18 14:37:05 -080039 obj->VisitReferences<false>(visitor, ref_visitor);
40 if (kCountScannedTypes) {
41 mirror::Class* klass = obj->GetClass<kVerifyNone>();
42 if (UNLIKELY(klass == mirror::Class::GetJavaLangClass())) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080043 ++class_count_;
Mathieu Chartier407f7022014-02-18 14:37:05 -080044 } else if (UNLIKELY(klass->IsArrayClass<kVerifyNone>())) {
45 ++array_count_;
46 } else {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080047 ++other_count_;
48 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080049 }
50}
51
Ian Rogers1d54e732013-05-02 21:10:01 -070052} // namespace collector
53} // namespace gc
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080054} // namespace art
55
Brian Carlstromfc0e3212013-07-17 14:40:12 -070056#endif // ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_