OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 return (Memory::uint32_at(rset_address) & bitmask) != 0; | 170 return (Memory::uint32_at(rset_address) & bitmask) != 0; |
171 } | 171 } |
172 | 172 |
173 | 173 |
174 // ----------------------------------------------------------------------------- | 174 // ----------------------------------------------------------------------------- |
175 // MemoryAllocator | 175 // MemoryAllocator |
176 | 176 |
177 bool MemoryAllocator::IsValidChunk(int chunk_id) { | 177 bool MemoryAllocator::IsValidChunk(int chunk_id) { |
178 if (!IsValidChunkId(chunk_id)) return false; | 178 if (!IsValidChunkId(chunk_id)) return false; |
179 | 179 |
180 ChunkInfo& c = chunks_[chunk_id]; | 180 MemoryAllocatorData::ChunkInfo& c = |
| 181 v8_context()->memory_allocator_data_.chunks_[chunk_id]; |
181 return (c.address() != NULL) && (c.size() != 0) && (c.owner() != NULL); | 182 return (c.address() != NULL) && (c.size() != 0) && (c.owner() != NULL); |
182 } | 183 } |
183 | 184 |
184 | 185 |
185 bool MemoryAllocator::IsValidChunkId(int chunk_id) { | 186 bool MemoryAllocator::IsValidChunkId(int chunk_id) { |
186 return (0 <= chunk_id) && (chunk_id < max_nof_chunks_); | 187 return (0 <= chunk_id) && |
| 188 (chunk_id < v8_context()->memory_allocator_data_.max_nof_chunks_); |
187 } | 189 } |
188 | 190 |
189 | 191 |
190 bool MemoryAllocator::IsPageInSpace(Page* p, PagedSpace* space) { | 192 bool MemoryAllocator::IsPageInSpace(Page* p, PagedSpace* space) { |
191 ASSERT(p->is_valid()); | 193 ASSERT(p->is_valid()); |
192 | 194 |
193 int chunk_id = GetChunkId(p); | 195 int chunk_id = GetChunkId(p); |
194 if (!IsValidChunkId(chunk_id)) return false; | 196 if (!IsValidChunkId(chunk_id)) return false; |
195 | 197 |
196 ChunkInfo& c = chunks_[chunk_id]; | 198 MemoryAllocatorData::ChunkInfo& c = |
| 199 v8_context()->memory_allocator_data_.chunks_[chunk_id]; |
197 return (c.address() <= p->address()) && | 200 return (c.address() <= p->address()) && |
198 (p->address() < c.address() + c.size()) && | 201 (p->address() < c.address() + c.size()) && |
199 (space == c.owner()); | 202 (space == c.owner()); |
200 } | 203 } |
201 | 204 |
202 | 205 |
203 Page* MemoryAllocator::GetNextPage(Page* p) { | 206 Page* MemoryAllocator::GetNextPage(Page* p) { |
204 ASSERT(p->is_valid()); | 207 ASSERT(p->is_valid()); |
205 intptr_t raw_addr = p->opaque_header & ~Page::kPageAlignmentMask; | 208 intptr_t raw_addr = p->opaque_header & ~Page::kPageAlignmentMask; |
206 return Page::FromAddress(AddressFrom<Address>(raw_addr)); | 209 return Page::FromAddress(AddressFrom<Address>(raw_addr)); |
(...skipping 10 matching lines...) Expand all Loading... |
217 ASSERT(prev->is_valid()); | 220 ASSERT(prev->is_valid()); |
218 int chunk_id = GetChunkId(prev); | 221 int chunk_id = GetChunkId(prev); |
219 ASSERT_PAGE_ALIGNED(next->address()); | 222 ASSERT_PAGE_ALIGNED(next->address()); |
220 prev->opaque_header = OffsetFrom(next->address()) | chunk_id; | 223 prev->opaque_header = OffsetFrom(next->address()) | chunk_id; |
221 } | 224 } |
222 | 225 |
223 | 226 |
224 PagedSpace* MemoryAllocator::PageOwner(Page* page) { | 227 PagedSpace* MemoryAllocator::PageOwner(Page* page) { |
225 int chunk_id = GetChunkId(page); | 228 int chunk_id = GetChunkId(page); |
226 ASSERT(IsValidChunk(chunk_id)); | 229 ASSERT(IsValidChunk(chunk_id)); |
227 return chunks_[chunk_id].owner(); | 230 return v8_context()->memory_allocator_data_.chunks_[chunk_id].owner(); |
228 } | 231 } |
229 | 232 |
230 | 233 |
231 bool MemoryAllocator::InInitialChunk(Address address) { | 234 bool MemoryAllocator::InInitialChunk(Address address) { |
232 if (initial_chunk_ == NULL) return false; | 235 MemoryAllocatorData& data = v8_context()->memory_allocator_data_; |
| 236 if (data.initial_chunk_ == NULL) return false; |
233 | 237 |
234 Address start = static_cast<Address>(initial_chunk_->address()); | 238 Address start = static_cast<Address>(data.initial_chunk_->address()); |
235 return (start <= address) && (address < start + initial_chunk_->size()); | 239 return (start <= address) && (address < start + data.initial_chunk_->size()); |
236 } | 240 } |
237 | 241 |
238 | 242 |
239 #ifdef ENABLE_HEAP_PROTECTION | 243 #ifdef ENABLE_HEAP_PROTECTION |
240 | 244 |
241 void MemoryAllocator::Protect(Address start, size_t size) { | 245 void MemoryAllocator::Protect(Address start, size_t size) { |
242 OS::Protect(start, size); | 246 OS::Protect(start, size); |
243 } | 247 } |
244 | 248 |
245 | 249 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 367 |
364 bool FreeListNode::IsFreeListNode(HeapObject* object) { | 368 bool FreeListNode::IsFreeListNode(HeapObject* object) { |
365 return object->map() == Heap::raw_unchecked_byte_array_map() | 369 return object->map() == Heap::raw_unchecked_byte_array_map() |
366 || object->map() == Heap::raw_unchecked_one_pointer_filler_map() | 370 || object->map() == Heap::raw_unchecked_one_pointer_filler_map() |
367 || object->map() == Heap::raw_unchecked_two_pointer_filler_map(); | 371 || object->map() == Heap::raw_unchecked_two_pointer_filler_map(); |
368 } | 372 } |
369 | 373 |
370 } } // namespace v8::internal | 374 } } // namespace v8::internal |
371 | 375 |
372 #endif // V8_SPACES_INL_H_ | 376 #endif // V8_SPACES_INL_H_ |
OLD | NEW |