OLD | NEW |
---|---|
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 } | 86 } |
87 | 87 |
88 | 88 |
89 Address Page::AllocationTop() { | 89 Address Page::AllocationTop() { |
90 PagedSpace* owner = MemoryAllocator::PageOwner(this); | 90 PagedSpace* owner = MemoryAllocator::PageOwner(this); |
91 return owner->PageAllocationTop(this); | 91 return owner->PageAllocationTop(this); |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 void Page::ClearRSet() { | 95 void Page::ClearRSet() { |
96 #ifndef V8_HOST_ARCH_64_BIT | |
97 // This method can be called in all rset states. | 96 // This method can be called in all rset states. |
98 memset(RSetStart(), 0, kRSetEndOffset - kRSetStartOffset); | 97 memset(RSetStart(), 0, kRSetEndOffset - kRSetStartOffset); |
99 #endif | |
100 } | 98 } |
101 | 99 |
102 | 100 |
103 // Give an address a (32-bits): | 101 // Given an address (32-bits), separate its bits into: |
104 // | page address | words (6) | bit offset (5) | pointer alignment (2) | | 102 // | page address | words (6) | bit offset (5) | pointer alignment (2) | |
105 // The rset address is computed as: | 103 // The rset address is computed as: |
106 // page_address + words * 4 | 104 // page_address + words * 4 |
105 // For a 64-bit address, if it is: | |
106 // | page address | quadwords(5) | bit offset(5) | pointer alignment (3) | | |
107 // The reset address is computed as: | |
Lasse Reichstein
2009/07/01 12:30:18
reset -> rset (or RSet?)
| |
108 // page_address + words * 4 + kRSetOffset. | |
Lasse Reichstein
2009/07/01 12:30:18
words -> quadwords
| |
109 // The rset is accessed as 32-bit words, and bit offsets in a 32-bit word, | |
110 // even on the X64 architecture. | |
Lasse Reichstein
2009/07/01 12:30:18
We could probably speed up a little by loading 64
| |
107 | 111 |
108 Address Page::ComputeRSetBitPosition(Address address, int offset, | 112 Address Page::ComputeRSetBitPosition(Address address, int offset, |
109 uint32_t* bitmask) { | 113 uint32_t* bitmask) { |
110 ASSERT(Page::is_rset_in_use()); | 114 ASSERT(Page::is_rset_in_use()); |
111 | 115 |
112 Page* page = Page::FromAddress(address); | 116 Page* page = Page::FromAddress(address); |
113 uint32_t bit_offset = ArithmeticShiftRight(page->Offset(address) + offset, | 117 uint32_t bit_offset = ArithmeticShiftRight(page->Offset(address) + offset, |
114 kObjectAlignmentBits); | 118 kObjectAlignmentBits); |
115 *bitmask = 1 << (bit_offset % kBitsPerInt); | 119 *bitmask = 1 << (bit_offset % kBitsPerInt); |
116 | 120 |
117 Address rset_address = | 121 Address rset_address = |
118 page->address() + (bit_offset / kBitsPerInt) * kIntSize; | 122 page->address() + kRSetOffset + (bit_offset / kBitsPerInt) * kIntSize; |
119 // The remembered set address is either in the normal remembered set range | 123 // The remembered set address is either in the normal remembered set range |
120 // of a page or else we have a large object page. | 124 // of a page or else we have a large object page. |
121 ASSERT((page->RSetStart() <= rset_address && rset_address < page->RSetEnd()) | 125 ASSERT((page->RSetStart() <= rset_address && rset_address < page->RSetEnd()) |
122 || page->IsLargeObjectPage()); | 126 || page->IsLargeObjectPage()); |
123 | 127 |
124 if (rset_address >= page->RSetEnd()) { | 128 if (rset_address >= page->RSetEnd()) { |
125 // We have a large object page, and the remembered set address is actually | 129 // We have a large object page, and the remembered set address is actually |
126 // past the end of the object. The address of the remembered set in this | 130 // past the end of the object. The address of the remembered set in this |
127 // case is the extra remembered set start address at the address of the | 131 // case is the extra remembered set start address at the address of the |
128 // end of the object: | 132 // end of the object: |
129 // (page->ObjectAreaStart() + object size) | 133 // (page->ObjectAreaStart() + object size) |
130 // plus the offset of the computed remembered set address from the start | 134 // plus the offset of the computed remembered set address from the start |
131 // of the object: | 135 // of the object: |
132 // (rset_address - page->ObjectAreaStart()). | 136 // (rset_address - page->ObjectAreaStart()). |
133 // Ie, we can just add the object size. | 137 // Ie, we can just add the object size. |
138 // In the X64 architecture, the remembered set ends before the object start, | |
139 // so we need to add an additional offset, from rset end to object start | |
134 ASSERT(HeapObject::FromAddress(address)->IsFixedArray()); | 140 ASSERT(HeapObject::FromAddress(address)->IsFixedArray()); |
135 rset_address += | 141 rset_address += kObjectStartOffset - kRSetEndOffset + |
136 FixedArray::SizeFor(Memory::int_at(page->ObjectAreaStart() | 142 FixedArray::SizeFor(Memory::int_at(page->ObjectAreaStart() |
137 + Array::kLengthOffset)); | 143 + Array::kLengthOffset)); |
138 } | 144 } |
139 return rset_address; | 145 return rset_address; |
140 } | 146 } |
141 | 147 |
142 | 148 |
143 void Page::SetRSet(Address address, int offset) { | 149 void Page::SetRSet(Address address, int offset) { |
144 uint32_t bitmask = 0; | 150 uint32_t bitmask = 0; |
145 Address rset_address = ComputeRSetBitPosition(address, offset, &bitmask); | 151 Address rset_address = ComputeRSetBitPosition(address, offset, &bitmask); |
146 Memory::uint32_at(rset_address) |= bitmask; | 152 Memory::uint32_at(rset_address) |= bitmask; |
147 | 153 |
148 ASSERT(IsRSetSet(address, offset)); | 154 ASSERT(IsRSetSet(address, offset)); |
149 } | 155 } |
150 | 156 |
151 | 157 |
152 // Clears the corresponding remembered set bit for a given address. | 158 // Clears the corresponding remembered set bit for a given address. |
153 void Page::UnsetRSet(Address address, int offset) { | 159 void Page::UnsetRSet(Address address, int offset) { |
154 uint32_t bitmask = 0; | 160 uint32_t bitmask = 0; |
155 Address rset_address = ComputeRSetBitPosition(address, offset, &bitmask); | 161 Address rset_address = ComputeRSetBitPosition(address, offset, &bitmask); |
156 Memory::uint32_at(rset_address) &= ~bitmask; | 162 Memory::uint32_at(rset_address) &= ~bitmask; |
157 | 163 |
158 ASSERT(!IsRSetSet(address, offset)); | 164 ASSERT(!IsRSetSet(address, offset)); |
159 } | 165 } |
160 | 166 |
161 | 167 |
162 bool Page::IsRSetSet(Address address, int offset) { | 168 bool Page::IsRSetSet(Address address, int offset) { |
163 #ifdef V8_HOST_ARCH_64_BIT | |
164 // TODO(X64): Reenable when RSet works. | |
165 return true; | |
166 #else // V8_HOST_ARCH_64_BIT | |
167 uint32_t bitmask = 0; | 169 uint32_t bitmask = 0; |
168 Address rset_address = ComputeRSetBitPosition(address, offset, &bitmask); | 170 Address rset_address = ComputeRSetBitPosition(address, offset, &bitmask); |
169 return (Memory::uint32_at(rset_address) & bitmask) != 0; | 171 return (Memory::uint32_at(rset_address) & bitmask) != 0; |
170 #endif // V8_HOST_ARCH_64_BIT | |
171 } | 172 } |
172 | 173 |
173 | 174 |
174 // ----------------------------------------------------------------------------- | 175 // ----------------------------------------------------------------------------- |
175 // MemoryAllocator | 176 // MemoryAllocator |
176 | 177 |
177 bool MemoryAllocator::IsValidChunk(int chunk_id) { | 178 bool MemoryAllocator::IsValidChunk(int chunk_id) { |
178 if (!IsValidChunkId(chunk_id)) return false; | 179 if (!IsValidChunkId(chunk_id)) return false; |
179 | 180 |
180 ChunkInfo& c = chunks_[chunk_id]; | 181 ChunkInfo& c = chunks_[chunk_id]; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 ASSERT(space->low() <= alloc_info->top | 357 ASSERT(space->low() <= alloc_info->top |
357 && alloc_info->top <= space->high() | 358 && alloc_info->top <= space->high() |
358 && alloc_info->limit == space->high()); | 359 && alloc_info->limit == space->high()); |
359 #endif | 360 #endif |
360 return obj; | 361 return obj; |
361 } | 362 } |
362 | 363 |
363 } } // namespace v8::internal | 364 } } // namespace v8::internal |
364 | 365 |
365 #endif // V8_SPACES_INL_H_ | 366 #endif // V8_SPACES_INL_H_ |
OLD | NEW |