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

Classes

struct  CodeProtectionInfo
 
struct  CodeProtectionInfoListEntry
 
class  MetadataLock
 
struct  ProtectedInstructionData
 
struct  SandboxRecord
 
class  SandboxRecordsLock
 

Functions

void HandleSignal (int signum, siginfo_t *info, void *context)
 
bool TryHandleSignal (int signum, siginfo_t *info, void *context)
 
LONG WINAPI HandleWasmTrap (EXCEPTION_POINTERS *exception)
 
TH_DISABLE_ASAN bool TryHandleWasmTrap (EXCEPTION_POINTERS *exception)
 
constexpr size_t HandlerDataSize (size_t num_protected_instructions)
 
CodeProtectionInfoCreateHandlerData (uintptr_t base, size_t size, size_t num_protected_instructions, const ProtectedInstructionData *protected_instructions)
 
int RegisterHandlerData (uintptr_t base, size_t size, size_t num_protected_instructions, const ProtectedInstructionData *protected_instructions)
 
void ReleaseHandlerData (int index)
 
bool RegisterV8Sandbox (uintptr_t base, size_t size)
 
void UnregisterV8Sandbox (uintptr_t base, size_t size)
 
int * GetThreadInWasmThreadLocalAddress ()
 
size_t GetRecoveredTrapCount ()
 
bool RegisterDefaultTrapHandler ()
 
void RemoveTrapHandler ()
 
bool EnableTrapHandler (bool use_v8_handler)
 
void SetLandingPad (uintptr_t landing_pad)
 
bool IsFaultAddressCovered (uintptr_t fault_addr)
 
bool IsAccessedMemoryCovered (uintptr_t accessed_addr)
 
bool IsTrapHandlerEnabled ()
 
TH_DISABLE_ASAN bool IsThreadInWasm ()
 
void SetThreadInWasm ()
 
void ClearThreadInWasm ()
 
void AssertThreadNotInWasm ()
 

Variables

constexpr size_t kInitialCodeObjectSize = 1024
 
constexpr size_t kCodeObjectGrowthFactor = 2
 
bool g_is_trap_handler_enabled {false}
 
std::atomic< boolg_can_enable_trap_handler {true}
 
thread_local int g_thread_in_wasm_code
 
size_t gNumCodeObjects = 0
 
CodeProtectionInfoListEntrygCodeObjects = nullptr
 
SandboxRecordgSandboxRecordsHead = nullptr
 
std::atomic_size_t gRecoveredTrapCount = {0}
 
std::atomic< uintptr_t > gLandingPad = {0}
 
const int kInvalidIndex = -1
 

Function Documentation

◆ AssertThreadNotInWasm()

void v8::internal::trap_handler::AssertThreadNotInWasm ( )
inline

Definition at line 216 of file trap-handler.h.

Here is the caller graph for this function:

◆ ClearThreadInWasm()

void v8::internal::trap_handler::ClearThreadInWasm ( )
inline

Definition at line 195 of file trap-handler.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateHandlerData()

CodeProtectionInfo * v8::internal::trap_handler::CreateHandlerData ( uintptr_t base,
size_t size,
size_t num_protected_instructions,
const ProtectedInstructionData * protected_instructions )

Definition at line 108 of file handler-outside.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnableTrapHandler()

TH_EXPORT_PRIVATE bool v8::internal::trap_handler::EnableTrapHandler ( bool use_v8_handler)

Definition at line 298 of file handler-outside.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRecoveredTrapCount()

TH_EXPORT_PRIVATE size_t v8::internal::trap_handler::GetRecoveredTrapCount ( )

Definition at line 282 of file handler-outside.cc.

Here is the caller graph for this function:

◆ GetThreadInWasmThreadLocalAddress()

V8_NOINLINE TH_EXPORT_PRIVATE int * v8::internal::trap_handler::GetThreadInWasmThreadLocalAddress ( )

Definition at line 280 of file handler-outside.cc.

Here is the caller graph for this function:

◆ HandlerDataSize()

size_t v8::internal::trap_handler::HandlerDataSize ( size_t num_protected_instructions)
constexpr

Definition at line 48 of file handler-outside.cc.

Here is the caller graph for this function:

◆ HandleSignal()

void v8::internal::trap_handler::HandleSignal ( int signum,
siginfo_t * info,
void * context )

◆ HandleWasmTrap()

LONG WINAPI v8::internal::trap_handler::HandleWasmTrap ( EXCEPTION_POINTERS * exception)

◆ IsAccessedMemoryCovered()

bool v8::internal::trap_handler::IsAccessedMemoryCovered ( uintptr_t accessed_addr)

◆ IsFaultAddressCovered()

bool v8::internal::trap_handler::IsFaultAddressCovered ( uintptr_t fault_addr)

◆ IsThreadInWasm()

TH_DISABLE_ASAN bool v8::internal::trap_handler::IsThreadInWasm ( )
inline

Definition at line 186 of file trap-handler.h.

Here is the caller graph for this function:

◆ IsTrapHandlerEnabled()

bool v8::internal::trap_handler::IsTrapHandlerEnabled ( )
inline

Definition at line 158 of file trap-handler.h.

Here is the caller graph for this function:

◆ RegisterDefaultTrapHandler()

bool v8::internal::trap_handler::RegisterDefaultTrapHandler ( )

Definition at line 290 of file handler-outside.cc.

Here is the caller graph for this function:

◆ RegisterHandlerData()

int TH_EXPORT_PRIVATE v8::internal::trap_handler::RegisterHandlerData ( uintptr_t base,
size_t size,
size_t num_protected_instructions,
const ProtectedInstructionData * protected_instructions )

Adds the handler data to the place where the trap handler will find it.

This returns a number that can be used to identify the handler data to ReleaseHandlerData, or -1 on failure.

Definition at line 131 of file handler-outside.cc.

Here is the call graph for this function:

◆ RegisterV8Sandbox()

bool TH_EXPORT_PRIVATE v8::internal::trap_handler::RegisterV8Sandbox ( uintptr_t base,
size_t size )

Registers the base and size of the V8 sandbox region into list of sandboxes records. If successful, these will be used by the trap handler: only faulting accesses to memory inside the V8 sandboxes should be handled by the trap handler since all Wasm memory objects are located inside the sandboxes.

Definition at line 234 of file handler-outside.cc.

◆ ReleaseHandlerData()

void TH_EXPORT_PRIVATE v8::internal::trap_handler::ReleaseHandlerData ( int index)

Removes the data from the master list and frees any memory, if necessary. TODO(mtrofin): We can switch to using size_t for index and not need kInvalidIndex.

Definition at line 207 of file handler-outside.cc.

Here is the caller graph for this function:

◆ RemoveTrapHandler()

TH_EXPORT_PRIVATE void v8::internal::trap_handler::RemoveTrapHandler ( )

Definition at line 292 of file handler-outside.cc.

◆ SetLandingPad()

TH_EXPORT_PRIVATE void v8::internal::trap_handler::SetLandingPad ( uintptr_t landing_pad)

Definition at line 318 of file handler-outside.cc.

Here is the caller graph for this function:

◆ SetThreadInWasm()

void v8::internal::trap_handler::SetThreadInWasm ( )
inline

Definition at line 188 of file trap-handler.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryHandleSignal()

bool v8::internal::trap_handler::TryHandleSignal ( int signum,
siginfo_t * info,
void * context )

◆ TryHandleWasmTrap()

TH_DISABLE_ASAN bool v8::internal::trap_handler::TryHandleWasmTrap ( EXCEPTION_POINTERS * exception)

◆ UnregisterV8Sandbox()

void TH_EXPORT_PRIVATE v8::internal::trap_handler::UnregisterV8Sandbox ( uintptr_t base,
size_t size )

Unregisters the base and size of the V8 sandbox region decribed by base and size.

Definition at line 257 of file handler-outside.cc.

Variable Documentation

◆ g_can_enable_trap_handler

TH_EXPORT_PRIVATE std::atomic< bool > v8::internal::trap_handler::g_can_enable_trap_handler {true}

Definition at line 296 of file handler-outside.cc.

◆ g_is_trap_handler_enabled

TH_EXPORT_PRIVATE bool v8::internal::trap_handler::g_is_trap_handler_enabled {false}

Definition at line 295 of file handler-outside.cc.

◆ g_thread_in_wasm_code

thread_local int v8::internal::trap_handler::g_thread_in_wasm_code

Definition at line 29 of file handler-shared.cc.

◆ gCodeObjects

CodeProtectionInfoListEntry * v8::internal::trap_handler::gCodeObjects = nullptr

Definition at line 36 of file handler-shared.cc.

◆ gLandingPad

std::atomic< uintptr_t > v8::internal::trap_handler::gLandingPad = {0}

Definition at line 39 of file handler-shared.cc.

◆ gNumCodeObjects

size_t v8::internal::trap_handler::gNumCodeObjects = 0

Definition at line 35 of file handler-shared.cc.

◆ gRecoveredTrapCount

std::atomic_size_t v8::internal::trap_handler::gRecoveredTrapCount = {0}

Definition at line 38 of file handler-shared.cc.

◆ gSandboxRecordsHead

SandboxRecord * v8::internal::trap_handler::gSandboxRecordsHead = nullptr

Definition at line 37 of file handler-shared.cc.

◆ kCodeObjectGrowthFactor

size_t v8::internal::trap_handler::kCodeObjectGrowthFactor = 2
constexpr

Definition at line 46 of file handler-outside.cc.

◆ kInitialCodeObjectSize

size_t v8::internal::trap_handler::kInitialCodeObjectSize = 1024
constexpr

Definition at line 45 of file handler-outside.cc.

◆ kInvalidIndex

const int v8::internal::trap_handler::kInvalidIndex = -1

Definition at line 111 of file trap-handler.h.