Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 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 | */ |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef ART_SRC_HEAP_H_ |
| 18 | #define ART_SRC_HEAP_H_ |
| 19 | |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 20 | #include <vector> |
| 21 | |
Ian Rogers | 5d76c43 | 2011-10-31 21:42:49 -0700 | [diff] [blame^] | 22 | #include "card_table.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 23 | #include "globals.h" |
Elliott Hughes | 5e71b52 | 2011-10-20 13:12:32 -0700 | [diff] [blame] | 24 | #include "heap_bitmap.h" |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 25 | #include "offsets.h" |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 26 | |
Elliott Hughes | 3e465b1 | 2011-09-02 18:26:12 -0700 | [diff] [blame] | 27 | #define VERIFY_OBJECT_ENABLED 0 |
| 28 | |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 29 | namespace art { |
| 30 | |
Brian Carlstrom | a40f9bc | 2011-07-26 21:26:07 -0700 | [diff] [blame] | 31 | class Class; |
Elliott Hughes | 410c0c8 | 2011-09-01 17:58:25 -0700 | [diff] [blame] | 32 | class Mutex; |
Brian Carlstrom | a40f9bc | 2011-07-26 21:26:07 -0700 | [diff] [blame] | 33 | class Object; |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 34 | class Space; |
| 35 | class HeapBitmap; |
| 36 | |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 37 | class Heap { |
| 38 | public: |
Brian Carlstrom | 27ec961 | 2011-09-19 20:20:38 -0700 | [diff] [blame] | 39 | static const size_t kInitialSize = 4 * MB; |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 40 | |
Brian Carlstrom | 27ec961 | 2011-09-19 20:20:38 -0700 | [diff] [blame] | 41 | static const size_t kMaximumSize = 16 * MB; |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 42 | |
Elliott Hughes | 410c0c8 | 2011-09-01 17:58:25 -0700 | [diff] [blame] | 43 | typedef void (RootVisitor)(const Object* root, void* arg); |
Elliott Hughes | c33a32b | 2011-10-11 18:18:07 -0700 | [diff] [blame] | 44 | typedef bool (IsMarkedTester)(const Object* object, void* arg); |
Brian Carlstrom | 7e93b50 | 2011-08-04 14:16:22 -0700 | [diff] [blame] | 45 | |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 46 | // Create a heap with the requested sizes. The possible empty |
| 47 | // image_file_names names specify Spaces to load based on |
| 48 | // ImageWriter output. |
Brian Carlstrom | 6b4ef02 | 2011-10-23 14:59:04 -0700 | [diff] [blame] | 49 | static void Init(bool is_verbose_heap, bool is_verbose_gc, |
jeffhao | c116070 | 2011-10-27 15:48:45 -0700 | [diff] [blame] | 50 | size_t starting_size, size_t maximum_size, size_t growth_size, |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 51 | const std::vector<std::string>& image_file_names); |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 52 | |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 53 | static void Destroy(); |
Brian Carlstrom | a7f4f48 | 2011-07-17 17:01:34 -0700 | [diff] [blame] | 54 | |
Brian Carlstrom | 6b4ef02 | 2011-10-23 14:59:04 -0700 | [diff] [blame] | 55 | static bool IsVerboseHeap() { |
Elliott Hughes | 352a424 | 2011-10-31 15:15:21 -0700 | [diff] [blame] | 56 | return is_verbose_heap_ || is_verbose_gc_ /* TODO: remove when pause times are down */; |
Brian Carlstrom | 6b4ef02 | 2011-10-23 14:59:04 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | static bool IsVerboseGc() { |
| 60 | return is_verbose_gc_; |
| 61 | } |
| 62 | |
Brian Carlstrom | a40f9bc | 2011-07-26 21:26:07 -0700 | [diff] [blame] | 63 | // Allocates and initializes storage for an object instance. |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 64 | static Object* AllocObject(Class* klass, size_t num_bytes); |
Brian Carlstrom | a7f4f48 | 2011-07-17 17:01:34 -0700 | [diff] [blame] | 65 | |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 66 | // Check sanity of given reference. Requires the heap lock. |
Elliott Hughes | 3e465b1 | 2011-09-02 18:26:12 -0700 | [diff] [blame] | 67 | #if VERIFY_OBJECT_ENABLED |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 68 | static void VerifyObject(const Object *obj); |
Elliott Hughes | 3e465b1 | 2011-09-02 18:26:12 -0700 | [diff] [blame] | 69 | #else |
| 70 | static void VerifyObject(const Object *obj) {} |
| 71 | #endif |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 72 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 73 | // Check sanity of all live references. Requires the heap lock. |
| 74 | static void VerifyHeap(); |
| 75 | |
Elliott Hughes | 6a5bd49 | 2011-10-28 14:33:57 -0700 | [diff] [blame] | 76 | // A weaker test than IsLiveObject or VerifyObject that doesn't require the heap lock, |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 77 | // and doesn't abort on error, allowing the caller to report more |
| 78 | // meaningful diagnostics. |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 79 | static bool IsHeapAddress(const Object* obj); |
Elliott Hughes | 6a5bd49 | 2011-10-28 14:33:57 -0700 | [diff] [blame] | 80 | // Returns true if 'obj' is a live heap object, false otherwise (including for invalid addresses). |
| 81 | // Requires the heap lock to be held. |
| 82 | static bool IsLiveObjectLocked(const Object* obj); |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 83 | |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 84 | // Initiates an explicit garbage collection. |
| 85 | static void CollectGarbage(); |
| 86 | |
Elliott Hughes | bf86d04 | 2011-08-31 17:53:14 -0700 | [diff] [blame] | 87 | // Implements java.lang.Runtime.maxMemory. |
| 88 | static int64_t GetMaxMemory(); |
| 89 | // Implements java.lang.Runtime.totalMemory. |
| 90 | static int64_t GetTotalMemory(); |
| 91 | // Implements java.lang.Runtime.freeMemory. |
| 92 | static int64_t GetFreeMemory(); |
| 93 | |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 94 | // Implements VMDebug.countInstancesOfClass. |
| 95 | static int64_t CountInstances(Class* c, bool count_assignable); |
| 96 | |
Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 97 | // Implements dalvik.system.VMRuntime.clearGrowthLimit. |
jeffhao | c116070 | 2011-10-27 15:48:45 -0700 | [diff] [blame] | 98 | static void ClearGrowthLimit(); |
| 99 | |
Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 100 | // Implements dalvik.system.VMRuntime.getTargetHeapUtilization. |
| 101 | static float GetTargetHeapUtilization() { |
Brian Carlstrom | 395520e | 2011-09-25 19:35:00 -0700 | [diff] [blame] | 102 | return target_utilization_; |
Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 103 | } |
| 104 | // Implements dalvik.system.VMRuntime.setTargetHeapUtilization. |
| 105 | static void SetTargetHeapUtilization(float target) { |
Brian Carlstrom | 395520e | 2011-09-25 19:35:00 -0700 | [diff] [blame] | 106 | target_utilization_ = target; |
Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 107 | } |
Shih-wei Liao | 7f1caab | 2011-10-06 12:11:04 -0700 | [diff] [blame] | 108 | // Sets the maximum number of bytes that the heap is allowed to allocate |
| 109 | // from the system. Clamps to the appropriate maximum value. |
Shih-wei Liao | 8c2f641 | 2011-10-03 22:58:14 -0700 | [diff] [blame] | 110 | static void SetIdealFootprint(size_t max_allowed_footprint); |
Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 111 | |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 112 | // Blocks the caller until the garbage collector becomes idle. |
| 113 | static void WaitForConcurrentGcToComplete(); |
| 114 | |
Brian Carlstrom | 24a3c2e | 2011-10-17 18:07:52 -0700 | [diff] [blame] | 115 | static pid_t GetLockOwner(); // For SignalCatcher. |
Elliott Hughes | 92b3b56 | 2011-09-08 16:32:26 -0700 | [diff] [blame] | 116 | static void Lock(); |
Elliott Hughes | 92b3b56 | 2011-09-08 16:32:26 -0700 | [diff] [blame] | 117 | static void Unlock(); |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 118 | |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 119 | static const std::vector<Space*>& GetSpaces() { |
| 120 | return spaces_; |
| 121 | } |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 122 | |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 123 | static HeapBitmap* GetLiveBits() { |
| 124 | return live_bitmap_; |
Carl Shapiro | 744ad05 | 2011-08-06 15:53:36 -0700 | [diff] [blame] | 125 | } |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 126 | |
| 127 | static HeapBitmap* GetMarkBits() { |
| 128 | return mark_bitmap_; |
Carl Shapiro | 744ad05 | 2011-08-06 15:53:36 -0700 | [diff] [blame] | 129 | } |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 130 | |
Elliott Hughes | adb460d | 2011-10-05 17:02:34 -0700 | [diff] [blame] | 131 | static void SetWellKnownClasses(Class* java_lang_ref_FinalizerReference, |
| 132 | Class* java_lang_ref_ReferenceQueue); |
| 133 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 134 | static void SetReferenceOffsets(MemberOffset reference_referent_offset, |
| 135 | MemberOffset reference_queue_offset, |
| 136 | MemberOffset reference_queueNext_offset, |
| 137 | MemberOffset reference_pendingNext_offset, |
Elliott Hughes | adb460d | 2011-10-05 17:02:34 -0700 | [diff] [blame] | 138 | MemberOffset finalizer_reference_zombie_offset); |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 139 | |
Elliott Hughes | adb460d | 2011-10-05 17:02:34 -0700 | [diff] [blame] | 140 | static Object* GetReferenceReferent(Object* reference); |
| 141 | static void ClearReferenceReferent(Object* reference); |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 142 | |
Elliott Hughes | adb460d | 2011-10-05 17:02:34 -0700 | [diff] [blame] | 143 | // Returns true if the reference object has not yet been enqueued. |
| 144 | static bool IsEnqueuable(const Object* ref); |
| 145 | static void EnqueueReference(Object* ref, Object** list); |
| 146 | static void EnqueuePendingReference(Object* ref, Object** list); |
| 147 | static Object* DequeuePendingReference(Object** list); |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 148 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 149 | static MemberOffset GetReferencePendingNextOffset() { |
| 150 | DCHECK_NE(reference_pendingNext_offset_.Uint32Value(), 0U); |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 151 | return reference_pendingNext_offset_; |
| 152 | } |
| 153 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 154 | static MemberOffset GetFinalizerReferenceZombieOffset() { |
| 155 | DCHECK_NE(finalizer_reference_zombie_offset_.Uint32Value(), 0U); |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 156 | return finalizer_reference_zombie_offset_; |
| 157 | } |
| 158 | |
Elliott Hughes | 85d1545 | 2011-09-16 17:33:01 -0700 | [diff] [blame] | 159 | static void EnableObjectValidation() { |
| 160 | verify_objects_ = true; |
| 161 | } |
| 162 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 163 | static void DisableObjectValidation() { |
Elliott Hughes | 85d1545 | 2011-09-16 17:33:01 -0700 | [diff] [blame] | 164 | verify_objects_ = false; |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Elliott Hughes | 92b3b56 | 2011-09-08 16:32:26 -0700 | [diff] [blame] | 167 | // Callers must hold the heap lock. |
Elliott Hughes | 307f75d | 2011-10-12 18:04:40 -0700 | [diff] [blame] | 168 | static void RecordFreeLocked(size_t freed_objects, size_t freed_bytes); |
Brian Carlstrom | 693267a | 2011-09-06 09:25:34 -0700 | [diff] [blame] | 169 | |
Elliott Hughes | 5ea047b | 2011-09-13 14:38:18 -0700 | [diff] [blame] | 170 | // Must be called if a field of an Object in the heap changes, and before any GC safe-point. |
| 171 | // The call is not needed if NULL is stored in the field. |
Ian Rogers | 5d76c43 | 2011-10-31 21:42:49 -0700 | [diff] [blame^] | 172 | static void WriteBarrierField(const Object* dest, MemberOffset offset, const Object* new_val) { |
| 173 | if (!card_marking_disabled_) { |
| 174 | card_table_->MarkCard(dest); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | // Write barrier for array operations that update many field positions |
| 179 | static void WriteBarrierArray(const Object* dest, int pos, size_t len) { |
| 180 | if (UNLIKELY(!card_marking_disabled_)) { |
| 181 | card_table_->MarkCard(dest); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | static CardTable* GetCardTable() { |
| 186 | return card_table_; |
| 187 | } |
| 188 | |
| 189 | static void DisableCardMarking() { |
| 190 | // TODO: we shouldn't need to disable card marking, this is here to help the image_writer |
| 191 | card_marking_disabled_ = true; |
Elliott Hughes | 3a4f8df | 2011-09-13 15:22:36 -0700 | [diff] [blame] | 192 | } |
Elliott Hughes | 5ea047b | 2011-09-13 14:38:18 -0700 | [diff] [blame] | 193 | |
Elliott Hughes | 6a5bd49 | 2011-10-28 14:33:57 -0700 | [diff] [blame] | 194 | // dlmalloc_walk_heap-compatible heap walker. |
| 195 | static void WalkHeap(void(*callback)(const void*, size_t, const void*, size_t, void*), void* arg); |
| 196 | |
Elliott Hughes | adb460d | 2011-10-05 17:02:34 -0700 | [diff] [blame] | 197 | static void AddFinalizerReference(Object* object); |
| 198 | |
Elliott Hughes | 7162ad9 | 2011-10-27 14:08:42 -0700 | [diff] [blame] | 199 | static size_t GetBytesAllocated() { return num_bytes_allocated_; } |
| 200 | static size_t GetObjectsAllocated() { return num_objects_allocated_; } |
| 201 | |
Ian Rogers | 5d76c43 | 2011-10-31 21:42:49 -0700 | [diff] [blame^] | 202 | static Space* GetAllocSpace() { |
| 203 | return alloc_space_; |
| 204 | } |
| 205 | |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 206 | private: |
| 207 | // Allocates uninitialized storage. |
Elliott Hughes | 92b3b56 | 2011-09-08 16:32:26 -0700 | [diff] [blame] | 208 | static Object* AllocateLocked(size_t num_bytes); |
| 209 | static Object* AllocateLocked(Space* space, size_t num_bytes); |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 210 | |
Elliott Hughes | adb460d | 2011-10-05 17:02:34 -0700 | [diff] [blame] | 211 | // Pushes a list of cleared references out to the managed heap. |
| 212 | static void EnqueueClearedReferences(Object** cleared_references); |
| 213 | |
Elliott Hughes | 92b3b56 | 2011-09-08 16:32:26 -0700 | [diff] [blame] | 214 | static void RecordAllocationLocked(Space* space, const Object* object); |
Brian Carlstrom | 9cff8e1 | 2011-08-18 16:47:29 -0700 | [diff] [blame] | 215 | static void RecordImageAllocations(Space* space); |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 216 | |
| 217 | static void CollectGarbageInternal(); |
| 218 | |
| 219 | static void GrowForUtilization(); |
| 220 | |
Elliott Hughes | 92b3b56 | 2011-09-08 16:32:26 -0700 | [diff] [blame] | 221 | static void VerifyObjectLocked(const Object *obj); |
| 222 | |
Brian Carlstrom | 78128a6 | 2011-09-15 17:21:19 -0700 | [diff] [blame] | 223 | static void VerificationCallback(Object* obj, void* arg); |
Elliott Hughes | 92b3b56 | 2011-09-08 16:32:26 -0700 | [diff] [blame] | 224 | |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 225 | static Mutex* lock_; |
| 226 | |
Brian Carlstrom | 6b4ef02 | 2011-10-23 14:59:04 -0700 | [diff] [blame] | 227 | static bool is_verbose_heap_; |
| 228 | |
| 229 | static bool is_verbose_gc_; |
| 230 | |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 231 | static std::vector<Space*> spaces_; |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 232 | |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 233 | // default Space for allocations |
| 234 | static Space* alloc_space_; |
| 235 | |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 236 | static HeapBitmap* mark_bitmap_; |
| 237 | |
| 238 | static HeapBitmap* live_bitmap_; |
| 239 | |
Ian Rogers | 5d76c43 | 2011-10-31 21:42:49 -0700 | [diff] [blame^] | 240 | static CardTable* card_table_; |
| 241 | |
| 242 | // Used by the image writer to disable card marking on copied objects |
| 243 | // TODO: remove |
| 244 | static bool card_marking_disabled_; |
| 245 | |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 246 | // The maximum size of the heap in bytes. |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 247 | static size_t maximum_size_; |
| 248 | |
jeffhao | c116070 | 2011-10-27 15:48:45 -0700 | [diff] [blame] | 249 | // The largest size the heap may grow. This value allows the app to limit the |
| 250 | // growth below the maximum size. This is a work around until we can |
| 251 | // dynamically set the maximum size. This value can range between the starting |
| 252 | // size and the maximum size but should never be set below the current |
| 253 | // footprint of the heap. |
| 254 | static size_t growth_size_; |
| 255 | |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 256 | // True while the garbage collector is running. |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 257 | static bool is_gc_running_; |
| 258 | |
Carl Shapiro | 58551df | 2011-07-24 03:09:51 -0700 | [diff] [blame] | 259 | // Number of bytes allocated. Adjusted after each allocation and |
| 260 | // free. |
| 261 | static size_t num_bytes_allocated_; |
| 262 | |
| 263 | // Number of objects allocated. Adjusted after each allocation and |
| 264 | // free. |
| 265 | static size_t num_objects_allocated_; |
| 266 | |
Elliott Hughes | adb460d | 2011-10-05 17:02:34 -0700 | [diff] [blame] | 267 | static Class* java_lang_ref_FinalizerReference_; |
| 268 | static Class* java_lang_ref_ReferenceQueue_; |
| 269 | |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 270 | // offset of java.lang.ref.Reference.referent |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 271 | static MemberOffset reference_referent_offset_; |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 272 | |
| 273 | // offset of java.lang.ref.Reference.queue |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 274 | static MemberOffset reference_queue_offset_; |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 275 | |
| 276 | // offset of java.lang.ref.Reference.queueNext |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 277 | static MemberOffset reference_queueNext_offset_; |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 278 | |
| 279 | // offset of java.lang.ref.Reference.pendingNext |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 280 | static MemberOffset reference_pendingNext_offset_; |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 281 | |
| 282 | // offset of java.lang.ref.FinalizerReference.zombie |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 283 | static MemberOffset finalizer_reference_zombie_offset_; |
| 284 | |
Brian Carlstrom | 395520e | 2011-09-25 19:35:00 -0700 | [diff] [blame] | 285 | // Target ideal heap utilization ratio |
| 286 | static float target_utilization_; |
| 287 | |
Elliott Hughes | 85d1545 | 2011-09-16 17:33:01 -0700 | [diff] [blame] | 288 | static bool verify_objects_; |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 289 | |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 290 | DISALLOW_IMPLICIT_CONSTRUCTORS(Heap); |
| 291 | }; |
| 292 | |
Elliott Hughes | 6a5bd49 | 2011-10-28 14:33:57 -0700 | [diff] [blame] | 293 | class ScopedHeapLock { |
| 294 | public: |
| 295 | ScopedHeapLock() { |
| 296 | Heap::Lock(); |
| 297 | } |
| 298 | |
| 299 | ~ScopedHeapLock() { |
| 300 | Heap::Unlock(); |
| 301 | } |
| 302 | |
| 303 | private: |
| 304 | DISALLOW_COPY_AND_ASSIGN(ScopedHeapLock); |
| 305 | }; |
| 306 | |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 307 | } // namespace art |
| 308 | |
| 309 | #endif // ART_SRC_HEAP_H_ |