+ All Categories
Home > Technology > TMPA-2017: Static Checking of Array Objects in JavaScript

TMPA-2017: Static Checking of Array Objects in JavaScript

Date post: 05-Apr-2017
Category:
Upload: iosif-itkin
View: 145 times
Download: 1 times
Share this document with a friend
16
Astrid Younang & Lunjin Lu & Nabil Almashfi March 3,2017
Transcript

Astrid Younang & Lunjin Lu & Nabil Almashfi

March 3,2017

Outline

1. Motivation

2. Related Work

3. Conventionality Analysis

4. Conclusion and Future Work

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

Abstract string domain- Operations

n – a non-index numeric stringr – a non-numeric string

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

Studied 98 benchmark programs

70 out of them had less than 2 arrays (were omitted)

Evaluation

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

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


Recommended