from object fields to local variables a practical
play

From Object Fields to Local Variables: a Practical Approach to - PowerPoint PPT Presentation

From Object Fields to Local Variables: a Practical Approach to Field-Sensitive Analysis Elvira Albert (1) , Puri Arenas (1) , Samir Genaim (1) , an Puebla (2) and Diana Ram rez (2) Germ (1) Complutense University of Madrid (2) Technical


  1. From Object Fields to Local Variables: a Practical Approach to Field-Sensitive Analysis Elvira Albert (1) , Puri Arenas (1) , Samir Genaim (1) , an Puebla (2) and Diana Ram´ ırez (2) Germ´ (1) Complutense University of Madrid (2) Technical University of Madrid 17th International Static Analysis Symposium Perpignan, France Elvira Albert, UCM From Object Fields to Local Variables 1/21

  2. From Object Fields to Local Variables: a Practical Approach to Field-Sensitive Analysis Elvira Albert (1) , Puri Arenas (1) , Samir Genaim (1) , an Puebla (2) and Diana Ram´ ırez (2) Germ´ (1) Complutense University of Madrid (2) Technical University of Madrid 17th International Static Analysis Symposium Perpignan, France Elvira Albert, UCM From Object Fields to Local Variables 1/21

  3. Field-sensitive vs. Field-Insensitive Analysis Static analysis of object fields (numeric or references) classified: field-sensitive - approximate them precise but .... inefficient ! field-insensitive - ignore them efficient but .... imprecise ! Elvira Albert, UCM From Object Fields to Local Variables 2/21

  4. Field-sensitive vs. Field-Insensitive Analysis Static analysis of object fields (numeric or references) classified: field-sensitive - approximate them precise but .... inefficient ! field-insensitive - ignore them efficient but .... imprecise ! Heuristics exist which differ in how the value of fields is modeled field-based analysis : modeling all instances of a field in a single abstraction. Efficient but imprecise . Elvira Albert, UCM From Object Fields to Local Variables 2/21

  5. Field-sensitive vs. Field-Insensitive Analysis Static analysis of object fields (numeric or references) classified: field-sensitive - approximate them precise but .... inefficient ! field-insensitive - ignore them efficient but .... imprecise ! Heuristics exist which differ in how the value of fields is modeled field-based analysis : modeling all instances of a field in a single abstraction. Efficient but imprecise . Challenge: develop techniques that have good balance between: accuracy of analysis. computational cost. Elvira Albert, UCM From Object Fields to Local Variables 2/21

  6. Field-Sensitive Termination Analysis Automated techniques for proving termination are typically based on analyses which track size information . Elvira Albert, UCM From Object Fields to Local Variables 3/21

  7. Field-Sensitive Termination Analysis Automated techniques for proving termination are typically based on analyses which track size information . How the size of the data involved in loop guards changes when the loop goes through its iterations . Elvira Albert, UCM From Object Fields to Local Variables 3/21

  8. Field-Sensitive Termination Analysis Automated techniques for proving termination are typically based on analyses which track size information . How the size of the data involved in loop guards changes when the loop goes through its iterations . Determine (the existence of) a ranking function for the loop (function which strictly decreases on a well-founded domain). Elvira Albert, UCM From Object Fields to Local Variables 3/21

  9. Field-Sensitive Termination Analysis Automated techniques for proving termination are typically based on analyses which track size information . How the size of the data involved in loop guards changes when the loop goes through its iterations . Determine (the existence of) a ranking function for the loop (function which strictly decreases on a well-founded domain). while (i < n ) { i++;o.m(); } n-i is a ranking function Elvira Albert, UCM From Object Fields to Local Variables 3/21

  10. Field-Sensitive Termination Analysis Automated techniques for proving termination are typically based on analyses which track size information . How the size of the data involved in loop guards changes when the loop goes through its iterations . Determine (the existence of) a ranking function for the loop (function which strictly decreases on a well-founded domain). while (i < n ) { i++;o.m(); } n-i is a ranking function while (i < f.n ) { i++;o.m(); } f.n-i ranking function? Elvira Albert, UCM From Object Fields to Local Variables 3/21

  11. Field-Sensitive Termination Analysis Automated techniques for proving termination are typically based on analyses which track size information . How the size of the data involved in loop guards changes when the loop goes through its iterations . Determine (the existence of) a ranking function for the loop (function which strictly decreases on a well-founded domain). while (i < n ) { i++;o.m(); } n-i is a ranking function while (i < f.n ) { i++;o.m(); } f.n-i ranking function? Data stored in the heap is rather difficult to reason about statically because it is: shared (i.e., aliases are allowed). mutable (i.e., can be modified multiple times). Elvira Albert, UCM From Object Fields to Local Variables 3/21

  12. Field-sensitive by field-insensitive analysis Overview of our approach : while (i < f.n ) { i = i++; o.m() ; } ; Elvira Albert, UCM From Object Fields to Local Variables 4/21

  13. Field-sensitive by field-insensitive analysis Overview of our approach : while (i < f.n ) { i = i++; o.m() ; } ; 1. Partition the program in fragments (scopes). Elvira Albert, UCM From Object Fields to Local Variables 4/21

  14. Field-sensitive by field-insensitive analysis Overview of our approach : while (i < f.n ) { i = i++; o.m() ; } ; 1. Partition the program in fragments (scopes). 2. Model only those fields which behave as local variables . Elvira Albert, UCM From Object Fields to Local Variables 4/21

  15. Field-sensitive by field-insensitive analysis Overview of our approach : while (i < f.n ) { i = i++; o.m() ; } ; 1. Partition the program in fragments (scopes). 2. Model only those fields which behave as local variables . 3. Transform the code to replace local fields by variables. Elvira Albert, UCM From Object Fields to Local Variables 4/21

  16. Field-sensitive by field-insensitive analysis Overview of our approach : while (i < v ) { f.n i = i++; v = o.m(v) ; } ; 1. Partition the program in fragments (scopes). 2. Model only those fields which behave as local variables . 3. Transform the code to replace local fields by variables. Elvira Albert, UCM From Object Fields to Local Variables 4/21

  17. Field-sensitive by field-insensitive analysis Overview of our approach : while (i < v ) { f.n i = i++; v = o.m(v) ; } ; 1. Partition the program in fragments (scopes). 2. Model only those fields which behave as local variables . 3. Transform the code to replace local fields by variables. 4. Infer information on the fields through ghost variables . Elvira Albert, UCM From Object Fields to Local Variables 4/21

  18. Field-sensitive by field-insensitive analysis Overview of our approach : v = f.n; while (i < v ) { f.n i = i++; v = o.m(v) ; } ; f.n = v ; 1. Partition the program in fragments (scopes). 2. Model only those fields which behave as local variables . 3. Transform the code to replace local fields by variables. 4. Infer information on the fields through ghost variables . Elvira Albert, UCM From Object Fields to Local Variables 4/21

  19. Step 1: Proving Locality of Object Fields Elvira Albert, UCM From Object Fields to Local Variables 5/21

  20. Locality Conditions for Scopes Sufficient Conditions 1. Memory location where the field is stored does not change . 2. All accesses done through the same reference ( not aliases ). Elvira Albert, UCM From Object Fields to Local Variables 6/21

  21. Locality Conditions for Scopes Sufficient Conditions 1. Memory location where the field is stored does not change . 2. All accesses done through the same reference ( not aliases ). example 1 if (k > 0) x = z; else x = y; x.f=10; for(; i < x.f ; i++) b[i]=x.b[i]; Elvira Albert, UCM From Object Fields to Local Variables 6/21

  22. Locality Conditions for Scopes Sufficient Conditions 1. Memory location where the field is stored does not change . 2. All accesses done through the same reference ( not aliases ). example 1 if (k > 0) x = z; else x = y; x.f=10; for(; i < x.f ; i++) b[i]=x.b[i]; Elvira Albert, UCM From Object Fields to Local Variables 6/21

  23. Locality Conditions for Scopes Sufficient Conditions 1. Memory location where the field is stored does not change . 2. All accesses done through the same reference ( not aliases ). example 1 if (k > 0) x = z; else x = y; x.f=10; for(; i < x.f ; i++) b[i]=x.b[i]; Elvira Albert, UCM From Object Fields to Local Variables 6/21

  24. Locality Conditions for Scopes Sufficient Conditions 1. Memory location where the field is stored does not change . 2. All accesses done through the same reference ( not aliases ). example 2 while (x != null) { for (; x.c < n; x.c ++) value[ x.c ]++; x = x.next; } Elvira Albert, UCM From Object Fields to Local Variables 6/21

  25. Locality Conditions for Scopes Sufficient Conditions 1. Memory location where the field is stored does not change . 2. All accesses done through the same reference ( not aliases ). example 2 while (x != null) { for (; x.c < n; x.c ++) value[ x.c ]++; x = x.next; } Elvira Albert, UCM From Object Fields to Local Variables 6/21

  26. Locality Conditions for Scopes Sufficient Conditions 1. Memory location where the field is stored does not change . 2. All accesses done through the same reference ( not aliases ). example 2 while (x != null) { for (; x.c < n; x.c ++) value[ x.c ]++; x = x.next; } Elvira Albert, UCM From Object Fields to Local Variables 6/21

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend