As the size of my blog Chrome Development Tool tips used in my daily work turns to be larger I create a separate post to record down this small tip.
Are you curious about the “native code” here? At least I am.

Today I find that the Profiles tab in Chrome development tool can help us to unveil the mysteries to some degree.
In Chrome development, just select this checkbox:

And then execute the simple JavaScript code below:

var arr = [];
for (var i=0; i<1000; i++){arr.push(i)
}
console.profile("Array toString");for( var i = 0; i < 1000; i++){var a = arr.toString();
}
console.profileEnd("Array toString");

Once done, you can see a profile record with the name specified in JavaScript code above, “Array toString”. Hover the mouse to the first row, “anonymous function”, we find the hint “array.js”.

Switch display style from Chart to Tree:

From here the callstack of native implementation of toString is displayed:

The next step is to look into in array.js.
Launch url: https://cs.chromium.org/
Click this hyperlink:

now you can find the array.js file via path: src/v8/src/js/array.js

The callstack analyzed through the source code exactly matches the one we get in Chrome development tool Profile tab:
ArrayToString will delegate to Join if current caller is an Array:

Join will call DoJoin:

DoJoin will first call UseSparseVariant to evaluate the possibility to perform Join via SparseVariant. If not possible, call ConvertToString as fall back. ( The line number of source code may vary with the one you see in Chrome Development Tool profile tab due to the different version of Chrome being used. )

If you could not tolerate the poor performance of this online source code repository, you could download the whole source code of V8 to your local laptop by cloning this github repository:
https://chromium.googlesource.com/v8/v8.git/

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

使用Chrome开发者工具研究JavaScript里函数的原生实现相关推荐

  1. 使用Chrome开发者工具研究JavaScript函数的原生实现原理

    As the size of my blog Chrome Development Tool tips used in my daily work turns to be larger I creat ...

  2. 使用 Chrome 开发者工具进行 JavaScript 问题定位与调试

    引言 Google Chrome 是由 Goole 公司开发的一款网页浏览器,自 2008 年 9 月第一个测试版本发布以来,其市场占有率逐步上升,至 2014 年 5 月,Chrome 已超越 Fi ...

  3. 使用 Chrome 开发者工具研究一个基于 Angular 开发的网站源代码

    Chrome 开发者工具是前端开发工程师工具箱里使用频率最高的工具之一. 本文通过一个具体的例子,给大家分享笔者工作中,是如何通过 Chrome 开发者工具,分析一个网站的实现明细. 下图是 SAP ...

  4. Chrome开发者工具Element style里的Computed标签页

    View only the CSS that's actually applied to an element 根据Chrome开发者工具文档介绍,styles标签页里显示的是所有施加到一个HTML ...

  5. 使用chrome开发者工具调试JavaScript代码的三种常用方法

    对 JS 程序的调试,除了在 JS 程序中使用 alert().console.log() 方法跟踪和调试代码外,开发人员也会经常使用一些调试工具.最常用的 JS 调试工具就是一些主流的浏览器的调试工 ...

  6. Chrome开发者工具之JavaScript内存分析

    为什么80%的码农都做不了架构师?>>>    内存泄漏是指计算机可用内存的逐渐减少.当程序持续无法释放其使用的临时内存时就会发生.JavaScript的web应用也会经常遇到在原生 ...

  7. 一串最简单的JavaScript代码,在Chrome开发者工具调试器里触发VM8标签的出现

    代码如下: <html> <script>var code = "{ /* Jerry test generation */; debugger; console.l ...

  8. Chrome开发者工具Cookie标签里看到的ga cookie是什么意思

    如图: 答案是和这个analytics.js有关,google家的东西. 为让 Google Analytics(分析)能够确定两个不同匹配是否属于同一用户,必须将与特定用户关联的唯一标识和每个匹配一 ...

  9. Chrome 开发者工具 live expression 的用法

    live expression 相当于给 Chrome 开发者工具 console 面板里的表达式置顶,并且能随着用户点击的变化,而动态刷新该置顶的表达式.看个例子: 点击下图绿色高亮的图标,输入一个 ...

最新文章

  1. P1083 借教室(标记永久化线段树/二分+前缀和)难度⭐⭐⭐★
  2. sendmail启动virtusertable.db错误解决
  3. Android5.0之CardView的使用
  4. java list 查找_java面试之容器
  5. 1047 Student List for Course (25 分)【难度: 简单 / 知识点: 模拟】
  6. android四个按钮平分,android 水平平分两个按钮
  7. 无聊 乱写写 CSDN博客挺好玩的 确实
  8. 集合运算c语言程序设计,C语言运算符的含义集合,~^!|
  9. Android 的安全性岌岌可危!
  10. docker容器启动与停止命令
  11. JavaWeb学习笔记7--JSP脚本元素、指令元素、动作元素
  12. 矩阵相关定义性质全总结
  13. 浅谈项目管理结构化思维
  14. HTML元素居中的三种方法
  15. 替换字符串中全部斜杠
  16. AT89C51(Atmel)芯片制作简易的频率计
  17. statgraphics画Multifactor ANOVA图
  18. win10卸载补丁发生错误,没有成功卸载全部更新
  19. python维度互换_python – 有效地改变scipy.spare.csr_matrix的维度[复制]
  20. MySQL-条件查询

热门文章

  1. OpenTLD相关资料
  2. Linux 查看CPU信息、机器型号等硬件信息
  3. 如何使用新的邮件传输规则和邮件策略
  4. 网页设计师应向肖像画家吸取的11个理念
  5. OO第三次博客总结作业
  6. 文件重定向函数freopen
  7. InstallShield高级应用--获取机机所有ORACLE服务列表
  8. 一个让我魂牵梦萦的地方——婺源
  9. WebDeploymentSetup使用乱码问题解决
  10. [转载]VC++程序员应当如何阅读ADO文档