v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
isolate.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_ISOLATE_H_
6#define V8_SANDBOX_ISOLATE_H_
7
14
15namespace v8::internal {
16
17class Isolate;
18
19// A reference to an Isolate that only exposes the sandbox-related parts of an
20// isolate, in particular the various pointer tables. Can be used off-thread
21// and implicitly constructed from both an Isolate* and a LocalIsolate*.
22#ifdef V8_ENABLE_SANDBOX
23
24class V8_EXPORT_PRIVATE IsolateForSandbox final {
25 public:
26 template <typename IsolateT>
27 IsolateForSandbox(IsolateT* isolate) // NOLINT(runtime/explicit)
28 : isolate_(isolate->ForSandbox()) {}
29
30 inline ExternalPointerTable& GetExternalPointerTableFor(
31 ExternalPointerTagRange tag_range);
32 inline ExternalPointerTable::Space* GetExternalPointerTableSpaceFor(
33 ExternalPointerTagRange tag_range, Address host);
34
35 inline CodePointerTable::Space* GetCodePointerTableSpaceFor(
36 Address owning_slot);
37
38 inline TrustedPointerTable& GetTrustedPointerTableFor(IndirectPointerTag tag);
39 inline TrustedPointerTable::Space* GetTrustedPointerTableSpaceFor(
40 IndirectPointerTag tag);
41
42 // Object is needed as a witness that this handle does not come from the
43 // shared space.
44 inline ExternalPointerTag GetExternalPointerTableTagFor(
45 Tagged<HeapObject> witness, ExternalPointerHandle handle);
46
47 // Check whether the shared pointer tables of two IsolateForSandbox objects
48 // are the same.
49 inline bool SharesPointerTablesWith(IsolateForSandbox other) const;
50
51 private:
52 Isolate* const isolate_;
53};
54
55// Use this function instead of `Internals::GetIsolateForSandbox` for internal
56// code, as this function is fully inlinable.
57// Note that this method might return an isolate which is not the "current" one
58// as returned by `Isolate::Current()`. Use `GetCurrentIsolateForSandbox`
59// instead where possible.
60// TODO(396607238): Replace all callers with `GetCurrentIsolateForSandbox()`.
61V8_INLINE IsolateForSandbox GetIsolateForSandbox(Tagged<HeapObject> object);
62
63V8_INLINE IsolateForSandbox GetCurrentIsolateForSandbox();
64
65#else // V8_ENABLE_SANDBOX
66
68 public:
69 template <typename IsolateT>
70 constexpr IsolateForSandbox(IsolateT*) {} // NOLINT(runtime/explicit)
71
72 constexpr IsolateForSandbox() = default;
73};
74
79
80#endif // V8_ENABLE_SANDBOX
81
82#ifdef V8_COMPRESS_POINTERS
83class V8_EXPORT_PRIVATE IsolateForPointerCompression final {
84 public:
85 template <typename IsolateT>
86 IsolateForPointerCompression(IsolateT* isolate) // NOLINT(runtime/explicit)
87 : isolate_(isolate->ForSandbox()) {}
88
89 inline ExternalPointerTable& GetExternalPointerTableFor(
90 ExternalPointerTagRange tag_range);
91 inline ExternalPointerTable::Space* GetExternalPointerTableSpaceFor(
92 ExternalPointerTagRange tag_range, Address host);
93
94 inline CppHeapPointerTable& GetCppHeapPointerTable();
95 inline CppHeapPointerTable::Space* GetCppHeapPointerTableSpace();
96
97 private:
98 Isolate* const isolate_;
99};
100#else // V8_COMPRESS_POINTERS
102 public:
103 template <typename IsolateT>
104 constexpr IsolateForPointerCompression(IsolateT*) // NOLINT(runtime/explicit)
105 {}
106};
107#endif // V8_COMPRESS_POINTERS
108
109} // namespace v8::internal
110
111#endif // V8_SANDBOX_ISOLATE_H_
Isolate * isolate_
constexpr IsolateForPointerCompression(IsolateT *)
Definition isolate.h:104
constexpr IsolateForSandbox()=default
constexpr IsolateForSandbox(IsolateT *)
Definition isolate.h:70
V8_INLINE IsolateForSandbox GetCurrentIsolateForSandbox()
Definition isolate.h:78
kInterpreterTrampolineOffset Tagged< HeapObject >
V8_INLINE IsolateForSandbox GetIsolateForSandbox(Tagged< HeapObject >)
Definition isolate.h:75
#define V8_EXPORT_PRIVATE
Definition macros.h:460
#define V8_INLINE
Definition v8config.h:500