The JavaScript engine V8 has been released in version 7.4 and is currently in beta, with the official release coming in a few weeks with the Chrome 74 Stable.
This release brings some new features and significantly improved performance.
JIT-less V8
V8 can now execute JavaScript without the need for runtime allocation of executable memory. We covered the details of this new feature earlier: NEW V8 mechanism: Jit-less mode.
WebAssembly Threads/Atomics
WebAssembly Threads/Atomics is enabled on non-Android operating systems and can be enabled in Chrome with chrom://flags/#enable-webassembly-threads.
This feature enables WebAssembly to unlock the use of multiple cores on a user’s computer, enabling new, computationally intensive use cases on the Web.
Calls with mismatched parameters are faster
JavaScript allows a function to be called with a different number of arguments than it was defined with, both with fewer and more arguments being perfectly valid, and JavaScript functions can get the actual arguments from parameter objects, REST arguments, and so on.
Therefore, the JavaScript engine must provide a way to get the actual parameters, and in V8, this is done through a technique called parameter adaptation.
Parameter adaptation takes real parameters, but at the expense of performance, which is often unavoidable in modern front-end and middleware frameworks because there are so many apis with optional or variable parameter lists.
A new feature has been introduced in V8 7.4 to address this issue.
In some cases, such as when a strictly modal function is called that uses neither arguments nor REST arguments, parameter adaptation is not required at all. V8 now skips this adaptive process in this case, reducing the call overhead by more than 60%.
Improved native accessor performance
The Angular team found that native accessors like DOM property accessors called directly from their respective GET functions in Chrome are much slower than monomorphic or even megamorphic property accessors.
This is because in V8 a slow path is used to call the DOM accessor through Function#call(), rather than the fast path that already exists for property access.
In this release, the performance of calling native accessors has been improved to make it much faster than synthetic property access, with the following effects:
Interpreter performance
In Chrome, large scripts are streamed on worker threads when they are downloaded. This release fixes a source stream decoding problem with custom UTF-8, resulting in streaming parsing performance that is 8% faster on average.
Another problem was also found in the V8 preparser: attribute names were unnecessarily repeated in worker threads. Removing these duplicates improved streaming parser performance by 10.5%.
Byte code flush reduces memory
Bytecode compiled from JavaScript source takes up a large portion of V8 heap space, typically around 15%, including associated metadata. But there are many functions that are executed only during initialization or rarely used after compilation, which is obviously wasteful.
To reduce V8’s memory overhead, this release implements a new bytecode flush feature, which purgs compiled bytecode from the function during GC if it has not been executed recently.
To do this, V8 keeps track of the age of the function section code, increments the age during GC, and resets it to zero when the function executes. The memory of any bytecode that exceeds the preset “aging threshold” will be collected by the next garbage collector, and if the function is executed again in the future, it will recompile its bytecode.
This bytecode Flush feature saves Chrome users a lot of memory, reducing the amount of memory in the V8 heap by 5-15% without compromising performance or significantly increasing the CPU time spent compiling JavaScript code.
There are also improvements to JavaScript private class fields, V8 apis, and more.
https://v8.dev/blog/v8-release-74
Open source China call for contributions!
Open Source China www.oschina.net is a highly concerned and influential open source technology community with more than 2 million open source technology elites. We spread the concept of open source, promote open source projects, and provide a platform for IT developers to discover, use, and exchange open source technologies.
Now we are calling for contributions. If you have excellent technical articles to share, hot industry news to report and so on, please contact Open Source China to contribute. Please refer to “I want to contribute” for details and contact information
RedMonk language rankings: Kotlin up 8 places, TS fast forward to the top 10
New JavaScript engine V8 mechanism: Jit-less mode
Java 12 / JDK 12 is released
Alibaba open source OpenJDK release Dragonwell
Three years after graduation, I grew from a new background developer to a team leader
“Watching” to share with more developers ↓↓↓