Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the V8 engine in nodejs

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the V8 engine in nodejs". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In nodejs, the V8 engine is the interpreter that JavaScript runs and is a JavaScript engine; V8 is developed using "C++" and used in Google browser. Before running JavaScript, V8 compiles it into native machine code and uses methods such as inline caching to improve performance.

This tutorial operating environment: windows7 system, nodejs version 12.19.0, DELL G3 computer.

Overview of NodeJS

According to Baidu encyclopedia, Node.js is a set of JavaScript toolkits used to write high-performance web servers. Node.js is a platform that can quickly build web services and applications. The platform is based on Chrome's JavaScript runtime, that is, it actually encapsulates the GoogleV8 engine (applied to Google Chrome browsers). The V8 pilot engine executes Javascript very fast and the performance is very good.

NodeJS doesn't provide a simple wrapper and then an API call, and if that were the case, it wouldn't be as popular as it is now. Node optimizes some special use cases to provide an alternative API to make V8 run better in a non-browser environment. For example, in a server environment, dealing with binary data is usually necessary, but Javascript does not support it enough, so V8.Node adds the Buffer class to handle binary data conveniently and efficiently. Therefore, Node not only uses V8 simply, but also optimizes it to make it more powerful in all environments.

Overview of just-in-time compilation JIT

V8 uses just-in-time compilation (JIT) to compile JavaScript code directly into machine code on the local platform. From a macro point of view, the step is JavaScript source code-> abstract syntax tree-> native machine code, and the latter step depends only on the previous step. This is different from other interpreters, for example, the Java language needs to compile the source code into bytecode first, and then interpret and execute it to JVM. According to the optimization strategy, JVM selectively compiles part of the bytecode into local machine code. V8 does not generate intermediate code, one step in place, compiled into machine code, CPU begins to execute. The V8 strategy saves a step and the program starts to run earlier than the way the intermediate code is interpreted. And executing compiled machine instructions is also faster than interpreting and executing intermediate code. Unfortunately, the lack of an intermediate representation of bytecode makes code optimization more difficult.

V8 Overview

V8, as a JavaScript engine, was originally used in Google Chrome browsers. It was released as well as open source with the first release of Chrome. Now it has a lot of other users besides Chrome browser. Such as NodeJS, MongoDB, CouchDB, etc.

V8 is developed in C++ and is used in Google browser. Before running JavaScript, V8 compiles it to native machine code (IA-32, x86-64, ARM, or MIPS CPUs) compared to other JavaScript engines that convert to bytecode or interpret execution, and uses methods such as inline caching (inline caching) to improve performance. With these features, JavaScript programs run as fast as binary programs under the V8 engine.

ECMA-262is specified in the ECMAScript implemented in V8, and version 3 runs on Windows XP and Vista,Mac OS X 10.5 (Snow Leopard and Linux systems use IA-32 or ARM processors.

V8 can be run independently or embedded in any C++ application. The project is hosted on Google Code [1]. Based on the BSD protocol, any organization or individual can use its source code in its own project.

This is the end of the content of "what is the V8 engine in nodejs". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report