#include <v8-value.h>
Public Member Functions | |
TypecheckWitness (Isolate *isolate) | |
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).
|
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.
Remembers a new baseline for future {Matches} queries.