blob: e72277ffb211083de9e475b2f98e18f7e07a4fb3 [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
Mathieu Chartierc7853442015-03-27 14:35:38 -070020#include "mark_sweep.h"
Ian Rogers1d54e732013-05-02 21:10:01 -070021
22#include "gc/heap.h"
Mathieu Chartier4aeec172014-03-27 16:09:46 -070023#include "mirror/class-inl.h"
Mathieu Chartier407f7022014-02-18 14:37:05 -080024#include "mirror/object_array-inl.h"
25#include "mirror/reference.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080026
27namespace art {
Ian Rogers1d54e732013-05-02 21:10:01 -070028namespace gc {
29namespace collector {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080030
Mathieu Chartier407f7022014-02-18 14:37:05 -080031template<typename MarkVisitor, typename ReferenceVisitor>
Mathieu Chartier1ac1c2b2015-09-22 14:53:32 -070032inline void MarkSweep::ScanObjectVisit(mirror::Object* obj,
33 const MarkVisitor& visitor,
Mathieu Chartier407f7022014-02-18 14:37:05 -080034 const ReferenceVisitor& ref_visitor) {
Mathieu Chartier4c13a3f2014-07-14 14:57:16 -070035 DCHECK(IsMarked(obj)) << "Scanning unmarked object " << obj << "\n" << heap_->DumpSpaces();
Mathieu Chartier059ef3d2015-08-18 13:54:21 -070036 obj->VisitReferences(visitor, ref_visitor);
Mathieu Chartier407f7022014-02-18 14:37:05 -080037 if (kCountScannedTypes) {
38 mirror::Class* klass = obj->GetClass<kVerifyNone>();
Mathieu Chartier52a7f5c2015-08-18 18:35:52 -070039 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) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080047 ++class_count_;
Mathieu Chartier52a7f5c2015-08-18 18:35:52 -070048 } else if ((class_flags & mirror::kClassFlagReference) != 0) {
49 ++reference_count_;
Mathieu Chartier407f7022014-02-18 14:37:05 -080050 } else {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080051 ++other_count_;
52 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080053 }
54}
55
Ian Rogers1d54e732013-05-02 21:10:01 -070056} // namespace collector
57} // namespace gc
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080058} // namespace art
59
Brian Carlstromfc0e3212013-07-17 14:40:12 -070060#endif // ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_