OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/gc_sweeper.h" | 5 #include "vm/gc_sweeper.h" |
6 | 6 |
7 #include "vm/freelist.h" | 7 #include "vm/freelist.h" |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
10 #include "vm/lockers.h" | 10 #include "vm/lockers.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 if (next_obj->IsMarked()) { | 37 if (next_obj->IsMarked()) { |
38 // Reached the end of the free block. | 38 // Reached the end of the free block. |
39 break; | 39 break; |
40 } | 40 } |
41 // Expand the free block by the size of this object. | 41 // Expand the free block by the size of this object. |
42 free_end += next_obj->Size(); | 42 free_end += next_obj->Size(); |
43 } | 43 } |
44 obj_size = free_end - current; | 44 obj_size = free_end - current; |
45 if (is_executable) { | 45 if (is_executable) { |
46 memset(reinterpret_cast<void*>(current), 0xcc, obj_size); | 46 memset(reinterpret_cast<void*>(current), 0xcc, obj_size); |
| 47 } else { |
| 48 #if defined(DEBUG) |
| 49 memset(reinterpret_cast<void*>(current), Heap::kZapByte, obj_size); |
| 50 #endif // DEBUG |
47 } | 51 } |
48 if ((current != start) || (free_end != end)) { | 52 if ((current != start) || (free_end != end)) { |
49 // Only add to the free list if not covering the whole page. | 53 // Only add to the free list if not covering the whole page. |
50 if (locked) { | 54 if (locked) { |
51 freelist->FreeLocked(current, obj_size); | 55 freelist->FreeLocked(current, obj_size); |
52 } else { | 56 } else { |
53 freelist->Free(current, obj_size); | 57 freelist->Free(current, obj_size); |
54 } | 58 } |
55 } | 59 } |
56 } | 60 } |
(...skipping 13 matching lines...) Expand all Loading... |
70 words_to_end = (raw_obj->Size() >> kWordSizeLog2); | 74 words_to_end = (raw_obj->Size() >> kWordSizeLog2); |
71 } | 75 } |
72 #ifdef DEBUG | 76 #ifdef DEBUG |
73 // String::MakeExternal and Array::MakeArray create trailing filler objects, | 77 // String::MakeExternal and Array::MakeArray create trailing filler objects, |
74 // but they are always unreachable. Verify that they are not marked. | 78 // but they are always unreachable. Verify that they are not marked. |
75 uword current = RawObject::ToAddr(raw_obj) + raw_obj->Size(); | 79 uword current = RawObject::ToAddr(raw_obj) + raw_obj->Size(); |
76 uword end = page->object_end(); | 80 uword end = page->object_end(); |
77 while (current < end) { | 81 while (current < end) { |
78 RawObject* cur_obj = RawObject::FromAddr(current); | 82 RawObject* cur_obj = RawObject::FromAddr(current); |
79 ASSERT(!cur_obj->IsMarked()); | 83 ASSERT(!cur_obj->IsMarked()); |
80 current += cur_obj->Size(); | 84 intptr_t obj_size = cur_obj->Size(); |
| 85 memset(reinterpret_cast<void*>(current), Heap::kZapByte, obj_size); |
| 86 current += obj_size; |
81 } | 87 } |
82 #endif // DEBUG | 88 #endif // DEBUG |
83 return words_to_end; | 89 return words_to_end; |
84 } | 90 } |
85 | 91 |
86 | 92 |
87 class SweeperTask : public ThreadPool::Task { | 93 class SweeperTask : public ThreadPool::Task { |
88 public: | 94 public: |
89 SweeperTask(Isolate* isolate, | 95 SweeperTask(Isolate* isolate, |
90 PageSpace* old_space, | 96 PageSpace* old_space, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 SweeperTask* task = | 163 SweeperTask* task = |
158 new SweeperTask(isolate->ShallowCopy(), | 164 new SweeperTask(isolate->ShallowCopy(), |
159 isolate->heap()->old_space(), | 165 isolate->heap()->old_space(), |
160 first, last, | 166 first, last, |
161 freelist); | 167 freelist); |
162 ThreadPool* pool = Dart::thread_pool(); | 168 ThreadPool* pool = Dart::thread_pool(); |
163 pool->Run(task); | 169 pool->Run(task); |
164 } | 170 } |
165 | 171 |
166 } // namespace dart | 172 } // namespace dart |
OLD | NEW |