[K/N] Crash with OOM on large array allocations ^KT-54659

Merge-request: KT-MR-7507
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
This commit is contained in:
Alexander Shabalin
2022-11-01 11:00:23 +00:00
committed by Space Team
parent cc4d22b4c9
commit 5ef9a5a240
12 changed files with 116 additions and 61 deletions
@@ -13,7 +13,8 @@ namespace kotlin {
constexpr size_t kObjectAlignment = 8;
constexpr inline size_t AlignUp(size_t size, size_t alignment) {
template <typename T>
constexpr T AlignUp(T size, T alignment) {
return (size + alignment - 1) & ~(alignment - 1);
}
@@ -3,6 +3,8 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
#pragma once
#if __has_include(<optional>)
#include <optional>
#elif __has_include(<experimental/optional>)
@@ -15,4 +17,4 @@ inline constexpr auto nullopt = std::experimental::nullopt;
} // namespace std
#else
#error "No <optional>"
#endif
#endif