Slide 1

Slide 1 text

Astrid Younang & Lunjin Lu & Nabil Almashfi March 3,2017

Slide 2

Slide 2 text

Outline 1. Motivation 2. Related Work 3. Conventionality Analysis 4. Conclusion and Future Work

Slide 3

Slide 3 text

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 ?

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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”, SNum true // A is not conventional “length”  11

Slide 6

Slide 6 text

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?

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

Related Work Existing abstract string domains  do not track range of indexes (which are strings) precisely  do not supports conventionality analysis

Slide 9

Slide 9 text

Abstract string domain 

Slide 10

Slide 10 text

Abstract string domain- Operations n – a non-index numeric string r – a non-numeric string

Slide 11

Slide 11 text

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 --

Slide 12

Slide 12 text

Evaluation  Studied 98 benchmark programs  70 out of them had less than 2 arrays (were omitted)

Slide 13

Slide 13 text

Evaluation

Slide 14

Slide 14 text

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.

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Conclusion & Future work  Conventionality analysis can be integrated in static analyzers  Future work will investigate the use the use of array information for performance optimization