diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-03-14 18:25:43 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-03-14 18:25:43 +0300 |
commit | c7783ffcebf50c210ca2b469f3a52f59eb9045f8 (patch) | |
tree | 6c0885079aaefb96aa502108f458659aa66570de /library/cpp/coroutine/engine/stack/ut | |
parent | 831543961b2710a44df149e1d363638bc008d265 (diff) | |
download | ydb-c7783ffcebf50c210ca2b469f3a52f59eb9045f8.tar.gz |
intermediate changes
ref:e520cbb2bc5359a80a7e56e636d1404e61f0c48c
Diffstat (limited to 'library/cpp/coroutine/engine/stack/ut')
5 files changed, 22 insertions, 22 deletions
diff --git a/library/cpp/coroutine/engine/stack/ut/stack_allocator_ut.cpp b/library/cpp/coroutine/engine/stack/ut/stack_allocator_ut.cpp index a7283d44a3..f828793721 100644 --- a/library/cpp/coroutine/engine/stack/ut/stack_allocator_ut.cpp +++ b/library/cpp/coroutine/engine/stack/ut/stack_allocator_ut.cpp @@ -33,7 +33,7 @@ namespace NCoro::NStack::Tests { TEST_P(TAllocatorParamFixture, StackAllocationAndRelease) { - uint64_t stackSize = PageSize * 12; + size_t stackSize = PageSize * 12; auto stack = Allocator_->AllocStack(stackSize, "test_stack"); #if defined(_san_enabled_) || !defined(NDEBUG) stackSize *= DebugOrSanStackMultiplier; @@ -41,10 +41,10 @@ namespace NCoro::NStack::Tests { // Correct stack should have EXPECT_EQ(stack.GetSize(), stackSize); // predefined size - EXPECT_FALSE((uint64_t)stack.GetAlignedMemory() & PageSizeMask); // aligned pointer + EXPECT_FALSE((size_t)stack.GetAlignedMemory() & PageSizeMask); // aligned pointer // Writable workspace auto workspace = Allocator_->GetStackWorkspace(stack.GetAlignedMemory(), stack.GetSize()); - for (uint64_t i = 0; i < workspace.size(); i += 512) { + for (size_t i = 0; i < workspace.size(); i += 512) { workspace[i] = 42; } EXPECT_TRUE(Allocator_->CheckStackOverflow(stack.GetAlignedMemory())); @@ -87,7 +87,7 @@ namespace NCoro::NStack::Tests { : Allocator_(GetAllocator<AllocatorType>(EGuard::Page)) {} - const uint64_t StackSize_ = PageSize * 2; + const size_t StackSize_ = PageSize * 2; THolder<IAllocator> Allocator_; }; diff --git a/library/cpp/coroutine/engine/stack/ut/stack_guards_ut.cpp b/library/cpp/coroutine/engine/stack/ut/stack_guards_ut.cpp index 9da9a9b3d5..418ec56096 100644 --- a/library/cpp/coroutine/engine/stack/ut/stack_guards_ut.cpp +++ b/library/cpp/coroutine/engine/stack/ut/stack_guards_ut.cpp @@ -32,7 +32,7 @@ namespace NCoro::NStack::Tests { } TYPED_TEST(TGuardFixture, StackWorkspace) { - for (uint64_t sizeInPages : {2, 5, 12}) { + for (size_t sizeInPages : {2, 5, 12}) { char *rawPtr, *alignedPtr = nullptr; ASSERT_TRUE(GetAlignedMemory(sizeInPages, rawPtr, alignedPtr)); auto workspace = this->Guard_.GetWorkspace(alignedPtr, sizeInPages * PageSize); @@ -52,7 +52,7 @@ namespace NCoro::NStack::Tests { TYPED_TEST(TGuardFixture, SetRemoveProtectionWorks) { char *rawPtr, *alignedPtr = nullptr; - constexpr uint64_t sizeInPages = 4; + constexpr size_t sizeInPages = 4; ASSERT_TRUE(GetAlignedMemory(sizeInPages + 1, rawPtr, alignedPtr)); this->Guard_.Protect(alignedPtr, PageSize, false); // set previous guard @@ -72,7 +72,7 @@ namespace NCoro::NStack::Tests { const auto& guard = GetGuard<TCanaryGuard>(); char *rawPtr, *alignedPtr = nullptr; - constexpr uint64_t sizeInPages = 4; + constexpr size_t sizeInPages = 4; ASSERT_TRUE(GetAlignedMemory(sizeInPages + 1, rawPtr, alignedPtr)); guard.Protect(alignedPtr, PageSize, false); // set previous guard alignedPtr += PageSize; // leave first page for previous guard @@ -93,7 +93,7 @@ namespace NCoro::NStack::Tests { const auto& guard = GetGuard<TCanaryGuard>(); char *rawPtr, *alignedPtr = nullptr; - constexpr uint64_t sizeInPages = 4; + constexpr size_t sizeInPages = 4; ASSERT_TRUE(GetAlignedMemory(sizeInPages + 1, rawPtr, alignedPtr)); guard.Protect(alignedPtr, PageSize, false); // set previous guard alignedPtr += PageSize; // leave first page for previous guard @@ -116,7 +116,7 @@ namespace NCoro::NStack::Tests { char* rawPtr = nullptr; char* alignedPtr = nullptr; - constexpr uint64_t sizeInPages = 4; + constexpr size_t sizeInPages = 4; ASSERT_TRUE(GetAlignedMemory(sizeInPages + 1, rawPtr, alignedPtr)); guard.Protect(alignedPtr, PageSize, false); // set previous guard @@ -139,7 +139,7 @@ namespace NCoro::NStack::Tests { char* rawPtr = nullptr; char* alignedPtr = nullptr; - constexpr uint64_t sizeInPages = 4; + constexpr size_t sizeInPages = 4; ASSERT_TRUE(GetAlignedMemory(sizeInPages + 1, rawPtr, alignedPtr)); guard.Protect(alignedPtr, PageSize, false); // set previous guard alignedPtr += PageSize; // leave first page for previous guard diff --git a/library/cpp/coroutine/engine/stack/ut/stack_pool_ut.cpp b/library/cpp/coroutine/engine/stack/ut/stack_pool_ut.cpp index 9e3e5e7117..cec3f2ae56 100644 --- a/library/cpp/coroutine/engine/stack/ut/stack_pool_ut.cpp +++ b/library/cpp/coroutine/engine/stack/ut/stack_pool_ut.cpp @@ -13,7 +13,7 @@ namespace NCoro::NStack::Tests { protected: TPoolFixture() : Guard_(GetGuard<TGuard>()), Pool_(StackSize_, TPoolAllocatorSettings{1, 1, 8, 32}, Guard_) {} - const uint64_t StackSize_ = PageSize * 4; + const size_t StackSize_ = PageSize * 4; const TGuard& Guard_; TPool<TGuard> Pool_; }; diff --git a/library/cpp/coroutine/engine/stack/ut/stack_ut.cpp b/library/cpp/coroutine/engine/stack/ut/stack_ut.cpp index 31f8ad6b61..7b02d0cfd4 100644 --- a/library/cpp/coroutine/engine/stack/ut/stack_ut.cpp +++ b/library/cpp/coroutine/engine/stack/ut/stack_ut.cpp @@ -9,7 +9,7 @@ using namespace testing; namespace NCoro::NStack::Tests { - constexpr uint64_t StackSizeInPages = 4; + constexpr size_t StackSizeInPages = 4; template <class TGuard> class TStackFixture : public Test { @@ -34,7 +34,7 @@ namespace NCoro::NStack::Tests { protected: // data const TGuard& Guard_; - const uint64_t StackSize_ = 0; + const size_t StackSize_ = 0; char* RawMemory_ = nullptr; char* AlignedMemory_ = nullptr; THolder<NDetails::TStack> Stack_; @@ -51,7 +51,7 @@ namespace NCoro::NStack::Tests { TYPED_TEST(TStackFixture, WriteStack) { auto workspace = this->Guard_.GetWorkspace(this->Stack_->GetAlignedMemory(), this->Stack_->GetSize()); - for (uint64_t i = 0; i < workspace.size(); i += 512) { + for (size_t i = 0; i < workspace.size(); i += 512) { workspace[i] = 42; } EXPECT_TRUE(this->Guard_.CheckOverride(this->Stack_->GetAlignedMemory(), this->Stack_->GetSize())); diff --git a/library/cpp/coroutine/engine/stack/ut/stack_utils_ut.cpp b/library/cpp/coroutine/engine/stack/ut/stack_utils_ut.cpp index dc0593dcf2..8ef895dcf0 100644 --- a/library/cpp/coroutine/engine/stack/ut/stack_utils_ut.cpp +++ b/library/cpp/coroutine/engine/stack/ut/stack_utils_ut.cpp @@ -9,11 +9,11 @@ namespace NCoro::NStack::Tests { TEST(StackUtilsTest, Allocation) { char *rawPtr, *alignedPtr = nullptr; - for (uint64_t i : {1, 2, 3, 4, 11}) { + for (size_t i : {1, 2, 3, 4, 11}) { EXPECT_TRUE(GetAlignedMemory(i, rawPtr, alignedPtr)); EXPECT_TRUE(rawPtr); EXPECT_TRUE(alignedPtr); - EXPECT_FALSE((uint64_t)alignedPtr & PageSizeMask); + EXPECT_FALSE((size_t)alignedPtr & PageSizeMask); free(rawPtr); } } @@ -22,11 +22,11 @@ namespace NCoro::NStack::Tests { TEST(StackUtilsTest, RssReleaseOnePage) { char *rawPtr, *alignedPtr = nullptr; - for (uint64_t i : {1, 2, 8}) { + for (size_t i : {1, 2, 8}) { EXPECT_TRUE(GetAlignedMemory(i, rawPtr, alignedPtr)); EXPECT_TRUE(rawPtr); EXPECT_TRUE(alignedPtr); - EXPECT_FALSE((uint64_t)alignedPtr & PageSizeMask); + EXPECT_FALSE((size_t)alignedPtr & PageSizeMask); ReleaseRss(alignedPtr, i); // allocator can provide reused memory with RSS memory on it EXPECT_EQ(CountMapped(alignedPtr, i), 0ul); // no RSS memory allocated @@ -44,21 +44,21 @@ namespace NCoro::NStack::Tests { TEST(StackUtilsTest, RssReleaseSeveralPages) { char *rawPtr, *alignedPtr = nullptr; - for (uint64_t i : {1, 2, 5, 8}) { + for (size_t i : {1, 2, 5, 8}) { EXPECT_TRUE(GetAlignedMemory(i, rawPtr, alignedPtr)); EXPECT_TRUE(rawPtr); EXPECT_TRUE(alignedPtr); - EXPECT_FALSE((uint64_t)alignedPtr & PageSizeMask); + EXPECT_FALSE((size_t)alignedPtr & PageSizeMask); ReleaseRss(alignedPtr, i); // allocator can provide reused memory with RSS memory on it EXPECT_EQ(CountMapped(alignedPtr, i), 0ul); // no RSS memory allocated - for (uint64_t page = 0; page < i; ++page) { + for (size_t page = 0; page < i; ++page) { *(alignedPtr + page * PageSize) = 42; // map RSS memory EXPECT_EQ(CountMapped(alignedPtr, page + 1), page + 1); } - const uint64_t pagesToKeep = (i > 2) ? 2 : i; + const size_t pagesToKeep = (i > 2) ? 2 : i; ReleaseRss(alignedPtr, i - pagesToKeep); EXPECT_EQ(CountMapped(alignedPtr, i), pagesToKeep) << "number of pages " << i; // no RSS memory allocated |