fast escape analysis for region based memory management
play

Fast Escape Analysis for Region-Based Memory Management Guillaume - PowerPoint PPT Presentation

Fast Escape Analysis for Region-Based Memory Management Guillaume Salagnac 1 , Sergio Yovine 1 , Diego Garbervetsky 2 salagnac@imag.fr, yovine@imag.fr, diegog@dc.uba.ar (1) Laboratoire Vrimag Grenoble France (2) School of Computer Science


  1. Fast Escape Analysis for Region-Based Memory Management Guillaume Salagnac 1 , Sergio Yovine 1 , Diego Garbervetsky 2 salagnac@imag.fr, yovine@imag.fr, diegog@dc.uba.ar (1) Laboratoire Vérimag Grenoble France (2) School of Computer Science Universidad de Buenos Aires Argentina. 1/11

  2. Introduction Java Attractive language No manual dynamic memory management Use for Real-time : Implementation pitfalls Virtual machine Garbage Collector 2/11

  3. Realtime specification for Java objects Allocate objects in regions One region per Runnable No more Garbage Collector Manual bookkeeping = ⇒ changes Java paradigm. Thread stack 3/11

  4. Our approach (work in progress) stay close to the Java model not all the advanced features no manual dynamic memory management semi-automatized development cycle development instrumented source instrumentation program code analysis fixing results 4/11

  5. The Analysis tradeoff between precision and performance variable-based VS points-to based start with the simpliest/fastest algorithm and add information alias analysis points-to analysis parameter binding at method call [G&S] D. Gay and B. Steensgaard. Fast escape analysis and stack allocation for object-based programs. In CC’00 . Springer-Verlag, 2000. 5/11

  6. The lattices ⊤ ր ↑ տ ∀ v , escape ( v ) ∈ Escape FIELD RETURNED STATIC տ ↑ ր ⊥ ∀ v , def ( v ) ∈ { NEW , RETVAL , PARAM , STATIC , COPY , PHI , FIELD , CONSTANT } ∀ v , fielduse ( v ) ⊆ { variables of m } ∀ v , sites ( v ) ⊆ AllocationSites ∪ { UNKNOWN } mrefs ⊆ AllocationSites × Fields × AllocationSites ∀ v , side ( v ) ∈ { INSIDE , OUTSIDE } 6/11

  7. The algorithm class RefObject { Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } return a; Object m1() { } RefObject c=m2(); } Object d=c.f; return d; } 7/11

  8. The algorithm class RefObject { Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } return a; Object m1() { } RefObject c=m2(); } Object d=c.f; return d; } escape m0 ⊥ ⊥ e m1 RETURNED ⊥ c d RETURNED m2 RETURNED a RETURNED b FIELD 7/11

  9. The algorithm class RefObject { Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } return a; Object m1() { } RefObject c=m2(); } Object d=c.f; return d; } escape def m0 ⊥ ⊥ e RETVAL m1 RETURNED ⊥ c RETVAL d RETURNED FIELD m2 RETURNED a RETURNED NEW b FIELD NEW 7/11

  10. The algorithm class RefObject { Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } return a; Object m1() { } RefObject c=m2(); } Object d=c.f; return d; } escape def fielduse m0 ⊥ ⊥ ∅ e RETVAL m1 RETURNED ⊥ ∅ c RETVAL d ∅ RETURNED FIELD m2 RETURNED ∅ a RETURNED NEW [a] b FIELD NEW 7/11

  11. The algorithm class RefObject { Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } return a; Object m1() { } RefObject c=m2(); } Object d=c.f; return d; } escape def fielduse sites mrefs m0 ⊥ ∅ [m2:b=new] ⊥ ∅ e RETVAL m2:a=new [m2:b=new] m1 RETURNED [m2:a=new] ⊥ ∅ c RETVAL f [m2:b=new] d ∅ RETURNED FIELD [m2:a=new] m2 m2:b=new RETURNED [m2:a=new] ∅ a RETURNED NEW [a] [m2:b=new] b FIELD NEW 7/11

  12. The algorithm class RefObject { Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } return a; Object m1() { } RefObject c=m2(); } Object d=c.f; return d; } escape def fielduse sites side mrefs m0 ⊥ ∅ [m2:b=new] ⊥ ∅ e RETVAL INSIDE m2:a=new [m2:b=new] m1 RETURNED [m2:a=new] ⊥ ∅ c RETVAL INSIDE f [m2:b=new] d ∅ RETURNED FIELD OUTSIDE [m2:a=new] m2 m2:b=new RETURNED [m2:a=new] ∅ a RETURNED NEW OUTSIDE [a] [m2:b=new] b FIELD NEW OUTSIDE 7/11

  13. Example2 class RefObject { static Object s; Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } s=b; Object m1() { return a; RefObject c=m2(); } Object d=c.f; } return d; } 8/11

  14. Example2 class RefObject { static Object s; Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } s=b; Object m1() { return a; RefObject c=m2(); } Object d=c.f; } return d; } escape m0 ⊥ ⊥ e m1 RETURNED ⊥ c d RETURNED m2 RETURNED a RETURNED b ⊤ 8/11

  15. Example2 class RefObject { static Object s; Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } s=b; Object m1() { return a; RefObject c=m2(); } Object d=c.f; } return d; } escape def m0 ⊥ ⊥ e RETVAL m1 RETURNED ⊥ c RETVAL d RETURNED FIELD m2 RETURNED a RETURNED NEW b ⊤ NEW 8/11

  16. Example2 class RefObject { static Object s; Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } s=b; Object m1() { return a; RefObject c=m2(); } Object d=c.f; } return d; } escape def fielduse m0 ⊥ ⊥ ∅ e RETVAL m1 RETURNED ⊥ ∅ c RETVAL d ∅ RETURNED FIELD m2 RETURNED ∅ a RETURNED NEW [a] b ⊤ NEW 8/11

  17. Example2 class RefObject { static Object s; Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } s=b; Object m1() { return a; RefObject c=m2(); } Object d=c.f; } return d; } mrefs escape def fielduse sites m2:a=new m0 ⊥ ∅ [m2:b=new] e ⊥ ∅ RETVAL f [m2:b=new] m1 RETURNED [m2:a=new] ⊥ ∅ c RETVAL m2:b=new [m2:b=new] d ∅ RETURNED FIELD [m2:a=new] m2 RETURNED [m2:a=new] a ∅ RETURNED NEW [a] [m2:b=new] UNKNOWN b ⊤ NEW 8/11

  18. Example2 class RefObject { static Object s; Object f; } RefObject m2() { class Example1 { RefObject a=new RefObject(); void m0() { Object b=new Object(); Object e=m1(); a.f=b; } s=b; Object m1() { return a; RefObject c=m2(); } Object d=c.f; } return d; } mrefs escape def fielduse sites side m2:a=new m0 ⊥ ∅ [m2:b=new] e ⊥ ∅ RETVAL OUTSIDE f [m2:b=new] m1 RETURNED [m2:a=new] ⊥ ∅ c RETVAL INSIDE m2:b=new [m2:b=new] d ∅ RETURNED FIELD OUTSIDE [m2:a=new] m2 RETURNED [m2:a=new] a ∅ RETURNED NEW OUTSIDE [a] [m2:b=new] UNKNOWN b ⊤ NEW OUTSIDE 8/11

  19. Example3 class RefObject { Object f; void m1(RefObject x) } { class Example3 { Object a=x.f; void m0() { Object b=a; RefObject t1=new RefObject(); } Object t2=new Object(); } t1.f=t2; m1(t1); } 9/11

  20. Example3 class RefObject { Object f; void m1(RefObject x) } { class Example3 { Object a=x.f; void m0() { Object b=a; RefObject t1=new RefObject(); } Object t2=new Object(); } t1.f=t2; m1(t1); } escape m0 ⊥ ⊥ t1 t2 FIELD m1 ⊥ ⊥ x a ⊥ b ⊥ 9/11

  21. Example3 class RefObject { Object f; void m1(RefObject x) } { class Example3 { Object a=x.f; void m0() { Object b=a; RefObject t1=new RefObject(); } Object t2=new Object(); } t1.f=t2; m1(t1); } escape def m0 ⊥ ⊥ t1 NEW t2 FIELD NEW m1 ⊥ ⊥ x PARAM a ⊥ FIELD b ⊥ COPY 9/11

  22. Example3 class RefObject { Object f; void m1(RefObject x) } { class Example3 { Object a=x.f; void m0() { Object b=a; RefObject t1=new RefObject(); } Object t2=new Object(); } t1.f=t2; m1(t1); } escape def IsD uP m0 ⊥ ⊥ t1 true true NEW t2 false false FIELD NEW m1 ⊥ ⊥ x true false PARAM a ⊥ false false FIELD b ⊥ false false COPY 9/11

  23. Example3 class RefObject { Object f; void m1(RefObject x) } { class Example3 { Object a=x.f; void m0() { Object b=a; RefObject t1=new RefObject(); } Object t2=new Object(); } t1.f=t2; m1(t1); } escape def IsD uP fielduse m0 ⊥ ⊥ ∅ t1 true true NEW [t1] t2 false false FIELD NEW m1 ⊥ ⊥ ∅ x true false PARAM a ⊥ false false ∅ FIELD b ⊥ false false ∅ COPY 9/11

  24. Example3 class RefObject { Object f; void m1(RefObject x) } { class Example3 { Object a=x.f; void m0() { Object b=a; RefObject t1=new RefObject(); } Object t2=new Object(); } t1.f=t2; m1(t1); } mrefs escape def IsD uP fielduse sites m0:t1=new m0 ⊥ ∅ [m0:t1=new] f ⊥ ∅ t1 true true NEW [t1] [m0:t2=new] t2 false false FIELD NEW m0:t2=new m1 ⊥ ∅ [UNKNOWN] x ⊥ true false ∅ PARAM [UNKNOWN] a ⊥ false false ∅ FIELD [UNKNOWN] UNKNOWN ⊥ ∅ b false false COPY 9/11

Recommend


More recommend