How to detect transition from one shape to another in V8?

Let’s say I have next code:

let x = null;
x = 10;

How I can detect shape transition here? From NULL_TYPE to SMI ? I know that there should be some built in function. Here is the list.

I expect that it will be possible to run node --allow-natives-syntax or smth like that, for instance:

let x = null;
x = 10;
console.log(%DetectTransition(x))

Answer

(V8 developer here.)

There is no shape transition in that code snippet, as the concept “shape” only applies to objects.

Here is an example with a shape transition:

let a = {x: 1};
let b = {x: 1};
%HaveSameMap(a, b);  // true
b.y = 2;
%HaveSameMap(a, b);  // false
a.y = 3;
%HaveSameMap(a, b);  // true

%HaveSameMap compares the shape descriptors of the provided objects and returns true or false. For a lot more detail, you can also use %DebugPrint as @JonasWilms suggested.

Of course, we’re talking about internal details here (both what happens under the hood, and how you can inspect it for debugging or curiosity purposes). Nobody is making any promises that things will continue to work in exactly this way. (I think the basics are unlikely to change, but the details do change.)