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

Side by Side Diff: src/mark-compact.h

Issue 2073018: Reverting r4703. (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/ia32/stub-cache-ia32.cc ('k') | src/mark-compact.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 23 matching lines...) Expand all
34 // Callback function, returns whether an object is alive. The heap size 34 // Callback function, returns whether an object is alive. The heap size
35 // of the object is returned in size. It optionally updates the offset 35 // of the object is returned in size. It optionally updates the offset
36 // to the first live object in the page (only used for old and map objects). 36 // to the first live object in the page (only used for old and map objects).
37 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); 37 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset);
38 38
39 // Callback function for non-live blocks in the old generation. 39 // Callback function for non-live blocks in the old generation.
40 // If add_to_freelist is false then just accounting stats are updated and 40 // If add_to_freelist is false then just accounting stats are updated and
41 // no attempt to add area to free list is made. 41 // no attempt to add area to free list is made.
42 typedef void (*DeallocateFunction)(Address start, 42 typedef void (*DeallocateFunction)(Address start,
43 int size_in_bytes, 43 int size_in_bytes,
44 bool add_to_freelist, 44 bool add_to_freelist);
45 bool last_on_page);
46 45
47 46
48 // Forward declarations. 47 // Forward declarations.
49 class RootMarkingVisitor; 48 class RootMarkingVisitor;
50 class MarkingVisitor; 49 class MarkingVisitor;
51 50
52 51
53 // ------------------------------------------------------------------------- 52 // -------------------------------------------------------------------------
54 // Mark-Compact collector 53 // Mark-Compact collector
55 // 54 //
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 124
126 private: 125 private:
127 #ifdef DEBUG 126 #ifdef DEBUG
128 enum CollectorState { 127 enum CollectorState {
129 IDLE, 128 IDLE,
130 PREPARE_GC, 129 PREPARE_GC,
131 MARK_LIVE_OBJECTS, 130 MARK_LIVE_OBJECTS,
132 SWEEP_SPACES, 131 SWEEP_SPACES,
133 ENCODE_FORWARDING_ADDRESSES, 132 ENCODE_FORWARDING_ADDRESSES,
134 UPDATE_POINTERS, 133 UPDATE_POINTERS,
135 RELOCATE_OBJECTS 134 RELOCATE_OBJECTS,
135 REBUILD_RSETS
136 }; 136 };
137 137
138 // The current stage of the collector. 138 // The current stage of the collector.
139 static CollectorState state_; 139 static CollectorState state_;
140 #endif 140 #endif
141 141
142 // Global flag that forces a compaction. 142 // Global flag that forces a compaction.
143 static bool force_compaction_; 143 static bool force_compaction_;
144 144
145 // Global flag indicating whether spaces were compacted on the last GC. 145 // Global flag indicating whether spaces were compacted on the last GC.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // list. 262 // list.
263 // 263 //
264 // After: (Compacting collection.) The forwarding address of live 264 // After: (Compacting collection.) The forwarding address of live
265 // objects in the paged spaces is encoded in their map word 265 // objects in the paged spaces is encoded in their map word
266 // along with their (non-forwarded) map pointer. 266 // along with their (non-forwarded) map pointer.
267 // 267 //
268 // The forwarding address of live objects in the new space is 268 // The forwarding address of live objects in the new space is
269 // written to their map word's offset in the inactive 269 // written to their map word's offset in the inactive
270 // semispace. 270 // semispace.
271 // 271 //
272 // Bookkeeping data is written to the page header of 272 // Bookkeeping data is written to the remembered-set are of
273 // eached paged-space page that contains live objects after 273 // eached paged-space page that contains live objects after
274 // compaction: 274 // compaction:
275 // 275 //
276 // The allocation watermark field is used to track the 276 // The 3rd word of the page (first word of the remembered
277 // relocation top address, the address of the first word 277 // set) contains the relocation top address, the address of
278 // after the end of the last live object in the page after 278 // the first word after the end of the last live object in
279 // compaction. 279 // the page after compaction.
280 // 280 //
281 // The Page::mc_page_index field contains the zero-based index of the 281 // The 4th word contains the zero-based index of the page in
282 // page in its space. This word is only used for map space pages, in 282 // its space. This word is only used for map space pages, in
283 // order to encode the map addresses in 21 bits to free 11 283 // order to encode the map addresses in 21 bits to free 11
284 // bits per map word for the forwarding address. 284 // bits per map word for the forwarding address.
285 // 285 //
286 // The Page::mc_first_forwarded field contains the (nonencoded) 286 // The 5th word contains the (nonencoded) forwarding address
287 // forwarding address of the first live object in the page. 287 // of the first live object in the page.
288 // 288 //
289 // In both the new space and the paged spaces, a linked list 289 // In both the new space and the paged spaces, a linked list
290 // of live regions is constructructed (linked through 290 // of live regions is constructructed (linked through
291 // pointers in the non-live region immediately following each 291 // pointers in the non-live region immediately following each
292 // live region) to speed further passes of the collector. 292 // live region) to speed further passes of the collector.
293 293
294 // Encodes forwarding addresses of objects in compactable parts of the 294 // Encodes forwarding addresses of objects in compactable parts of the
295 // heap. 295 // heap.
296 static void EncodeForwardingAddresses(); 296 static void EncodeForwardingAddresses();
297 297
(...skipping 14 matching lines...) Expand all
312 312
313 // Iterates the live objects between a range of addresses, returning the 313 // Iterates the live objects between a range of addresses, returning the
314 // number of live objects. 314 // number of live objects.
315 static int IterateLiveObjectsInRange(Address start, Address end, 315 static int IterateLiveObjectsInRange(Address start, Address end,
316 HeapObjectCallback size_func); 316 HeapObjectCallback size_func);
317 317
318 // Callback functions for deallocating non-live blocks in the old 318 // Callback functions for deallocating non-live blocks in the old
319 // generation. 319 // generation.
320 static void DeallocateOldPointerBlock(Address start, 320 static void DeallocateOldPointerBlock(Address start,
321 int size_in_bytes, 321 int size_in_bytes,
322 bool add_to_freelist, 322 bool add_to_freelist);
323 bool last_on_page);
324 323
325 static void DeallocateOldDataBlock(Address start, 324 static void DeallocateOldDataBlock(Address start,
326 int size_in_bytes, 325 int size_in_bytes,
327 bool add_to_freelist, 326 bool add_to_freelist);
328 bool last_on_page);
329 327
330 static void DeallocateCodeBlock(Address start, 328 static void DeallocateCodeBlock(Address start,
331 int size_in_bytes, 329 int size_in_bytes,
332 bool add_to_freelist, 330 bool add_to_freelist);
333 bool last_on_page);
334 331
335 static void DeallocateMapBlock(Address start, 332 static void DeallocateMapBlock(Address start,
336 int size_in_bytes, 333 int size_in_bytes,
337 bool add_to_freelist, 334 bool add_to_freelist);
338 bool last_on_page);
339 335
340 static void DeallocateCellBlock(Address start, 336 static void DeallocateCellBlock(Address start,
341 int size_in_bytes, 337 int size_in_bytes,
342 bool add_to_freelist, 338 bool add_to_freelist);
343 bool last_on_page);
344 339
345 // If we are not compacting the heap, we simply sweep the spaces except 340 // If we are not compacting the heap, we simply sweep the spaces except
346 // for the large object space, clearing mark bits and adding unmarked 341 // for the large object space, clearing mark bits and adding unmarked
347 // regions to each space's free list. 342 // regions to each space's free list.
348 static void SweepSpaces(); 343 static void SweepSpaces();
349 344
350 // ----------------------------------------------------------------------- 345 // -----------------------------------------------------------------------
351 // Phase 3: Updating pointers in live objects. 346 // Phase 3: Updating pointers in live objects.
352 // 347 //
353 // Before: Same as after phase 2 (compacting collection). 348 // Before: Same as after phase 2 (compacting collection).
354 // 349 //
355 // After: All pointers in live objects, including encoded map 350 // After: All pointers in live objects, including encoded map
356 // pointers, are updated to point to their target's new 351 // pointers, are updated to point to their target's new
357 // location. 352 // location. The remembered set area of each paged-space
353 // page containing live objects still contains bookkeeping
354 // information.
358 355
359 friend class UpdatingVisitor; // helper for updating visited objects 356 friend class UpdatingVisitor; // helper for updating visited objects
360 357
361 // Updates pointers in all spaces. 358 // Updates pointers in all spaces.
362 static void UpdatePointers(); 359 static void UpdatePointers();
363 360
364 // Updates pointers in an object in new space. 361 // Updates pointers in an object in new space.
365 // Returns the heap size of the object. 362 // Returns the heap size of the object.
366 static int UpdatePointersInNewObject(HeapObject* obj); 363 static int UpdatePointersInNewObject(HeapObject* obj);
367 364
368 // Updates pointers in an object in old spaces. 365 // Updates pointers in an object in old spaces.
369 // Returns the heap size of the object. 366 // Returns the heap size of the object.
370 static int UpdatePointersInOldObject(HeapObject* obj); 367 static int UpdatePointersInOldObject(HeapObject* obj);
371 368
372 // Calculates the forwarding address of an object in an old space. 369 // Calculates the forwarding address of an object in an old space.
373 static Address GetForwardingAddressInOldSpace(HeapObject* obj); 370 static Address GetForwardingAddressInOldSpace(HeapObject* obj);
374 371
375 // ----------------------------------------------------------------------- 372 // -----------------------------------------------------------------------
376 // Phase 4: Relocating objects. 373 // Phase 4: Relocating objects.
377 // 374 //
378 // Before: Pointers to live objects are updated to point to their 375 // Before: Pointers to live objects are updated to point to their
379 // target's new location. 376 // target's new location. The remembered set area of each
377 // paged-space page containing live objects still contains
378 // bookkeeping information.
380 // 379 //
381 // After: Objects have been moved to their new addresses. 380 // After: Objects have been moved to their new addresses. The
381 // remembered set area of each paged-space page containing
382 // live objects still contains bookkeeping information.
382 383
383 // Relocates objects in all spaces. 384 // Relocates objects in all spaces.
384 static void RelocateObjects(); 385 static void RelocateObjects();
385 386
386 // Converts a code object's inline target to addresses, convention from 387 // Converts a code object's inline target to addresses, convention from
387 // address to target happens in the marking phase. 388 // address to target happens in the marking phase.
388 static int ConvertCodeICTargetToAddress(HeapObject* obj); 389 static int ConvertCodeICTargetToAddress(HeapObject* obj);
389 390
390 // Relocate a map object. 391 // Relocate a map object.
391 static int RelocateMapObject(HeapObject* obj); 392 static int RelocateMapObject(HeapObject* obj);
392 393
393 // Relocates an old object. 394 // Relocates an old object.
394 static int RelocateOldPointerObject(HeapObject* obj); 395 static int RelocateOldPointerObject(HeapObject* obj);
395 static int RelocateOldDataObject(HeapObject* obj); 396 static int RelocateOldDataObject(HeapObject* obj);
396 397
397 // Relocate a property cell object. 398 // Relocate a property cell object.
398 static int RelocateCellObject(HeapObject* obj); 399 static int RelocateCellObject(HeapObject* obj);
399 400
400 // Helper function. 401 // Helper function.
401 static inline int RelocateOldNonCodeObject(HeapObject* obj, 402 static inline int RelocateOldNonCodeObject(HeapObject* obj,
402 PagedSpace* space); 403 PagedSpace* space);
403 404
404 // Relocates an object in the code space. 405 // Relocates an object in the code space.
405 static int RelocateCodeObject(HeapObject* obj); 406 static int RelocateCodeObject(HeapObject* obj);
406 407
407 // Copy a new object. 408 // Copy a new object.
408 static int RelocateNewObject(HeapObject* obj); 409 static int RelocateNewObject(HeapObject* obj);
409 410
411 // -----------------------------------------------------------------------
412 // Phase 5: Rebuilding remembered sets.
413 //
414 // Before: The heap is in a normal state except that remembered sets
415 // in the paged spaces are not correct.
416 //
417 // After: The heap is in a normal state.
418
419 // Rebuild remembered set in old and map spaces.
420 static void RebuildRSets();
421
410 #ifdef DEBUG 422 #ifdef DEBUG
411 // ----------------------------------------------------------------------- 423 // -----------------------------------------------------------------------
412 // Debugging variables, functions and classes 424 // Debugging variables, functions and classes
413 // Counters used for debugging the marking phase of mark-compact or 425 // Counters used for debugging the marking phase of mark-compact or
414 // mark-sweep collection. 426 // mark-sweep collection.
415 427
416 // Size of live objects in Heap::to_space_. 428 // Size of live objects in Heap::to_space_.
417 static int live_young_objects_size_; 429 static int live_young_objects_size_;
418 430
419 // Size of live objects in Heap::old_pointer_space_. 431 // Size of live objects in Heap::old_pointer_space_.
(...skipping 22 matching lines...) Expand all
442 454
443 friend class UnmarkObjectVisitor; 455 friend class UnmarkObjectVisitor;
444 static void UnmarkObject(HeapObject* obj); 456 static void UnmarkObject(HeapObject* obj);
445 #endif 457 #endif
446 }; 458 };
447 459
448 460
449 } } // namespace v8::internal 461 } } // namespace v8::internal
450 462
451 #endif // V8_MARK_COMPACT_H_ 463 #endif // V8_MARK_COMPACT_H_
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698