| OLD | NEW |
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 Page* PageIterator::next() { | 54 Page* PageIterator::next() { |
| 55 ASSERT(has_next()); | 55 ASSERT(has_next()); |
| 56 prev_page_ = next_page_; | 56 prev_page_ = next_page_; |
| 57 next_page_ = next_page_->next_page(); | 57 next_page_ = next_page_->next_page(); |
| 58 return prev_page_; | 58 return prev_page_; |
| 59 } | 59 } |
| 60 | 60 |
| 61 | 61 |
| 62 // ----------------------------------------------------------------------------- | 62 // ----------------------------------------------------------------------------- |
| 63 // NewSpacePageIterator |
| 64 |
| 65 |
| 66 NewSpacePageIterator::NewSpacePageIterator(SemiSpace* space) |
| 67 : prev_page_(&space->anchor_), |
| 68 next_page_(prev_page_->next_page()), |
| 69 last_page_(prev_page_->prev_page()) { } |
| 70 |
| 71 NewSpacePageIterator::NewSpacePageIterator(Address start, Address limit) |
| 72 : prev_page_(NewSpacePage::FromAddress(start)->prev_page()), |
| 73 next_page_(NewSpacePage::FromAddress(start)), |
| 74 last_page_(NewSpacePage::FromLimit(limit)) { |
| 75 #ifdef DEBUG |
| 76 SemiSpace::ValidateRange(start, limit); |
| 77 #endif |
| 78 } |
| 79 |
| 80 |
| 81 bool NewSpacePageIterator::has_next() { |
| 82 return prev_page_ != last_page_; |
| 83 } |
| 84 |
| 85 |
| 86 NewSpacePage* NewSpacePageIterator::next() { |
| 87 ASSERT(has_next()); |
| 88 prev_page_ = next_page_; |
| 89 next_page_ = next_page_->next_page(); |
| 90 return prev_page_; |
| 91 } |
| 92 |
| 93 |
| 94 // ----------------------------------------------------------------------------- |
| 63 // HeapObjectIterator | 95 // HeapObjectIterator |
| 64 HeapObject* HeapObjectIterator::FromCurrentPage() { | 96 HeapObject* HeapObjectIterator::FromCurrentPage() { |
| 65 while (cur_addr_ != cur_end_) { | 97 while (cur_addr_ != cur_end_) { |
| 66 if (cur_addr_ == space_->top() && cur_addr_ != space_->limit()) { | 98 if (cur_addr_ == space_->top() && cur_addr_ != space_->limit()) { |
| 67 cur_addr_ = space_->limit(); | 99 cur_addr_ = space_->limit(); |
| 68 continue; | 100 continue; |
| 69 } | 101 } |
| 70 HeapObject* obj = HeapObject::FromAddress(cur_addr_); | 102 HeapObject* obj = HeapObject::FromAddress(cur_addr_); |
| 71 int obj_size = (size_func_ == NULL) ? obj->Size() : size_func_(obj); | 103 int obj_size = (size_func_ == NULL) ? obj->Size() : size_func_(obj); |
| 72 cur_addr_ += obj_size; | 104 cur_addr_ += obj_size; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 } | 274 } |
| 243 | 275 |
| 244 return Failure::RetryAfterGC(identity()); | 276 return Failure::RetryAfterGC(identity()); |
| 245 } | 277 } |
| 246 | 278 |
| 247 | 279 |
| 248 // ----------------------------------------------------------------------------- | 280 // ----------------------------------------------------------------------------- |
| 249 // NewSpace | 281 // NewSpace |
| 250 | 282 |
| 251 MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes) { | 283 MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes) { |
| 252 Address new_top = allocation_info_.top + size_in_bytes; | 284 Address old_top = allocation_info_.top; |
| 285 Address new_top = old_top + size_in_bytes; |
| 253 if (new_top > allocation_info_.limit) { | 286 if (new_top > allocation_info_.limit) { |
| 254 Address high = to_space_.high(); | 287 Address high = to_space_.page_high(); |
| 255 if (allocation_info_.limit < high) { | 288 if (allocation_info_.limit < high) { |
| 256 allocation_info_.limit = Min( | 289 allocation_info_.limit = Min( |
| 257 allocation_info_.limit + inline_alloction_limit_step_, | 290 allocation_info_.limit + inline_alloction_limit_step_, |
| 258 high); | 291 high); |
| 259 int bytes_allocated = new_top - top_on_previous_step_; | 292 int bytes_allocated = new_top - top_on_previous_step_; |
| 260 heap()->incremental_marking()->Step(bytes_allocated); | 293 heap()->incremental_marking()->Step(bytes_allocated); |
| 261 top_on_previous_step_ = new_top; | 294 top_on_previous_step_ = new_top; |
| 262 return AllocateRawInternal(size_in_bytes); | 295 return AllocateRawInternal(size_in_bytes); |
| 296 } else if (AddFreshPage()) { |
| 297 // Switched to new page. Try allocating again. |
| 298 int bytes_allocated = old_top - top_on_previous_step_; |
| 299 heap()->incremental_marking()->Step(bytes_allocated); |
| 300 top_on_previous_step_ = to_space_.page_low(); |
| 301 return AllocateRawInternal(size_in_bytes); |
| 263 } else { | 302 } else { |
| 264 return Failure::RetryAfterGC(); | 303 return Failure::RetryAfterGC(); |
| 265 } | 304 } |
| 266 } | 305 } |
| 267 | 306 |
| 268 Object* obj = HeapObject::FromAddress(allocation_info_.top); | 307 Object* obj = HeapObject::FromAddress(allocation_info_.top); |
| 269 allocation_info_.top = new_top; | 308 allocation_info_.top = new_top; |
| 270 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); | 309 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); |
| 271 | 310 |
| 272 return obj; | 311 return obj; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 299 bool FreeListNode::IsFreeListNode(HeapObject* object) { | 338 bool FreeListNode::IsFreeListNode(HeapObject* object) { |
| 300 // TODO(gc) ISOLATES MERGE | 339 // TODO(gc) ISOLATES MERGE |
| 301 return object->map() == HEAP->raw_unchecked_free_space_map() | 340 return object->map() == HEAP->raw_unchecked_free_space_map() |
| 302 || object->map() == HEAP->raw_unchecked_one_pointer_filler_map() | 341 || object->map() == HEAP->raw_unchecked_one_pointer_filler_map() |
| 303 || object->map() == HEAP->raw_unchecked_two_pointer_filler_map(); | 342 || object->map() == HEAP->raw_unchecked_two_pointer_filler_map(); |
| 304 } | 343 } |
| 305 | 344 |
| 306 } } // namespace v8::internal | 345 } } // namespace v8::internal |
| 307 | 346 |
| 308 #endif // V8_SPACES_INL_H_ | 347 #endif // V8_SPACES_INL_H_ |
| OLD | NEW |