Loading...
Searching...
No Matches
Public Member Functions | List of all members
v8::TypecheckWitness Class Reference

#include <v8-value.h>

Public Member Functions

 TypecheckWitness (Isolate *isolate)
 
bool Matches (Local< Value > candidate) const
 
void Update (Local< Value > baseline)
 

Detailed Description

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).

Constructor & Destructor Documentation

◆ TypecheckWitness()

v8::TypecheckWitness::TypecheckWitness ( Isolate isolate)
explicit

Member Function Documentation

◆ Matches()

bool v8::TypecheckWitness::Matches ( Local< Value candidate) const
inline

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.

Here is the call graph for this function:

◆ Update()

void v8::TypecheckWitness::Update ( Local< Value baseline)

Remembers a new baseline for future {Matches} queries.


The documentation for this class was generated from the following file: