计算机与现代化

• 应用与开发 • 上一篇    下一篇

Chrome V8引擎中的JavaScript数组实现分析与性能优化

  

  1. SAP中国研究院商务智能部,上海201203
  • 收稿日期:2014-07-28 出版日期:2014-11-03 发布日期:2014-11-05
  • 作者简介:刘旭(1982-),男,四川遂宁人,SAP中国研究院商务智能软件部工程师,学士,研究方向:数据可视化,用户数据的聚合、展现,人机交互及性能优化。

Implementation Analysis and Performance Optimization for JavaScript Array in Chrome V8

  1. Department of Business Intelligence of SAP Labs China, Shanghai 201203, China
  • Received:2014-07-28 Online:2014-11-03 Published:2014-11-05

摘要: 随着实际应用中JavaScript程序的复杂度日益提高,程序执行的性能问题变得突出,而优化JavaScript程序中数组的使用方式可以提高程序效率。通过分析JavaScript数组的特点,结合广泛应用的Chrome V8引擎的源程序,描述V8对JavaScript数组的实现细节,重点分析Fast Elements和Dictionary Elements两种数组存储模式,给出对JavaScript数组性能优化的基本原则,并举例分析4个实际应用中可以优化的程序片段。

关键词: V8, Chrome, JavaScript, 数组, 性能, 优化

Abstract: With the complexity of JavaScript applications increasing, performance issues of JavaScript become increasingly prominent, but to optimize the use of JavaScript array can improve program efficiency. This paper, by analyzing the characteristics of JavaScript arrays and reviewing the source code of Chrome V8 JavaScript engine, describes the implementation details for JavaScript array in V8, and focuses on the Fast Elements and Dictionary Elements array storage modes. It also gives the basic principles of performance optimization of JavaScript array and four examples to show how to analyze and optimize programs in practical applications.

Key words: V8, Chrome, JavaScript, array, performance, optimization

中图分类号: