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

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

Semi-Automatic Region-Based Memory Management for Real-Time Java Embedded Systems G. Salagnac, C. 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 programming language 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 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 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 region 1 region 2 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 region 1 region 2 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 region 1 region 2 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() <init>() add() Example: pointer interference analysis class ArrayList { Object[] data; int index; main() { <init>(int capacity) ArrayList list = { new ArrayList; this.index = 0; list.<init>(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() { <init>(int capacity) ArrayList list = { new ArrayList; this.index = 0; list.<init>(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } <init>() 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() { <init>(int capacity) list o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.<init>(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } <init>() 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() { <init>(int capacity) list o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.<init>(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } <init>() 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() { <init>(int capacity) list o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.<init>(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } <init>() 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() { <init>(int capacity) list o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.<init>(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } <init>() 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() { <init>(int capacity) list o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.<init>(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } <init>() 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() { <init>(int capacity) list ∼ o1 o2 ArrayList list = { new ArrayList; this.index = 0; list.<init>(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } <init>() 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 <init>(int capacity) list ∼ o1 o2 ArrayList list = {//this∼tmp new ArrayList; this.index = 0; list.<init>(3); tmp = new Object[capacity]; this.data = tmp; Object o1=new Object; } <init>() Object o2=new Object; void add(Object o) this ∼ tmp

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    72 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us