基于预测的JavaScript类型系统研究
JavaScript Typing System with Prediction
-
摘要: 随着互联网和万维网的流行以及JavaScript在Web浏览器中的作用越来越重要,对JavaScript程序的执行行为的研究将有利于提高浏览器的性能,改善用户的体验.传统的研究认为JavaScript语言的动态性是其性能的主要瓶颈,因此大部分主流的JavaScript执行引擎都将优化集中在其动态性的处理上.为了更深入的研究JavaScript程序的动态性,提出了两种算法:类型预测算法和基于位置的内联缓存算法,分别用于处理JavaScript程序中元数据和对象的类型.以这些算法为基础,在SunSpider测试程序集上系统地研究了JavaScript的类型系统.实验表明,算法平均能够正确识别或者预测99%的类型实例,因此可以认为,尽管JavaScript语言提供了丰富的动态性,实际的应用程序所使用到的动态行为是有限的.这是已知文献中首次提出类似的观点.Abstract: As the Internet and the World Wide Web become more and more popular nowadays, and the JavaScript programming language is becoming a key role in Web browsers, investigation on the behavior of JavaScript applications is important to improve Web browser’s performance and user experience. Traditional study believes that, the dynamic typing nature of the JavaScript language is the major performance bottleneck. So the main optimizations of most advanced mainstream JavaScript engines are all focused on dynamic typing problems. To learn the dynamic typing nature of JavaScript language in depth, two novel predication-based algorithms, called “type prediction” and “position-based inline caching”, are introduced to tackle the problems. With these algorithms, the typing system of JavaScript language is studied systematically and the techniques are evaluated with a representative JavaScript performance benchmark—SunSpider. In experiments with the SunSpider applications, the predication-based algorithms can identify the types with 99% accuracy on average. And so it is believed that although the JavaScript language provides abundant dynamics with its typing system, the actual applications do not really use all the features and hence their behaviors are static at most time. This is the first time that such discovery is made and published.