Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: src/spaces.cc

Issue 6542047: Basic implementation of incremental marking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2010 the V8 project authors. All rights reserved. 1 // Copyright 2006-2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void HeapObjectIterator::Initialize(Address cur, Address end, 67 void HeapObjectIterator::Initialize(Address cur, Address end,
68 HeapObjectCallback size_f) { 68 HeapObjectCallback size_f) {
69 cur_addr_ = cur; 69 cur_addr_ = cur;
70 end_addr_ = end; 70 end_addr_ = end;
71 end_page_ = Page::FromAllocationTop(end); 71 end_page_ = Page::FromAllocationTop(end);
72 size_func_ = size_f; 72 size_func_ = size_f;
73 Page* p = Page::FromAllocationTop(cur_addr_); 73 Page* p = Page::FromAllocationTop(cur_addr_);
74 cur_limit_ = (p == end_page_) ? end_addr_ : p->AllocationTop(); 74 cur_limit_ = (p == end_page_) ? end_addr_ : p->AllocationTop();
75 75
76 if (!p->IsFlagSet(Page::IS_CONTINUOUS)) { 76 if (!p->IsFlagSet(Page::IS_CONTINUOUS)) {
77 ASSERT(IncrementalMarking::state() == IncrementalMarking::STOPPED);
77 cur_addr_ = Marking::FirstLiveObject(cur_addr_, cur_limit_); 78 cur_addr_ = Marking::FirstLiveObject(cur_addr_, cur_limit_);
78 if (cur_addr_ > cur_limit_) cur_addr_ = cur_limit_; 79 if (cur_addr_ > cur_limit_) cur_addr_ = cur_limit_;
79 } 80 }
80 81
81 #ifdef DEBUG 82 #ifdef DEBUG
82 Verify(); 83 Verify();
83 #endif 84 #endif
84 } 85 }
85 86
86 87
87 HeapObject* HeapObjectIterator::FromNextPage() { 88 HeapObject* HeapObjectIterator::FromNextPage() {
88 if (cur_addr_ == end_addr_) return NULL; 89 if (cur_addr_ == end_addr_) return NULL;
89 90
90 Page* cur_page = Page::FromAllocationTop(cur_addr_); 91 Page* cur_page = Page::FromAllocationTop(cur_addr_);
91 cur_page = cur_page->next_page(); 92 cur_page = cur_page->next_page();
92 ASSERT(cur_page->is_valid()); 93 ASSERT(cur_page->is_valid());
93 94
94 cur_addr_ = cur_page->ObjectAreaStart(); 95 cur_addr_ = cur_page->ObjectAreaStart();
95 cur_limit_ = (cur_page == end_page_) ? end_addr_ : cur_page->AllocationTop(); 96 cur_limit_ = (cur_page == end_page_) ? end_addr_ : cur_page->AllocationTop();
96 97
97 if (!cur_page->IsFlagSet(Page::IS_CONTINUOUS)) { 98 if (!cur_page->IsFlagSet(Page::IS_CONTINUOUS)) {
99 ASSERT(IncrementalMarking::state() == IncrementalMarking::STOPPED);
98 cur_addr_ = Marking::FirstLiveObject(cur_addr_, cur_limit_); 100 cur_addr_ = Marking::FirstLiveObject(cur_addr_, cur_limit_);
99 if (cur_addr_ > cur_limit_) cur_addr_ = cur_limit_; 101 if (cur_addr_ > cur_limit_) cur_addr_ = cur_limit_;
100 } 102 }
101 103
102 if (cur_addr_ == end_addr_) return NULL; 104 if (cur_addr_ == end_addr_) return NULL;
103 ASSERT(cur_addr_ < cur_limit_); 105 ASSERT(cur_addr_ < cur_limit_);
104 #ifdef DEBUG 106 #ifdef DEBUG
105 Verify(); 107 Verify();
106 #endif 108 #endif
107 return FromCurrentPage(); 109 return FromCurrentPage();
108 } 110 }
109 111
110 112
111 void HeapObjectIterator::AdvanceUsingMarkbits() { 113 void HeapObjectIterator::AdvanceUsingMarkbits() {
114 ASSERT(IncrementalMarking::state() == IncrementalMarking::STOPPED);
112 HeapObject* obj = HeapObject::FromAddress(cur_addr_); 115 HeapObject* obj = HeapObject::FromAddress(cur_addr_);
113 int obj_size = (size_func_ == NULL) ? obj->Size() : size_func_(obj); 116 int obj_size = (size_func_ == NULL) ? obj->Size() : size_func_(obj);
114 ASSERT_OBJECT_SIZE(obj_size); 117 ASSERT_OBJECT_SIZE(obj_size);
115 cur_addr_ = Marking::NextLiveObject(obj, 118 cur_addr_ = Marking::NextLiveObject(obj,
116 obj_size, 119 obj_size,
117 cur_limit_); 120 cur_limit_);
118 if (cur_addr_ > cur_limit_) cur_addr_ = cur_limit_; 121 if (cur_addr_ > cur_limit_) cur_addr_ = cur_limit_;
119 } 122 }
120 123
121 124
(...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2303 this); 2306 this);
2304 if (page == NULL) return Failure::RetryAfterGC(identity()); 2307 if (page == NULL) return Failure::RetryAfterGC(identity());
2305 ASSERT(page->body_size() >= object_size); 2308 ASSERT(page->body_size() >= object_size);
2306 2309
2307 size_ += static_cast<int>(page->size()); 2310 size_ += static_cast<int>(page->size());
2308 objects_size_ += object_size; 2311 objects_size_ += object_size;
2309 page_count_++; 2312 page_count_++;
2310 page->set_next_page(first_page_); 2313 page->set_next_page(first_page_);
2311 first_page_ = page; 2314 first_page_ = page;
2312 2315
2316
2317 IncrementalMarking::Step(object_size);
2313 return page->GetObject(); 2318 return page->GetObject();
2314 } 2319 }
2315 2320
2316 2321
2317 MaybeObject* LargeObjectSpace::AllocateRawCode(int size_in_bytes) { 2322 MaybeObject* LargeObjectSpace::AllocateRawCode(int size_in_bytes) {
2318 ASSERT(0 < size_in_bytes); 2323 ASSERT(0 < size_in_bytes);
2319 return AllocateRawInternal(size_in_bytes, EXECUTABLE); 2324 return AllocateRawInternal(size_in_bytes, EXECUTABLE);
2320 } 2325 }
2321 2326
2322 2327
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2507 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) { 2512 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) {
2508 if (obj->IsCode()) { 2513 if (obj->IsCode()) {
2509 Code* code = Code::cast(obj); 2514 Code* code = Code::cast(obj);
2510 code_kind_statistics[code->kind()] += code->Size(); 2515 code_kind_statistics[code->kind()] += code->Size();
2511 } 2516 }
2512 } 2517 }
2513 } 2518 }
2514 #endif // DEBUG 2519 #endif // DEBUG
2515 2520
2516 } } // namespace v8::internal 2521 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698