Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory...

43
Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    216
  • download

    0

Transcript of Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory...

Page 1: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Establishing Local Temporal Heap Safety Properties with Applications to

Compile-Time Memory Management

Ran Shaham

Eran Yahav

Elliot Kolodner

Mooly Sagiv

Page 2: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Memory deallocation in a timely manner is a hard problem

• Premature deallocation Program errors

• Late deallocation Memory leaks Inefficient use of memory

Page 3: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

(Old) Idea: Compile-Time GC

• The compiler can issue free when objects are no longer needed– Object may still be reachable– Potentially collects objects earlier than run-time

garbage collection• Low cost• Candidate for memory/cpu constrained

environments• Difficult for imperative heap-manipulating

programs– No static names for objects– Destructive updates (mutations) x.field=null

Page 4: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Results

• A framework for developing static algorithms for memory management– Compile-Time GC

• Free an unneeded object• Handle destructive updates

– GC assistance • Assign null to heap references• Reduces reachability heap graph• GC exploits information

Page 5: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Plan

• A motivating example program

• The heap safety automaton

• Concrete semantics for deallocating space

• Abstract semantics for deallocating space

• Assign Null

• Summary

Page 6: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

A Linked List Example class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n;[11] y = t; } } }

Page 7: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

A Linked List Example class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n;[11] y = t; } } }

xu1 u2 u3 u7u6

y

u4n nn n n n nu5

Page 8: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

A Linked List Example class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n;[11] y = t; } } }

t

xu1 u2 u3 u7u6

y

u4n nn n n n nu5

Page 9: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

A Linked List Example class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n;[11] y = t; } } }

t

xu1 u2 u3 u7u6

y

u4n nn n n n nu5

Page 10: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

A Linked List Example class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n;[11] y = t; } } }

y t

xu1 u2 u3 u7u6u4

n nn n n n nu5

Page 11: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

A Linked List Example class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n;[11] y = t; } } }

y t

xu1 u2 u3 u7u6u4

n nn n n n nu5

Page 12: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Free Unneeded Objects class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n; “free y;”[11] y = t; } } }

y t

xu1 u2 u3 u7u6u4

n nn n n n nu5

Page 13: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

When can we free an object?

a = malloc(…) ;

b = a;

// free (a); ?

c = malloc (…);

if (b == c) printf(“unexpected equality”);

Cannot free an object if it has a reference with a future use!

Page 14: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

When can free x be inserted after p?

pcannot free x

x references an object l

some reference to l is used

On all execution paths after p there are no uses of references to the object referenced by x

inserting free x after p is valid

Page 15: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Computing Free Information

• Forward (history) information– Heap paths– For free x after p

• Aliases of x after p

• Backward (future) information– Use of references– For free x after p

• Future use of aliases of x after p

• Integration of forward and backward heap information– Alternatives

• Integration of an operational semantics and a backward collecting semantics

• Automaton-based solution– Automaton states record “future” information

Page 16: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

The Heap Safety Automaton

• Describes a local temporal heap safety property (a typestate property)– Holds on an execution path for an object– Independent of other objects– In an accepting state on an execution path for an

object

• Used for property verification– Automaton does not reach the “err” state– For all execution paths for all objects

Page 17: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

free x after p automaton

pcannot free x

x references an object l

some reference to l is used

errinitial refp,x use

0

use refp,x

1

Automaton for an object l

Page 18: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

A Concrete Semantics for Deallocating Space

• Program state– “Usual heap information”

• Variable values, Field Values

– Free x after p automaton state• For every object l

• Program statement effect– “Usual semantics”– Trigger automaton events

Page 19: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n;[11] y = t; } } }

Automaton for an object l

Free “y at 10” Automaton

errinitial ref10,y use

0

use ref10,y

1

xu1 u2 u3 u7u6

y

u4n nn n n n nu5

S[0] S[0] S[0] S[0]S[0] S[0]S[0]

Page 20: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; (use x) [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n;[11] y = t; } } }

Automaton for an object l

Free “y at 10” Automaton

errinitial ref10,y use

0

use ref10,y

1

xu1 u2 u3 u7u6

y

u4n nn n n n nu5

S[0] S[0] S[0] S[0]S[0] S[0]S[0]

Page 21: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n;[11] y = t; } } }

Automaton for an object l

Free “y at 10” Automaton

errinitial ref10,y use

0

use ref10,y

1

y t

xu1 u2 u3 u7u6u4

n nn n n n nu5S[0] S[0] S[0] S[0]S[0] S[0]S[0]

Page 22: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n; (use y, use y.n, ref10,y)[11] y = t; } } }

Automaton for an object l

Free “y at 10” Automaton

errinitial ref10,y use

0

use ref10,y

1

y t

xu1 u2 u3 u7u6u4

n nn n n n nu5S[0] S[0] S[0] S[0]S[0] S[0]S[0]

Page 23: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n; (use y, use y.n, ref10,y)[11] y = t; } } }

Automaton for an object l

Free “y at 10” Automaton

errinitial ref10,y use

0

use ref10,y

1

y t

xu1 u2 u3 u7u6u4

n nn n n n nu5S[0] S[0] S[0] S[0]S[0] S[0]S[0]

Page 24: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n; (use y, use y.n, ref10,y)[11] y = t; } } }

Automaton for an object l

Free “y at 10” Automaton

errinitial ref10,y use

0

use ref10,y

1

y t

xu1 u2 u3 u7u6u4

n nn n n n nu5S[0] S[0] S[0] S[0]S[0] S[0]S[0]

Page 25: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n; (use y, use y.n, ref10,y)[11] y = t; } } }

Automaton for an object l

Free “y at 10” Automaton

errinitial ref10,y use

0

use ref10,y

1

y t

xu1 u2 u3 u7u6u4

n nn n n n nu5S[1] S[0] S[0] S[0]S[0] S[0]S[0]

Page 26: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n; (use y, use y.n, ref10,y)[11] y = t; } } }

Automaton for an object l

Free “y at 10” Automaton

errinitial ref10,y use

0

use ref10,y

1

y t

xu1 u2 u3 u7u6u4

n nn n n n nu5S[1] S[1] S[1] S[0]S[0] S[0]S[1]

Page 27: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Abstract Semantics for Deallocating Space –

Challenges• Infinite states

– Number of objects is unbounded

• Precise heap path information– Precise Association of

• an event• corresponding automaton state of a program object

• Our framework– Allows a rather precise heap abstraction– Abstraction refinement

• automaton state of each program object

Page 28: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Abstract Semantics for Deallocating Space

• Program state– Heap Abstraction

• Parametric Shape Analysis [SRW02]• Based on 3-valued logical structures

– Automaton States• Unary predicates s[q]• q ranges over automaton states

• Program statement effect– Shape analysis abstract transformers– Events associated with every statement update s[q]

• Property Verification– s[err] does not hold

Page 29: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Automaton for an object l

Free “y at 10” Automaton class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n;[11] y = t; } } }

errinitial ref10,y use

0

use ref10,y

1

x S[1]

y

S[0]n n n

S[1]

nt

S[0]n

n

S[0]

Page 30: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Automaton for an object l

Free “y at 10” Automaton class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n; (use y, use y.n, ref10,y)[11] y = t; } } }

errinitial ref10,y use

0

use ref10,y

1

x S[1]

y

S[0]n n n

S[1]

nt

S[0]n

n

S[0]

Page 31: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Automaton for an object l

Free “y at 10” Automaton class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n; (use y, use y.n, ref10,y)[11] y = t; } } }

errinitial ref10,y use

0

use ref10,y

1

x S[1]

y

S[0]n n n

S[1]

nt

S[0]n

n

S[0]

Page 32: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Automaton for an object l

Free “y at 10” Automaton class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n; (use y, use y.n, ref10,y)[11] y = t; } } }

errinitial ref10,y use

0

use ref10,y

1

x S[1]

y

S[0]n n n

S[1]

nt

S[0]n

n

S[0]

Page 33: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Automaton for an object l

Free “y at 10” Automaton class L { // L is a singly linked list public L n; // next field public int val; // data field } class Main { // Creation and traversal of a singly-linked list public static void main(String args[]) { L x, y, t; [1] x = null; [2] while (...) { // list creation [3] y = new L(); [4] y.val = ...; [5] y.n = x; [6] x = y; } [7] y = x; [8] while (y != null) { // list traversal [9] System.out.print(y.val);[10] t = y.n; (use y, use y.n, ref10,y)[11] y = t; } } }

errinitial ref10,y use

0

use ref10,y

1

x S[1]

y

S[1]n n n

S[1]

nt

S[0]n

n

S[0]

Page 34: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Assign Null

• Allows GC to collect more space– Reduces heap reachability

• Assign-Null automaton– Contains “back-edges”

Page 35: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

When can x.f = null be inserted after p?

pp’

x.f cannot be assigned null

On all execution paths after p, x.f is not used before redefinition

inserting x.f = null after p is valid

field f of object l is not assigned

field f of object l is used

x references an object l

Page 36: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

pp’field f of object l

is not assigned

field f of object l is used

errinitial refp,x usef0

usef,deff refp,x

1

deff

x.f cannot be assigned null

x references an object l

When can x.f = null be inserted after p?

Page 37: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

pp’field f of object l

is not assigned

field f of object l is used

errinitial refp,x usef0

usef,deff refp,x

1

deff

x.f cannot be assigned null

x references an object l

When can x.f = null be inserted after p?

Page 38: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

pp’field f of object l

is not assigned

field f of object l is used

errinitial refp,x usef0

usef,deff refp,x

1

deff

x.f cannot be assigned null

x references an object l

When can x.f = null be inserted after p?

Page 39: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

pp’field f of object l

is not assigned

field f of object l is used

errinitial refp,x usef0

usef,deff refp,x

1

deff

x.f cannot be assigned null

x references an object l

When can x.f = null be inserted after p?

Page 40: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

pp’field f of object l

is not assigned

field f of object l is used

errinitial refp,x usef0

usef,deff refp,x

1

deff

x.f cannot be assigned null

x references an object l

When can x.f = null be inserted after p?

Page 41: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Prototype Implementation

• Analysis of Java/JavaCard programs

• Precise– Points-to is not enough

• Even when it is flow-sensitive, field-sensitive with unbounded context [Emami et al. – PLDI 94]

• Scalability issues– Interprocedural shape analysis

Page 42: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Related Work

• Memory Management– Compile-Time GC

• Mostly for functional languages

– Escape Analysis• Limited to objects not escaping their allocating method

– Region-based memory management• Usually requires programmer awareness

• Software verification of safety properties– Bandera, ESP, SLAM

• Precision• Application domain

Page 43: Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.

Summary

• Statically identify a subset of unneeded objects • Free

– Free an unneeded object– Similar to compile-time GC studied for functional languages

• We need to handle destructive updates

• Assign null – Assign null to heap references– Reduces reachability heap graph– GC exploits information

• Identify potential errors– Issue a warning when a potentially needed object is reclaimed

• False alarms may arise

• A framework– Formulate compile-time memory management as a verification

problem