Date post: | 05-Apr-2017 |
Category: |
Technology |
Upload: | iosif-itkin |
View: | 145 times |
Download: | 1 times |
Motivation
JavaScript objects have dynamic set of fields (properties)
Arrays are just like regular objects with the property (field) length that is automatically updated;
Arrays can have fields whose names are not indices;
Are they used like regular objects?
Are they used in a conventional way like in Java ?
Motivation
A conventional array is an array that does not have any properties other than indices and length.
Conventionality analysis
• provides valuable information for program comprehension
• provides valuable information for performance optimization
• Feature to add to JavaScript development tool
var A = [ ] ; / New empty array /var i ;
function populate_array (x,y,A) {for (i=x ; i<=y ; i++) {
A[i]= 2*i +10;}return A;
}
A = populate_array (0, 3, A) ;A = populate_array (6, 10, A) ;A.prop1 = “foo” ;i= -3.5; A[i] = true;
[0, 3] [10,16], [6,10] [22,30], // A has indexes 0—3, 6—10// A is not dense
“prop1” “foo”, SNumtrue // A is not conventional“length” 11
Information tracked by conventional analysis String information: what strings a variable can take as
value?
Number information: what numbers a variable can take as a value?
Type information: is a number definitely integer or possibly a floating point number?
Related Work
Existing abstract string domains
Constant propagation domain for strings (TAJS, SAFE, JSAI)
Character inclusion, prefix domain, suffix domain, bricks and string graphs
Automata-based string domains
Related Work
Existing abstract string domains
do not track range of indexes (which are strings) precisely
do not supports conventionality analysis
Abstract numeric domain
Range -- Interval domain
intv(3,5) – all numbers between 3 and 5
norm(3,5) – all numbers between 3 and d plus NaN
Type -- <int, any>
Evaluation
Only conventional arrays were found on GitHub
o Programmers most likely use arrays in a conventional way and flagging possible non-conventional arrays provides useful information during program development.
Evaluation
Arrays are used in a conventional way in 95% of the benchmark programs.
Storage of single/mixed types
o 377 arrays analyzed
o 11.93% - string values
o 33% - integer values