1 /* 2 * Copyright (C) 2008 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 #ifndef _DALVIK_ALLOC_MARK_SWEEP 17 #define _DALVIK_ALLOC_MARK_SWEEP 18 19 #include "alloc/HeapBitmap.h" 20 #include "alloc/HeapSource.h" 21 22 /* Downward-growing stack for better cache read behavior. 23 */ 24 typedef struct { 25 /* Lowest address (inclusive) 26 */ 27 const Object **limit; 28 29 /* Current top of the stack (inclusive) 30 */ 31 const Object **top; 32 33 /* Highest address (exclusive) 34 */ 35 const Object **base; 36 } GcMarkStack; 37 38 /* This is declared publicly so that it can be included in gDvm.gcHeap. 39 */ 40 typedef struct { 41 HeapBitmap bitmaps[HEAP_SOURCE_MAX_HEAP_COUNT]; 42 size_t numBitmaps; 43 GcMarkStack stack; 44 const void *finger; // only used while scanning/recursing. 45 } GcMarkContext; 46 47 enum RefType { 48 REF_SOFT, 49 REF_WEAK, 50 REF_PHANTOM, 51 REF_WEAKGLOBAL 52 }; 53 54 bool dvmHeapBeginMarkStep(void); 55 void dvmHeapMarkRootSet(void); 56 void dvmHeapScanMarkedObjects(void); 57 void dvmHeapHandleReferences(Object *refListHead, enum RefType refType); 58 void dvmHeapScheduleFinalizations(void); 59 void dvmHeapFinishMarkStep(void); 60 61 void dvmHeapSweepUnmarkedObjects(int *numFreed, size_t *sizeFreed); 62 63 #endif // _DALVIK_ALLOC_MARK_SWEEP 64