write barrier removal by static analysiskkz/oopsla02.pdf · 2002-11-18 · write barriers for...

68
Write Barrier Removal by Static Analysis Karen Zee Martin Rinard MIT Laboratory for Computer Science

Upload: others

Post on 10-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Write Barrier Removal by Static Analysis

Karen ZeeMartin Rinard

MIT Laboratory for Computer Science

Page 2: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Research Goal

Use static program analysis to identify and remove unnecessary write barriers in programs that use generational garbage collection.

Page 3: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Write Barriers andGenerational Garbage Collection

Page 4: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Garbage Collection

“Root Set”

Page 5: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Garbage Collection

“Root Set”

Page 6: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Garbage Collection

“Root Set”

Page 7: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Generational Garbage Collection

Young Generation Old Generation

Page 8: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Generational Garbage Collection

Young Generation Old Generation

Page 9: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Generational Garbage Collection

Young Generation Old Generation

Page 10: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Generational Garbage Collection

Young Generation Old Generation

“Root Set”

Page 11: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Generational Garbage Collection

Young Generation Old Generation

“Root Set”Remembered set of references

Page 12: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Write BarriersCode added by the compiler to every store of a reference into the heapEx. Remembered set of references

Array of locations that could contain references into the young generationMaintained at store instructions:

v1.f = v2; // storers[i++] = &v1.f; // write barrier

Undesirable overhead on stores to the heap

Page 13: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Generational Garbage Collection

Young Generation Old Generation

Young-to-Young

Young-to-Old

Old-to-YoungOld-to-Old

Page 14: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Write Barrier Removal Principle

Write barrier unnecessary for stores that create references from younger to older objectsAnalysis approach

Identify stores that create references from younger to older objectsSpecifically, references from the youngest object to other objects

Then remove the corresponding write barriers

Page 15: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

The Analyses

Track youngest objectTarget Java bytecodeIntraproceduralInterprocedural

With callee informationWith caller information

Page 16: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Intraprocedural Analysis

Forward dataflow analysisComputes must points-to informationFor each point in the program, the analysis generates

A set V of local variablesAll v ∈ V refer to the youngest object

Page 17: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Using the Analysis Information

Store statement v1.f = v2Write barrier for the store statement can be removed if

v1 refers to the youngest objecti.e. v1 ∈ V

Page 18: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Transfer Functions

V…

V − { lv }lv = …

∅lv = CALL m(…)

V ∪ { lv1 } if lv2 ∈ VV − { lv1 } if lv2 ∉ V

lv1 = lv2

{ lv }lv = NEW C

[ stm ]( V )stm

Page 19: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Dataflow FrameworkJoin operator is set intersection ∩Initial value of V∅ at method entryAll program variables Vars at all other program points

Page 20: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Exampleclass Point {

Integer x;Integer y;

}

…x = new Integer(11);y = new Integer(7);p = new Point();p.x = x;p.y = y;…

11

Page 21: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Exampleclass Point {

Integer x;Integer y;

}

…x = new Integer(11);y = new Integer(7);p = new Point();p.x = x;p.y = y;…

11

7

Page 22: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Exampleclass Point {

Integer x;Integer y;

}

…x = new Integer(11);y = new Integer(7);p = new Point();p.x = x;p.y = y;…

11

7

11

7

Page 23: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Exampleclass Point {

Integer x;Integer y;

}

…x = new Integer(11);y = new Integer(7);p = new Point();p.x = x;p.y = y;…

11

7

Page 24: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Exampleclass Point {

Integer x;Integer y;

}

…x = new Integer(11);y = new Integer(7);p = new Point();p.x = x;p.y = y;…

11

7

Only young-to-old references created.Write barriers should be unnecessary!

Page 25: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Exampleclass Point {

Integer x;Integer y;

}

…x = new Integer(11);y = new Integer(7);p = new Point();p.x = x;p.y = y;…

{ p }

{ p }

V

{ p }

p = new Point();

p.y = y;

p.x = x;

// write barrier not needed// write barrier not needed

Page 26: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Example

{ p }

p.y = y;

p.x = x;

V

CALL Point(p);

p = NEW Point;

{ p }

{ p }

V

{ p }

p = new Point();

p.y = y;

p.x = x;

Page 27: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Interprocedural Information

Page 28: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Allocated Object TypesConsider the method-youngest objectTrack the types of objects that invoked methods may allocateUse type-based reasoning to remove write barriers associated with stores that

Create a reference from the youngest object allocated in the current methodProvided that reference does not point to an object allocated by an invoked method

Page 29: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Allocated Type AnalysisFlow-insensitive interprocedural analysisCollects types of objects allocated either

Directly by the given method, orIndirectly by (transitively) invoked methods

Page 30: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Information from CalleesFor each point in the program, the analysis generates a pair ⟨ V, T ⟩

Set V of local variablesAll v ∈ V refer to the method-youngest objectSet T of typesObjects of type t ∈ T may have been allocated by (transitively) invoked methods

Page 31: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Using the Analysis InformationStore statement v1.f = v2Write barrier for the store statement can be removed if

v1 refers to the method-youngest objecti.e. v1 ∈ Vv2 refers to an object older than the method-youngest objecti.e. subtypes(C) ∩ T = ∅ where C is the static type of v2

Page 32: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Modified Transfer Functions

⟨ V, T ⟩…

⟨ V − { lv }, T ⟩lv = …

⟨ V’, T’ ⟩ where V’ = V − { lv1 } andT’ = T ∪ (∪m’∈callees(m)alloctypes(m’))

lv = CALL m(…)

⟨ V ∪ { lv1 }, T ⟩ if lv2 ∈ V⟨ V − { lv1 }, T ⟩ if lv2 ∉ V

lv1 = lv2

⟨ { lv }, ∅ ⟩lv = NEW C

[ st ](⟨ V, T ⟩)st

Page 33: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Dataflow FrameworkJoin operator is ⟨ ∩, ∪ ⟩Initial value of ⟨ V, T ⟩⟨ ∅, Types ⟩ at method entry⟨ Vars, ∅ ⟩ at all other program points

Page 34: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Example

⟨ { p }, { Exception } ⟩

⟨ { p }, { Exception } ⟩

⟨ { p }, { Exception } ⟩

⟨ { p }, ∅ ⟩

CALL Point(p);

p = NEW Point;

p.y = y;

p.x = x;

⟨ V, T ⟩

alloctypes(Point()) = ∅alloctypes(Point()) = { Exception }

Page 35: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Example

Remove write barrier for v1.f = v2 if:v1 ∈ V, andsubtypes(C) ∩ T = ∅where C is the static type of v2

⟨ { p }, { Exception } ⟩

⟨ { p }, { Exception } ⟩

p.y = y;

p.x = x;

Type(x) = IntegerType(y) = Integersubtypes(Integer) ∩ { Exception } = ∅

Page 36: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Example

Type(x) = IntegerType(y) = Integersubtypes(Integer) ∩ { Exception } = ∅

⟨ { p }, { Exception } ⟩

⟨ { p }, { Exception } ⟩

p.y = y;

p.x = x;Can remove write barriers!

Page 37: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Exampleclass Point {

Integer x;Integer y;

}…x = new Integer(11);y = new Integer(7);p = new Point();p.x = x; // no write barrierp.y = y; // no write barrier…

Page 38: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Exampleclass Point {

private Integer x;private Integer y;

}…x = new Integer(11);y = new Integer(7);p = new Point();p.x = x; // no write barrierp.y = y; // no write barrier…

class Point {private Integer x;private Integer y;Point(Integer x, Integer y) {

this.x = x;this.y = y;

}}…x = new Integer(11);y = new Integer(7);p = new Point(x, y);…

// write barrier?// write barrier?

Page 39: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Constructor Example

⟨ ∅, Types ⟩

⟨ ∅, Types ⟩

CALL Object(p);

this.y = y;

this.x = x;

class Point {private Integer x;private Integer y;Point(Integer x, Integer y) {

this.x = x; // write barrier?this.y = y; // write barrier?

}}…x = new Integer(11);y = new Integer(7);p = new Point(x, y);…

alloctypes(Object()) = { }

⟨ ∅, Types ⟩

⟨ ∅, Types ⟩

Page 40: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Information from Callers

Use information from callersAt call sites where the youngest object is an argument to the call, propagate analysis results to entry point of invoked method

Page 41: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Constructor Example

⟨ { p }, ∅ ⟩

class Point {private Integer x;private Integer y;Point(Integer x, Integer y) {

this.x = x; // write barrier?this.y = y; // write barrier?

}}…x = new Integer(11);y = new Integer(7);p = new Point(x, y);…

CALL Point(p, x, y);

p = NEW Point;

The first argument to the Point constructor is the youngest object.

Page 42: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Constructor Example

⟨ { this }, ∅ ⟩

⟨ { this }, ∅ ⟩

CALL Object(p);

this.y = y;

this.x = x;

class Point {private Integer x;private Integer y;Point(Integer x, Integer y) {

this.x = x; // write barrier?this.y = y; // write barrier?

}}…x = new Integer(11);y = new Integer(7);p = new Point(x, y);…

⟨ { this }, ∅ ⟩

alloctypes(Object()) = ∅

⟨ { this }, ∅ ⟩

Page 43: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Constructor Exampleclass Point {

private Integer x;private Integer y;Point(Integer x, Integer y) {

this.x = x; // no write barrier!this.y = y; // no write barrier!

}}…x = new Integer(11);y = new Integer(7);p = new Point(x, y);…

⟨ { this }, ∅ ⟩

⟨ { this }, ∅ ⟩

CALL Object(p);

this.y = y;

this.x = x;

⟨ { this }, ∅ ⟩

⟨ { this }, ∅ ⟩

Page 44: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Point Constructor Exampleclass Point {

private Integer x;private Integer y;Point(Integer x, Integer y) {

this.x = x; // no write barrierthis.y = y; // no write barrier

}}…x = new Integer(11);y = new Integer(7);p = new Point(x, y);…

class Point {private Integer x;private Integer y;Point(int x, int y) {

this.x = new Integer(x);this.y = new Integer(y);

}}…p = new Point(11, 7);…

Clearly the receiver object is older than the Integer objects!The write barrier for the field assignment cannot be removed.

Solution: Transform program to reverse the order of the allocations!

Page 45: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Allocation Order Transformationsclass Point {

private Integer x;private Integer y;Point(int x, int y) {

tmp0 = NEW Integer;CALL Integer(tmp0, x);this.x = tmp0;tmp1 = NEW Integer;CALL Integer(tmp1, y);this.y = tmp1;

}}…p = new Point(11, 7);…

class Point {private Integer x;private Integer y;Point(int x, int y, Integer tmp0, Integer tmp1) {

CALL Integer(tmp0, x);this.x = tmp0;CALL Integer(tmp1, y);this.y = tmp1;

}}…tmp0 = NEW Integer;tmp1 = NEW Integer;p = new Point(11, 7, tmp0, tmp1);…

Now the write barriers for the field assignments can be removed!

Page 46: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Allocation Order Transformations

Make write barriers removable that previously could not be removedHandles recursive constructors for data structures such as trees

Top-down construction

1 Point

2

Integer

3

Integer

Bottom-up construction

1

Integer

3 Point

2

Integer

Page 47: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Experimental Results

Page 48: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

MethodologyImplemented in Flex compiler infrastructure

Ahead-of-time Java bytecode compilerGenerates native code or C

MeasuredWrite barrier countsExecution timeWrite barrier characterizationAnalysis time

Page 49: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Dynamic Write Barriers Removed

0%20%40%60%80%

100%BH

BiSo

rt

Em3d

Hea

lth

MST

Perim

eter

Pow

er

Tree

Add

Voro

noi

Intraprocedural Interprocedural Transformed

Page 50: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Normalized Execution Time

0.800.850.900.951.001.05

BH

BiSo

rt

Em3d

Hea

lth

MST

Perim

eter

Pow

er

Tree

Add

Voro

noi

Intraprocedural Interprocedural Transformed

Page 51: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Write Barrier Characterization

0.00.20.40.60.81.0BH

BiSo

rt

Em3d

Hea

lth

MST

Perim

eter

Pow

er

Tree

Add

Voro

noi

Removed Potentially Removable Unremovable

Page 52: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Write Barrier Characterizationwith Allocation Order Transformations

0.00.20.40.60.81.0BH

BiSo

rt

Em3d

Hea

lth

MST

Perim

eter

Pow

er

Tree

Add

Voro

noi

Removed Potentially Removable Unremovable

Page 53: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Analysis Time

4214Voronoi3712TreeAdd3815Power3515Perimeter3516MST3816Health3816Em3d3416BiSort3815BH

Interprocedural (s)Intraprocedural (s)

Page 54: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Other CollectorsAnalysis assumptions

Objects initially allocated in young generationOlder objects promoted before younger

Concurrent collectors may not promote objects in age-orderOther collectors may not always allocate objects initially in the young generation

Page 55: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

An Optimistic Extension

Young Generation Old Generation

Reserve a bit in the object header

01

Page 56: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

An Optimistic Extension

Young Generation Old Generation

1

Remembered set of objects

0

0

Page 57: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

An Optimistic Extension

Young Generation Old Generation

Remembered set of objects

0

0

Page 58: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

An Optimistic Extension

Young Generation Old Generation

0

0

Remembered set of references

Page 59: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

An Optimistic Extension

Out-of-order promotionAllocation in other generationsMulti-threaded programsLow overhead

Page 60: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Overhead of Optimistic Extension

-0.83%0.09%Voronoi

0.22%0.06%TreeAdd

-0.12%0.23%Power

0.37%0.37%Perimeter

0.19%0.55%MST

0.37%-0.08%Health

0.17%0.02%Em3d

-0.05%-0.33%BiSort

-0.95%0.36%BH

With Allocation Order Transformations

Without Allocation Order TransformationsBenchmark

% Increase in Execution Time

Page 61: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Related Work

Page 62: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Write Barriers for Generational GCLieberman and Hewitt, 1983 – Entry tableUngar, 1984 – Remembered set of objectsMoon, 1984 – Hardware write barriersShaw, 1988 – Virtual memory write barriersSobalvarro, 1988 – Card and word markingAppel, 1989 – Remembered set of addressesWilson and Moher, 1989 – Card markingHudson and Diwan, 1990 – Hashed remembered setZorn, 1990 – Write-protected pagesChambers, 1992 – 3 SPARC instructionsHölzle, 1993 – 2 SPARC instructionsHosking and Hudson, 1993 – Remembered sets + card-marking

Page 63: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Write Barrier EvaluationsZorn, 1990

Word marking in hardware, software, and page protectionLisp system

Hosking, Moss, and Stefanović, 1992Remembered sets, card marking, page protectionSmalltalk system

Jones and Lins, 1996Blackburn and McKinley, 2002

Inlining strategies for remembered sets of referencesJava system (Jikes RVM)

Page 64: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Type-based Garbage Collection

Prolific TypesShuf, Gupta, Bordawekar, and Singh, 2002

Connectivity-Based Garbage CollectionHirzel, Henkel, Diwan, and Hind, 2002

Page 65: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

ConclusionStatic program analysis for removing write barriers used for generational collection

Interprocedural informationAllocation order transformationsReasonable analysis timesIn many cases, remove almost all removable write barriers

Optimistic extension for collectors that may not promote objects in age order

Page 66: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Questions

Page 67: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

ScalingQ: How does this analysis scale?A: Because we use interprocedural information, it may

seem like the analysis would not scale well. However, the main analysis is actually intraprocedural, even though it uses type information that has to be computed using an interprocedural analysis. Now, that analysis, though interprocedural, is flow-insensitive, and context-insensitive. It can actually be computed very efficiently in linear time. So, in a efficient implementation, we expect the analysis to have very reasonable scaling properties.

Page 68: Write Barrier Removal by Static Analysiskkz/oopsla02.pdf · 2002-11-18 · Write Barriers for Generational GC Lieberman and Hewitt, 1983 – Entry table Ungar, 1984 – Remembered

Dynamic Class LoadingQ: Does the analysis support dynamic class loading?A: Like many other analyses of this type, dynamic class

loading may invalidate some analysis results. However, the optimistic extension will allow the system to operate correctly even in the presence of invalid analysis results. This makes the optimistic extension a good, low-overhead solution for using our analysis in the presence of dynamic class loading.