Chromium Code Reviews| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 PagedSpace* owner) { | 120 PagedSpace* owner) { |
| 121 Page* page = reinterpret_cast<Page*>(chunk); | 121 Page* page = reinterpret_cast<Page*>(chunk); |
| 122 MemoryChunk::Initialize(heap, | 122 MemoryChunk::Initialize(heap, |
| 123 reinterpret_cast<Address>(chunk), | 123 reinterpret_cast<Address>(chunk), |
| 124 kPageSize, | 124 kPageSize, |
| 125 executable, | 125 executable, |
| 126 owner); | 126 owner); |
| 127 owner->IncreaseCapacity(Page::kObjectAreaSize); | 127 owner->IncreaseCapacity(Page::kObjectAreaSize); |
| 128 owner->Free(page->ObjectAreaStart(), | 128 owner->Free(page->ObjectAreaStart(), |
| 129 page->ObjectAreaEnd() - page->ObjectAreaStart()); | 129 page->ObjectAreaEnd() - page->ObjectAreaStart()); |
| 130 | |
| 131 heap->incremental_marking()->SetOldSpacePageFlags(chunk); | |
| 132 | |
| 130 return page; | 133 return page; |
| 131 } | 134 } |
| 132 | 135 |
| 133 | 136 |
| 134 bool PagedSpace::Contains(Address addr) { | 137 bool PagedSpace::Contains(Address addr) { |
| 135 Page* p = Page::FromAddress(addr); | 138 Page* p = Page::FromAddress(addr); |
| 136 if (!p->is_valid()) return false; | 139 if (!p->is_valid()) return false; |
| 137 return p->owner() == this; | 140 return p->owner() == this; |
| 138 } | 141 } |
| 139 | 142 |
| 140 | 143 |
| 141 void MemoryChunk::set_scan_on_scavenge(bool scan) { | 144 void MemoryChunk::set_scan_on_scavenge(bool scan) { |
| 142 if (scan) { | 145 if (scan) { |
| 143 if (!scan_on_scavenge_) heap_->increment_scan_on_scavenge_pages(); | 146 if (!scan_on_scavenge()) heap_->increment_scan_on_scavenge_pages(); |
| 147 SetFlag(SCAN_ON_SCAVENGE); | |
| 144 } else { | 148 } else { |
| 145 if (scan_on_scavenge_) heap_->decrement_scan_on_scavenge_pages(); | 149 if (scan_on_scavenge()) heap_->decrement_scan_on_scavenge_pages(); |
| 150 ClearFlag(SCAN_ON_SCAVENGE); | |
| 146 } | 151 } |
| 147 scan_on_scavenge_ = scan; | 152 heap_->incremental_marking()->SetOldSpacePageFlags(this); |
| 148 } | 153 } |
| 149 | 154 |
| 150 | 155 |
| 151 MemoryChunk* MemoryChunk::FromAnyPointerAddress(Address addr) { | 156 MemoryChunk* MemoryChunk::FromAnyPointerAddress(Address addr) { |
| 152 MemoryChunk* maybe = reinterpret_cast<MemoryChunk*>( | 157 MemoryChunk* maybe = reinterpret_cast<MemoryChunk*>( |
| 153 OffsetFrom(addr) & ~Page::kPageAlignmentMask); | 158 OffsetFrom(addr) & ~Page::kPageAlignmentMask); |
| 154 if (maybe->owner() != NULL) return maybe; | 159 if (maybe->owner() != NULL) return maybe; |
| 155 // TODO(gc) ISOLATESMERGE HEAP | 160 // TODO(gc) ISOLATESMERGE HEAP |
| 156 LargeObjectIterator iterator(HEAP->lo_space()); | 161 LargeObjectIterator iterator(HEAP->lo_space()); |
| 157 for (HeapObject* o = iterator.next(); o != NULL; o = iterator.next()) { | 162 for (HeapObject* o = iterator.next(); o != NULL; o = iterator.next()) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 } | 267 } |
| 263 | 268 |
| 264 Object* obj = HeapObject::FromAddress(allocation_info_.top); | 269 Object* obj = HeapObject::FromAddress(allocation_info_.top); |
| 265 allocation_info_.top = new_top; | 270 allocation_info_.top = new_top; |
| 266 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); | 271 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); |
| 267 | 272 |
| 268 return obj; | 273 return obj; |
| 269 } | 274 } |
| 270 | 275 |
| 271 | 276 |
| 277 LargePage* LargePage::Initialize(Heap* heap, MemoryChunk* chunk) { | |
| 278 // TODO(gc) ISOLATESMERGE initialize chunk to point to heap? | |
|
Erik Corry
2011/05/11 18:53:57
I don't see how we can defer this to a TODO. We h
Vyacheslav Egorov (Chromium)
2011/05/13 11:06:52
Done.
| |
| 279 heap->incremental_marking()->SetOldSpacePageFlags(chunk); | |
| 280 return static_cast<LargePage*>(chunk); | |
| 281 } | |
| 282 | |
| 283 | |
| 272 intptr_t LargeObjectSpace::Available() { | 284 intptr_t LargeObjectSpace::Available() { |
| 273 return ObjectSizeFor(heap()->isolate()->memory_allocator()->Available()); | 285 return ObjectSizeFor(heap()->isolate()->memory_allocator()->Available()); |
| 274 } | 286 } |
| 275 | 287 |
| 276 | 288 |
| 277 template <typename StringType> | 289 template <typename StringType> |
| 278 void NewSpace::ShrinkStringAtAllocationBoundary(String* string, int length) { | 290 void NewSpace::ShrinkStringAtAllocationBoundary(String* string, int length) { |
| 279 ASSERT(length <= string->length()); | 291 ASSERT(length <= string->length()); |
| 280 ASSERT(string->IsSeqString()); | 292 ASSERT(string->IsSeqString()); |
| 281 ASSERT(string->address() + StringType::SizeFor(string->length()) == | 293 ASSERT(string->address() + StringType::SizeFor(string->length()) == |
| 282 allocation_info_.top); | 294 allocation_info_.top); |
| 283 allocation_info_.top = | 295 allocation_info_.top = |
| 284 string->address() + StringType::SizeFor(length); | 296 string->address() + StringType::SizeFor(length); |
| 285 string->set_length(length); | 297 string->set_length(length); |
| 286 } | 298 } |
| 287 | 299 |
| 288 | 300 |
| 289 bool FreeListNode::IsFreeListNode(HeapObject* object) { | 301 bool FreeListNode::IsFreeListNode(HeapObject* object) { |
| 290 // TODO(gc) ISOLATES MERGE | 302 // TODO(gc) ISOLATES MERGE |
| 291 return object->map() == HEAP->raw_unchecked_free_space_map() | 303 return object->map() == HEAP->raw_unchecked_free_space_map() |
| 292 || object->map() == HEAP->raw_unchecked_one_pointer_filler_map() | 304 || object->map() == HEAP->raw_unchecked_one_pointer_filler_map() |
| 293 || object->map() == HEAP->raw_unchecked_two_pointer_filler_map(); | 305 || object->map() == HEAP->raw_unchecked_two_pointer_filler_map(); |
| 294 } | 306 } |
| 295 | 307 |
| 296 } } // namespace v8::internal | 308 } } // namespace v8::internal |
| 297 | 309 |
| 298 #endif // V8_SPACES_INL_H_ | 310 #endif // V8_SPACES_INL_H_ |
| OLD | NEW |