2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * Types and macros used internally by the heap.
19 #ifndef DALVIK_ALLOC_HEAP_INTERNAL_H_
20 #define DALVIK_ALLOC_HEAP_INTERNAL_H_
22 #include "MarkSweep.h"
27 HeapSource *heapSource;
29 /* Linked lists of subclass instances of java/lang/ref/Reference
30 * that we find while recursing. The "next" pointers are hidden
31 * in the Reference objects' pendingNext fields. These lists are
32 * cleared and rebuilt each time the GC runs.
34 Object *softReferences;
35 Object *weakReferences;
36 Object *finalizerReferences;
37 Object *phantomReferences;
39 /* The list of Reference objects that need to be enqueued.
41 Object *clearedReferences;
43 /* The current state of the mark step.
44 * Only valid during a GC.
46 GcMarkContext markContext;
50 size_t cardTableLength;
51 size_t cardTableOffset;
53 /* Is the GC running? Used to avoid recursive calls to GC.
58 * Debug control values
67 bool dvmLockHeap(void);
68 void dvmUnlockHeap(void);
74 #define HEAP_LOG_TAG LOG_TAG "-heap"
77 #define LOGV_HEAP(...) ((void)0)
78 #define LOGD_HEAP(...) ((void)0)
80 #define LOGV_HEAP(...) LOG(LOG_VERBOSE, HEAP_LOG_TAG, __VA_ARGS__)
81 #define LOGD_HEAP(...) LOG(LOG_DEBUG, HEAP_LOG_TAG, __VA_ARGS__)
83 #define LOGI_HEAP(...) \
85 if (!gDvm.zygote) { LOG(LOG_INFO, HEAP_LOG_TAG, __VA_ARGS__); } \
88 #define LOGW_HEAP(...) LOG(LOG_WARN, HEAP_LOG_TAG, __VA_ARGS__)
89 #define LOGE_HEAP(...) LOG(LOG_ERROR, HEAP_LOG_TAG, __VA_ARGS__)
91 #define FRACTIONAL_MB(n) (n) / (1024 * 1024), \
92 ((((n) % (1024 * 1024)) / 1024) * 1000) / 1024
93 #define FRACTIONAL_PCT(n,max) ((n) * 100) / (max), \
94 (((n) * 1000) / (max)) % 10
96 #endif // DALVIK_ALLOC_HEAP_INTERNAL_H_