Challenges in Pointer Analysis of JavaScript

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

My first computer: The Apple ][ It wanted to be programmed.
Pointer Analysis – Part I Mayur Naik Intel Research, Berkeley CS294 Lecture March 17, 2009.
GATEKEEPER MOSTLY STATIC ENFORCEMENT OF SECURITY AND RELIABILITY PROPERTIES FOR JAVASCRIPT CODE Salvatore Guarnieri & Benjamin Livshits Presented by Michael.
Web Server Programming
1 / 28 Modeling the HTML DOM and Browser API in Static Analysis of JavaScript Web Applications ESEC/FSE 2011 Anders Møller, Magnus Madsen and Simon Holm.
Run time vs. Compile time
Staged Information Flow for JavaScript Ravi Chugh, Jeff Meister, Ranjit Jhala, Sorin Lerner UC San Diego.
V1.00 © 2009 Research In Motion Limited Introduction to Mobile Device Web Development Trainer name Date.
Development of mobile applications using PhoneGap and HTML 5
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Automatic Mediation Of Privacy-sensitive Resource Access In Smartphone Applications Ben Livshits and Jaeyeon Jung Microsoft Research.
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
Object Oriented Databases by Adam Stevenson. Object Databases Became commercially popular in mid 1990’s Became commercially popular in mid 1990’s You.
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
Gulfstream Salvatore Guarnieri University of Washington Ben Livshits Microsoft Research Staged Static Analysis for Streaming JavaScript Applications.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Angelo Chan Kamran Bilgrami. Agenda ● WinJS - What and Why ● Modern Apps ● WinRT Architecture ● Demos o Controls o Data Bindings o Program LifeCycle Management.
Test Of Distributed Data Quality Monitoring Of CMS Tracker Dataset H->ZZ->2e2mu with PileUp - 10,000 events ( ~ 50,000 hits for events) The monitoring.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
HTML5 for Mobile Andrew Kinai. HTML vs HTML5 HTML:A language that describes documents' formatting and content, which is basically composed of static text.
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
Chapter 5: Programming Languages and Constructs by Ravi Sethi Activation Records Dolores Zage.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
1 JavaScript in Context. Server-Side Programming.
Cross Site Integration “mashups” cross site scripting.
AjaxScope & Doloto: Towards Optimizing Client-side Web 2.0 App Performance Ben Livshits Microsoft Research (joint work with Emre.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Mobile web Sebastian Lopienski IT Technical Forum 29 June 2012.
Session: 1. © Aptech Ltd. 2Introduction to the Web / Session 1  Explain the evolution of HTML  Explain the page structure used by HTML  List the drawbacks.
Introduction to JavaScript CS101 Introduction to Computing.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
CSE 425: Control Abstraction I Functions vs. Procedures It is useful to differentiate functions vs. procedures –Procedures have side effects but usually.
CS 343 presentation Concrete Type Inference Department of Computer Science Stanford University.
© 2011 IBM Corporation Hybrid Analysis for JavaScript Security Assessment Omer Tripp Omri Weisman Salvatore Guarnieri IBM Software Group Sep 2011.
Internet Explorer 10 IE9 hardware-accelerated platform CSS 2D Transforms CSS Backgrounds & Borders CSS Color CSS Fonts CSS Media Queries CSS Namespaces.
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
The Ins and Outs of Gradual Type Inference Avik Chaudhuri Basil Hosmer Adobe Systems Aseem Rastogi Stony Brook University.
Agenda 1)Modern web standards overview 2)JavaScript library overview 3)Building a Single Page Application SPA.
Microsoft Visual Basic 2015 CHAPTER ONE Introduction to Visual Basic 2015 Programming.
丁建文 國立高雄應用科大資管系副教授 兼任計網中心軟體發展組組長 跨平台行動應用軟體開發技術 : HTML5 & Mobile JavaScript Framework 暨南大學.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
INTRODUCING HYBRID APP KAU with MICT PARK IT COMPANIES Supported by KOICA
QML and JavaScript for Native App Development Michael Tims Jen Trieu.
DHTML.
Internet of the Past.
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
Introduction to Visual Basic 2008 Programming
Introduction to Redux Header Eric W. Greene Microsoft Virtual Academy
Spark Presentation.
Apache Cordova Overview
Application with Cross-Platform GUI
MVC Framework, in general.
CSC 253 Lecture 8.
Programming vs. Packaged
JavaScript an introduction.
The Application Lifecycle
The Canvas.
CSC 253 Lecture 8.
CIS16 Application Development – Programming with Visual Basic
Where Intelligence Lives & Intelligence Management
CIS 133 mashup Javascript, jQuery and XML
An Introduction to JavaScript
Lecture 4: Instruction Set Design/Pipelining
Report from the trenches of an HTML5 game provider
Running C# in the browser
Blazor A new framework for browser-based .NET apps Ryan Nowak
Presentation transcript:

Challenges in Pointer Analysis of JavaScript Ben Livshits MSR

JavaScript leads the pack as most popular programming language Area man says: JavaScript leads the pack as most popular programming language

Two Issues in JavaScript Pointer Analysis

1is distributed Gulfstream JavaScript programs on the web are streaming Fully static analysis pointer analysis is not possible, calling for a hybrid approach Setting: analyzing pages before they reach the browser

2is distributed Use analysis JavaScript programs interop with a set of reach APIs such as the DOM We need to understand these APIs for analysis to be useful Setting: analyzing Win8 apps written in JavaScript

Gulfstream Staged Static Analysis for Streaming JavaScript Applications, Salvatore Guarnieri, Ben Livshits, WebApps 2009

Whole program analysis? What whole program?

JavaScript programs are streaming You might be wondering how one does this

Facebook Code Exploration

OWA Code Exploration

Script Creation What does f refer to? <HTML> <HEAD> <SCRIPT> function foo(){...} var f = foo; </SCRIPT> function bar(){...} if (...) f = bar; </HEAD> <BODY onclick="f();"> ...</BODY> </HTML> What does f refer to? Tell call graph story

Plan Server Client Pre-compute pointer information offline, for most of the program Optionally update server knowledge as more code is observed When more code is discovered, do analysis of it Combine the incremental results with pre-computed results

Gulfstream In Action Is it faster to Offline Online ✔ ✔ ✔ Is it faster to transfer pre-computed results + add incremental results Compute everything from scratch Proceeds in 2 stages Offline is done on server Online is done in the browser Checking a safety property Offline Online

Simulated Devices For each device we have relative CPU speed, and network parameters. It is these parameters that allow us to compare the effectiveness of gulfstream on different devices

Try Different Configurations Slow devices benefit from Gulfstream A slow network can negate the benefits of the staged analysis Large page updates don’t benefit from Gulfstream “+” means that staged incremental analysis is advantageous compared to full analysis on the client.

Gulfstream Savings: Fast Devices 10 seconds saved Savings were as much as 10 seconds

Gulfstream Savings: Slow Devices

Laptop Running Time Comparison Break even point: After 30KB of updates, incremental Gulfstream is no longer faster Explain static base page first call out colors

Conclusion Gulfstream, staged analysis for JavaScript WebApps 2010 Offline on the server Online in the browser Wide range of experiments For small updates, Gulfstream is faster Devices with slow CPU benefit most

Pointer Analysis and Use Analysis

Use Analysis Practical Static Analysis of JavaScript Applications in the Presence of Frameworks and Libraries, Madsen, Livshits, Fanning, in submission, 2013

Motivation: Win8 App Store Native C/C++ apps .NET aps JavaScript/HTML apps

Win8 & Web Applications Windows 8 App Web App Builtin Builtin DOM DOM WinJS WinJS Win8 Win8 Builtin Builtin DOM DOM jQuery jQuery … …

Practical Applications Call graph discovery API surface discovery Capability analysis Auto-complete Concrete type inference Runtime optimizations

Practical Applications Call graph discovery API surface discovery Capability analysis Auto-complete Concrete type inference Runtime optimizations Windows.Devices.Sensors Windows.Devices.Sms Windows.Media.Capture Windows.Networking.Sockets …

Practical Applications Call graph discovery API surface discovery Capability analysis Auto-complete Concrete type inference Runtime optimizations

Practical Applications Call graph discovery API surface discovery Capability analysis Auto-complete Concrete type inference Runtime optimizations

Practical Applications Call graph discovery API surface discovery Capability analysis Auto-complete Concrete type inference Runtime optimizations

Practical Applications Call graph discovery API surface discovery Capability analysis Auto-complete Concrete type inference Runtime optimizations str int ref ref memory layout

Canvas Dilemma var canvas = document.querySelector("#leftcol .logo"); var context = canvas.getContext("2d"); context.fillRect(20, 20, c.width / 2, c.height / 2); context.strokeRect(0, 0, c.width, c. height); model querySelector as returning a reference to HTMLElement:prototype However, HTMLElement:prototype does not define getContext, so getContext remains unresolved Model querySelector as returning any HTML element within underlying page Returns elements on which getContext is undefined

Introducing Use Analysis elm flows into playVideo elm flows into reset elm must have: muted and play elm must have: pause

Pointer vs. Use Analysis Pointer analysis deals with “concrete” facts Facts we can observe variables declared in the program allocation sites

Pointer vs. Use Analysis Use analysis deals with the “invisible” part of the heap It can exist entirely outside the JavaScript heap Constraints flows from callers to callees

Promises driveUtil.uploadFilesAsync( server.imagesFolderId). then( function (results) {...} )) analysis correctly maps then to WinJS:Promise:prototype.then

Local Storage var json = Windows.Storage. ApplicationData.current. localSettings.values[key]; correctly resolves localSettings to an instance of Windows:Storage:ApplicationDataContainer

Benchmarks 25 Windows 8 Apps: Average 1,587 lines of code Approx. 30,000 lines of stubs Average ~1.500 lines of code compared to almost ~30.000 lines of library stubs.

Evaluation: Summary The technique improves call graph resolution Unification is both effective and precise The technique improves auto-completion compared to what is found in four widely used IDEs Analysis completes in a reasonable amount of time

Call Graph Resolution Baseline Partial Median baseline resolution is 71.5% Baseline Median partial resolution is 81.5% Partial

Validating Results Incomplete is # of call sites which are sound, but have some spurious targets (i.e. imprecision is present) Unsound is the number of call sites for which some call targets are missing (i.e. the set of targets is too small ) Stubs is the number of call sites which were unresolved due to missing or faulty stubs.

Auto-complete We compared our technique to the auto-complete in four popular IDEs: Eclipse for JavaScript developers IntelliJ IDEA Visual Studio 2010 Visual Studio 2012 In all cases, where libraries were involved, our technique was an improvement

Auto-complete

Running Times All benchmarks complete within 22.0 sec Median runtime for partial is 10.5 sec Analysis is not incremental – room for improvement

Conclusion We have presented a technique for handling large and complex libraries in static analysis of JavaScript applications It is based on pointer analysis and use analysis It is implemented declaratively in Datalog It exists in two flavors: partial and full inference We have evaluated our technique on 25 Windows 8 applications Call graph resolution is improved Running time is reasonable We improve on auto-complete compared to four widely available JavaScript IDEs We have shown a variety of practical applications

Two Issues in JavaScript Pointer Analysis Gulfstream JSCap JavaScript programs on the web are streaming Fully static analysis pointer analysis is not possible, calling for a hybrid approach Setting: analyzing pages before they reach the browser JavaScript programs interop with a set of reach APIs such as the DOM We need to understand these APIs for analysis to be useful Setting: analyzing Win8 apps written in JavaScript