v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
indirect-pointer.h
Go to the documentation of this file.
1// Copyright 2023 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_SANDBOX_INDIRECT_POINTER_H_
6#define V8_SANDBOX_INDIRECT_POINTER_H_
7
10#include "src/sandbox/isolate.h"
11
12namespace v8 {
13namespace internal {
14
15// Indirect pointers.
16//
17// An indirect pointer references a HeapObject (like a tagged pointer), but
18// does so through a pointer table indirection. Indirect pointers are used when
19// the sandbox is enabled to reference objects _outside_ of the sandbox in a
20// memory-safe way. For that, each indirect pointer has an associated
21// IndirectPointerTag which encodes the type of the referenced object. The
22// pointer table indirection then ensures that the tag of the entry in the
23// table matches the type of the referenced object, or else the pointer will be
24// invalid (it cannot be dereferenced).
25
26// Initialize the 'self' indirect pointer that contains a reference back to the
27// owning object through its pointer table entry. For Code objects, this will
28// allocate an entry in the code pointer table. For all other trusted objects,
29// this will allocate an entry in the trusted pointer table.
30//
31// Only available when the sandbox is enabled.
33 Address field_address, IsolateForSandbox isolate, Tagged<HeapObject> host,
35 TrustedPointerPublishingScope* opt_publishing_scope);
36
37// Reads the IndirectPointerHandle from the field and loads the Object
38// referenced by this handle from the appropriate pointer table. The given
39// IndirectPointerTag specifies the expected type of object and determines
40// which pointer table is used: the code pointer table for Code objects and the
41// trusted pointer table for all other trusted objects.
42//
43// Only available when the sandbox is enabled.
44template <IndirectPointerTag tag>
46 IsolateForSandbox isolate,
47 AcquireLoadTag);
48
49// Loads the 'self' IndirectPointerHandle from the given object and stores it
50// into the indirect pointer field. In this way, the field becomes a (indirect)
51// reference to the given object.
52//
53// Only available when the sandbox is enabled.
54template <IndirectPointerTag tag>
57 ReleaseStoreTag);
58
59} // namespace internal
60} // namespace v8
61
62#endif // V8_SANDBOX_INDIRECT_POINTER_H_
V8_INLINE void WriteIndirectPointerField(Address field_address, Tagged< ExposedTrustedObject > value, ReleaseStoreTag)
V8_INLINE Tagged< Object > ReadIndirectPointerField(Address field_address, IsolateForSandbox isolate, AcquireLoadTag)
Tagged(T object) -> Tagged< T >
kInterpreterTrampolineOffset Tagged< HeapObject >
V8_INLINE void InitSelfIndirectPointerField(Address field_address, IsolateForSandbox isolate, Tagged< HeapObject > host, IndirectPointerTag tag, TrustedPointerPublishingScope *opt_publishing_scope)
#define V8_INLINE
Definition v8config.h:500