v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
sandboxed-pointer-inl.h
Go to the documentation of this file.
1// Copyright 2021 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_SANDBOXED_POINTER_INL_H_
6#define V8_SANDBOX_SANDBOXED_POINTER_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
11#include "include/v8-internal.h"
13#include "src/sandbox/sandbox.h"
14
15namespace v8 {
16namespace internal {
17
19 PtrComprCageBase cage_base) {
20#ifdef V8_ENABLE_SANDBOX
21 SandboxedPointer_t sandboxed_pointer =
23
24 Address offset = sandboxed_pointer >> kSandboxedPointerShift;
25 Address pointer = cage_base.address() + offset;
26 return pointer;
27#else
28 return ReadMaybeUnalignedValue<Address>(field_address);
29#endif
30}
31
33 PtrComprCageBase cage_base,
34 Address pointer) {
35#ifdef V8_ENABLE_SANDBOX
36 // The pointer must point into the sandbox.
37 CHECK(Sandbox::current()->Contains(pointer));
38
39 Address offset = pointer - cage_base.address();
40 SandboxedPointer_t sandboxed_pointer = offset << kSandboxedPointerShift;
42 sandboxed_pointer);
43#else
44 WriteMaybeUnalignedValue<Address>(field_address, pointer);
45#endif
46}
47
48} // namespace internal
49} // namespace v8
50
51#endif // V8_SANDBOX_SANDBOXED_POINTER_INL_H_
int32_t offset
static V ReadUnalignedValue(Address p)
Definition memory.h:28
static void WriteUnalignedValue(Address p, V value)
Definition memory.h:41
static void WriteMaybeUnalignedValue(Address p, V value)
Definition ptr-compr.h:225
V8_INLINE Address ReadSandboxedPointerField(Address field_address, PtrComprCageBase cage_base)
Address SandboxedPointer_t
V8_INLINE void WriteSandboxedPointerField(Address field_address, PtrComprCageBase cage_base, Address pointer)
static V ReadMaybeUnalignedValue(Address p)
Definition ptr-compr.h:207
#define CHECK(condition)
Definition logging.h:124
#define V8_INLINE
Definition v8config.h:500