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

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

Issue 3382007: [Isolates] ScavengeVisitor gets member Heap*. (Closed)
Patch Set: fixed per review comments Created 10 years, 3 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/spaces.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 ? space_->first_page_ 50 ? space_->first_page_
51 : prev_page_->next_page(); 51 : prev_page_->next_page();
52 return prev_page_; 52 return prev_page_;
53 } 53 }
54 54
55 55
56 // ----------------------------------------------------------------------------- 56 // -----------------------------------------------------------------------------
57 // Page 57 // Page
58 58
59 Page* Page::next_page() { 59 Page* Page::next_page() {
60 return Isolate::Current()->memory_allocator()->GetNextPage(this); 60 return heap_->isolate()->memory_allocator()->GetNextPage(this);
61 } 61 }
62 62
63 63
64 Address Page::AllocationTop() { 64 Address Page::AllocationTop() {
65 PagedSpace* owner = Isolate::Current()->memory_allocator()->PageOwner(this); 65 PagedSpace* owner = heap_->isolate()->memory_allocator()->PageOwner(this);
66 return owner->PageAllocationTop(this); 66 return owner->PageAllocationTop(this);
67 } 67 }
68 68
69 69
70 Address Page::AllocationWatermark() { 70 Address Page::AllocationWatermark() {
71 PagedSpace* owner = Isolate::Current()->memory_allocator()->PageOwner(this); 71 PagedSpace* owner = heap_->isolate()->memory_allocator()->PageOwner(this);
72 if (this == owner->AllocationTopPage()) { 72 if (this == owner->AllocationTopPage()) {
73 return owner->top(); 73 return owner->top();
74 } 74 }
75 return address() + AllocationWatermarkOffset(); 75 return address() + AllocationWatermarkOffset();
76 } 76 }
77 77
78 78
79 uint32_t Page::AllocationWatermarkOffset() { 79 uint32_t Page::AllocationWatermarkOffset() {
80 return static_cast<uint32_t>((flags_ & kAllocationWatermarkOffsetMask) >> 80 return static_cast<uint32_t>((flags_ & kAllocationWatermarkOffsetMask) >>
81 kAllocationWatermarkOffsetShift); 81 kAllocationWatermarkOffsetShift);
82 } 82 }
83 83
84 84
85 void Page::SetAllocationWatermark(Address allocation_watermark) { 85 void Page::SetAllocationWatermark(Address allocation_watermark) {
86 if ((HEAP->gc_state() == Heap::SCAVENGE) && IsWatermarkValid()) { 86 if ((heap_->gc_state() == Heap::SCAVENGE) && IsWatermarkValid()) {
87 // When iterating intergenerational references during scavenge 87 // When iterating intergenerational references during scavenge
88 // we might decide to promote an encountered young object. 88 // we might decide to promote an encountered young object.
89 // We will allocate a space for such an object and put it 89 // We will allocate a space for such an object and put it
90 // into the promotion queue to process it later. 90 // into the promotion queue to process it later.
91 // If space for object was allocated somewhere beyond allocation 91 // If space for object was allocated somewhere beyond allocation
92 // watermark this might cause garbage pointers to appear under allocation 92 // watermark this might cause garbage pointers to appear under allocation
93 // watermark. To avoid visiting them during dirty regions iteration 93 // watermark. To avoid visiting them during dirty regions iteration
94 // which might be still in progress we store a valid allocation watermark 94 // which might be still in progress we store a valid allocation watermark
95 // value and mark this page as having an invalid watermark. 95 // value and mark this page as having an invalid watermark.
96 SetCachedAllocationWatermark(AllocationWatermark()); 96 SetCachedAllocationWatermark(AllocationWatermark());
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 while (++rstart < rend) { 213 while (++rstart < rend) {
214 bitmask |= 1 << rstart; 214 bitmask |= 1 << rstart;
215 } 215 }
216 216
217 if (bitmask) { 217 if (bitmask) {
218 SetRegionMarks(GetRegionMarks() & ~bitmask); 218 SetRegionMarks(GetRegionMarks() & ~bitmask);
219 } 219 }
220 } 220 }
221 221
222 222
223 void Page::FlipMeaningOfInvalidatedWatermarkFlag() { 223 void Page::FlipMeaningOfInvalidatedWatermarkFlag(Heap* heap) {
224 HEAP->page_watermark_invalidated_mark_ ^= 1 << WATERMARK_INVALIDATED; 224 heap->page_watermark_invalidated_mark_ ^= 1 << WATERMARK_INVALIDATED;
225 } 225 }
226 226
227 227
228 bool Page::IsWatermarkValid() { 228 bool Page::IsWatermarkValid() {
229 return (flags_ & (1 << WATERMARK_INVALIDATED)) != 229 return (flags_ & (1 << WATERMARK_INVALIDATED)) !=
230 HEAP->page_watermark_invalidated_mark_; 230 heap_->page_watermark_invalidated_mark_;
231 } 231 }
232 232
233 233
234 void Page::InvalidateWatermark(bool value) { 234 void Page::InvalidateWatermark(bool value) {
235 if (value) { 235 if (value) {
236 flags_ = (flags_ & ~(1 << WATERMARK_INVALIDATED)) | 236 flags_ = (flags_ & ~(1 << WATERMARK_INVALIDATED)) |
237 HEAP->page_watermark_invalidated_mark_; 237 heap_->page_watermark_invalidated_mark_;
238 } else { 238 } else {
239 flags_ = 239 flags_ =
240 (flags_ & ~(1 << WATERMARK_INVALIDATED)) | 240 (flags_ & ~(1 << WATERMARK_INVALIDATED)) |
241 (HEAP->page_watermark_invalidated_mark_ ^ (1 << WATERMARK_INVALIDATED)); 241 (heap_->page_watermark_invalidated_mark_ ^ (1 << WATERMARK_INVALIDATED)) ;
242 } 242 }
243 243
244 ASSERT(IsWatermarkValid() == !value); 244 ASSERT(IsWatermarkValid() == !value);
245 } 245 }
246 246
247 247
248 bool Page::GetPageFlag(PageFlag flag) { 248 bool Page::GetPageFlag(PageFlag flag) {
249 return (flags_ & static_cast<intptr_t>(1 << flag)) != 0; 249 return (flags_ & static_cast<intptr_t>(1 << flag)) != 0;
250 } 250 }
251 251
252 252
253 void Page::SetPageFlag(PageFlag flag, bool value) { 253 void Page::SetPageFlag(PageFlag flag, bool value) {
254 if (value) { 254 if (value) {
255 flags_ |= static_cast<intptr_t>(1 << flag); 255 flags_ |= static_cast<intptr_t>(1 << flag);
256 } else { 256 } else {
257 flags_ &= ~static_cast<intptr_t>(1 << flag); 257 flags_ &= ~static_cast<intptr_t>(1 << flag);
258 } 258 }
259 } 259 }
260 260
261 261
262 void Page::ClearPageFlags() { 262 void Page::ClearPageFlags() {
263 flags_ = 0; 263 flags_ = 0;
264 } 264 }
265 265
266 266
267 void Page::ClearGCFields() { 267 void Page::ClearGCFields() {
268 InvalidateWatermark(true); 268 InvalidateWatermark(true);
269 SetAllocationWatermark(ObjectAreaStart()); 269 SetAllocationWatermark(ObjectAreaStart());
270 if (HEAP->gc_state() == Heap::SCAVENGE) { 270 if (heap_->gc_state() == Heap::SCAVENGE) {
271 SetCachedAllocationWatermark(ObjectAreaStart()); 271 SetCachedAllocationWatermark(ObjectAreaStart());
272 } 272 }
273 SetRegionMarks(kAllRegionsCleanMarks); 273 SetRegionMarks(kAllRegionsCleanMarks);
274 } 274 }
275 275
276 276
277 bool Page::WasInUseBeforeMC() { 277 bool Page::WasInUseBeforeMC() {
278 return GetPageFlag(WAS_IN_USE_BEFORE_MC); 278 return GetPageFlag(WAS_IN_USE_BEFORE_MC);
279 } 279 }
280 280
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 #endif 405 #endif
406 406
407 407
408 // -------------------------------------------------------------------------- 408 // --------------------------------------------------------------------------
409 // PagedSpace 409 // PagedSpace
410 410
411 bool PagedSpace::Contains(Address addr) { 411 bool PagedSpace::Contains(Address addr) {
412 Page* p = Page::FromAddress(addr); 412 Page* p = Page::FromAddress(addr);
413 ASSERT(p->is_valid()); 413 ASSERT(p->is_valid());
414 414
415 return Isolate::Current()->memory_allocator()->IsPageInSpace(p, this); 415 return heap()->isolate()->memory_allocator()->IsPageInSpace(p, this);
416 } 416 }
417 417
418 418
419 // Try linear allocation in the page of alloc_info's allocation top. Does 419 // Try linear allocation in the page of alloc_info's allocation top. Does
420 // not contain slow case logic (eg, move to the next page or try free list 420 // not contain slow case logic (eg, move to the next page or try free list
421 // allocation) so it can be used by all the allocation functions and for all 421 // allocation) so it can be used by all the allocation functions and for all
422 // the paged spaces. 422 // the paged spaces.
423 HeapObject* PagedSpace::AllocateLinearly(AllocationInfo* alloc_info, 423 HeapObject* PagedSpace::AllocateLinearly(AllocationInfo* alloc_info,
424 int size_in_bytes) { 424 int size_in_bytes) {
425 Address current_top = alloc_info->top; 425 Address current_top = alloc_info->top;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 ASSERT(space->low() <= alloc_info->top 488 ASSERT(space->low() <= alloc_info->top
489 && alloc_info->top <= space->high() 489 && alloc_info->top <= space->high()
490 && alloc_info->limit == space->high()); 490 && alloc_info->limit == space->high());
491 #endif 491 #endif
492 return obj; 492 return obj;
493 } 493 }
494 494
495 495
496 int LargeObjectSpace::Available() { 496 int LargeObjectSpace::Available() {
497 return LargeObjectChunk::ObjectSizeFor( 497 return LargeObjectChunk::ObjectSizeFor(
498 Isolate::Current()->memory_allocator()->Available()); 498 heap()->isolate()->memory_allocator()->Available());
499 } 499 }
500 500
501 501
502 bool FreeListNode::IsFreeListNode(HeapObject* object) { 502 bool FreeListNode::IsFreeListNode(HeapObject* object) {
503 return object->map() == HEAP->raw_unchecked_byte_array_map() 503 return object->map() == HEAP->raw_unchecked_byte_array_map()
504 || object->map() == HEAP->raw_unchecked_one_pointer_filler_map() 504 || object->map() == HEAP->raw_unchecked_one_pointer_filler_map()
505 || object->map() == HEAP->raw_unchecked_two_pointer_filler_map(); 505 || object->map() == HEAP->raw_unchecked_two_pointer_filler_map();
506 } 506 }
507 507
508 } } // namespace v8::internal 508 } } // namespace v8::internal
509 509
510 #endif // V8_SPACES_INL_H_ 510 #endif // V8_SPACES_INL_H_
OLDNEW
« no previous file with comments | « src/spaces.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698