cppgc: Provide alignment attribute to allocations functions
assume_aligned allows the caller may assume alignment of the allocation methods. Bug: v8:12295 Change-Id: I0c946dd668ae9c0c1d83da7278ad8d87bab96717 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3218984 Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Anton Bikineev <bikineev@chromium.org> Cr-Commit-Position: refs/heads/main@{#77366}
This commit is contained in:
parent
5638b7db6a
commit
83c9bdeddf
@ -18,6 +18,23 @@
|
||||
#include "cppgc/type-traits.h"
|
||||
#include "v8config.h" // NOLINT(build/include_directory)
|
||||
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(assume_aligned)
|
||||
#define CPPGC_DEFAULT_ALIGNED \
|
||||
__attribute__((assume_aligned(api_constants::kDefaultAlignment)))
|
||||
#define CPPGC_DOUBLE_WORD_ALIGNED \
|
||||
__attribute__((assume_aligned(2 * api_constants::kDefaultAlignment)))
|
||||
#endif // __has_attribute(assume_aligned)
|
||||
#endif // defined(__has_attribute)
|
||||
|
||||
#if !defined(CPPGC_DEFAULT_ALIGNED)
|
||||
#define CPPGC_DEFAULT_ALIGNED
|
||||
#endif
|
||||
|
||||
#if !defined(CPPGC_DOUBLE_WORD_ALIGNED)
|
||||
#define CPPGC_DOUBLE_WORD_ALIGNED
|
||||
#endif
|
||||
|
||||
namespace cppgc {
|
||||
|
||||
/**
|
||||
@ -104,15 +121,16 @@ class V8_EXPORT MakeGarbageCollectedTraitInternal {
|
||||
};
|
||||
|
||||
private:
|
||||
static void* Allocate(cppgc::AllocationHandle& handle, size_t size,
|
||||
GCInfoIndex index);
|
||||
static void* Allocate(cppgc::AllocationHandle& handle, size_t size,
|
||||
AlignVal alignment, GCInfoIndex index);
|
||||
static void* Allocate(cppgc::AllocationHandle& handle, size_t size,
|
||||
GCInfoIndex index, CustomSpaceIndex space_index);
|
||||
static void* Allocate(cppgc::AllocationHandle& handle, size_t size,
|
||||
AlignVal alignment, GCInfoIndex index,
|
||||
CustomSpaceIndex space_index);
|
||||
static void* CPPGC_DEFAULT_ALIGNED Allocate(cppgc::AllocationHandle&, size_t,
|
||||
GCInfoIndex);
|
||||
static void* CPPGC_DOUBLE_WORD_ALIGNED Allocate(cppgc::AllocationHandle&,
|
||||
size_t, AlignVal,
|
||||
GCInfoIndex);
|
||||
static void* CPPGC_DEFAULT_ALIGNED Allocate(cppgc::AllocationHandle&, size_t,
|
||||
GCInfoIndex, CustomSpaceIndex);
|
||||
static void* CPPGC_DOUBLE_WORD_ALIGNED Allocate(cppgc::AllocationHandle&,
|
||||
size_t, AlignVal, GCInfoIndex,
|
||||
CustomSpaceIndex);
|
||||
|
||||
friend class HeapObjectHeader;
|
||||
};
|
||||
@ -286,4 +304,7 @@ V8_INLINE T* MakeGarbageCollected(AllocationHandle& handle,
|
||||
|
||||
} // namespace cppgc
|
||||
|
||||
#undef CPPGC_DEFAULT_ALIGNED
|
||||
#undef CPPGC_DOUBLE_WORD_ALIGNED
|
||||
|
||||
#endif // INCLUDE_CPPGC_ALLOCATION_H_
|
||||
|
Loading…
Reference in New Issue
Block a user