Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/heap/spaces-inl.h

Issue 1632913003: [heap] Move to page lookups for SemiSpace, NewSpace, and Heap containment methods (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mips ports Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/spaces.cc ('k') | src/heap/store-buffer-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) {
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 14 matching lines...) Expand all
205 return page; 251 return page;
206 } 252 }
207 253
208 254
209 bool PagedSpace::Contains(Address addr) { 255 bool PagedSpace::Contains(Address addr) {
210 Page* p = Page::FromAddress(addr); 256 Page* p = Page::FromAddress(addr);
211 if (!p->is_valid()) return false; 257 if (!p->is_valid()) return false;
212 return p->owner() == this; 258 return p->owner() == this;
213 } 259 }
214 260
215 261 bool PagedSpace::Contains(Object* o) {
216 bool PagedSpace::Contains(HeapObject* o) { return Contains(o->address()); } 262 if (!o->IsHeapObject()) return false;
217 263 Page* p = Page::FromAddress(HeapObject::cast(o)->address());
264 if (!p->is_valid()) return false;
265 return p->owner() == this;
266 }
218 267
219 MemoryChunk* MemoryChunk::FromAnyPointerAddress(Heap* heap, Address addr) { 268 MemoryChunk* MemoryChunk::FromAnyPointerAddress(Heap* heap, Address addr) {
220 MemoryChunk* maybe = reinterpret_cast<MemoryChunk*>( 269 MemoryChunk* maybe = reinterpret_cast<MemoryChunk*>(
221 OffsetFrom(addr) & ~Page::kPageAlignmentMask); 270 OffsetFrom(addr) & ~Page::kPageAlignmentMask);
222 if (maybe->owner() != NULL) return maybe; 271 if (maybe->owner() != NULL) return maybe;
223 LargeObjectIterator iterator(heap->lo_space()); 272 LargeObjectIterator iterator(heap->lo_space());
224 for (HeapObject* o = iterator.Next(); o != NULL; o = iterator.Next()) { 273 for (HeapObject* o = iterator.Next(); o != NULL; o = iterator.Next()) {
225 // Fixed arrays are the only pointer-containing objects in large object 274 // Fixed arrays are the only pointer-containing objects in large object
226 // space. 275 // space.
227 if (o->IsFixedArray()) { 276 if (o->IsFixedArray()) {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 other->allocation_info_.Reset(nullptr, nullptr); 581 other->allocation_info_.Reset(nullptr, nullptr);
533 return true; 582 return true;
534 } 583 }
535 return false; 584 return false;
536 } 585 }
537 586
538 } // namespace internal 587 } // namespace internal
539 } // namespace v8 588 } // namespace v8
540 589
541 #endif // V8_HEAP_SPACES_INL_H_ 590 #endif // V8_HEAP_SPACES_INL_H_
OLDNEW
« no previous file with comments | « src/heap/spaces.cc ('k') | src/heap/store-buffer-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698