OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 6668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6679 if (chunk->owner()->identity() == LO_SPACE) { | 6679 if (chunk->owner()->identity() == LO_SPACE) { |
6680 // StoreBuffer::Filter relies on MemoryChunk::FromAnyPointerAddress. | 6680 // StoreBuffer::Filter relies on MemoryChunk::FromAnyPointerAddress. |
6681 // If FromAnyPointerAddress encounters a slot that belongs to a large | 6681 // If FromAnyPointerAddress encounters a slot that belongs to a large |
6682 // chunk queued for deletion it will fail to find the chunk because | 6682 // chunk queued for deletion it will fail to find the chunk because |
6683 // it try to perform a search in the list of pages owned by of the large | 6683 // it try to perform a search in the list of pages owned by of the large |
6684 // object space and queued chunks were detached from that list. | 6684 // object space and queued chunks were detached from that list. |
6685 // To work around this we split large chunk into normal kPageSize aligned | 6685 // To work around this we split large chunk into normal kPageSize aligned |
6686 // pieces and initialize size, owner and flags field of every piece. | 6686 // pieces and initialize size, owner and flags field of every piece. |
6687 // If FromAnyPointerAddress encounters a slot that belongs to one of | 6687 // If FromAnyPointerAddress encounters a slot that belongs to one of |
6688 // these smaller pieces it will treat it as a slot on a normal Page. | 6688 // these smaller pieces it will treat it as a slot on a normal Page. |
| 6689 Address chunk_end = chunk->address() + chunk->size(); |
6689 MemoryChunk* inner = MemoryChunk::FromAddress( | 6690 MemoryChunk* inner = MemoryChunk::FromAddress( |
6690 chunk->address() + Page::kPageSize); | 6691 chunk->address() + Page::kPageSize); |
6691 MemoryChunk* inner_last = MemoryChunk::FromAddress( | 6692 MemoryChunk* inner_last = MemoryChunk::FromAddress(chunk_end - 1); |
6692 chunk->address() + chunk->size() - 1); | |
6693 while (inner <= inner_last) { | 6693 while (inner <= inner_last) { |
6694 // Size of a large chunk is always a multiple of | 6694 // Size of a large chunk is always a multiple of |
6695 // OS::AllocateAlignment() so there is always | 6695 // OS::AllocateAlignment() so there is always |
6696 // enough space for a fake MemoryChunk header. | 6696 // enough space for a fake MemoryChunk header. |
| 6697 Address area_end = Min(inner->address() + Page::kPageSize, chunk_end); |
| 6698 // Guard against overflow. |
| 6699 if (area_end < inner->address()) area_end = chunk_end; |
| 6700 inner->SetArea(inner->address(), area_end); |
6697 inner->set_size(Page::kPageSize); | 6701 inner->set_size(Page::kPageSize); |
6698 inner->set_owner(lo_space()); | 6702 inner->set_owner(lo_space()); |
6699 inner->SetFlag(MemoryChunk::ABOUT_TO_BE_FREED); | 6703 inner->SetFlag(MemoryChunk::ABOUT_TO_BE_FREED); |
6700 inner = MemoryChunk::FromAddress( | 6704 inner = MemoryChunk::FromAddress( |
6701 inner->address() + Page::kPageSize); | 6705 inner->address() + Page::kPageSize); |
6702 } | 6706 } |
6703 } | 6707 } |
6704 } | 6708 } |
6705 isolate_->heap()->store_buffer()->Compact(); | 6709 isolate_->heap()->store_buffer()->Compact(); |
6706 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); | 6710 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); |
6707 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { | 6711 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { |
6708 next = chunk->next_chunk(); | 6712 next = chunk->next_chunk(); |
6709 isolate_->memory_allocator()->Free(chunk); | 6713 isolate_->memory_allocator()->Free(chunk); |
6710 } | 6714 } |
6711 chunks_queued_for_free_ = NULL; | 6715 chunks_queued_for_free_ = NULL; |
6712 } | 6716 } |
6713 | 6717 |
6714 } } // namespace v8::internal | 6718 } } // namespace v8::internal |
OLD | NEW |