p rogramming l anguage s emantics as n atural s cience
play

P ROGRAMMING L ANGUAGE S EMANTICS AS N ATURAL S CIENCE T HE P ECULIAR - PowerPoint PPT Presentation

P ROGRAMMING L ANGUAGE S EMANTICS AS N ATURAL S CIENCE T HE P ECULIAR , E VOLVING , AND B ARELY C ONSUMMATED R ELATIONSHIP B ETWEEN S EMANTICS AND S CRIPTING L ANGUAGES Arjun Guha Joe Gibbs Politz Ben Lerner Justin Pombrio Shriram Krishnamurthi


  1. P ROGRAMMING L ANGUAGE S EMANTICS AS N ATURAL S CIENCE T HE P ECULIAR , E VOLVING , AND B ARELY C ONSUMMATED R ELATIONSHIP B ETWEEN S EMANTICS AND S CRIPTING L ANGUAGES Arjun Guha Joe Gibbs Politz Ben Lerner Justin Pombrio Shriram Krishnamurthi

  2. "JavaScript ¡has ¡much ¡in ¡common ¡with ¡Scheme ¡[…] ¡ ( ) Because ¡of ¡this ¡deep ¡similarity ¡…" ¡ 2 ¡

  3. function ¡bar(x) ¡{ ¡ function ¡bar(x) ¡{ ¡ ¡ ¡return ¡function() ¡{ ¡ ¡ ¡return ¡function() ¡{ ¡ ¡ ¡ ¡ ¡var ¡x ¡= ¡x; ¡ ¡ ¡ ¡ ¡var ¡x ¡= ¡x; ¡ ¡ ¡ ¡ ¡return ¡x; ¡ ¡ ¡ ¡ ¡return ¡x; ¡ ¡ ¡}; ¡ ¡ ¡}; ¡ } ¡ } ¡ ¡ ¡ var ¡f ¡= ¡bar(200); ¡ var ¡f ¡= ¡bar(200); ¡ f() ¡ f() ¡ à ¡200 ¡ � ¡undefined ¡ 3 ¡

  4. var ¡x ¡= ¡0; ¡ var ¡y ¡= ¡900; ¡ ¡ function ¡baz(obj) ¡{ ¡ ¡ ¡with ¡(obj) ¡{ ¡ ¡ ¡ ¡ ¡x ¡= ¡y; ¡ ¡ ¡} ¡ } ¡ ¡ baz({ ¡y: ¡100 ¡}); ¡ x ¡ � ¡100 ¡ ¡ var ¡myObj ¡= ¡{ ¡x ¡: ¡0 ¡}; ¡ baz(myObj); ¡ x ¡ � ¡100 ¡ myObj.x ¡ � ¡900 ¡ 4 ¡

  5. "JavaScript ¡has ¡much ¡in ¡common ¡with ¡Scheme ¡[…] ¡ Because ¡of ¡this ¡deep ¡similarity ¡…" ¡ No ¡help ¡to ¡researchers ¡ ¡ studying ¡Web ¡security, ¡ ¡ building ¡JavaScript ¡analyses, ¡ ¡ etc. ¡ 7 ¡

  6. λ JS ¡(sort ¡of) ¡ on ¡one ¡slide ¡ 10 ¡

  7. JavaScript ¡ λ JS ¡ desugar ¡ program ¡ program ¡ SpiderMonkey, ¡ definiMonal ¡ V8, ¡Rhino ¡ interpreter ¡ Iden%cal ¡for ¡ “their ¡ conformance ¡suites ¡ “our ¡ answer” ¡ answer” ¡ 11 ¡

  8. What About the Spec? 1. The spec is embodied in the implementations 2. The spec is incomplete: e.g., SES depends on window.console 3. The spec depends on implementations! If […], the behavior of sort is implementation-defined. 4. Attackers attack implementations, not specs

  9. Internal/ ¡ External ¡ validaMon ¡ 13 ¡

  10. T WO WO P P OSITIONS OSITIONS 1. The desugar/semantics split is vital 2. Tests are a form of specification

  11. JavaScript ¡ λ JS ¡ desugar ¡ program ¡ program ¡ 1. Curated ¡“essence”— provides ¡insight ¡ ¡ SpiderMonkey, ¡ 100 ¡LOC ¡ 2. Target ¡for ¡proofs ¡ V8, ¡Rhino ¡ interpreter ¡ 3. Target ¡for ¡tools ¡ ¡ 4. Stabilizes ¡quickly ¡and ¡ rarely ¡changes ¡aVer ¡ “their ¡ “our ¡ answer” ¡ answer” ¡ 5. What ¡we ¡as ¡scienMsts ¡ should ¡do ¡ 15 ¡

  12. T ESTS ESTS AS AS S S PECIFICA TIONS PECIFICATIONS Tests are incomplete but formal Implementations on their own over-specify Tests keep up with evolution Tests ease the interface with specification authors

  13. T HREE HREE R R ESEARCH ESEARCH P P ROBLEMS ROBLEMS

  14. 1. S 1. S HRINKING HRINKING D ESUGARING ESUGARING O O UTPUT UTPUT

  15. let ¡(%context ¡= ¡%nonstrictContext) ¡{ ¡ ¡ ¡%defineGlobalAccessors(%context, ¡"n"); ¡ ¡ ¡%defineGlobalAccessors(%context, ¡"x"); ¡ ¡ ¡let ¡(#strict ¡= ¡false) ¡{ ¡ ¡ ¡ ¡ ¡try ¡{ ¡ ¡ ¡ ¡ ¡ ¡ ¡%set-­‑property( ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡%ToObject( ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡%context["x", ¡{[#proto: ¡null, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#class: ¡"Object", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#extensible: ¡true,]}]), ¡ x["count"] ¡= ¡n ¡+ ¡1; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡"count", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡%PrimAdd(%context["n" ¡, ¡{[#proto: ¡null, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#class: ¡"Object", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#extensible: ¡true,]}], ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡1.)) ¡ ¡ ¡ ¡ ¡} ¡catch ¡{ ¡ ¡ ¡ ¡ ¡ ¡ ¡%ErrorDispatch ¡ ¡ ¡ ¡ ¡} ¡ ¡ ¡} ¡ } ¡

  16. let ¡(%context ¡= ¡%nonstrictContext) ¡{ ¡ ¡ ¡%defineGlobalAccessors(%context, ¡"n"); ¡ ¡ ¡%defineGlobalAccessors(%context, ¡"x"); ¡ ¡ ¡let ¡(#strict ¡= ¡false) ¡{ ¡ ¡ ¡ ¡ ¡try ¡{ ¡ ¡ ¡ ¡ ¡ ¡ ¡%set-­‑property( ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡%ToObject( ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡%context["x", ¡{[#proto: ¡null, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#class: ¡"Object", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#extensible: ¡true,]}]), ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡"count", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡%PrimAdd(%context["n" ¡, ¡{[#proto: ¡null, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#class: ¡"Object", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#extensible: ¡true,]}], ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡1.)) ¡ ¡ ¡ ¡ ¡} ¡catch ¡{ ¡ ¡ ¡ ¡ ¡ ¡ ¡%ErrorDispatch ¡ ¡ ¡ ¡ ¡} ¡ ¡ ¡} ¡ try ¡{ ¡ } ¡ ¡ ¡%set-­‑property( ¡ ¡ ¡ ¡ ¡%ToObject( ¡ ¡ ¡ ¡ ¡ ¡ ¡%context["x", ¡{[#proto: ¡null, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#class: ¡"Object", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#extensible: ¡true,]}]), ¡ ¡ ¡ ¡ ¡"count", ¡ ¡ ¡ ¡ ¡%PrimAdd(%context["n" ¡, ¡{[#proto: ¡null, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#class: ¡"Object", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#extensible: ¡true,]}], ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡1.)) ¡ } ¡catch ¡{ ¡ ¡ ¡%ErrorDispatch ¡ } ¡

  17. try ¡{ ¡ ¡ ¡%set-­‑property( ¡ ¡ ¡ ¡ ¡%ToObject( ¡ ¡ ¡ ¡ ¡ ¡ ¡%context["x", ¡{[#proto: ¡null, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#class: ¡"Object", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#extensible: ¡true,]}]), ¡ ¡ ¡ ¡ ¡"count", ¡ ¡ ¡ ¡ ¡%PrimAdd(%context["n" ¡, ¡{[#proto: ¡null, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#class: ¡"Object", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#extensible: ¡true,]}], ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡1.)) ¡ } ¡catch ¡{ ¡ ¡ ¡%ErrorDispatch ¡ } ¡ %set-­‑property( ¡ ¡ ¡%ToObject( ¡ ¡ ¡ ¡ ¡%context["x", ¡{[#proto: ¡null, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#class: ¡"Object", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#extensible: ¡true,]}]), ¡ ¡ ¡"count", ¡ ¡ ¡%PrimAdd(%context["n" ¡, ¡{[#proto: ¡null, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#class: ¡"Object", ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡#extensible: ¡true,]}], ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡1.)) ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend