[sandbox] Reduce max size of ExternalPointerTable on Android

Bug: v8:13661
Change-Id: Iec08bc81fc2d42b728a05bbbe51c765d3982427c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4173595
Reviewed-by: Samuel Groß <saelo@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Paolo Severini <paolosev@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#85347}
This commit is contained in:
Paolo Severini 2023-01-17 08:09:49 -08:00 committed by V8 LUCI CQ
parent 0033691b2a
commit 11a63fa8d2

View File

@ -242,21 +242,26 @@ static_assert(1ULL << (64 - kBoundedSizeShift) ==
#ifdef V8_COMPRESS_POINTERS
#ifdef V8_TARGET_OS_ANDROID
// The size of the virtual memory reservation for an external pointer table.
// This determines the maximum number of entries in a table. Using a maximum
// size allows omitting bounds checks on table accesses if the indices are
// guaranteed (e.g. through shifting) to be below the maximum index. This
// value must be a power of two.
static const size_t kExternalPointerTableReservationSize = 1024 * MB;
// The maximum number of entries in an external pointer table.
static const size_t kMaxExternalPointers =
kExternalPointerTableReservationSize / kApiSystemPointerSize;
static const size_t kExternalPointerTableReservationSize = 512 * MB;
// The external pointer table indices stored in HeapObjects as external
// pointers are shifted to the left by this amount to guarantee that they are
// smaller than the maximum table size.
static const uint32_t kExternalPointerIndexShift = 6;
#else
static const size_t kExternalPointerTableReservationSize = 1024 * MB;
static const uint32_t kExternalPointerIndexShift = 5;
#endif // V8_TARGET_OS_ANDROID
// The maximum number of entries in an external pointer table.
static const size_t kMaxExternalPointers =
kExternalPointerTableReservationSize / kApiSystemPointerSize;
static_assert((1 << (32 - kExternalPointerIndexShift)) == kMaxExternalPointers,
"kExternalPointerTableReservationSize and "
"kExternalPointerIndexShift don't match");