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

Side by Side Diff: src/spaces-inl.h

Issue 6880010: Merge (7265, 7271] from bleeding_edge to experimental/gc branch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 8 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_SPACES_INL_H_ 28 #ifndef V8_SPACES_INL_H_
29 #define V8_SPACES_INL_H_ 29 #define V8_SPACES_INL_H_
30 30
31 #include "isolate.h"
31 #include "memory.h" 32 #include "memory.h"
32 #include "spaces.h" 33 #include "spaces.h"
33 34
34 namespace v8 { 35 namespace v8 {
35 namespace internal { 36 namespace internal {
36 37
37 38
38 // ----------------------------------------------------------------------------- 39 // -----------------------------------------------------------------------------
39 // PageIterator 40 // PageIterator
40 41
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 int id = GetChunkId(page); 107 int id = GetChunkId(page);
107 OS::Unprotect(chunks_[id].address(), chunks_[id].size(), 108 OS::Unprotect(chunks_[id].address(), chunks_[id].size(),
108 chunks_[id].owner()->executable() == EXECUTABLE); 109 chunks_[id].owner()->executable() == EXECUTABLE);
109 } 110 }
110 111
111 #endif 112 #endif
112 113
113 114
114 // -------------------------------------------------------------------------- 115 // --------------------------------------------------------------------------
115 // PagedSpace 116 // PagedSpace
116 Page* Page::Initialize(MemoryChunk* chunk, 117 Page* Page::Initialize(Heap* heap,
118 MemoryChunk* chunk,
117 Executability executable, 119 Executability executable,
118 PagedSpace* owner) { 120 PagedSpace* owner) {
119 Page* page = reinterpret_cast<Page*>(chunk); 121 Page* page = reinterpret_cast<Page*>(chunk);
120 MemoryChunk::Initialize(reinterpret_cast<Address>(chunk), 122 MemoryChunk::Initialize(heap,
123 reinterpret_cast<Address>(chunk),
121 kPageSize, 124 kPageSize,
122 executable, 125 executable,
123 owner); 126 owner);
124 owner->IncreaseCapacity(Page::kObjectAreaSize); 127 owner->IncreaseCapacity(Page::kObjectAreaSize);
125 owner->Free(page->ObjectAreaStart(), 128 owner->Free(page->ObjectAreaStart(),
126 page->ObjectAreaEnd() - page->ObjectAreaStart()); 129 page->ObjectAreaEnd() - page->ObjectAreaStart());
127 return page; 130 return page;
128 } 131 }
129 132
130 133
131 bool PagedSpace::Contains(Address addr) { 134 bool PagedSpace::Contains(Address addr) {
132 Page* p = Page::FromAddress(addr); 135 Page* p = Page::FromAddress(addr);
133 if (!p->is_valid()) return false; 136 if (!p->is_valid()) return false;
134 return p->owner() == this; 137 return p->owner() == this;
135 } 138 }
136 139
137 140
138 MemoryChunk* MemoryChunk::FromAnyPointerAddress(Address addr) { 141 MemoryChunk* MemoryChunk::FromAnyPointerAddress(Address addr) {
139 MemoryChunk* maybe = reinterpret_cast<MemoryChunk*>( 142 MemoryChunk* maybe = reinterpret_cast<MemoryChunk*>(
140 OffsetFrom(addr) & ~Page::kPageAlignmentMask); 143 OffsetFrom(addr) & ~Page::kPageAlignmentMask);
141 if (maybe->owner() != NULL) return maybe; 144 if (maybe->owner() != NULL) return maybe;
142 LargeObjectIterator iterator(Heap::lo_space()); 145 // TODO(gc) ISOLATESMERGE HEAP
146 LargeObjectIterator iterator(HEAP->lo_space());
143 for (HeapObject* o = iterator.next(); o != NULL; o = iterator.next()) { 147 for (HeapObject* o = iterator.next(); o != NULL; o = iterator.next()) {
144 // Fixed arrays are the only pointer-containing objects in large object 148 // Fixed arrays are the only pointer-containing objects in large object
145 // space. 149 // space.
146 if (o->IsFixedArray()) { 150 if (o->IsFixedArray()) {
147 MemoryChunk* chunk = MemoryChunk::FromAddress(o->address()); 151 MemoryChunk* chunk = MemoryChunk::FromAddress(o->address());
148 if (chunk->Contains(addr)) { 152 if (chunk->Contains(addr)) {
149 return chunk; 153 return chunk;
150 } 154 }
151 } 155 }
152 } 156 }
153 UNREACHABLE(); 157 UNREACHABLE();
154 return NULL; 158 return NULL;
155 } 159 }
156 160
157 161
162 // TODO(gc) ISOLATESMERGE HEAP
158 PointerChunkIterator::PointerChunkIterator() 163 PointerChunkIterator::PointerChunkIterator()
159 : state_(kOldPointerState), 164 : state_(kOldPointerState),
160 old_pointer_iterator_(Heap::old_pointer_space()), 165 old_pointer_iterator_(HEAP->old_pointer_space()),
161 map_iterator_(Heap::map_space()), 166 map_iterator_(HEAP->map_space()),
162 lo_iterator_(Heap::lo_space()) { } 167 lo_iterator_(HEAP->lo_space()) { }
163 168
164 169
165 Page* Page::next_page() { 170 Page* Page::next_page() {
166 ASSERT(next_chunk()->owner() == owner()); 171 ASSERT(next_chunk()->owner() == owner());
167 return static_cast<Page*>(next_chunk()); 172 return static_cast<Page*>(next_chunk());
168 } 173 }
169 174
170 175
171 Page* Page::prev_page() { 176 Page* Page::prev_page() {
172 ASSERT(prev_chunk()->owner() == owner()); 177 ASSERT(prev_chunk()->owner() == owner());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 return AllocateRawInternal(size_in_bytes); 245 return AllocateRawInternal(size_in_bytes);
241 } 246 }
242 return Failure::RetryAfterGC(); 247 return Failure::RetryAfterGC();
243 } 248 }
244 249
245 Object* obj = HeapObject::FromAddress(allocation_info_.top); 250 Object* obj = HeapObject::FromAddress(allocation_info_.top);
246 allocation_info_.top = new_top; 251 allocation_info_.top = new_top;
247 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); 252 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
248 253
249 int bytes_allocated = new_top - top_on_previous_step_; 254 int bytes_allocated = new_top - top_on_previous_step_;
250 IncrementalMarking::Step(bytes_allocated); 255 heap()->incremental_marking()->Step(bytes_allocated);
251 top_on_previous_step_ = new_top; 256 top_on_previous_step_ = new_top;
252 257
253 return obj; 258 return obj;
254 } 259 }
255 260
256 261
262 intptr_t LargeObjectSpace::Available() {
263 return ObjectSizeFor(heap()->isolate()->memory_allocator()->Available());
264 }
265
266
257 template <typename StringType> 267 template <typename StringType>
258 void NewSpace::ShrinkStringAtAllocationBoundary(String* string, int length) { 268 void NewSpace::ShrinkStringAtAllocationBoundary(String* string, int length) {
259 ASSERT(length <= string->length()); 269 ASSERT(length <= string->length());
260 ASSERT(string->IsSeqString()); 270 ASSERT(string->IsSeqString());
261 ASSERT(string->address() + StringType::SizeFor(string->length()) == 271 ASSERT(string->address() + StringType::SizeFor(string->length()) ==
262 allocation_info_.top); 272 allocation_info_.top);
263 allocation_info_.top = 273 allocation_info_.top =
264 string->address() + StringType::SizeFor(length); 274 string->address() + StringType::SizeFor(length);
265 string->set_length(length); 275 string->set_length(length);
266 } 276 }
267 277
268 278
269 bool FreeListNode::IsFreeListNode(HeapObject* object) { 279 bool FreeListNode::IsFreeListNode(HeapObject* object) {
270 return object->map() == Heap::raw_unchecked_free_space_map() 280 return object->map() == HEAP->raw_unchecked_free_space_map()
Erik Corry 2011/04/20 20:07:40 I think this needs a todo
Vyacheslav Egorov (Chromium) 2011/04/24 11:24:08 Done.
271 || object->map() == Heap::raw_unchecked_one_pointer_filler_map() 281 || object->map() == HEAP->raw_unchecked_one_pointer_filler_map()
272 || object->map() == Heap::raw_unchecked_two_pointer_filler_map(); 282 || object->map() == HEAP->raw_unchecked_two_pointer_filler_map();
273 } 283 }
274 284
275 } } // namespace v8::internal 285 } } // namespace v8::internal
276 286
277 #endif // V8_SPACES_INL_H_ 287 #endif // V8_SPACES_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698