Semi-Automatic Region-Based for Real-Time Java Embedded Systems

G. Salagnac, . Rippert, S. Yovine

Verimag Lab. Université Joseph Fourier Grenoble, France

http://www-verimag.imag.fr/~salagnac

[email protected]

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 1 / 16 Motivation

The Java

I Attractive language

I Automatic memory management

Implementation pitfalls

I Garbage Collection ⇒ pause times and fragmentation

=⇒ Difficult to use in a real-time embedded context

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 2 / 16 Our approach

Non-determinism of Garbage Collector pause times: the problem is in the JVM, not in the language!

Proposition:

I Keep the language

I no manual memory management

I Change the implementation I replace the GC by a predictable

I use region-based memory management

I automatically compute object lifetimes at compilation

I undecidable problem I find a reasonable over-approximation

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 3 / 16 Our approach

Non-determinism of Garbage Collector pause times: the problem is in the JVM, not in the language!

Proposition:

I Keep the language

I no manual memory management

I Change the implementation I replace the GC by a predictable allocator

I use region-based memory management

I automatically compute object lifetimes at compilation

I undecidable problem I find a reasonable over-approximation

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 3 / 16 Outline

Introduction

Region-Based Memory management

Pointer Interference Analysis

Experimental results

Conclusion

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 4 / 16 Memory management using regions

a java heap...... organised in regions ein1region 2 region 1 program variables

Objects in a region will share the same (physical) lifetime

I Benefits: a more real-time-compatible behaviour I objects allocated side by side

I no fragmentation, constant time

I region destroyed as a whole: predictable times

I Drawbacks: more difficult bookkeeping

I object placement issue: who decides? I region destroyed as a whole: space overhead, risk of faults

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 5 / 16 Memory management using regions

a java heap...... organised in regions ein1region 2 region 1 program variables

Objects in a region will share the same (physical) lifetime

I Benefits: a more real-time-compatible behaviour I objects allocated side by side

I no fragmentation, constant time

I region destroyed as a whole: predictable times

I Drawbacks: more difficult bookkeeping

I object placement issue: who decides? I region destroyed as a whole: space overhead, risk of faults

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 5 / 16 Memory management using regions

a java heap...... organised in regions ein1region 2 region 1 program variables

Objects in a region will share the same (physical) lifetime

I Benefits: a more real-time-compatible behaviour I objects allocated side by side

I no fragmentation, constant time

I region destroyed as a whole: predictable times

I Drawbacks: more difficult bookkeeping

I object placement issue: who decides? I region destroyed as a whole: space overhead, risk of faults

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 5 / 16 Outline

Introduction

Region-Based Memory management

Pointer Interference Analysis

Experimental results

Conclusion

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 6 / 16 Region analysis and allocation policy

Hypothesis: Objects within the same data structure (i.e. connected together) will often have similar (logical) lifetimes

=⇒ one region for each data structure

I no inter-region pointer

Static analysis:

I identify variables that may point to connected objects Allocation Policy:

I place objects so that each structure is grouped in a region

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 7 / 16 Region analysis and allocation policy

Hypothesis: Objects within the same data structure (i.e. connected together) will often have similar (logical) lifetimes

=⇒ one region for each data structure

I no inter-region pointer

Static analysis:

I identify variables that may point to connected objects Allocation Policy:

I place objects so that each structure is grouped in a region

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 7 / 16 ∼ ∼

list o1 o2

this tmp

this o

main()

()

add()

Example: pointer interference analysis

class ArrayList { Object[] data; int index; main() { (int capacity) ArrayList list = { new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; void add(Object o) list.add(o1); { } this.data[this.index] = o; this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 8 / 16 ∼ ∼

list o1 o2

this tmp

this o

Example: pointer interference analysis

for all methods,

class ArrayList { Object[] data; int index; main() main() { (int capacity) ArrayList list = { new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } () Object o2=new Object; void add(Object o) list.add(o1); { } this.data[this.index] = o; this.index ++; } } add()

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 8 / 16 ∼

∼ ∼

this tmp

this o

Example: pointer interference analysis

identify local variables

class ArrayList { Object[] data; int index; main() main() { (int capacity) list o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } () Object o2=new Object; void add(Object o) list.add(o1); { } this.data[this.index] = o; this.index ++; } } add()

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 8 / 16 ∼

∼ ∼

this o

Example: pointer interference analysis

identify local variables

class ArrayList { Object[] data; int index; main() main() { (int capacity) list o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } () Object o2=new Object; void add(Object o) this tmp list.add(o1); { } this.data[this.index] = o; this.index ++; } } add()

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 8 / 16 ∼ ∼

Example: pointer interference analysis

identify local variables

class ArrayList { Object[] data; int index; main() main() { (int capacity) list o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } () Object o2=new Object; void add(Object o) this tmp list.add(o1); { } this.data[this.index] = o; this.index ++; } } add() this o

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 8 / 16 ∼ ∼

Example: pointer interference analysis

local interference:

class ArrayList v1.f=v2 =⇒ v1∼v2 { Object[] data; int index; main() main() { (int capacity) list o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } () Object o2=new Object; void add(Object o) this ∼ tmp list.add(o1); { } this.data[this.index] = o; this.index ++; } } add() this o

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 8 / 16 ∼ ∼

Example: pointer interference analysis

local interference:

class ArrayList v1.f=v2 =⇒ v1∼v2 { Object[] data; int index; main() main() { (int capacity) list o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } () Object o2=new Object; void add(Object o) this ∼ tmp list.add(o1); { } this.data[this.index] = o; this.index ++; } } add() this ∼ o

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 8 / 16 ∼

Example: pointer interference analysis

interproc. interference:

class ArrayList p1∼p2 =⇒ a1∼a2 { Object[] data; int index; main() main() { (int capacity) list ∼ o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } () Object o2=new Object; void add(Object o) this ∼ tmp list.add(o1); { } this.data[this.index] = o; this.index ++; } } add() this ∼ o

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 8 / 16 ∼

Example: pointer interference analysis

results:

class ArrayList { Object[] data; int index; main() main() {//list∼o1 o2 (int capacity) list ∼ o1 o2 ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } () Object o2=new Object; void add(Object o) this ∼ tmp list.add(o1); {//this∼o } this.data[this.index] = o; this.index ++; } } add() this ∼ o

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 8 / 16 Example: allocation policy

class ArrayList { Object[] data; • int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; void add(Object o) list.add(o1); {//this∼o } this.data[this.index] = o; this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) •ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp new ArrayList;• this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp new ArrayList; this.index = 0; •list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp tmp new ArrayList; this.index = 0; • this •list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp tmp new ArrayList; this.index = 0; • this •list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp tmp new ArrayList; this.index = 0; this •list.(3); •tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp tmp new ArrayList; this.index = 0; this •list.(3); tmp = new Object[capacity];• this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp tmp new ArrayList; this.index = 0; this •list.(3); tmp = new Object[capacity]; •this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp tmp new ArrayList; this.index = 0; this •list.(3); tmp = new Object[capacity]; this.data = tmp;• Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.(3);• tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; •Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object;• } Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } •Object o2=new Object; o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object;• o2 void add(Object o) o1 list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 •list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp o new ArrayList; this.index = 0; this list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 •list.add(o1); {//this∼o } •this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp o new ArrayList; this.index = 0; this list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 •list.add(o1); {//this∼o } this.data[this.index] = o;• list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp o new ArrayList; this.index = 0; this list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 •list.add(o1); {//this∼o } this.data[this.index] = o; list •this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp o new ArrayList; this.index = 0; this list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 •list.add(o1); {//this∼o } this.data[this.index] = o; list this.index ++;• } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; o2 void add(Object o) o1 list.add(o1);• {//this∼o } this.data[this.index] = o; list this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Example: allocation policy

class ArrayList { Object[] data; int index; main() {//list∼o1 o2 (int capacity) ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } Object o2=new Object; void add(Object o) list.add(o1); {//this∼o }• this.data[this.index] = o; this.index ++; } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 9 / 16 Outline

Introduction

Region-Based Memory management

Pointer Interference Analysis

Experimental results

Conclusion

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 10 / 16 Experimental setup

Static analysis implemented with the Soot infrastructure Memory manager implemented in the JITS virtual machine JITS = Java In The Small (LIFL, France)

I a J2SE JavaOS for resource-constrained systems

Comparison of memory occupancy:

I with the default GC (mark & sweep)

I with static analysis + regions JOlden benchmark suite

I lots of allocations

I different memory usage patterns

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 11 / 16 Experimental setup

Static analysis implemented with the Soot infrastructure Memory manager implemented in the JITS virtual machine JITS = Java In The Small (LIFL, France)

I a J2SE JavaOS for resource-constrained systems

Comparison of memory occupancy:

I with the default GC (mark & sweep)

I with static analysis + regions JOlden benchmark suite

I lots of allocations

I different memory usage patterns

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 11 / 16 Experimental results (1)

1x106

900000

800000

700000

Heap Size (bytes) 600000

500000 Garbage Collector Regions + Static Analysis

400000

0 1x107 2x107 3x107 4x107 5x107 VMTime (cycles)

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 12 / 16 Experimental results (1)

1x106

900000

0 10.80.60.400..22 00 10.80.60.40.2 0 800000 0.40.2 0.60.4 0.6 0.80.8 1 1 700000

Heap Size (bytes) 600000

500000 Garbage Collector Regions + Static Analysis

400000

0 1x107 2x107 3x107 4x107 5x107 VMTime (cycles)

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 12 / 16 Experimental results (2)

1x106

Garbage Collector 900000 Regions + Static Analysis

800000

700000 Heap Size (bytes) 600000

500000

400000

0 5x106 1x107 1.5x107 2x107 VMTime (cycles)

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 13 / 16 Region explosion syndrome

class RefObject { Object f;

foo() { Object bar=new Object; this.f=bar; } }

main() { RefObject r=new RefObject(); while(true) { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Pointer interference analysis: Object f;

foo() { Object bar=new Object; foo() this.f=bar; } this∼bar }

main() { RefObject r=new RefObject(); main() while(true) { r r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; } }

main() { RefObject r=new RefObject(); while(true) { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; } }

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; } }

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; } }

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; } }

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; bar } } this

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; } }

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Object f;

foo() {//this∼bar Object bar=new Object; this.f=bar; } }

main() { RefObject r=new RefObject(); while(true) r { r.foo(); } }

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Region explosion syndrome

class RefObject { Region behaviour analysis: Object f; search for bad paths in the foo() {//this∼bar call+interference graph... Object bar=new Object; this.f=bar; main() r } call site within loop body } allocation site main() { RefObject r=new RefObject(); while(true) foo() this∼bar { r.foo(); } } ...and report them to the programmer

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 14 / 16 Outline

Introduction

Region-Based Memory management

Pointer Interference Analysis

Experimental results

Conclusion

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 15 / 16 Conclusion and perspectives

Results:

I a new region inference algorithm

I regions work fine for most programming patterns

I compile-time feedback to the programmer otherwise

Work in progress:

I improvement of the allocation policy

I combination with a GC

Perspectives:

I extension to concurrency

G. Salagnac (Verimag) Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems 16 / 16