blob: c142702936a6750e9c93dbecce5df9963d9d9b09 [file] [log] [blame]
/*
* 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
/*
* TODO: Better documentation of these values pending integration of
* concurrent collections and the card table.
*/
#define GC_CARD_SHIFT 7
#define GC_CARD_SIZE (1 << GC_CARD_SHIFT)
#define GC_OBJ_PER_CARD (GC_CARD_SIZE >> 3)
#define GC_CARD_CLEAN 0
#define GC_CARD_DIRTY 0x70
struct GcHeap;
struct HeapBitmap;
/*
* Initializes the card table; must be called before any other
* dvmCardTable*() functions.
*/
bool dvmCardTableStartup(struct GcHeap *gcHeap, void *heapBase);
/*
* Tears down the entire CardTable structure.
*/
void dvmCardTableShutdown(void);
/*
* Returns The address of the relevent byte in the card table, given
* an address on the heap.
*/
u1 *dvmCardFromAddr(const void *addr);
void *dvmAddrFromCard(const u1 *card);
/*
* Set the card associated with the given address to GC_CARD_DIRTY.
*/
void dvmMarkCard(const void *addr);
/*
* dvmAbort if a clean, immune Object in the bitmap contains a pointer
* to a threatened Object.
*/
void dvmVerifyCardTable(struct HeapBitmap *bitmap, const char *immuneLimit);
/* TODO: Clearing, querying, and iterating over the card table. */
#endif /*_DALVIK_ALLOC_CARDTABLE*/