Home | History | Annotate | Download | only in alloc
      1 /*
      2  * Copyright (C) 2010 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 /*
     18  * Maintain a card table from the the write barrier. All writes of
     19  * non-NULL values to heap addresses should go through an entry in
     20  * WriteBarrier, and from there to here.
     21  */
     22 
     23 #ifndef DALVIK_ALLOC_CARDTABLE_H_
     24 #define DALVIK_ALLOC_CARDTABLE_H_
     25 
     26 #define GC_CARD_SHIFT 7
     27 #define GC_CARD_SIZE (1 << GC_CARD_SHIFT)
     28 #define GC_CARD_CLEAN 0
     29 #define GC_CARD_DIRTY 0x70
     30 
     31 /*
     32  * Initializes the card table; must be called before any other
     33  * dvmCardTable*() functions.
     34  */
     35 bool dvmCardTableStartup(size_t heapMaximumSize);
     36 
     37 /*
     38  * Tears down the entire CardTable structure.
     39  */
     40 void dvmCardTableShutdown(void);
     41 
     42 /*
     43  * Resets all of the bytes in the card table to clean.
     44  */
     45 void dvmClearCardTable(void);
     46 
     47 /*
     48  * Returns the address of the relevent byte in the card table, given
     49  * an address on the heap.
     50  */
     51 u1 *dvmCardFromAddr(const void *addr);
     52 
     53 /*
     54  * Returns the first address in the heap which maps to this card.
     55  */
     56 void *dvmAddrFromCard(const u1 *card);
     57 
     58 /*
     59  * Returns true if addr points to a valid card.
     60  */
     61 bool dvmIsValidCard(const u1 *card);
     62 
     63 /*
     64  * Set the card associated with the given address to GC_CARD_DIRTY.
     65  */
     66 void dvmMarkCard(const void *addr);
     67 
     68 /*
     69  * Verifies that all gray objects are on a dirty card.
     70  */
     71 void dvmVerifyCardTable(void);
     72 
     73 #endif  // DALVIK_ALLOC_CARDTABLE_H_
     74