v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8::TypecheckWitness Class Reference

#include <v8-value.h>

Collaboration diagram for v8::TypecheckWitness:

Public Member Functions

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

Private Attributes

Local< Datacached_map_
 

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

Definition at line 515 of file v8-value.h.

Constructor & Destructor Documentation

◆ TypecheckWitness()

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

Definition at line 8368 of file api.cc.

Member Function Documentation

◆ Matches()

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

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 664 of file v8-value.h.

Here is the call graph for this function:

◆ Update()

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

Remembers a new baseline for future {Matches} queries.

Definition at line 8380 of file api.cc.

Here is the call graph for this function:

Member Data Documentation

◆ cached_map_

Local<Data> v8::TypecheckWitness::cached_map_
private

Definition at line 533 of file v8-value.h.


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