blob: 0fc5933dddfe8d6bd60699c96a16300eb91b07c6 [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001/*
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 */
24typedef 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 */
40typedef struct {
Carl Shapirof373efd2010-02-19 00:46:33 -080041 HeapBitmap *bitmap;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080042 GcMarkStack stack;
Carl Shapirod25566d2010-03-11 20:39:47 -080043 const char *immuneLimit;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080044 const void *finger; // only used while scanning/recursing.
45} GcMarkContext;
46
Carl Shapirod25566d2010-03-11 20:39:47 -080047bool dvmHeapBeginMarkStep(GcMode mode);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080048void dvmHeapMarkRootSet(void);
Carl Shapiro106c5fd2010-07-28 14:12:27 -070049void dvmHeapReMarkRootSet(void);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080050void dvmHeapScanMarkedObjects(void);
Carl Shapiro106c5fd2010-07-28 14:12:27 -070051void dvmHeapReScanMarkedObjects(void);
Carl Shapiro29540742010-03-26 15:34:39 -070052void dvmHandleSoftRefs(Object **list);
53void dvmClearWhiteRefs(Object **list);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080054void dvmHeapScheduleFinalizations(void);
55void dvmHeapFinishMarkStep(void);
56
Carl Shapirod25566d2010-03-11 20:39:47 -080057void dvmHeapSweepUnmarkedObjects(GcMode mode, int *numFreed, size_t *sizeFreed);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080058
59#endif // _DALVIK_ALLOC_MARK_SWEEP