v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
|
#include <v8-value.h>
Public Member Functions | |
TypecheckWitness (Isolate *isolate) | |
V8_INLINE bool | Matches (Local< Value > candidate) const |
void | Update (Local< Value > baseline) |
Can be used to avoid repeated expensive type checks for groups of objects that are expected to be similar (e.g. when Blink converts a bunch of JavaScript objects to "ScriptWrappable" after a "HasInstance" check) by making use of V8-internal "hidden classes". An object that has passed the full check can be remembered via {Update}; further objects can be queried using {Matches}. Note that the answer will be conservative/"best-effort": when {Matches} returns true, then the {candidate} can be relied upon to have the same shape/constructor/prototype/etc. as the {baseline}. Otherwise, no reliable statement can be made (the objects might still have indistinguishable shapes for all intents and purposes, but this mechanism, being optimized for speed, couldn't determine that quickly).
Definition at line 497 of file v8-value.h.
|
explicit |
Checks whether {candidate} can cheaply be identified as being "similar" to the {baseline} that was passed to {Update} earlier. It's safe to call this on an uninitialized {TypecheckWitness} instance: it will then return {false} for any input.
Definition at line 645 of file v8-value.h.
References Internals::LoadMap(), and ValueHelper::ValueAsAddress().