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 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_HEAP_SPACES_INL_H_ | 5 #ifndef V8_HEAP_SPACES_INL_H_ |
| 6 #define V8_HEAP_SPACES_INL_H_ | 6 #define V8_HEAP_SPACES_INL_H_ |
| 7 | 7 |
| 8 #include "src/heap/incremental-marking.h" | 8 #include "src/heap/incremental-marking.h" |
| 9 #include "src/heap/spaces.h" | 9 #include "src/heap/spaces.h" |
| 10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 | 171 |
| 172 | 172 |
| 173 void MemoryAllocator::UnprotectChunkFromPage(Page* page) { | 173 void MemoryAllocator::UnprotectChunkFromPage(Page* page) { |
| 174 int id = GetChunkId(page); | 174 int id = GetChunkId(page); |
| 175 base::OS::Unprotect(chunks_[id].address(), chunks_[id].size(), | 175 base::OS::Unprotect(chunks_[id].address(), chunks_[id].size(), |
| 176 chunks_[id].owner()->executable() == EXECUTABLE); | 176 chunks_[id].owner()->executable() == EXECUTABLE); |
| 177 } | 177 } |
| 178 | 178 |
| 179 #endif | 179 #endif |
| 180 | 180 |
| 181 // ----------------------------------------------------------------------------- | |
| 182 // SemiSpace | |
| 183 | |
| 184 bool SemiSpace::Contains(HeapObject* o) { | |
| 185 return id_ == kToSpace | |
| 186 ? MemoryChunk::FromAddress(o->address())->InToSpace() | |
| 187 : MemoryChunk::FromAddress(o->address())->InFromSpace(); | |
| 188 } | |
| 189 | |
| 190 bool SemiSpace::Contains(Object* o) { | |
| 191 return o->IsHeapObject() && Contains(HeapObject::cast(o)); | |
| 192 } | |
| 193 | |
| 194 bool SemiSpace::ContainsSlow(Address a) { | |
|
Hannes Payer (out of office)
2016/02/08 16:05:40
This one is really slow and should be just used fo
Michael Lippautz
2016/02/08 18:00:38
Acknowledged.
| |
| 195 NewSpacePageIterator it(this); | |
| 196 while (it.has_next()) { | |
| 197 if (it.next() == MemoryChunk::FromAddress(a)) return true; | |
| 198 } | |
| 199 return false; | |
| 200 } | |
| 201 | |
| 202 // -------------------------------------------------------------------------- | |
| 203 // NewSpace | |
| 204 | |
| 205 bool NewSpace::Contains(HeapObject* o) { | |
| 206 return MemoryChunk::FromAddress(o->address())->InNewSpace(); | |
| 207 } | |
| 208 | |
| 209 bool NewSpace::Contains(Object* o) { | |
| 210 return o->IsHeapObject() && Contains(HeapObject::cast(o)); | |
| 211 } | |
| 212 | |
| 213 bool NewSpace::ContainsSlow(Address a) { | |
| 214 return from_space_.ContainsSlow(a) || to_space_.ContainsSlow(a); | |
| 215 } | |
| 216 | |
| 217 bool NewSpace::ToSpaceContainsSlow(Address a) { | |
| 218 return to_space_.ContainsSlow(a); | |
| 219 } | |
| 220 | |
| 221 bool NewSpace::FromSpaceContainsSlow(Address a) { | |
| 222 return from_space_.ContainsSlow(a); | |
| 223 } | |
| 224 | |
| 225 bool NewSpace::ToSpaceContains(Object* o) { return to_space_.Contains(o); } | |
| 226 bool NewSpace::FromSpaceContains(Object* o) { return from_space_.Contains(o); } | |
| 181 | 227 |
| 182 // -------------------------------------------------------------------------- | 228 // -------------------------------------------------------------------------- |
| 183 // AllocationResult | 229 // AllocationResult |
| 184 | 230 |
| 185 AllocationSpace AllocationResult::RetrySpace() { | 231 AllocationSpace AllocationResult::RetrySpace() { |
| 186 DCHECK(IsRetry()); | 232 DCHECK(IsRetry()); |
| 187 return static_cast<AllocationSpace>(Smi::cast(object_)->value()); | 233 return static_cast<AllocationSpace>(Smi::cast(object_)->value()); |
| 188 } | 234 } |
| 189 | 235 |
| 190 | 236 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 other->allocation_info_.Reset(nullptr, nullptr); | 590 other->allocation_info_.Reset(nullptr, nullptr); |
| 545 return true; | 591 return true; |
| 546 } | 592 } |
| 547 return false; | 593 return false; |
| 548 } | 594 } |
| 549 | 595 |
| 550 } // namespace internal | 596 } // namespace internal |
| 551 } // namespace v8 | 597 } // namespace v8 |
| 552 | 598 |
| 553 #endif // V8_HEAP_SPACES_INL_H_ | 599 #endif // V8_HEAP_SPACES_INL_H_ |
| OLD | NEW |