You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now if we declare a class (let's say, Lira), and we don't create an instance of that class, v8 findjsobjects will still show us that we have 1 instance of Lira. If we have a class with instances (let's say, Lero), v8 findjsobjects will show us one more instance than we actually have. Example of this behavior below.
I'm not sure how mdb_v8 handles this, but Chrome DevTools snapshots won't count classes as objects. Should we change the current behavior? Or maybe make it clearer when some object is actually a class instead of an instance?
Good idea, we could print them as e.g. Class: Foo.
I believe you distinguish a class constructor from a normal constructor function by looking at one of the bits (bit 3?) of its SharedFunctionInfo::compiler_hints field.
Maybe we could look at in object properties count? Seems to be zero every time the object is a class and non-zero otherwise.
SharedFunctionInfo::compiler_hints has the IsClassConstructor bit on even on some instances (for example, if a class doesn't implement its own constructor), so it doesn't seem to be an accurate check. There's also the IsConstructor bit in Map::bit_field, but I could'nt get one example where Map::bit_field is not 00000000.
Worst case we could just look at the object's properties and consider it to be a Class if it has a constructor property...
Right now if we declare a class (let's say,
Lira
), and we don't create an instance of that class,v8 findjsobjects
will still show us that we have 1 instance ofLira
. If we have a class with instances (let's say,Lero
),v8 findjsobjects
will show us one more instance than we actually have. Example of this behavior below.I'm not sure how mdb_v8 handles this, but Chrome DevTools snapshots won't count classes as objects. Should we change the current behavior? Or maybe make it clearer when some object is actually a class instead of an instance?
Example:
index.js
llnode results
The text was updated successfully, but these errors were encountered: