aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/coroutine/engine/stack
diff options
context:
space:
mode:
authorilnurkh <ilnurkh@yandex-team.com>2023-10-09 23:39:40 +0300
committerilnurkh <ilnurkh@yandex-team.com>2023-10-09 23:57:14 +0300
commite601ca03f859335d57ecff2e5aa6af234b6052ed (patch)
treede519a847e58a1b3993fcbfe05ff44cc946a3e24 /library/cpp/coroutine/engine/stack
parentbbf2b6878af3854815a2c0ecb07a687071787639 (diff)
downloadydb-e601ca03f859335d57ecff2e5aa6af234b6052ed.tar.gz
Y_VERIFY->Y_ABORT_UNLESS at ^l
https://clubs.at.yandex-team.ru/arcadia/29404
Diffstat (limited to 'library/cpp/coroutine/engine/stack')
-rw-r--r--library/cpp/coroutine/engine/stack/benchmark/alloc_bm.cpp4
-rw-r--r--library/cpp/coroutine/engine/stack/stack_allocator.inl8
-rw-r--r--library/cpp/coroutine/engine/stack/stack_guards.h2
-rw-r--r--library/cpp/coroutine/engine/stack/stack_pool.inl2
-rw-r--r--library/cpp/coroutine/engine/stack/stack_storage.h6
-rw-r--r--library/cpp/coroutine/engine/stack/stack_utils.cpp8
6 files changed, 15 insertions, 15 deletions
diff --git a/library/cpp/coroutine/engine/stack/benchmark/alloc_bm.cpp b/library/cpp/coroutine/engine/stack/benchmark/alloc_bm.cpp
index 0a71b02e62..6573dd0dc9 100644
--- a/library/cpp/coroutine/engine/stack/benchmark/alloc_bm.cpp
+++ b/library/cpp/coroutine/engine/stack/benchmark/alloc_bm.cpp
@@ -17,14 +17,14 @@ namespace NCoro::NStack::NBenchmark {
constexpr size_t ManyStacks = 4096;
void BasicOperations(TStackHolder& stack) {
- Y_VERIFY(!stack.Get().empty());
+ Y_ABORT_UNLESS(!stack.Get().empty());
stack.LowerCanaryOk();
stack.UpperCanaryOk();
}
void WriteStack(TStackHolder& stack) {
auto memory = stack.Get();
- Y_VERIFY(!memory.empty());
+ Y_ABORT_UNLESS(!memory.empty());
stack.LowerCanaryOk();
stack.UpperCanaryOk();
for (size_t i = PageSize / 2; i < memory.size(); i += PageSize * 2) {
diff --git a/library/cpp/coroutine/engine/stack/stack_allocator.inl b/library/cpp/coroutine/engine/stack/stack_allocator.inl
index 2f8856da46..5d2de52f0d 100644
--- a/library/cpp/coroutine/engine/stack/stack_allocator.inl
+++ b/library/cpp/coroutine/engine/stack/stack_allocator.inl
@@ -52,7 +52,7 @@ namespace NCoro::NStack {
, Guard_(GetGuard<TGuard>())
{
#ifdef _linux_
- Y_VERIFY(sysconf(_SC_PAGESIZE) == PageSize);
+ Y_ABORT_UNLESS(sysconf(_SC_PAGESIZE) == PageSize);
#endif
}
@@ -64,7 +64,7 @@ namespace NCoro::NStack {
if (pool == Pools_.end()) {
Y_ASSERT(Pools_.size() < 1000); // too many different sizes for coroutine stacks
auto [newPool, success] = Pools_.emplace(alignedSize, TPool<TGuard>{alignedSize, PoolSettings_, Guard_});
- Y_VERIFY(success, "Failed to add new coroutine pool");
+ Y_ABORT_UNLESS(success, "Failed to add new coroutine pool");
pool = newPool;
}
return pool->second.AllocStack(name);
@@ -73,7 +73,7 @@ namespace NCoro::NStack {
template<typename TGuard>
void TPoolAllocator<TGuard>::DoFreeStack(NDetails::TStack& stack) noexcept {
auto pool = Pools_.find(stack.GetSize());
- Y_VERIFY(pool != Pools_.end(), "Attempt to free stack from another allocator");
+ Y_ABORT_UNLESS(pool != Pools_.end(), "Attempt to free stack from another allocator");
pool->second.FreeStack(stack);
}
@@ -117,7 +117,7 @@ namespace NCoro::NStack {
char* rawPtr = nullptr;
char* alignedPtr = nullptr; // with extra space for previous guard in this type of allocator
- Y_VERIFY(GetAlignedMemory((alignedSize + Guard_.GetPageAlignedSize()) / PageSize, rawPtr, alignedPtr)); // + memory for previous guard
+ Y_ABORT_UNLESS(GetAlignedMemory((alignedSize + Guard_.GetPageAlignedSize()) / PageSize, rawPtr, alignedPtr)); // + memory for previous guard
char* alignedStackMemory = alignedPtr + Guard_.GetPageAlignedSize(); // after previous guard
// Default allocator sets both guards, because it doesn't have memory chunk with previous stack and guard on it
diff --git a/library/cpp/coroutine/engine/stack/stack_guards.h b/library/cpp/coroutine/engine/stack/stack_guards.h
index f22000b152..b7f93f2160 100644
--- a/library/cpp/coroutine/engine/stack/stack_guards.h
+++ b/library/cpp/coroutine/engine/stack/stack_guards.h
@@ -42,7 +42,7 @@ namespace NCoro::NStack {
Y_ASSERT(size >= Canary.size()); // stack should have enough space to place guard
if (checkPrevious) {
- Y_VERIFY(CheckOverflow(stack), "Previous stack was corrupted");
+ Y_ABORT_UNLESS(CheckOverflow(stack), "Previous stack was corrupted");
}
auto guardPos = (char*) stack + size - Canary.size();
memcpy(guardPos, Canary.data(), Canary.size());
diff --git a/library/cpp/coroutine/engine/stack/stack_pool.inl b/library/cpp/coroutine/engine/stack/stack_pool.inl
index 503e75664e..0aa1f3a4d0 100644
--- a/library/cpp/coroutine/engine/stack/stack_pool.inl
+++ b/library/cpp/coroutine/engine/stack/stack_pool.inl
@@ -91,7 +91,7 @@ namespace NCoro::NStack {
TMemory memory;
const auto res = GetAlignedMemory(totalSizeInPages, memory.Raw, memory.Aligned);
- Y_VERIFY(res, "Failed to allocate memory for coro stack pool");
+ Y_ABORT_UNLESS(res, "Failed to allocate memory for coro stack pool");
NextToAlloc_ = memory.Aligned + Guard_.GetPageAlignedSize(); // skip first guard page
Guard_.Protect(memory.Aligned, Guard_.GetPageAlignedSize(), false); // protect first guard page
diff --git a/library/cpp/coroutine/engine/stack/stack_storage.h b/library/cpp/coroutine/engine/stack/stack_storage.h
index 8327ce6fe0..1a55d4a8c1 100644
--- a/library/cpp/coroutine/engine/stack/stack_storage.h
+++ b/library/cpp/coroutine/engine/stack/stack_storage.h
@@ -40,7 +40,7 @@ namespace NCoro::NStack {
template<typename TGuard>
NDetails::TStack TStorage::GetStack(const TGuard& guard, const char* name) {
- Y_VERIFY(!IsEmpty()); // check before call
+ Y_ABORT_UNLESS(!IsEmpty()); // check before call
void* newStack = nullptr;
if (!Full_.empty()) {
@@ -52,8 +52,8 @@ namespace NCoro::NStack {
Released_.pop_back();
}
- Y_VERIFY(guard.CheckOverflow(newStack), "corrupted stack in pool");
- Y_VERIFY(guard.CheckOverride(newStack, StackSize_), "corrupted stack in pool");
+ Y_ABORT_UNLESS(guard.CheckOverflow(newStack), "corrupted stack in pool");
+ Y_ABORT_UNLESS(guard.CheckOverride(newStack, StackSize_), "corrupted stack in pool");
return NDetails::TStack{newStack, newStack, StackSize_, name};
}
diff --git a/library/cpp/coroutine/engine/stack/stack_utils.cpp b/library/cpp/coroutine/engine/stack/stack_utils.cpp
index 6865772e32..d8fae1ae1f 100644
--- a/library/cpp/coroutine/engine/stack/stack_utils.cpp
+++ b/library/cpp/coroutine/engine/stack/stack_utils.cpp
@@ -35,12 +35,12 @@ namespace NCoro::NStack {
#ifdef _linux_
void ReleaseRss(char* alignedPtr, size_t numOfPages) noexcept {
- Y_VERIFY( !((size_t)alignedPtr & PageSizeMask), "Not aligned pointer to release RSS memory");
+ Y_ABORT_UNLESS( !((size_t)alignedPtr & PageSizeMask), "Not aligned pointer to release RSS memory");
if (!numOfPages) {
return;
}
if (auto res = madvise((void*) alignedPtr, numOfPages * PageSize, MADV_DONTNEED); res) {
- Y_VERIFY(errno == EAGAIN || errno == ENOMEM, "Failed to release memory");
+ Y_ABORT_UNLESS(errno == EAGAIN || errno == ENOMEM, "Failed to release memory");
}
}
#else
@@ -50,12 +50,12 @@ namespace NCoro::NStack {
#ifdef _linux_
size_t CountMapped(char* alignedPtr, size_t numOfPages) noexcept {
- Y_VERIFY( !((size_t)alignedPtr & PageSizeMask) );
+ Y_ABORT_UNLESS( !((size_t)alignedPtr & PageSizeMask) );
Y_ASSERT(numOfPages);
size_t result = 0;
unsigned char* mappedPages = (unsigned char*) calloc(numOfPages, numOfPages);
- Y_VERIFY(mappedPages);
+ Y_ABORT_UNLESS(mappedPages);
Y_DEFER {
free(mappedPages);
};