diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2018-02-21 14:53:53 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-02-22 15:11:55 +0000 |
commit | 13cb056e4cfce7419148eb089205735fb12bcd9f (patch) | |
tree | 3774f315b72e7136a6b0f042681a382f783adce3 /deps/v8/src/heap | |
parent | 26231548ad1dff971cdeaab3085b372a75ad1efb (diff) | |
download | android-node-v8-13cb056e4cfce7419148eb089205735fb12bcd9f.tar.gz android-node-v8-13cb056e4cfce7419148eb089205735fb12bcd9f.tar.bz2 android-node-v8-13cb056e4cfce7419148eb089205735fb12bcd9f.zip |
deps: cherry-pick 46c4979e86 from upstream v8
Original commit message:
Use wider types for max_old_space_size and co.
Make --max_old_space_size and friends work with values >= 2**31.
Such values did not work reliably (or sometimes not all) due to
signed integer overflow in size computations, which is UB.
Fixes https://github.com/nodejs/node/issues/18786.
Bug: chromium:814138
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Ibe23cef2417fd5b4a727022b8b0d4b50f1417182
Reviewed-on: https://chromium-review.googlesource.com/927063
Commit-Queue: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51433}
PR-URL: https://github.com/nodejs/node/pull/18920
Fixes: https://github.com/nodejs/node/issues/18786
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'deps/v8/src/heap')
-rw-r--r-- | deps/v8/src/heap/heap.cc | 4 | ||||
-rw-r--r-- | deps/v8/src/heap/heap.h | 26 |
2 files changed, 15 insertions, 15 deletions
diff --git a/deps/v8/src/heap/heap.cc b/deps/v8/src/heap/heap.cc index d90f086be4..5aed117903 100644 --- a/deps/v8/src/heap/heap.cc +++ b/deps/v8/src/heap/heap.cc @@ -5095,8 +5095,8 @@ bool Heap::ConfigureHeap(size_t max_semi_space_size_in_kb, // The new space size must be a power of two to support single-bit testing // for containment. - max_semi_space_size_ = base::bits::RoundUpToPowerOfTwo32( - static_cast<uint32_t>(max_semi_space_size_)); + max_semi_space_size_ = static_cast<size_t>(base::bits::RoundUpToPowerOfTwo64( + static_cast<uint64_t>(max_semi_space_size_))); if (max_semi_space_size_ == kMaxSemiSpaceSizeInKB * KB) { // Start with at least 1*MB semi-space on machines with a lot of memory. diff --git a/deps/v8/src/heap/heap.h b/deps/v8/src/heap/heap.h index 7048d01e25..72d74c9715 100644 --- a/deps/v8/src/heap/heap.h +++ b/deps/v8/src/heap/heap.h @@ -626,15 +626,15 @@ class Heap { #endif // Semi-space size needs to be a multiple of page size. - static const int kMinSemiSpaceSizeInKB = + static const size_t kMinSemiSpaceSizeInKB = 1 * kPointerMultiplier * ((1 << kPageSizeBits) / KB); - static const int kMaxSemiSpaceSizeInKB = + static const size_t kMaxSemiSpaceSizeInKB = 16 * kPointerMultiplier * ((1 << kPageSizeBits) / KB); // The old space size has to be a multiple of Page::kPageSize. // Sizes are in MB. - static const int kMinOldGenerationSize = 128 * kPointerMultiplier; - static const int kMaxOldGenerationSize = 1024 * kPointerMultiplier; + static const size_t kMinOldGenerationSize = 128 * kPointerMultiplier; + static const size_t kMaxOldGenerationSize = 1024 * kPointerMultiplier; static const int kTraceRingBufferSize = 512; static const int kStacktraceBufferSize = 512; @@ -1372,10 +1372,10 @@ class Heap { size_t MaxOldGenerationSize() { return max_old_generation_size_; } static size_t ComputeMaxOldGenerationSize(uint64_t physical_memory) { - const int old_space_physical_memory_factor = 4; - int computed_size = - static_cast<int>(physical_memory / i::MB / - old_space_physical_memory_factor * kPointerMultiplier); + const size_t old_space_physical_memory_factor = 4; + size_t computed_size = static_cast<size_t>( + physical_memory / i::MB / old_space_physical_memory_factor * + kPointerMultiplier); return Max(Min(computed_size, kMaxOldGenerationSize), kMinOldGenerationSize); } @@ -1387,11 +1387,11 @@ class Heap { uint64_t capped_physical_memory = Max(Min(physical_memory, max_physical_memory), min_physical_memory); // linearly scale max semi-space size: (X-A)/(B-A)*(D-C)+C - int semi_space_size_in_kb = - static_cast<int>(((capped_physical_memory - min_physical_memory) * - (kMaxSemiSpaceSizeInKB - kMinSemiSpaceSizeInKB)) / - (max_physical_memory - min_physical_memory) + - kMinSemiSpaceSizeInKB); + size_t semi_space_size_in_kb = + static_cast<size_t>(((capped_physical_memory - min_physical_memory) * + (kMaxSemiSpaceSizeInKB - kMinSemiSpaceSizeInKB)) / + (max_physical_memory - min_physical_memory) + + kMinSemiSpaceSizeInKB); return RoundUp(semi_space_size_in_kb, (1 << kPageSizeBits) / KB); } |