From 51eb323c5091f6bbb94ddd99b6e9244da52e0835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 2 Nov 2022 17:22:49 +0000 Subject: [PATCH] deps: V8: cherry-pick 92a7385171bb Original commit message: [heap] Fix 32bit msvc builds Size of ActiveSystemPages is 8 bytes even on 32bit builds, thus forcing 8 bytes alignment for MemoryChunk. Change-Id: I5ca1e18329d6e68a8b6811c3c27cb224c765cb63 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3966953 Commit-Queue: Omer Katz Reviewed-by: Michael Lippautz Cr-Commit-Position: refs/heads/main@{#83845} Refs: https://github.com/v8/v8/commit/92a7385171bb55840351533e0761eb4a1c5e7dd4 PR-URL: https://github.com/nodejs/node/pull/45230 Reviewed-By: Jiawen Geng Reviewed-By: Yagiz Nizipli --- common.gypi | 2 +- deps/v8/src/heap/memory-chunk-layout.h | 17 ++++++++++++++--- deps/v8/src/heap/memory-chunk.cc | 11 +++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/common.gypi b/common.gypi index 42a76de6ca3562..c8ecf1ffae8a9b 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.4', + 'v8_embedder_string': '-node.5', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/heap/memory-chunk-layout.h b/deps/v8/src/heap/memory-chunk-layout.h index 2e1d0e52bb5124..8c771f8b2b411d 100644 --- a/deps/v8/src/heap/memory-chunk-layout.h +++ b/deps/v8/src/heap/memory-chunk-layout.h @@ -37,8 +37,13 @@ using ActiveSystemPages = ::heap::base::ActiveSystemPages; class V8_EXPORT_PRIVATE MemoryChunkLayout { public: - static const int kNumSets = NUMBER_OF_REMEMBERED_SET_TYPES; - static const int kNumTypes = ExternalBackingStoreType::kNumTypes; + static constexpr int kNumSets = NUMBER_OF_REMEMBERED_SET_TYPES; + static constexpr int kNumTypes = ExternalBackingStoreType::kNumTypes; +#if V8_CC_MSVC && V8_TARGET_ARCH_IA32 + static constexpr int kMemoryChunkAlignment = 8; +#else + static constexpr int kMemoryChunkAlignment = sizeof(size_t); +#endif // V8_CC_MSVC && V8_TARGET_ARCH_IA32 #define FIELD(Type, Name) \ k##Name##Offset, k##Name##End = k##Name##Offset + sizeof(Type) - 1 enum Header { @@ -74,11 +79,17 @@ class V8_EXPORT_PRIVATE MemoryChunkLayout { #endif // V8_ENABLE_INNER_POINTER_RESOLUTION_OSB FIELD(size_t, WasUsedForAllocation), kMarkingBitmapOffset, - kMemoryChunkHeaderSize = kMarkingBitmapOffset, + kMemoryChunkHeaderSize = + kMarkingBitmapOffset + + ((kMarkingBitmapOffset % kMemoryChunkAlignment) == 0 + ? 0 + : kMemoryChunkAlignment - + (kMarkingBitmapOffset % kMemoryChunkAlignment)), kMemoryChunkHeaderStart = kSlotSetOffset, kBasicMemoryChunkHeaderSize = kMemoryChunkHeaderStart, kBasicMemoryChunkHeaderStart = 0, }; +#undef FIELD static size_t CodePageGuardStartOffset(); static size_t CodePageGuardSize(); static intptr_t ObjectStartOffsetInCodePage(); diff --git a/deps/v8/src/heap/memory-chunk.cc b/deps/v8/src/heap/memory-chunk.cc index 43749fed278533..fd26d5d73b95a1 100644 --- a/deps/v8/src/heap/memory-chunk.cc +++ b/deps/v8/src/heap/memory-chunk.cc @@ -496,6 +496,17 @@ void MemoryChunk::ValidateOffsets(MemoryChunk* chunk) { DCHECK_EQ(reinterpret_cast
(&chunk->possibly_empty_buckets_) - chunk->address(), MemoryChunkLayout::kPossiblyEmptyBucketsOffset); + DCHECK_EQ(reinterpret_cast
(&chunk->active_system_pages_) - + chunk->address(), + MemoryChunkLayout::kActiveSystemPagesOffset); +#ifdef V8_ENABLE_INNER_POINTER_RESOLUTION_OSB + DCHECK_EQ(reinterpret_cast
(&chunk->object_start_bitmap_) - + chunk->address(), + MemoryChunkLayout::kObjectStartBitmapOffset); +#endif // V8_ENABLE_INNER_POINTER_RESOLUTION_OSB + DCHECK_EQ(reinterpret_cast
(&chunk->was_used_for_allocation_) - + chunk->address(), + MemoryChunkLayout::kWasUsedForAllocationOffset); } #endif