| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 int id = GetChunkId(page); | 106 int id = GetChunkId(page); |
| 107 OS::Unprotect(chunks_[id].address(), chunks_[id].size(), | 107 OS::Unprotect(chunks_[id].address(), chunks_[id].size(), |
| 108 chunks_[id].owner()->executable() == EXECUTABLE); | 108 chunks_[id].owner()->executable() == EXECUTABLE); |
| 109 } | 109 } |
| 110 | 110 |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 | 113 |
| 114 // -------------------------------------------------------------------------- | 114 // -------------------------------------------------------------------------- |
| 115 // PagedSpace | 115 // PagedSpace |
| 116 | |
| 117 bool PagedSpace::Contains(Address addr) { | |
| 118 Page* p = Page::FromAddress(addr); | |
| 119 if (!p->is_valid()) return false; | |
| 120 return p->owner() == this; | |
| 121 } | |
| 122 | |
| 123 | |
| 124 Page* Page::Initialize(MemoryChunk* chunk, | 116 Page* Page::Initialize(MemoryChunk* chunk, |
| 125 Executability executable, | 117 Executability executable, |
| 126 PagedSpace* owner) { | 118 PagedSpace* owner) { |
| 127 Page* page = reinterpret_cast<Page*>(chunk); | 119 Page* page = reinterpret_cast<Page*>(chunk); |
| 128 MemoryChunk::Initialize(reinterpret_cast<Address>(chunk), | 120 MemoryChunk::Initialize(reinterpret_cast<Address>(chunk), |
| 129 kPageSize, | 121 kPageSize, |
| 130 executable, | 122 executable, |
| 131 owner); | 123 owner); |
| 132 owner->IncreaseCapacity(Page::kObjectAreaSize); | 124 owner->IncreaseCapacity(Page::kObjectAreaSize); |
| 133 owner->Free(page->ObjectAreaStart(), | 125 owner->Free(page->ObjectAreaStart(), |
| 134 page->ObjectAreaEnd() - page->ObjectAreaStart()); | 126 page->ObjectAreaEnd() - page->ObjectAreaStart()); |
| 135 return page; | 127 return page; |
| 136 } | 128 } |
| 137 | 129 |
| 138 | 130 |
| 131 bool PagedSpace::Contains(Address addr) { |
| 132 Page* p = Page::FromAddress(addr); |
| 133 if (!p->is_valid()) return false; |
| 134 return p->owner() == this; |
| 135 } |
| 136 |
| 137 |
| 138 MemoryChunk* MemoryChunk::FromAnyPointerAddress(Address addr) { |
| 139 MemoryChunk* maybe = reinterpret_cast<MemoryChunk*>( |
| 140 OffsetFrom(addr) & ~Page::kPageAlignmentMask); |
| 141 if (maybe->owner() != NULL) return maybe; |
| 142 LargeObjectIterator iterator(Heap::lo_space()); |
| 143 for (HeapObject* o = iterator.next(); o != NULL; o = iterator.next()) { |
| 144 // Fixed arrays are the only pointer-containing objects in large object |
| 145 // space. |
| 146 if (o->IsFixedArray()) { |
| 147 MemoryChunk* chunk = MemoryChunk::FromAddress(o->address()); |
| 148 if (chunk->Contains(addr)) { |
| 149 return chunk; |
| 150 } |
| 151 } |
| 152 } |
| 153 UNREACHABLE(); |
| 154 return NULL; |
| 155 } |
| 156 |
| 157 |
| 158 PointerChunkIterator::PointerChunkIterator() |
| 159 : state_(kOldPointerState), |
| 160 old_pointer_iterator_(Heap::old_pointer_space()), |
| 161 map_iterator_(Heap::map_space()), |
| 162 lo_iterator_(Heap::lo_space()) { } |
| 163 |
| 164 |
| 139 Page* Page::next_page() { | 165 Page* Page::next_page() { |
| 140 ASSERT(next_chunk()->owner() == owner()); | 166 ASSERT(next_chunk()->owner() == owner()); |
| 141 return static_cast<Page*>(next_chunk()); | 167 return static_cast<Page*>(next_chunk()); |
| 142 } | 168 } |
| 143 | 169 |
| 144 | 170 |
| 145 Page* Page::prev_page() { | 171 Page* Page::prev_page() { |
| 146 ASSERT(prev_chunk()->owner() == owner()); | 172 ASSERT(prev_chunk()->owner() == owner()); |
| 147 return static_cast<Page*>(prev_chunk()); | 173 return static_cast<Page*>(prev_chunk()); |
| 148 } | 174 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 264 |
| 239 bool FreeListNode::IsFreeListNode(HeapObject* object) { | 265 bool FreeListNode::IsFreeListNode(HeapObject* object) { |
| 240 return object->map() == Heap::raw_unchecked_free_space_map() | 266 return object->map() == Heap::raw_unchecked_free_space_map() |
| 241 || object->map() == Heap::raw_unchecked_one_pointer_filler_map() | 267 || object->map() == Heap::raw_unchecked_one_pointer_filler_map() |
| 242 || object->map() == Heap::raw_unchecked_two_pointer_filler_map(); | 268 || object->map() == Heap::raw_unchecked_two_pointer_filler_map(); |
| 243 } | 269 } |
| 244 | 270 |
| 245 } } // namespace v8::internal | 271 } } // namespace v8::internal |
| 246 | 272 |
| 247 #endif // V8_SPACES_INL_H_ | 273 #endif // V8_SPACES_INL_H_ |
| OLD | NEW |