v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
bounded-size-inl.h
Go to the documentation of this file.
1// Copyright 2022 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_BOUNDED_SIZE_INL_H_
6#define V8_SANDBOX_BOUNDED_SIZE_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"
15
16namespace v8::internal {
17
18V8_INLINE size_t ReadBoundedSizeField(Address field_address) {
19#ifdef V8_ENABLE_SANDBOX
20 size_t raw_value = base::ReadUnalignedValue<size_t>(field_address);
21 return raw_value >> kBoundedSizeShift;
22#else
23 return ReadMaybeUnalignedValue<size_t>(field_address);
24#endif
25}
26
27V8_INLINE void WriteBoundedSizeField(Address field_address, size_t value) {
28#ifdef V8_ENABLE_SANDBOX
29 DCHECK_LE(value, kMaxSafeBufferSizeForSandbox);
30 size_t raw_value = value << kBoundedSizeShift;
31 base::WriteUnalignedValue<size_t>(field_address, raw_value);
32#else
33 WriteMaybeUnalignedValue<size_t>(field_address, value);
34#endif
35}
36
37} // namespace v8::internal
38
39#endif // V8_SANDBOX_BOUNDED_SIZE_INL_H_
static V ReadUnalignedValue(Address p)
Definition memory.h:28
static void WriteUnalignedValue(Address p, V value)
Definition memory.h:41
V8_INLINE size_t ReadBoundedSizeField(Address field_address)
static void WriteMaybeUnalignedValue(Address p, V value)
Definition ptr-compr.h:225
V8_INLINE void WriteBoundedSizeField(Address field_address, size_t value)
static V ReadMaybeUnalignedValue(Address p)
Definition ptr-compr.h:207
#define DCHECK_LE(v1, v2)
Definition logging.h:490
#define V8_INLINE
Definition v8config.h:500