summaryrefslogtreecommitdiffstats
path: root/vm/alloc/CardTable.h
blob: 1c15a5409a87bf31cb6d8192b57bd5356a991254 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Maintain a card table from the the write barrier. All writes of
 * non-NULL values to heap addresses should go through an entry in
 * WriteBarrier, and from there to here.
 */

#ifndef _DALVIK_ALLOC_CARDTABLE
#define _DALVIK_ALLOC_CARDTABLE

#ifdef __cplusplus
extern "C" {
#endif

#define GC_CARD_SHIFT 7
#define GC_CARD_SIZE (1 << GC_CARD_SHIFT)
#define GC_CARD_CLEAN 0
#define GC_CARD_DIRTY 0x70

/*
 * Initializes the card table; must be called before any other
 * dvmCardTable*() functions.
 */
bool dvmCardTableStartup(size_t heapMaximumSize);

/*
 * Tears down the entire CardTable structure.
 */
void dvmCardTableShutdown(void);

/*
 * Resets all of the bytes in the card table to clean.
 */
void dvmClearCardTable(void);

/*
 * Returns the address of the relevent byte in the card table, given
 * an address on the heap.
 */
u1 *dvmCardFromAddr(const void *addr);

/*
 * Returns the first address in the heap which maps to this card.
 */
void *dvmAddrFromCard(const u1 *card);

/*
 * Returns true if addr points to a valid card.
 */
bool dvmIsValidCard(const u1 *card);

/*
 * Set the card associated with the given address to GC_CARD_DIRTY.
 */
void dvmMarkCard(const void *addr);

/*
 * Verifies that all gray objects are on a dirty card.
 */
void dvmVerifyCardTable(void);

#ifdef __cplusplus
}
#endif

#endif /*_DALVIK_ALLOC_CARDTABLE*/