diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-03-07 12:37:54 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-03-07 16:48:52 +0100 |
commit | 9759573997a1bbd58fc0ba62e8aa1b4f607ec158 (patch) | |
tree | 616289d04ec752aa94321c52cdfc1a0479631e51 /deps/v8/src/heap | |
parent | b4c1222acc6ada19349c4f18723edce105bfce72 (diff) | |
download | android-node-v8-9759573997a1bbd58fc0ba62e8aa1b4f607ec158.tar.gz android-node-v8-9759573997a1bbd58fc0ba62e8aa1b4f607ec158.tar.bz2 android-node-v8-9759573997a1bbd58fc0ba62e8aa1b4f607ec158.zip |
deps: cherry-pick 46c4979 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}
Refs: https://github.com/v8/v8/commit/46c4979e860a9aaf4444616955e896e70e72afbf
PR-URL: https://github.com/nodejs/node/pull/18453
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
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 49c2eccb2d..7f965602b8 100644 --- a/deps/v8/src/heap/heap.cc +++ b/deps/v8/src/heap/heap.cc @@ -5078,8 +5078,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 3d8234f392..7cc65479ca 100644 --- a/deps/v8/src/heap/heap.h +++ b/deps/v8/src/heap/heap.h @@ -603,15 +603,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; @@ -1360,10 +1360,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); } @@ -1375,11 +1375,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); } |