1/31
Understanding and Verifying JavaScript Programs
Philippa Gardner
Imperial College London
Understanding and Verifying JavaScript Programs Philippa Gardner - - PowerPoint PPT Presentation
Understanding and Verifying JavaScript Programs Philippa Gardner Imperial College London LFCS 30th Anniversary 1/31 JavaScript at Imperial Philippa Gardner Jos e Fragoso Santos Petar Maksimovi c Daiva Naud zi unien e Azalea
1/31
Imperial College London
2/31
Philippa Gardner Jos´ e Fragoso Santos Petar Maksimovi´ c Daiva Naudˇ zi¯ unien˙ e Azalea Raad Thomas Wood
3/31
4/31
4/31
4/31
JSCert JavaScript JSRef Test262
eraud
4/31
5/31
6/31
7/31
8/31
9/31
10/31
11/31
12/31
Core ES5 Strict JSCert
Non-core libraries Semantics-directed compilation
12/31
Core ES5 Strict JSCert
Non-core libraries Semantics-directed compilation
13/31
13/31
13/31
13/31
13/31
14/31
15/31
16/31
Object.prototype.foo = 1; var bar = 2; function f() { this.baz = this.bar + foo; } f.prototype.bar = 3
17/31
Object.prototype.foo = 1; var bar = 2; function f() { this.baz = this.bar + foo; } f.prototype.bar = 3
[lop, “foo”] := 1
18/31
Object.prototype.foo = 1; var bar = 2; function f() { this.baz = this.bar + foo; } f.prototype.bar = 3
[lg, “bar”] := 2
19/31
Object.prototype.foo = 1; var bar = 2; function f() { this.baz = this.bar + foo; } f.prototype.bar = 3
xfp := new() [xfp, @proto] := lop xfo := new() [xfo, @code] := “f” [xfo, @scope] := [lg] [xfo, @proto] := ... [xfo, ”prototype”] := xfp [lg, “f”] := xfo
20/31
Object.prototype.foo = 1; var bar = 2; function f() { this.baz = this.bar + foo; } f.prototype.bar = 3
[xfp, “bar”] := 3
21/31
Object.prototype.foo = 1; var bar = 2; function f() { this.baz = this.bar + foo; } f.prototype.bar = 3
− constructor call
xn := new() xfo := [lg, “f”] xfp := [xfo, “prototype”] [xn, @proto] := xfp xscope := [xfo, @scope] xthis := xn xf := [xfo, @code] xret := xf (xscope, xthis)
22/31
this.baz = this.bar + foo
22/31
this.baz = this.bar + foo ln.obaz
Step 1
22/31
this.baz = this.bar + foo ln.obaz
Step 1
ln.obar
Step 2
22/31
this.baz = this.bar + foo ln.obaz
Step 1
ln.obar
Step 2
getValue(ln.obar)
Step 3
22/31
this.baz = this.bar + foo ln.obaz
Step 1
ln.obar
Step 2
getValue(ln.obar)
Step 3
3
Step 4
22/31
this.baz = this.bar + foo ln.obaz
Step 1
ln.obar
Step 2
getValue(ln.obar)
Step 3
3
Step 4
lg.vfoo
Step 5
22/31
this.baz = this.bar + foo ln.obaz
Step 1
ln.obar
Step 2
getValue(ln.obar)
Step 3
3
Step 4
lg.vfoo
Step 5
getValue(lg.vfoo)
Step 6
22/31
this.baz = this.bar + foo ln.obaz
Step 1
ln.obar
Step 2
getValue(ln.obar)
Step 3
3
Step 4
lg.vfoo
Step 5
getValue(lg.vfoo)
Step 6
1
Step 7
22/31
this.baz = this.bar + foo ln.obaz
Step 1
ln.obar
Step 2
getValue(ln.obar)
Step 3
3
Step 4
lg.vfoo
Step 5
getValue(lg.vfoo)
Step 6
1
Step 7
4
Step 8 Step 8
22/31
this.baz = this.bar + foo ln.obaz
Step 1
ln.obar
Step 2
getValue(ln.obar)
Step 3
3
Step 4
lg.vfoo
Step 5
getValue(lg.vfoo)
Step 6
1
Step 7
4
Step 8 Step 8
23/31
this.baz = this.bar + foo undefined.obaz
Step 1
undefined.obar
Step 2
getValue(undefined.obar)
Step 3
ERROR
Step 4
24/31
this.baz = this.bar + foo lg.obaz
Step 1
lg.obar
Step 2
getValue(lg.obar)
Step 3
2
Step 4
lg.vfoo
Step 5
getValue(lg.vfoo)
Step 6
1
Step 7
3
Step 8 Step 8
25/31
Core ES5 Strict JSCert
Non-core libraries
Semantics-directed compilation. Pen-and-paper correctness proof. Extensive testing using the Test262 conformance test suite.
26/31
ES6 Test262 14998 tests Considerably better test classification than ES5 Test262.
26/31
ES6 Test262 14998 tests Considerably better test classification than ES5 Test262. ES5 Strict 10958 Tests Tests for ES6 features, Annex B, non-strict mode features
26/31
ES6 Test262 14998 tests Considerably better test classification than ES5 Test262. ES5 Strict 10958 Tests Tests for ES6 features, Annex B, non-strict mode features Core ES5 Strict 4599 Tests Tests for non-core features
26/31
ES6 Test262 14998 tests Considerably better test classification than ES5 Test262. ES5 Strict 10958 Tests Tests for ES6 features, Annex B, non-strict mode features Core ES5 Strict 4599 Tests Tests for non-core features Compiler Coverage 2738 Tests Tests for core features still to be implemented
26/31
ES6 Test262 14998 tests Considerably better test classification than ES5 Test262. ES5 Strict 10958 Tests Tests for ES6 features, Annex B, non-strict mode features Core ES5 Strict 4599 Tests Tests for non-core features Compiler Coverage 2738 Tests Tests for core features still to be implemented Tests using non-implemented core features Compiler Coverage 2481 Tests
26/31
ES6 Test262 14998 tests Considerably better test classification than ES5 Test262. ES5 Strict 10958 Tests Tests for ES6 features, Annex B, non-strict mode features Core ES5 Strict 4599 Tests Tests for non-core features Compiler Coverage 2738 Tests Tests for core features still to be implemented Tests using non-implemented core features Tests using non-core features Compiler Coverage 2481 Tests Compiler Coverage 2388 Tests
26/31
ES6 Test262 14998 tests Considerably better test classification than ES5 Test262. ES5 Strict 10958 Tests Tests for ES6 features, Annex B, non-strict mode features Core ES5 Strict 4599 Tests Tests for non-core features Compiler Coverage 2738 Tests Tests for core features still to be implemented Tests using non-implemented core features Tests using non-core features Compiler Coverage 2481 Tests Compiler Coverage 2388 Tests 99.6% success rate, 2378 passes, 10 failures due to parser issues, string/number conversion
27/31
Core ES5 Strict JSCert
Non-core libraries
28/31
getValue(ln.obar) 3
29/31
getValue(undefined.obar) ERROR
30/31
Core ES5 Strict JSCert
Non-core libraries
31/31
Infer (Facebook) CBMC (Oxford/Amazon) Rosette JSVerify Core ES5 Strict JSCert
Non-core libraries