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

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

Issue 5736008: Provide baseline for experimental GC implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 10 years 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
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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 // Test whether a (possibly marked) object is a Map. 255 // Test whether a (possibly marked) object is a Map.
256 static inline bool SafeIsMap(HeapObject* object); 256 static inline bool SafeIsMap(HeapObject* object);
257 257
258 // Map transitions from a live map to a dead map must be killed. 258 // Map transitions from a live map to a dead map must be killed.
259 // We replace them with a null descriptor, with the same key. 259 // We replace them with a null descriptor, with the same key.
260 static void ClearNonLiveTransitions(); 260 static void ClearNonLiveTransitions();
261 261
262 // ----------------------------------------------------------------------- 262 // -----------------------------------------------------------------------
263 // Phase 2: Sweeping to clear mark bits and free non-live objects for 263 // Phase 2: Sweeping to clear mark bits and free non-live objects for
264 // a non-compacting collection, or else computing and encoding 264 // a non-compacting collection.
265 // forwarding addresses for a compacting collection.
266 // 265 //
267 // Before: Live objects are marked and non-live objects are unmarked. 266 // Before: Live objects are marked and non-live objects are unmarked.
268 // 267 //
269 // After: (Non-compacting collection.) Live objects are unmarked, 268 // After: Live objects are unmarked, non-live regions have been added to
270 // non-live regions have been added to their space's free 269 // their space's free list. Active eden semispace is compacted by
271 // list. 270 // evacuation.
272 // 271 //
273 // After: (Compacting collection.) The forwarding address of live
274 // objects in the paged spaces is encoded in their map word
275 // along with their (non-forwarded) map pointer.
276 //
277 // The forwarding address of live objects in the new space is
278 // written to their map word's offset in the inactive
279 // semispace.
280 //
281 // Bookkeeping data is written to the page header of
282 // eached paged-space page that contains live objects after
283 // compaction:
284 //
285 // The allocation watermark field is used to track the
286 // relocation top address, the address of the first word
287 // after the end of the last live object in the page after
288 // compaction.
289 //
290 // The Page::mc_page_index field contains the zero-based index of the
291 // page in its space. This word is only used for map space pages, in
292 // order to encode the map addresses in 21 bits to free 11
293 // bits per map word for the forwarding address.
294 //
295 // The Page::mc_first_forwarded field contains the (nonencoded)
296 // forwarding address of the first live object in the page.
297 //
298 // In both the new space and the paged spaces, a linked list
299 // of live regions is constructructed (linked through
300 // pointers in the non-live region immediately following each
301 // live region) to speed further passes of the collector.
302
303 // Encodes forwarding addresses of objects in compactable parts of the
304 // heap.
305 static void EncodeForwardingAddresses();
306
307 // Encodes the forwarding addresses of objects in new space.
308 static void EncodeForwardingAddressesInNewSpace();
309
310 // Function template to encode the forwarding addresses of objects in
311 // paged spaces, parameterized by allocation and non-live processing
312 // functions.
313 template<AllocationFunction Alloc, ProcessNonLiveFunction ProcessNonLive>
314 static void EncodeForwardingAddressesInPagedSpace(PagedSpace* space);
315 272
316 // Iterates live objects in a space, passes live objects 273 // Iterates live objects in a space, passes live objects
317 // to a callback function which returns the heap size of the object. 274 // to a callback function which returns the heap size of the object.
318 // Returns the number of live objects iterated. 275 // Returns the number of live objects iterated.
319 static int IterateLiveObjects(NewSpace* space, HeapObjectCallback size_f); 276 static int IterateLiveObjects(NewSpace* space, HeapObjectCallback size_f);
320 static int IterateLiveObjects(PagedSpace* space, HeapObjectCallback size_f); 277 static int IterateLiveObjects(PagedSpace* space, HeapObjectCallback size_f);
321 278
322 // Iterates the live objects between a range of addresses, returning the 279 // Iterates the live objects between a range of addresses, returning the
323 // number of live objects. 280 // number of live objects.
324 static int IterateLiveObjectsInRange(Address start, Address end, 281 static int IterateLiveObjectsInRange(Address start, Address end,
325 HeapObjectCallback size_func); 282 HeapObjectCallback size_func);
326 283
327 // If we are not compacting the heap, we simply sweep the spaces except 284 // If we are not compacting the heap, we simply sweep the spaces except
328 // for the large object space, clearing mark bits and adding unmarked 285 // for the large object space, clearing mark bits and adding unmarked
329 // regions to each space's free list. 286 // regions to each space's free list.
330 static void SweepSpaces(); 287 static void SweepSpaces();
331 288
332 // -----------------------------------------------------------------------
333 // Phase 3: Updating pointers in live objects.
334 //
335 // Before: Same as after phase 2 (compacting collection).
336 //
337 // After: All pointers in live objects, including encoded map
338 // pointers, are updated to point to their target's new
339 // location.
340
341 friend class UpdatingVisitor; // helper for updating visited objects
342
343 // Updates pointers in all spaces.
344 static void UpdatePointers();
345
346 // Updates pointers in an object in new space.
347 // Returns the heap size of the object.
348 static int UpdatePointersInNewObject(HeapObject* obj);
349
350 // Updates pointers in an object in old spaces.
351 // Returns the heap size of the object.
352 static int UpdatePointersInOldObject(HeapObject* obj);
353
354 // Calculates the forwarding address of an object in an old space.
355 static Address GetForwardingAddressInOldSpace(HeapObject* obj);
356
357 // -----------------------------------------------------------------------
358 // Phase 4: Relocating objects.
359 //
360 // Before: Pointers to live objects are updated to point to their
361 // target's new location.
362 //
363 // After: Objects have been moved to their new addresses.
364
365 // Relocates objects in all spaces.
366 static void RelocateObjects();
367
368 // Converts a code object's inline target to addresses, convention from
369 // address to target happens in the marking phase.
370 static int ConvertCodeICTargetToAddress(HeapObject* obj);
371
372 // Relocate a map object.
373 static int RelocateMapObject(HeapObject* obj);
374
375 // Relocates an old object.
376 static int RelocateOldPointerObject(HeapObject* obj);
377 static int RelocateOldDataObject(HeapObject* obj);
378
379 // Relocate a property cell object.
380 static int RelocateCellObject(HeapObject* obj);
381
382 // Helper function.
383 static inline int RelocateOldNonCodeObject(HeapObject* obj,
384 PagedSpace* space);
385
386 // Relocates an object in the code space.
387 static int RelocateCodeObject(HeapObject* obj);
388
389 // Copy a new object.
390 static int RelocateNewObject(HeapObject* obj);
391
392 #ifdef DEBUG 289 #ifdef DEBUG
393 // ----------------------------------------------------------------------- 290 // -----------------------------------------------------------------------
394 // Debugging variables, functions and classes 291 // Debugging variables, functions and classes
395 // Counters used for debugging the marking phase of mark-compact or 292 // Counters used for debugging the marking phase of mark-compact or
396 // mark-sweep collection. 293 // mark-sweep collection.
397 294
398 // Size of live objects in Heap::to_space_. 295 // Size of live objects in Heap::to_space_.
399 static int live_young_objects_size_; 296 static int live_young_objects_size_;
400 297
401 // Size of live objects in Heap::old_pointer_space_. 298 // Size of live objects in Heap::old_pointer_space_.
(...skipping 22 matching lines...) Expand all
424 321
425 friend class UnmarkObjectVisitor; 322 friend class UnmarkObjectVisitor;
426 static void UnmarkObject(HeapObject* obj); 323 static void UnmarkObject(HeapObject* obj);
427 #endif 324 #endif
428 }; 325 };
429 326
430 327
431 } } // namespace v8::internal 328 } } // namespace v8::internal
432 329
433 #endif // V8_MARK_COMPACT_H_ 330 #endif // V8_MARK_COMPACT_H_
OLDNEW
« src/globals.h ('K') | « 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