According to V8 source code and turbofan materials, there is a type of deoptimization called lazy deoptimization which is described as follows(v8/src/common/globals.h): Lazy: the code has been marked as dependent on some assumption which is checked elsewhere and can trigger deoptimization the next time the code is executed. However, when observing the execution of ‘v8/test/mjsunit/compiler/deopt-lazy-shape-mutation.js’ with d8, I found that
Tag: v8
Concurrency optimization job in V8
When concurrency optimization is triggered, a new optimization job will be dispatched to a child-thread to complete. How does Runtime know that the optimization job has been completed? I’ve found that in runtime function StackGuard, the optimized code will be set in JSFunction, but I don’t know how this function is triggered. Answer When an optimization job is complete, it
Three different `this` behaviours for three different JS engines
I was learning about the this keyword and how it means different things with regards to regular functions vs ES6 arrow functions and function expressions and I came across something odd when trying to run the following code in Chrome, Deno and Node. So I prepared following: Example: Deno output: Node output: Chrome output: According to my understanding of this,
Why does this dynamic programming optimization actually make code slower?
This is from Leetcode problem: Concatenated Words. Below is a working solution. I added what I thought to be an optimization (see code comment), but it actually slows down the code. If I remove the …
Is it more performant to mix types or to keep types?
I was wondering, with v8, when storing class attributes, is it more performant to use one variable with mixed types or one variable per type? Consider the following snippets (written in TypeScript for …
Create big json object js
I am using Nodejs to Create a JSON file from a really large JSON object (1GB). In order to avoid memory problems, I’m using createWriteStream : var writeStream = fs.createWriteStream(‘./output/outPut….
Object.entries() time complexity
Does anyone know the complexity of Object.entries() in Javascript? Based on this question I’d guess at maybe O(n) as well if it’s implemented by obtaining the keys and values as arrays then zipping …
In javascript V8 does compilation phase happen to functions before execution phase then all the code is executed or only for global context
I read many articles saying that compilation(creation) phase happens first to the global execution context then the code is executed and when a function is invoked the creation phase then begins again …
Are arrow functions faster (more performant, lighter) than ordinary standalone function declaration in v8?
I am asking this question because I and my colleague have a dispute on coding style because he prefers arrows function declaration: const sum = (a, b) => a + b; And I prefer old-style standalone …
How to Disable V8’s Optimizing Compiler
I’m writing a constant-time string comparison function (for node.js) and would like to disable V8’s optimizing compiler for this single function; using command-line flags are out of the question. I …