热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

nodejs/V8是否将已编译的机器代码存储在磁盘上的任何位置?-Doesnodejs/V8storecompiledmachinecodeanywhereondisk?

Edit:NodeusesbytecodesinceNode8.3,beforethat,sourceswerecompileddirectlytomachinecode

Edit: Node uses bytecode since Node 8.3, before that, sources were compiled directly to machine code.

编辑:节点使用自Node 8.3以来的字节码,在此之前,源代码直接编译为机器代码。

I do a lot of Python coding, and there's always bytecode lying around in .pyc files.

我做了很多Python编码,并且.pyc文件中总是存在字节码。

I was wondering if node stores its machine code in similar files, eg it would make sense to keep the machine code representation around on disk and re-use it if a file's source is unchanged.

我想知道节点是否将其机器代码存储在类似的文件中,例如,将机器代码表示保存在磁盘上并在文件源不变的情况下重新使用它是有意义的。

If so, where does node/v8 store this machine code?

如果是这样,node / v8在哪里存储此机器代码?

Edit 2: As @dystroy mentions below this is a dupe of How can I see the machine code generated by v8?

编辑2:正如@dystroy下面提到的这是一个骗局我如何看到v8生成的机器代码?

3 个解决方案

#1


4  

V8 introduced a bytecode interpreter, Ignition, in 2016. You can print the bytecode with --print-bytecode (Node 8.3 and newer).

V8在2016年引入了字节码解释器Ignition。您可以使用--print-bytecode(Node 8.3和更新版本)打印字节码。

$ node --print-bytecode incrementX.js -e 'function incrementX(obj) {return 1 + obj.x;} incrementX({x: 42});`
...
[generating bytecode for function: incrementX]
Parameter count 2
Frame size 8
  12 E> 0x2ddf8802cf6e @    StackCheck
  19 S> 0x2ddf8802cf6f @    LdaSmi [1]
        0x2ddf8802cf71 @    Star r0
  34 E> 0x2ddf8802cf73 @    LdaNamedProperty a0, [0], [4]
  28 E> 0x2ddf8802cf77 @    Add r0, [6]
  36 S> 0x2ddf8802cf7a @    Return
Constant pool (size = 1)
0x2ddf8802cf21: [FixedArray] in OldSpace
 - map = 0x2ddfb2d02309 
 - length: 1
           0: 0x2ddf8db91611 
Handler Table (size = 16)

See Understanding V8's Bytecode.

请参阅了解V8的字节码。

To see the machine code, use --print-opt-code --code-comments.

要查看机器代码,请使用--print-opt-code --code-comments。

#2


8  

V8 is a just in time compiler. So Javascript cannot be compiled just once like python compiler which is static compilation. It is compiled as and when it needs to be executed.

V8是一个及时的编译器。所以Javascript不能像python编译器那样只编译一次,这是静态编译。它是在需要执行时编译的。

You cannot see the generated machine code for Javascript, because it is not stored. It does not make sense to store the machine code that was compiled, as compilation happens repeatedly and is affected by runtime optimisations. You don't get fixed machine code like for python, every time it happens.

您无法看到生成的Javascript机器代码,因为它未存储。存储编译的机器代码没有意义,因为编译反复发生并受运行时优化的影响。每次发生时,你都没有得到像python这样的固定机器代码。

#3


4  

From the project's page :

从项目的页面:

V8 compiles Javascript source code directly into machine code when it is first executed. There are no intermediate byte codes, no interpreter.

V8首次执行时,会将Javascript源代码直接编译为机器代码。没有中间字节代码,没有解释器。

That's why you won't find the bytecode, there is none.

这就是为什么你不会找到字节码,没有。

Regarding the new question following your edit, I think this related question answers it mostly. Of course there's no reason in general for V8 to write the machine code on disk with the default setup. As this code changes a lot (see the link above, explaining how dynamic classes are created), that would be a gigantic overhead.

关于编辑后的新问题,我认为这个相关问题主要是回答它。当然,V8通常没有理由使用默认设置在磁盘上写入机器代码。由于此代码发生了很大变化(请参阅上面的链接,解释了如何创建动态类),这将是一个巨大的开销。


推荐阅读
  • 如何解决《何时何地在Java源代码中初始化/存储String?》经验,如何解决这个问题? ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
  • Java中包装类的设计原因以及操作方法
    本文主要介绍了Java中设计包装类的原因以及操作方法。在Java中,除了对象类型,还有八大基本类型,为了将基本类型转换成对象,Java引入了包装类。文章通过介绍包装类的定义和实现,解答了为什么需要包装类的问题,并提供了简单易用的操作方法。通过本文的学习,读者可以更好地理解和应用Java中的包装类。 ... [详细]
  • 本文介绍了如何使用Express App提供静态文件,同时提到了一些不需要使用的文件,如package.json和/.ssh/known_hosts,并解释了为什么app.get('*')无法捕获所有请求以及为什么app.use(express.static(__dirname))可能会提供不需要的文件。 ... [详细]
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
  • Spring常用注解(绝对经典),全靠这份Java知识点PDF大全
    本文介绍了Spring常用注解和注入bean的注解,包括@Bean、@Autowired、@Inject等,同时提供了一个Java知识点PDF大全的资源链接。其中详细介绍了ColorFactoryBean的使用,以及@Autowired和@Inject的区别和用法。此外,还提到了@Required属性的配置和使用。 ... [详细]
  • 本文介绍了Swing组件的用法,重点讲解了图标接口的定义和创建方法。图标接口用来将图标与各种组件相关联,可以是简单的绘画或使用磁盘上的GIF格式图像。文章详细介绍了图标接口的属性和绘制方法,并给出了一个菱形图标的实现示例。该示例可以配置图标的尺寸、颜色和填充状态。 ... [详细]
  • 纠正网上的错误:自定义一个类叫java.lang.System/String的方法
    本文纠正了网上关于自定义一个类叫java.lang.System/String的错误答案,并详细解释了为什么这种方法是错误的。作者指出,虽然双亲委托机制确实可以阻止自定义的System类被加载,但通过自定义一个特殊的类加载器,可以绕过双亲委托机制,达到自定义System类的目的。作者呼吁读者对网上的内容持怀疑态度,并带着问题来阅读文章。 ... [详细]
  • 用NAN写一个nodejs的c++扩大
    NAN引见NAN的全称为NativeAbstractionforNode.js,其表现上是一个Node.js包。装置后,就获得一堆C++头文件,内里是一堆宏。它主要为Node.js ... [详细]
  • 大厂学院设计模式day01
    p01导论设计模式7大原则开闭原则里氏替换原则依赖倒装原则单一职责原则接口隔离原则迪米特法则合成复用原则p02创建型模式-为什么使用创建型模式p03单例模式***佟老师只能有一 ... [详细]
  • 如何解决《错误:代码太大》经验,求大佬解答? ... [详细]
author-avatar
hengldkslf
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有