v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
external-pointer.h
Go to the documentation of this file.
1// Copyright 2020 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_EXTERNAL_POINTER_H_
6#define V8_SANDBOX_EXTERNAL_POINTER_H_
7
10
11namespace v8 {
12namespace internal {
13
14template <ExternalPointerTag tag>
16 public:
18
19 void Init(Address host_address, IsolateForSandbox isolate, Address value);
20
21 inline Address load(const IsolateForSandbox isolate) const;
22 inline void store(IsolateForSandbox isolate, Address value);
23
24 inline ExternalPointer_t load_encoded() const;
25 inline void store_encoded(ExternalPointer_t value);
26
27 Address storage_address() { return reinterpret_cast<Address>(storage_); }
28
29 private:
30 alignas(alignof(Tagged_t)) char storage_[sizeof(ExternalPointer_t)];
31};
32
33// Writes the null handle or kNullAddress into the external pointer field.
35
36// Creates and initializes an entry in the external pointer table and writes the
37// handle for that entry to the field.
38template <ExternalPointerTag tag>
40 Address field_address,
41 IsolateForSandbox isolate,
42 Address value);
43
44// If the sandbox is enabled: reads the ExternalPointerHandle from the field and
45// loads the corresponding external pointer from the external pointer table. If
46// the sandbox is disabled: load the external pointer from the field.
47//
48// This can be used for both regular and lazily-initialized external pointer
49// fields since lazily-initialized field will initially contain
50// kNullExternalPointerHandle, which is guaranteed to result in kNullAddress
51// being returned from the external pointer table.
52template <ExternalPointerTagRange tag_range>
54 IsolateForSandbox isolate);
55
56// If the sandbox is enabled: reads the ExternalPointerHandle from the field and
57// stores the external pointer to the corresponding entry in the external
58// pointer table. If the sandbox is disabled: stores the external pointer to the
59// field.
60template <ExternalPointerTag tag>
62 IsolateForSandbox isolate,
63 Address value);
64
65} // namespace internal
66} // namespace v8
67
68#endif // V8_SANDBOX_EXTERNAL_POINTER_H_
void store_encoded(ExternalPointer_t value)
char storage_[sizeof(ExternalPointer_t)]
void store(IsolateForSandbox isolate, Address value)
void Init(Address host_address, IsolateForSandbox isolate, Address value)
Address load(const IsolateForSandbox isolate) const
V8_INLINE void WriteExternalPointerField(Address field_address, IsolateForSandbox isolate, Address value)
Address Tagged_t
Definition globals.h:547
V8_INLINE Address ReadExternalPointerField(Address field_address, IsolateForSandbox isolate)
Address ExternalPointer_t
V8_INLINE void InitExternalPointerField(Address host_address, Address field_address, IsolateForSandbox isolate, Address value)
V8_INLINE void InitLazyExternalPointerField(Address field_address)
#define V8_INLINE
Definition v8config.h:500