blob: c1c69fb37913be192a407cc4bdbcae310dc8fdb1 [file] [log] [blame]
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001/*
2 * Copyright (C) 2012 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_SRC_GC_MOD_UNION_TABLE_INL_H_
18#define ART_SRC_GC_MOD_UNION_TABLE_INL_H_
19
20#include "mod_union_table.h"
21
22namespace art {
23
24template <typename Implementation>
25class ModUnionTableToZygoteAllocspace : public Implementation {
26public:
27 ModUnionTableToZygoteAllocspace(Heap* heap) : Implementation(heap) {
28 }
29
30 bool AddReference(const mirror::Object* /* obj */, const mirror::Object* ref) {
31 const Spaces& spaces = Implementation::GetHeap()->GetSpaces();
32 for (Spaces::const_iterator it = spaces.begin(); it != spaces.end(); ++it) {
33 if ((*it)->Contains(ref)) {
34 return (*it)->IsAllocSpace();
35 }
36 }
37 // Assume it points to a large object.
38 // TODO: Check.
39 return true;
40 }
41};
42
43template <typename Implementation>
44class ModUnionTableToAllocspace : public Implementation {
45public:
46 ModUnionTableToAllocspace(Heap* heap) : Implementation(heap) {
47 }
48
49 bool AddReference(const mirror::Object* /* obj */, const mirror::Object* ref) {
50 const Spaces& spaces = Implementation::GetHeap()->GetSpaces();
51 for (Spaces::const_iterator it = spaces.begin(); it != spaces.end(); ++it) {
52 if ((*it)->Contains(ref)) {
53 return (*it)->GetGcRetentionPolicy() == kGcRetentionPolicyAlwaysCollect;
54 }
55 }
56 // Assume it points to a large object.
57 // TODO: Check.
58 return true;
59 }
60};
61
62} // namespace art
63
64#endif // ART_SRC_GC_MOD_UNION_TABLE_INL_H_