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

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

Issue 2274001: Revert r4715. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/heap.cc ('k') | src/ia32/builtins-ia32.cc » ('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 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // - to space is already 25% full. 177 // - to space is already 25% full.
178 return old_address < new_space_.age_mark() 178 return old_address < new_space_.age_mark()
179 || (new_space_.Size() + object_size) >= (new_space_.Capacity() >> 2); 179 || (new_space_.Size() + object_size) >= (new_space_.Capacity() >> 2);
180 } 180 }
181 181
182 182
183 void Heap::RecordWrite(Address address, int offset) { 183 void Heap::RecordWrite(Address address, int offset) {
184 if (new_space_.Contains(address)) return; 184 if (new_space_.Contains(address)) return;
185 ASSERT(!new_space_.FromSpaceContains(address)); 185 ASSERT(!new_space_.FromSpaceContains(address));
186 SLOW_ASSERT(Contains(address + offset)); 186 SLOW_ASSERT(Contains(address + offset));
187 Page::FromAddress(address)->MarkRegionDirty(address + offset); 187 Page::SetRSet(address, offset);
188 } 188 }
189 189
190 190
191 void Heap::RecordWrites(Address address, int start, int len) { 191 void Heap::RecordWrites(Address address, int start, int len) {
192 if (new_space_.Contains(address)) return; 192 if (new_space_.Contains(address)) return;
193 ASSERT(!new_space_.FromSpaceContains(address)); 193 ASSERT(!new_space_.FromSpaceContains(address));
194 for (int offset = start; 194 for (int offset = start;
195 offset < start + len * kPointerSize; 195 offset < start + len * kPointerSize;
196 offset += kPointerSize) { 196 offset += kPointerSize) {
197 SLOW_ASSERT(Contains(address + offset)); 197 SLOW_ASSERT(Contains(address + offset));
198 Page::FromAddress(address)->MarkRegionDirty(address + offset); 198 Page::SetRSet(address, offset);
199 } 199 }
200 } 200 }
201 201
202 202
203 OldSpace* Heap::TargetSpace(HeapObject* object) { 203 OldSpace* Heap::TargetSpace(HeapObject* object) {
204 InstanceType type = object->map()->instance_type(); 204 InstanceType type = object->map()->instance_type();
205 AllocationSpace space = TargetSpaceId(type); 205 AllocationSpace space = TargetSpaceId(type);
206 return (space == OLD_POINTER_SPACE) 206 return (space == OLD_POINTER_SPACE)
207 ? old_pointer_space_ 207 ? old_pointer_space_
208 : old_data_space_; 208 : old_data_space_;
(...skipping 18 matching lines...) Expand all
227 // non-map-word pointers to heap objects. 227 // non-map-word pointers to heap objects.
228 return ((type & kStringRepresentationMask) == kConsStringTag) 228 return ((type & kStringRepresentationMask) == kConsStringTag)
229 ? OLD_POINTER_SPACE 229 ? OLD_POINTER_SPACE
230 : OLD_DATA_SPACE; 230 : OLD_DATA_SPACE;
231 } else { 231 } else {
232 return (type <= LAST_DATA_TYPE) ? OLD_DATA_SPACE : OLD_POINTER_SPACE; 232 return (type <= LAST_DATA_TYPE) ? OLD_DATA_SPACE : OLD_POINTER_SPACE;
233 } 233 }
234 } 234 }
235 235
236 236
237 void Heap::CopyBlock(Address dst, Address src, int byte_size) { 237 void Heap::CopyBlock(Object** dst, Object** src, int byte_size) {
238 ASSERT(IsAligned(byte_size, kPointerSize)); 238 ASSERT(IsAligned(byte_size, kPointerSize));
239 CopyWords(reinterpret_cast<Object**>(dst), 239 CopyWords(dst, src, byte_size / kPointerSize);
240 reinterpret_cast<Object**>(src),
241 byte_size / kPointerSize);
242 } 240 }
243 241
244 242
245 void Heap::CopyBlockToOldSpaceAndUpdateRegionMarks(Address dst, 243 void Heap::MoveBlock(Object** dst, Object** src, int byte_size) {
246 Address src,
247 int byte_size) {
248 ASSERT(IsAligned(byte_size, kPointerSize));
249
250 Page* page = Page::FromAddress(dst);
251 uint32_t marks = page->GetRegionMarks();
252
253 for (int remaining = byte_size / kPointerSize;
254 remaining > 0;
255 remaining--) {
256 Memory::Object_at(dst) = Memory::Object_at(src);
257
258 if (Heap::InNewSpace(Memory::Object_at(dst))) {
259 marks |= page->GetRegionMaskForAddress(dst);
260 }
261
262 dst += kPointerSize;
263 src += kPointerSize;
264 }
265
266 page->SetRegionMarks(marks);
267 }
268
269
270 void Heap::MoveBlock(Address dst, Address src, int byte_size) {
271 ASSERT(IsAligned(byte_size, kPointerSize)); 244 ASSERT(IsAligned(byte_size, kPointerSize));
272 245
273 int size_in_words = byte_size / kPointerSize; 246 int size_in_words = byte_size / kPointerSize;
274 247
275 if ((dst < src) || (dst >= (src + size_in_words))) { 248 if ((dst < src) || (dst >= (src + size_in_words))) {
276 ASSERT((dst >= (src + size_in_words)) || 249 ASSERT((dst >= (src + size_in_words)) ||
277 ((OffsetFrom(reinterpret_cast<Address>(src)) - 250 ((OffsetFrom(reinterpret_cast<Address>(src)) -
278 OffsetFrom(reinterpret_cast<Address>(dst))) >= kPointerSize)); 251 OffsetFrom(reinterpret_cast<Address>(dst))) >= kPointerSize));
279 252
280 Object** src_slot = reinterpret_cast<Object**>(src); 253 Object** end = src + size_in_words;
281 Object** dst_slot = reinterpret_cast<Object**>(dst);
282 Object** end_slot = src_slot + size_in_words;
283 254
284 while (src_slot != end_slot) { 255 while (src != end) {
285 *dst_slot++ = *src_slot++; 256 *dst++ = *src++;
286 } 257 }
287 } else { 258 } else {
288 memmove(dst, src, byte_size); 259 memmove(dst, src, byte_size);
289 } 260 }
290 } 261 }
291 262
292 263
293 void Heap::MoveBlockToOldSpaceAndUpdateRegionMarks(Address dst,
294 Address src,
295 int byte_size) {
296 ASSERT(IsAligned(byte_size, kPointerSize));
297 ASSERT((dst >= (src + byte_size)) ||
298 ((OffsetFrom(src) - OffsetFrom(dst)) >= kPointerSize));
299
300 CopyBlockToOldSpaceAndUpdateRegionMarks(dst, src, byte_size);
301 }
302
303
304 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { 264 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) {
305 ASSERT(InFromSpace(object)); 265 ASSERT(InFromSpace(object));
306 266
307 // We use the first word (where the map pointer usually is) of a heap 267 // We use the first word (where the map pointer usually is) of a heap
308 // object to record the forwarding pointer. A forwarding pointer can 268 // object to record the forwarding pointer. A forwarding pointer can
309 // point to an old space, the code space, or the to space of the new 269 // point to an old space, the code space, or the to space of the new
310 // generation. 270 // generation.
311 MapWord first_word = object->map_word(); 271 MapWord first_word = object->map_word();
312 272
313 // If the first word is a forwarding address, the object has already been 273 // If the first word is a forwarding address, the object has already been
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 442
483 443
484 void ExternalStringTable::ShrinkNewStrings(int position) { 444 void ExternalStringTable::ShrinkNewStrings(int position) {
485 new_space_strings_.Rewind(position); 445 new_space_strings_.Rewind(position);
486 Verify(); 446 Verify();
487 } 447 }
488 448
489 } } // namespace v8::internal 449 } } // namespace v8::internal
490 450
491 #endif // V8_HEAP_INL_H_ 451 #endif // V8_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698