v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
allocation.cc
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
#include "
include/cppgc/allocation.h
"
6
7
#include "
include/cppgc/internal/api-constants.h
"
8
#include "
src/base/macros.h
"
9
#include "
src/heap/cppgc/globals.h
"
10
#include "
src/heap/cppgc/object-allocator.h
"
11
12
#if defined(__clang__) && !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE
13
#define CPPGC_FORCE_ALWAYS_INLINE __attribute__((always_inline))
14
#else
15
#define CPPGC_FORCE_ALWAYS_INLINE
16
#endif
17
18
namespace
cppgc
{
19
namespace
internal {
20
21
static_assert
(
api_constants::kLargeObjectSizeThreshold
==
22
kLargeObjectSizeThreshold
);
23
24
#if !(defined(V8_HOST_ARCH_32_BIT) && defined(V8_CC_GNU))
25
// GCC on x86 has alignof(std::max_align_t) == 16 (quad word) which is not
26
// satisfied by Oilpan.
27
static_assert
(
api_constants::kMaxSupportedAlignment
>=
28
alignof
(std::max_align_t),
29
"Maximum support alignment must at least cover "
30
"alignof(std::max_align_t)."
);
31
#endif
// !(defined(V8_HOST_ARCH_32_BIT) && defined(V8_CC_GNU))
32
33
// Using CPPGC_FORCE_ALWAYS_INLINE to guide LTO for inlining the allocation
34
// fast path.
35
// static
36
CPPGC_FORCE_ALWAYS_INLINE
void
*
MakeGarbageCollectedTraitInternal::Allocate
(
37
cppgc::AllocationHandle
& handle,
size_t
size,
GCInfoIndex
index) {
38
return
static_cast<
ObjectAllocator
&
>
(handle).AllocateObject(size, index);
39
}
40
41
// Using CPPGC_FORCE_ALWAYS_INLINE to guide LTO for inlining the allocation
42
// fast path.
43
// static
44
CPPGC_FORCE_ALWAYS_INLINE
void
*
MakeGarbageCollectedTraitInternal::Allocate
(
45
cppgc::AllocationHandle
& handle,
size_t
size,
AlignVal
alignment,
46
GCInfoIndex
index) {
47
return
static_cast<
ObjectAllocator
&
>
(handle).AllocateObject(size, alignment,
48
index);
49
}
50
51
// Using CPPGC_FORCE_ALWAYS_INLINE to guide LTO for inlining the allocation
52
// fast path.
53
// static
54
CPPGC_FORCE_ALWAYS_INLINE
void
*
MakeGarbageCollectedTraitInternal::Allocate
(
55
cppgc::AllocationHandle
& handle,
size_t
size,
GCInfoIndex
index,
56
CustomSpaceIndex
space_index) {
57
return
static_cast<
ObjectAllocator
&
>
(handle).AllocateObject(size, index,
58
space_index);
59
}
60
61
// Using CPPGC_FORCE_ALWAYS_INLINE to guide LTO for inlining the allocation
62
// fast path.
63
// static
64
CPPGC_FORCE_ALWAYS_INLINE
void
*
MakeGarbageCollectedTraitInternal::Allocate
(
65
cppgc::AllocationHandle
& handle,
size_t
size,
AlignVal
alignment,
66
GCInfoIndex
index,
CustomSpaceIndex
space_index) {
67
return
static_cast<
ObjectAllocator
&
>
(handle).AllocateObject(
68
size, alignment, index, space_index);
69
}
70
71
}
// namespace internal
72
}
// namespace cppgc
api-constants.h
cppgc::AllocationHandle
Definition
object-allocator.h:28
cppgc::internal::MakeGarbageCollectedTraitInternal::Allocate
static V8_EXPORT void *CPPGC_DEFAULT_ALIGNED Allocate(cppgc::AllocationHandle &, size_t, GCInfoIndex)
Definition
allocation.cc:36
cppgc::internal::ObjectAllocator
Definition
object-allocator.h:40
CPPGC_FORCE_ALWAYS_INLINE
#define CPPGC_FORCE_ALWAYS_INLINE
Definition
allocation.cc:15
globals.h
allocation.h
cppgc::internal::api_constants::kMaxSupportedAlignment
static constexpr size_t kMaxSupportedAlignment
Definition
api-constants.h:62
cppgc::internal::api_constants::kLargeObjectSizeThreshold
static constexpr size_t kLargeObjectSizeThreshold
Definition
api-constants.h:36
cppgc::internal::AlignVal
std::align_val_t AlignVal
Definition
allocation.h:47
cppgc::internal::kLargeObjectSizeThreshold
constexpr size_t kLargeObjectSizeThreshold
Definition
globals.h:46
cppgc::internal::GCInfoIndex
uint16_t GCInfoIndex
Definition
gc-info.h:21
cppgc
Definition
cross-heap-remembered-set.h:14
object-allocator.h
macros.h
cppgc::CustomSpaceIndex
Definition
custom-space.h:15
src
heap
cppgc
allocation.cc
Generated on Sun Apr 6 2025 21:08:54 for v8 by
1.12.0