Philip Wontae Choi and Satish Chandra and George Necula and Koushik Sen

EECS Department, University of California, Berkeley

Technical Report No. UCB/EECS-2015-13

April 1, 2015

http://www2.eecs.berkeley.edu/Pubs/TechRpts/2015/EECS-2015-13.pdf

We present a proposal for a static type system for a significant subset of JavaScript, dubbed SJS, with the goal of ensuring that objects have a statically known layout at the allocation time, which in turn enables an ahead-of-time (AOT) compiler to generate efficient code. The main technical challenge we address is to ensure fixed object layout, while supporting popular language features such as objects with prototype inheritance, structural subtyping, and method updates, with the additional constraint that SJS programs can run on any available standard JavaScript engine, with no deviation from JavaScript’s standard operational semantics. The core difficulty arises from the way standard JavaScript semantics implements object attribute update with prototype-based inheritance. To our knowledge, combining a fixed object layout property with prototype inheritance and subtyping has not been achieved previously. We describe the design of SJS, both at the type-system level and source level, along with a local type inference algorithm. We measured experimentally the effort required in adding the necessary typing annotations, and the effectiveness of a simple AOT compiler that exploits the fixed object layout property of SJS.


BibTeX citation:

@techreport{Choi:EECS-2015-13,
    Author= {Choi, Philip Wontae and Chandra, Satish and Necula, George and Sen, Koushik},
    Title= {SJS: a Typed Subset of JavaScript with Fixed Object Layout},
    Year= {2015},
    Month= {Apr},
    Url= {http://www2.eecs.berkeley.edu/Pubs/TechRpts/2015/EECS-2015-13.html},
    Number= {UCB/EECS-2015-13},
    Note= {This version fixes a typo in the affiliation of one of the authors. We will keep the previous version (EECS-2015-10) for a while.},
    Abstract= {We present a proposal for a static type system for a significant subset of JavaScript, dubbed SJS, with the goal of ensuring that objects have a statically known layout at the allocation time, which in turn enables an ahead-of-time (AOT) compiler to generate efficient code. The main technical challenge we address is to ensure fixed object layout, while supporting popular language features such as objects with prototype inheritance, structural subtyping, and method updates, with the additional constraint that SJS programs can run on any available standard JavaScript engine, with no deviation from JavaScript’s standard operational semantics. The core difficulty arises from the way standard JavaScript semantics implements object attribute update with prototype-based inheritance. To our knowledge, combining a fixed object layout property with prototype inheritance and subtyping has not been achieved previously. We describe the design of SJS, both at the type-system level and source level, along with a local type inference algorithm. We measured experimentally the effort required in adding the necessary typing annotations, and the effectiveness of a simple AOT compiler that exploits the fixed object layout property of SJS.},
}

EndNote citation:

%0 Report
%A Choi, Philip Wontae 
%A Chandra, Satish 
%A Necula, George 
%A Sen, Koushik 
%T SJS: a Typed Subset of JavaScript with Fixed Object Layout
%I EECS Department, University of California, Berkeley
%D 2015
%8 April 1
%@ UCB/EECS-2015-13
%U http://www2.eecs.berkeley.edu/Pubs/TechRpts/2015/EECS-2015-13.html
%F Choi:EECS-2015-13