Hybrid DOM-Sensitive Change Impact Analysis for JavaScript Saba - - PowerPoint PPT Presentation

hybrid dom sensitive change impact analysis for javascript
SMART_READER_LITE
LIVE PREVIEW

Hybrid DOM-Sensitive Change Impact Analysis for JavaScript Saba - - PowerPoint PPT Presentation

Hybrid DOM-Sensitive Change Impact Analysis for JavaScript Saba Alimadadi, Ali Mesbah and Karthik Pattabiraman ECOOP 2015 saba@ece.ubc.ca Change Impact Analysis (CIA) ! Software must continually change to adapt to the changing environment.


slide-1
SLIDE 1

Hybrid DOM-Sensitive Change Impact Analysis for JavaScript

Saba Alimadadi, Ali Mesbah and Karthik Pattabiraman

ECOOP 2015 saba@ece.ubc.ca

slide-2
SLIDE 2

Change Impact Analysis (CIA)!

  • Software must continually change to adapt to

the changing environment.

  • Goal: identifying parts of the program that are

potentially affected by a change.

1!

slide-3
SLIDE 3

Challenges of CIA for JavaScript!

2!

JavaScript DOM Server

slide-4
SLIDE 4

Challenge 1: Impact through the DOM!

3!

JavaScript DOM

function calculateTax() { $(‘.price’).each(function(index) { $(this).text(addTaxToPrice( $(this).text()); }); } function checkPrice() { . . . var cad_price = $(‘#price_ca’).innerText(); . . . }

id=price_ca

fieldset

div div body

class=price

slide-5
SLIDE 5

Challenge 2: Impact through Event Propagation!

4!

JavaScript DOM

function checkPrice() { . . . } fieldset

div div body

id=price_ca name=prices

function calculateTax() { . . . } $(‘#price_ca’).bind(‘click’, checkPrice); $(‘prices’).bind(‘click’, calculateTax);

slide-6
SLIDE 6

Challenge 3: Impact through XHRs!

5!

function updateItem(xhr) { var updatedInfo = getUpdatedPrice(xhr.responseText); suggestItem.apply(this, updatedInfo); } function checkPrice() { var itemName = extractName($(‘item231’)O; $.ajax({ url : ‘prices/latest.php’, type : ‘POST’, data : itemName, success : eval(getAction() + ‘item’) }); }

XHR!

JavaScript Server

slide-7
SLIDE 7

Challenges of CIA for Client-Side JavaScript

  • 1. JavaScript and Document Object Model (DOM)
  • 2. Events and event propagation
  • 3. JavaScript and XMLHttpRequests (XHRs)

+ High dynamism of JavaScript

6!

slide-8
SLIDE 8

Exploratory Study: DOM-related and Event-based Impacts

  • Subject: 10 web apps (online contests, GitHub trending, etc.)
  • Gathered data:

– JavaScript-DOM interactions (write-read pairs) – Event propagation

  • Further analysis of the structure of graphs.

– Measured metrics: fan-in and fan-out of functions and DOM elements, and average path lengths

7!

slide-9
SLIDE 9

Exploratory Study: Results!

  • W-R DOM elements:

42%

8!

  • Propagated handlers:

14%

42% 58%

DOM Elements

W-R Elements

14% 86%

Event Handlers

Propagated

foo() elem bar()

slide-10
SLIDE 10

Hybrid Analysis!

9!

Static Analysis Dynamic Analysis Hybrid Model Ranked Impact Sets

slide-11
SLIDE 11

Static Analysis!

10!

Dynamic Analysis Hybrid Model Ranked Impact Sets Static Analysis

Control (and data) dependencies Partial data-flow analysis

slide-12
SLIDE 12

Example: Static Model!

11!

checkPrice()! XHR! updateItem()! suggestItem()! getUpdatedPrice()! calculateTax()! addTaxToPrice()!

Function XHR object DOM element Directed and labeled edge

slide-13
SLIDE 13

Dynamic Analysis!

12!

Dynamic Analysis Hybrid Model Ranked Impact Sets Static Analysis

Impact through DOM

foo() elem bar()

Impact through events XHR relations

(open, send, response)

Dynamic call graph JavaScript dynamism

(eval(), function variadicity)

slide-14
SLIDE 14

Example: Dynamic Model!

13!

checkPrice()! XHR! updateItem()! suggestItem()! getUpdatedPrice()! calculateTax()! #item231! #priceGca! .price! displaySuggesKon()!

Function XHR object DOM element Directed and labeled edge

slide-15
SLIDE 15

14!

Static Analysis Dynamic Analysis Hybrid Model Ranked Impact Sets

slide-16
SLIDE 16

Example: Hybrid Analysis!

15! 15!

checkPrice()! XHR! updateItem()! suggestItem()! getUpdatedPrice()! calculateTax()! addTaxToPrice()! #item231! #priceGca! .price! displaySuggesKon()!

Function XHR object DOM element Directed and labeled edge

Vertices Edges

slide-17
SLIDE 17

16!

Static Analysis Dynamic Analysis Hybrid Model Ranked Impact Sets

slide-18
SLIDE 18

Impact Metrics and Impact Set Ranking

  • Problem: size of impact sets
  • Solutions: impact ranks, based on impact

metrics

– fin(d): Number of functions f such that f W d – fin(f): Number of elements d such that f R d – fout(f): Number of elements d such that f W d – Lavg(P): Average length of impact paths in the app – Dm(e): Minimum distance of e from the change set – IRpr(e): Impact of previous entity

17!

slide-19
SLIDE 19

Tool Implementation: Tochal

  • Tochal: open source

– https://github.com/saltlab/tochal

  • Proxy (Java, JavaScript)

– Esprima, Estraverse, Escodegen, Mutation Summary, WALA

  • Client-side (Google Chrome extension)

– Chrome DevTools

18!

slide-20
SLIDE 20

Research Question 1

Does Tochal outperform static and dynamic analysis methods in terms of the completeness of the results obtained?

19!

slide-21
SLIDE 21

Study: Static vs. Dynamic vs. Tochal

  • 10 web applications
  • 3 random functions as change sets
  • Comparing:

– Size of impact sets – Number of functions in dependency graphs

20!

slide-22
SLIDE 22

Results: Impact Sets

  • Comparing size of impact sets

21

0.5 1 1.5 2 Static Dynamic Tochal

Static Hybrid : 26% Dynamic Hybrid : 80%

slide-23
SLIDE 23

Results: Graphs

  • Comparing size of model graphs

22

Static Hybrid : 59% Dynamic Hybrid : 84%

Static Dynamic

slide-24
SLIDE 24

Results: Graphs

  • Comparing size of model graphs

23

Pure Static Hybrid : 15% Pure Dynamic Hybrid : 42%

Static Dynamic

slide-25
SLIDE 25

Research Question 2

24!

Does Tochal help developers in practice to perform change impact analysis?

slide-26
SLIDE 26

Experiment: Design

  • 12 participants from industry
  • Performed 4 tasks
  • We measured task completion

duration and accuracy

25!

Task Description T1

Finding the potential impact of a DOM element

T2

Finding the potential impact of a JavaScript function

T3

Finding a conflict after making a new change (no ranking)

T4

Finding a bug in JavaScript code

slide-27
SLIDE 27

User Experiment: Results!

26! 300 600 900 1200 1500 1800 2100 2400

T1 T2 T3 T4 Total Tochal Other

20 40 60 80 100

T1 T2 T3 T4 Total Tochal Other

Accuracy Duration 80% faster 2 times more accurate

slide-28
SLIDE 28

Results: Ranking

Duration Accuracy

0:00! 1:12! 2:24! 3:36! 4:48! 6:00! 7:12!

W/O rank W/ rank

2~3 times faster 25% more accurate

20 40 60 80 100

slide-29
SLIDE 29

28!