comparison of compacting algorithms for garbage collection · lisp2 .. summary • requires 1 extra...
TRANSCRIPT
![Page 1: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/1.jpg)
Comparison of Compacting Algorithms for Garbage Collection
Ahmed Hussein
Tuesday, February 7, 12
![Page 2: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/2.jpg)
Agenda
• Compaction..What is that?
• Presenting four different algorithms
• Lisp2
• Table Compactors
• Morris
• Jonkers
Tuesday, February 7, 12
![Page 3: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/3.jpg)
OverviewMemory
O1 O2 O3 O4
O5 O6
O7 O8 O9
Tuesday, February 7, 12
![Page 4: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/4.jpg)
Phase1..MarkingMemory
O1 O2 O3 O4
O5 O6
O7 O8 O9
Tuesday, February 7, 12
![Page 5: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/5.jpg)
Phase2..CollectingMemory
O1 O3
O5 O6
O7 O9
Tuesday, February 7, 12
![Page 6: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/6.jpg)
Phase2..CollectingMemory
O1 O3
O5 O6
O7 O9
O10
Tuesday, February 7, 12
![Page 7: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/7.jpg)
Phase3..CompactionMemory
O1 O3
O5 O6
O7 O9
O10
Tuesday, February 7, 12
![Page 8: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/8.jpg)
Phase3..CompactionMemory
O1 O3
O5 O6
O7 O9
O10
Tuesday, February 7, 12
![Page 9: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/9.jpg)
Phase3..CompactionMemory
O1 O3 O5
O6
O7 O9
O10
Tuesday, February 7, 12
![Page 10: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/10.jpg)
Phase3..CompactionMemory
O1 O3 O5
O6
O7
O9
O10
Tuesday, February 7, 12
![Page 11: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/11.jpg)
Phase3..CompactionMemory
O1 O3 O5
O6
O7
O9
O10
Tuesday, February 7, 12
![Page 12: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/12.jpg)
Phase3..CompactionMemory
O1 O3 O5
O6
O7
O9
O10
Tuesday, February 7, 12
![Page 13: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/13.jpg)
Object Model
Size c
npc
Sizenpc
data
Tuesday, February 7, 12
![Page 14: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/14.jpg)
Lisp2Memory
Size c1
npc
Size c2
npc
Size c1
npc
Tuesday, February 7, 12
![Page 15: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/15.jpg)
Lisp2Memory
Size c1
npc
Size c2
npc
Compacting
Size c1
npc
Tuesday, February 7, 12
![Page 16: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/16.jpg)
Lisp2Memory
Size c1
npc
Size c2
npc
Compacting
Size c1
npc
Tuesday, February 7, 12
![Page 17: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/17.jpg)
Lisp2Memory
Size c1
npc
Size c2
npc
Compacting
Size c1
npc
Tuesday, February 7, 12
![Page 18: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/18.jpg)
Lisp2
Size c1
npc
addressSize c
npc
Tuesday, February 7, 12
![Page 19: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/19.jpg)
Lisp2
Size c1
npc
address
Tuesday, February 7, 12
![Page 20: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/20.jpg)
Lisp2a2a1 a3 a4a0 a5
Pass1
Tuesday, February 7, 12
![Page 21: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/21.jpg)
Lisp2a2a1 a3 a4a0 a5
Pass1
Tuesday, February 7, 12
![Page 22: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/22.jpg)
Lisp2a2a1 a3 a4a0 a5
Pass1
Tuesday, February 7, 12
![Page 23: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/23.jpg)
Lisp2a2a1 a3 a4a0 a5
Pass1
Tuesday, February 7, 12
![Page 24: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/24.jpg)
Lisp2a2a1 a3 a4a0 a5
a1’
Pass1
Tuesday, February 7, 12
![Page 25: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/25.jpg)
Lisp2a2a1 a3 a4a0 a5
a1’a2’=a1’+size
Pass1
Tuesday, February 7, 12
![Page 26: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/26.jpg)
Lisp2a2a1 a3 a4a0 a5
a1’a2’=a1’+size
a4’=a2’+size
Pass1
Tuesday, February 7, 12
![Page 27: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/27.jpg)
Lisp2a2a1 a4
Pass2
Tuesday, February 7, 12
![Page 28: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/28.jpg)
Lisp2a2a1 a4
a1’
Pass2
Tuesday, February 7, 12
![Page 29: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/29.jpg)
Lisp2a2a1 a4
a1’a2’=a1’+
size a1
Pass2
Tuesday, February 7, 12
![Page 30: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/30.jpg)
Lisp2a2a1 a4
a1’a2’=a1’+
size a1
a4’=a2’+
size a2
Pass2
Tuesday, February 7, 12
![Page 31: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/31.jpg)
Lisp2a2a1 a4
a1’a2’=a1’+
size a1
a4’=a2’+
size a2
Pass2
a1’
Tuesday, February 7, 12
![Page 32: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/32.jpg)
Lisp2a2a1 a4
a1’a2’=a1’+
size a1
a4’=a2’+
size a2
Pass2
a1’ a2’
Tuesday, February 7, 12
![Page 33: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/33.jpg)
Lisp2a2a1 a4
a1’a2’=a1’+
size a1
a4’=a2’+
size a2
Pass2
a1’ a2’ a4’
Tuesday, February 7, 12
![Page 34: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/34.jpg)
Lisp2a4a1
a1’
a2a2’=a1’+size
a4’=a2’+size
Pass3
Tuesday, February 7, 12
![Page 35: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/35.jpg)
Lisp2a4a1
a1’
a2a2’=a1’+size
a4’=a2’+size
Pass3
Tuesday, February 7, 12
![Page 36: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/36.jpg)
Lisp2a4a1
a1’
a2a2’=a1’+size
a4’=a2’+size
Pass3
Tuesday, February 7, 12
![Page 37: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/37.jpg)
Lisp2a4a1
a1’
a2a2’=a1’+size
a4’=a2’+size
Pass3
Tuesday, February 7, 12
![Page 38: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/38.jpg)
Lisp2a4a1
a1’
a2a2’=a1’+size
a4’=a2’+size
Pass3
Tuesday, February 7, 12
![Page 39: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/39.jpg)
Lisp2a4a1
a1’
a2a2’=a1’+size
a4’=a2’+size
Pass3
a1’
Tuesday, February 7, 12
![Page 40: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/40.jpg)
Lisp2a4a1
a1’
a2a2’=a1’+size
a4’=a2’+size
Pass3
a1’ a2’
Tuesday, February 7, 12
![Page 41: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/41.jpg)
Lisp2a4a1
a1’
a2a2’=a1’+size
a4’=a2’+size
Pass3
a1’ a2’ a4’
Tuesday, February 7, 12
![Page 42: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/42.jpg)
Lisp2a4
a1
a1’
a2a2’=a1’+size
a4’=a2’+size
Pass3
a1’ a2’ a4’
Tuesday, February 7, 12
![Page 43: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/43.jpg)
Lisp2a4
a1
a1’
a2a2’=a1’+size
a4’=a2’+size
Pass3
a1’ a2’ a4’
Tuesday, February 7, 12
![Page 44: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/44.jpg)
Lisp2a4
a1
a1’
a2a2’=a1’+size
a4’=a2’+size
Pass3
a1’ a2’ a4’
Tuesday, February 7, 12
![Page 45: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/45.jpg)
Lisp2..Finala2a1 a3
nil
Tuesday, February 7, 12
![Page 46: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/46.jpg)
Lisp2..Finala2a1
nil
a3
nil
Tuesday, February 7, 12
![Page 47: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/47.jpg)
Lisp2..Finala2a1
nil nil
a3
nil
Tuesday, February 7, 12
![Page 48: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/48.jpg)
Lisp2 .. Summary
• Requires 1 extra word in each object for temp pointer. (even when the object is not live)
• Compaction is done in 3 phases:
1. Traverse the objects, sorted by address
• Compute new address of each live object
• free_ptr=0; free_ptr+=free_ptr+size of live object
2. Update Pointer fields.
3. Sliding CompactionTuesday, February 7, 12
![Page 49: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/49.jpg)
Table Compactors
• We need to save the overhead due to temp pointers.
• Using inactive cells to store readjustments.
Tuesday, February 7, 12
![Page 50: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/50.jpg)
Break Table
0 100 300 950 1200 1600 1999
Phase1
Tuesday, February 7, 12
![Page 51: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/51.jpg)
Break Table
0 100 300 950 1200 1600 1999
(100,100)
0 100 300 950 1200 1600 1999
Phase1
Tuesday, February 7, 12
![Page 52: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/52.jpg)
Break Table
0 100 300 950 1200 1600 1999
(100,100)
0 100 300 950 1200 1600 1999
(100,100)(950,750)
0 100 300 950 1200 1600 1999
Phase1
Tuesday, February 7, 12
![Page 53: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/53.jpg)
Break Table
0 100 300 950 1200 1600 1999
(100,100)
0 100 300 950 1200 1600 1999
(100,100)(950,750)
0 100 300 950 1200 1600 1999(950,750)(100,100)
(1600, 1150)0 100 300 950 1200 1600 1999
Phase1
Tuesday, February 7, 12
![Page 54: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/54.jpg)
Break Table
• Rolling back causes it to become unsorted.
• Need another phase just to sort the BT.
Tuesday, February 7, 12
![Page 55: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/55.jpg)
Break Table
• Phase3 to fix the pointers.
1. Search through the BT table and determine the adjacent pairs(a, s) and (a’, s’) such that a <= p < a’
2. readjusted value should be p - s.
Tuesday, February 7, 12
![Page 56: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/56.jpg)
Break Table ..Cost
• Phase1: linear
• Phase2: nlogn
• Phase3: nlogn
• we can enhance the last phase by constructing a hash if we have enough space.
• Other suggestions to keep a linked list in holes and update pointers before moving objects.
Tuesday, February 7, 12
![Page 57: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/57.jpg)
Problem .. revisited
• It is clear from the previous 2 algorithms that updating pointers is bottleneck.
Tuesday, February 7, 12
![Page 58: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/58.jpg)
Threading
A CB
PInfo
Tuesday, February 7, 12
![Page 59: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/59.jpg)
Threading
A CB
PInfo
P
CBAInfo
Tuesday, February 7, 12
![Page 60: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/60.jpg)
Threading
• After calculating the new address of P we can traverse the list and fix all the pointers to point to the new address of P.
Tuesday, February 7, 12
![Page 61: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/61.jpg)
Jonker Algorithm
infoP
Tuesday, February 7, 12
![Page 62: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/62.jpg)
Jonker Algorithm
info
First PathP
Tuesday, February 7, 12
![Page 63: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/63.jpg)
Jonker Algorithm
info
First Path
Info
P
Tuesday, February 7, 12
![Page 64: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/64.jpg)
Jonker Algorithm
info
First Path
Info
P
Info
p’=nextFree
Tuesday, February 7, 12
![Page 65: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/65.jpg)
Jonker Algorithm
Tuesday, February 7, 12
![Page 66: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/66.jpg)
Jonker AlgorithmSecond Path
Tuesday, February 7, 12
![Page 67: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/67.jpg)
Jonker AlgorithmSecond Path
InfoP
p’
Tuesday, February 7, 12
![Page 68: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/68.jpg)
Jonker AlgorithmSecond Path
InfoP
p’
info
Tuesday, February 7, 12
![Page 69: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/69.jpg)
Analysis of Threaded
• Each object is touched three times.
• Space:
• Jonker, no space required but each node has a pointer-sized header.
• Morris
• 2 tag bits per field, 0 inactive, 1 pointer, 2 swapped pointer, 3 non pointer.
• Could be improved by merging marking phase with first phase.
Tuesday, February 7, 12
![Page 70: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/70.jpg)
Threaded..Analysis
• Compact tables touch every object only twice.
Tuesday, February 7, 12
![Page 71: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/71.jpg)
Compaction Summary
• Suits smaller physical memory. Semi-Space requires double the memory space.
• For long lived objects, the heap becomes similar to “generational collector”.
• Improve locality.
• Other algorithms have only one path.
Tuesday, February 7, 12
![Page 72: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/72.jpg)
How to Compare
• Variable sized objects?
• Directions?
• Have to tag pointer data?
• Time and Space Performance.
Tuesday, February 7, 12
![Page 73: Comparison of Compacting Algorithms for Garbage Collection · Lisp2 .. Summary • Requires 1 extra word in each object for temp pointer. (even when the object is not live) • Compaction](https://reader034.vdocument.in/reader034/viewer/2022042214/5eb94b1fb7e4f539ec34080e/html5/thumbnails/73.jpg)
Time Comparison
Tuesday, February 7, 12