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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 if (!code_range->UncommitRawMemory(start, length)) return false; | 553 if (!code_range->UncommitRawMemory(start, length)) return false; |
554 } | 554 } |
555 } | 555 } |
556 | 556 |
557 area_end_ = area_start_ + requested; | 557 area_end_ = area_start_ + requested; |
558 return true; | 558 return true; |
559 } | 559 } |
560 | 560 |
561 | 561 |
562 void MemoryChunk::InsertAfter(MemoryChunk* other) { | 562 void MemoryChunk::InsertAfter(MemoryChunk* other) { |
563 next_chunk_ = other->next_chunk_; | 563 MemoryChunk* other_next = other->next_chunk(); |
564 prev_chunk_ = other; | |
565 | 564 |
566 // This memory barrier is needed since concurrent sweeper threads may iterate | 565 set_next_chunk(other_next); |
567 // over the list of pages while a new page is inserted. | 566 set_prev_chunk(other); |
568 // TODO(hpayer): find a cleaner way to guarantee that the page list can be | 567 other_next->set_prev_chunk(this); |
569 // expanded concurrently | 568 other->set_next_chunk(this); |
570 MemoryBarrier(); | |
571 | |
572 // The following two write operations can take effect in arbitrary order | |
573 // since pages are always iterated by the sweeper threads in LIFO order, i.e, | |
574 // the inserted page becomes visible for the sweeper threads after | |
575 // other->next_chunk_ = this; | |
576 other->next_chunk_->prev_chunk_ = this; | |
577 other->next_chunk_ = this; | |
578 } | 569 } |
579 | 570 |
580 | 571 |
581 void MemoryChunk::Unlink() { | 572 void MemoryChunk::Unlink() { |
582 if (!InNewSpace() && IsFlagSet(SCAN_ON_SCAVENGE)) { | 573 if (!InNewSpace() && IsFlagSet(SCAN_ON_SCAVENGE)) { |
583 heap_->decrement_scan_on_scavenge_pages(); | 574 heap_->decrement_scan_on_scavenge_pages(); |
584 ClearFlag(SCAN_ON_SCAVENGE); | 575 ClearFlag(SCAN_ON_SCAVENGE); |
585 } | 576 } |
586 next_chunk_->prev_chunk_ = prev_chunk_; | 577 MemoryChunk* next_element = next_chunk(); |
587 prev_chunk_->next_chunk_ = next_chunk_; | 578 MemoryChunk* prev_element = prev_chunk(); |
588 prev_chunk_ = NULL; | 579 next_element->set_prev_chunk(prev_element); |
589 next_chunk_ = NULL; | 580 prev_element->set_next_chunk(next_element); |
| 581 set_prev_chunk(NULL); |
| 582 set_next_chunk(NULL); |
590 } | 583 } |
591 | 584 |
592 | 585 |
593 MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size, | 586 MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size, |
594 intptr_t commit_area_size, | 587 intptr_t commit_area_size, |
595 Executability executable, | 588 Executability executable, |
596 Space* owner) { | 589 Space* owner) { |
597 ASSERT(commit_area_size <= reserve_area_size); | 590 ASSERT(commit_area_size <= reserve_area_size); |
598 | 591 |
599 size_t chunk_size; | 592 size_t chunk_size; |
(...skipping 2601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3201 object->ShortPrint(); | 3194 object->ShortPrint(); |
3202 PrintF("\n"); | 3195 PrintF("\n"); |
3203 } | 3196 } |
3204 printf(" --------------------------------------\n"); | 3197 printf(" --------------------------------------\n"); |
3205 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3198 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3206 } | 3199 } |
3207 | 3200 |
3208 #endif // DEBUG | 3201 #endif // DEBUG |
3209 | 3202 |
3210 } } // namespace v8::internal | 3203 } } // namespace v8::internal |
OLD | NEW |