diff --git a/kotlin-native/codestyle/cpp/README.md b/kotlin-native/codestyle/cpp/README.md index a1ac676d12d..ab30fbed442 100644 --- a/kotlin-native/codestyle/cpp/README.md +++ b/kotlin-native/codestyle/cpp/README.md @@ -23,8 +23,6 @@ * For `extern "C"` declarations emulate namespaces with `Kotlin_[module_name]_` prefixes. * To mark type as move-only, privately inherit from `kotlin::MoveOnly` * To mark type unmovable and uncopyable, privately inherit from `kotlin::Pinned` -* Use `std_support::*` containers and smart pointers instead of `std::*` ones. The former ones default to runtime-specific allocator. -* Use `new (std_support::kalloc) T(...)` (defined in `std_support/New.hpp` instead of `new T(...)` and `std_support::kdelete(ptr)` instead of `delete ptr`. The former ones use runtime-specific allocator. ## Naming diff --git a/kotlin-native/runtime/src/alloc/custom/cpp/AtomicStack.hpp b/kotlin-native/runtime/src/alloc/custom/cpp/AtomicStack.hpp index 72258478ac9..89b340b0ef4 100644 --- a/kotlin-native/runtime/src/alloc/custom/cpp/AtomicStack.hpp +++ b/kotlin-native/runtime/src/alloc/custom/cpp/AtomicStack.hpp @@ -7,10 +7,10 @@ #define CUSTOM_ALLOC_CPP_ATOMICSTACK_HPP_ #include +#include #include "KAssert.h" #include "Utils.hpp" -#include "std_support/Vector.hpp" namespace kotlin::alloc { @@ -91,8 +91,8 @@ public: } // Test method - std_support::vector GetElements() { - std_support::vector elements; + std::vector GetElements() { + std::vector elements; T* elm = stack_.load(); while (elm) { elements.push_back(elm); diff --git a/kotlin-native/runtime/src/alloc/custom/cpp/AtomicStackTest.cpp b/kotlin-native/runtime/src/alloc/custom/cpp/AtomicStackTest.cpp index 5169c784b88..9e663978095 100644 --- a/kotlin-native/runtime/src/alloc/custom/cpp/AtomicStackTest.cpp +++ b/kotlin-native/runtime/src/alloc/custom/cpp/AtomicStackTest.cpp @@ -26,15 +26,15 @@ struct Element { TEST(AtomicStackTest, StressPushPop) { alloc::AtomicStack ready; alloc::AtomicStack used; - std_support::vector elements(1000); - std_support::vector expected; + std::vector elements(1000); + std::vector expected; for (auto& element : elements) { ready.Push(&element); expected.push_back(&element); } std::atomic canStart = false; - std_support::vector mutators; + std::vector mutators; for (int i = 0; i < kDefaultThreadCount; ++i) { mutators.emplace_back([&]() NO_INLINE { while (!canStart.load(std::memory_order_relaxed)) { @@ -48,7 +48,7 @@ TEST(AtomicStackTest, StressPushPop) { canStart.store(true, std::memory_order_relaxed); mutators.clear(); - std_support::vector actual; + std::vector actual; while (auto* element = ready.Pop()) { actual.push_back(element); } diff --git a/kotlin-native/runtime/src/alloc/custom/cpp/FixedBlockPage.cpp b/kotlin-native/runtime/src/alloc/custom/cpp/FixedBlockPage.cpp index 30fedd700bf..0fcdfdcd557 100644 --- a/kotlin-native/runtime/src/alloc/custom/cpp/FixedBlockPage.cpp +++ b/kotlin-native/runtime/src/alloc/custom/cpp/FixedBlockPage.cpp @@ -86,8 +86,8 @@ bool FixedBlockPage::Sweep(GCSweepScope& sweepHandle, FinalizerQueue& finalizerQ return nextFree_.first > 0 || nextFree_.last < end_; } -std_support::vector FixedBlockPage::GetAllocatedBlocks() noexcept { - std_support::vector allocated; +std::vector FixedBlockPage::GetAllocatedBlocks() noexcept { + std::vector allocated; CustomAllocInfo("FixedBlockPage(%p)::Sweep()", this); FixedCellRange nextFree = nextFree_; // Accessing the previous free list structure. for (uint32_t cell = 0 ; cell < end_ ; cell += blockSize_) { diff --git a/kotlin-native/runtime/src/alloc/custom/cpp/FixedBlockPage.hpp b/kotlin-native/runtime/src/alloc/custom/cpp/FixedBlockPage.hpp index 5557c2770af..173c7a05371 100644 --- a/kotlin-native/runtime/src/alloc/custom/cpp/FixedBlockPage.hpp +++ b/kotlin-native/runtime/src/alloc/custom/cpp/FixedBlockPage.hpp @@ -8,11 +8,11 @@ #include #include +#include #include "AtomicStack.hpp" #include "ExtraObjectPage.hpp" #include "GCStatistics.hpp" -#include "std_support/Vector.hpp" namespace kotlin::alloc { @@ -45,7 +45,7 @@ public: bool Sweep(GCSweepScope& sweepHandle, FinalizerQueue& finalizerQueue) noexcept; // Testing method - std_support::vector GetAllocatedBlocks() noexcept; + std::vector GetAllocatedBlocks() noexcept; private: explicit FixedBlockPage(uint32_t blockSize) noexcept; diff --git a/kotlin-native/runtime/src/alloc/custom/cpp/Heap.cpp b/kotlin-native/runtime/src/alloc/custom/cpp/Heap.cpp index aeafe108c20..371863e5ac0 100644 --- a/kotlin-native/runtime/src/alloc/custom/cpp/Heap.cpp +++ b/kotlin-native/runtime/src/alloc/custom/cpp/Heap.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "CustomAllocConstants.hpp" #include "AtomicStack.hpp" @@ -19,7 +20,6 @@ #include "GCApi.hpp" #include "Memory.h" #include "ThreadRegistry.hpp" -#include "std_support/Vector.hpp" namespace kotlin::alloc { diff --git a/kotlin-native/runtime/src/alloc/custom/cpp/NextFitPage.cpp b/kotlin-native/runtime/src/alloc/custom/cpp/NextFitPage.cpp index 89bed47057b..2e1434d75c7 100644 --- a/kotlin-native/runtime/src/alloc/custom/cpp/NextFitPage.cpp +++ b/kotlin-native/runtime/src/alloc/custom/cpp/NextFitPage.cpp @@ -7,11 +7,11 @@ #include #include +#include #include "CustomLogging.hpp" #include "CustomAllocConstants.hpp" #include "GCApi.hpp" -#include "std_support/Vector.hpp" namespace kotlin::alloc { @@ -105,8 +105,8 @@ bool NextFitPage::CheckInvariants() noexcept { } } -std_support::vector NextFitPage::GetAllocatedBlocks() noexcept { - std_support::vector allocated; +std::vector NextFitPage::GetAllocatedBlocks() noexcept { + std::vector allocated; Cell* end = cells_ + NEXT_FIT_PAGE_CELL_COUNT; for (Cell* block = cells_ + 1; block != end; block = block->Next()) { if (block->isAllocated_) { diff --git a/kotlin-native/runtime/src/alloc/custom/cpp/NextFitPage.hpp b/kotlin-native/runtime/src/alloc/custom/cpp/NextFitPage.hpp index 38c3837dda6..3fb13cff142 100644 --- a/kotlin-native/runtime/src/alloc/custom/cpp/NextFitPage.hpp +++ b/kotlin-native/runtime/src/alloc/custom/cpp/NextFitPage.hpp @@ -8,12 +8,12 @@ #include #include +#include #include "AtomicStack.hpp" #include "Cell.hpp" #include "ExtraObjectPage.hpp" #include "GCStatistics.hpp" -#include "std_support/Vector.hpp" namespace kotlin::alloc { @@ -36,7 +36,7 @@ public: bool CheckInvariants() noexcept; // Testing method - std_support::vector GetAllocatedBlocks() noexcept; + std::vector GetAllocatedBlocks() noexcept; private: explicit NextFitPage(uint32_t cellCount) noexcept; diff --git a/kotlin-native/runtime/src/alloc/custom/cpp/PageStore.hpp b/kotlin-native/runtime/src/alloc/custom/cpp/PageStore.hpp index 9bd8b2a981a..8c04500adac 100644 --- a/kotlin-native/runtime/src/alloc/custom/cpp/PageStore.hpp +++ b/kotlin-native/runtime/src/alloc/custom/cpp/PageStore.hpp @@ -8,11 +8,11 @@ #include #include +#include #include "AtomicStack.hpp" #include "ExtraObjectPage.hpp" #include "GCStatistics.hpp" -#include "std_support/Vector.hpp" namespace kotlin::alloc { @@ -104,8 +104,8 @@ private: } // Testing method - std_support::vector GetPages() noexcept { - std_support::vector pages; + std::vector GetPages() noexcept { + std::vector pages; for (T* page : ready_.GetElements()) pages.push_back(page); for (T* page : used_.GetElements()) pages.push_back(page); for (T* page : unswept_.GetElements()) pages.push_back(page); diff --git a/kotlin-native/runtime/src/alloc/custom/cpp/SingleObjectPage.cpp b/kotlin-native/runtime/src/alloc/custom/cpp/SingleObjectPage.cpp index 69998c294a0..5196c7968a5 100644 --- a/kotlin-native/runtime/src/alloc/custom/cpp/SingleObjectPage.cpp +++ b/kotlin-native/runtime/src/alloc/custom/cpp/SingleObjectPage.cpp @@ -11,7 +11,6 @@ #include "CustomLogging.hpp" #include "CustomAllocConstants.hpp" #include "GCApi.hpp" -#include "std_support/Vector.hpp" namespace kotlin::alloc { @@ -47,8 +46,8 @@ bool SingleObjectPage::Sweep(GCSweepScope& sweepHandle, FinalizerQueue& finalize return false; } -std_support::vector SingleObjectPage::GetAllocatedBlocks() noexcept { - std_support::vector allocated; +std::vector SingleObjectPage::GetAllocatedBlocks() noexcept { + std::vector allocated; if (isAllocated_) { allocated.push_back(data_); } diff --git a/kotlin-native/runtime/src/alloc/custom/cpp/SingleObjectPage.hpp b/kotlin-native/runtime/src/alloc/custom/cpp/SingleObjectPage.hpp index 5eed1f7fd8f..d1d47650412 100644 --- a/kotlin-native/runtime/src/alloc/custom/cpp/SingleObjectPage.hpp +++ b/kotlin-native/runtime/src/alloc/custom/cpp/SingleObjectPage.hpp @@ -8,11 +8,11 @@ #include #include +#include #include "AtomicStack.hpp" #include "ExtraObjectPage.hpp" #include "GCStatistics.hpp" -#include "std_support/Vector.hpp" namespace kotlin::alloc { @@ -39,7 +39,7 @@ private: explicit SingleObjectPage(size_t size) noexcept; // Testing method - std_support::vector GetAllocatedBlocks() noexcept; + std::vector GetAllocatedBlocks() noexcept; std::atomic next_; bool isAllocated_ = false; diff --git a/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactoryAllocatorTest.cpp b/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactoryAllocatorTest.cpp index d4438cb6f4e..e52b6ed8a7b 100644 --- a/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactoryAllocatorTest.cpp +++ b/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactoryAllocatorTest.cpp @@ -5,11 +5,11 @@ #include "ObjectFactoryAllocator.hpp" +#include + #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "std_support/Memory.hpp" - using namespace kotlin; using testing::_; @@ -28,7 +28,7 @@ public: void* Alloc(size_t size) { return mock_->Alloc(size); } private: - std_support::unique_ptr> mock_ = std_support::make_unique>(); + std::unique_ptr> mock_ = std::make_unique>(); }; class MockGC { diff --git a/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweepTest.cpp b/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweepTest.cpp index 531fec30056..77515dedc61 100644 --- a/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweepTest.cpp +++ b/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweepTest.cpp @@ -194,11 +194,11 @@ public: } } - std_support::vector Sweep() { + std::vector Sweep() { gc::processWeaks(gc::GCHandle::getByEpoch(0), specialRefRegistry_); alloc::SweepExtraObjects(gc::GCHandle::getByEpoch(0), extraObjectFactory_); auto finalizers = alloc::Sweep(gc::GCHandle::getByEpoch(0), objectFactory_); - std_support::vector objects; + std::vector objects; for (auto node : finalizers.IterForTests()) { objects.push_back(node.GetObjHeader()); } @@ -206,16 +206,16 @@ public: return objects; } - std_support::vector Alive() { - std_support::vector objects; + std::vector Alive() { + std::vector objects; for (auto node : objectFactory_.LockForIter()) { objects.push_back(node.GetObjHeader()); } return objects; } - std_support::vector AliveExtraObjects() { - std_support::vector objects; + std::vector AliveExtraObjects() { + std::vector objects; for (auto &node : extraObjectFactory_.LockForIter()) { objects.push_back(&node); } @@ -273,7 +273,7 @@ private: mm::SpecialRefRegistry specialRefRegistry_; mm::SpecialRefRegistry::ThreadQueue specialRefRegistryThreadQueue_{specialRefRegistry_}; - std_support::vector finalizers_; + std::vector finalizers_; }; } // namespace diff --git a/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactoryTest.cpp b/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactoryTest.cpp index ba4aad4dc4a..3cf1e3b6d15 100644 --- a/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactoryTest.cpp +++ b/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactoryTest.cpp @@ -6,7 +6,9 @@ #include "ObjectFactory.hpp" #include +#include #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -18,8 +20,6 @@ #include "ScopedThread.hpp" #include "TestSupport.hpp" #include "Types.h" -#include "std_support/CStdlib.hpp" -#include "std_support/Vector.hpp" // ObjectFactory is not used by custom allocator using namespace kotlin; @@ -30,8 +30,8 @@ namespace { class SimpleAllocator { public: - void* Alloc(size_t size) noexcept { return std_support::calloc(1, size); } - static void Free(void* instance, size_t size) noexcept { std_support::free(instance); } + void* Alloc(size_t size) noexcept { return std::calloc(1, size); } + static void Free(void* instance, size_t size) noexcept { std::free(instance); } }; struct DataSizeProvider { @@ -50,8 +50,8 @@ template using Consumer = typename Storage::Consumer; template -std_support::vector Collect(ObjectFactoryStorage& storage) { - std_support::vector result; +std::vector Collect(ObjectFactoryStorage& storage) { + std::vector result; for (auto& node : storage.LockForIter()) { result.push_back(node.Data()); } @@ -59,8 +59,8 @@ std_support::vector Collect(ObjectFactoryStorage& storage) } template -std_support::vector Collect(ObjectFactoryStorage& storage) { - std_support::vector result; +std::vector Collect(ObjectFactoryStorage& storage) { + std::vector result; for (auto& node : storage.LockForIter()) { result.push_back(*reinterpret_cast(node.Data())); } @@ -68,8 +68,8 @@ std_support::vector Collect(ObjectFactoryStorage& storage) { } template -std_support::vector Collect(Consumer>& consumer) { - std_support::vector result; +std::vector Collect(Consumer>& consumer) { + std::vector result; for (auto& node : consumer) { result.push_back(*reinterpret_cast(node.Data())); } @@ -641,8 +641,8 @@ TEST(ObjectFactoryStorageTest, ConcurrentPublish) { constexpr int kThreadCount = kDefaultThreadCount; std::atomic canStart(false); std::atomic readyCount(0); - std_support::vector threads; - std_support::vector expected; + std::vector threads; + std::vector expected; for (int i = 0; i < kThreadCount; ++i) { expected.push_back(i); @@ -672,8 +672,8 @@ TEST(ObjectFactoryStorageTest, IterWhileConcurrentPublish) { constexpr int kStartCount = 50; constexpr int kThreadCount = kDefaultThreadCount; - std_support::vector expectedBefore; - std_support::vector expectedAfter; + std::vector expectedBefore; + std::vector expectedAfter; Producer producer(storage, SimpleAllocator()); for (int i = 0; i < kStartCount; ++i) { expectedBefore.push_back(i); @@ -685,7 +685,7 @@ TEST(ObjectFactoryStorageTest, IterWhileConcurrentPublish) { std::atomic canStart(false); std::atomic readyCount(0); std::atomic startedCount(0); - std_support::vector threads; + std::vector threads; for (int i = 0; i < kThreadCount; ++i) { int j = i + kStartCount; expectedAfter.push_back(j); @@ -700,7 +700,7 @@ TEST(ObjectFactoryStorageTest, IterWhileConcurrentPublish) { }); } - std_support::vector actualBefore; + std::vector actualBefore; { auto iter = storage.LockForIter(); while (readyCount < kThreadCount) { @@ -730,7 +730,7 @@ TEST(ObjectFactoryStorageTest, EraseWhileConcurrentPublish) { constexpr int kStartCount = 50; constexpr int kThreadCount = kDefaultThreadCount; - std_support::vector expectedAfter; + std::vector expectedAfter; Producer producer(storage, SimpleAllocator()); for (int i = 0; i < kStartCount; ++i) { if (i % 2 == 0) { @@ -743,7 +743,7 @@ TEST(ObjectFactoryStorageTest, EraseWhileConcurrentPublish) { std::atomic canStart(false); std::atomic readyCount(0); std::atomic startedCount(0); - std_support::vector threads; + std::vector threads; for (int i = 0; i < kThreadCount; ++i) { int j = i + kStartCount; expectedAfter.push_back(j); @@ -793,9 +793,9 @@ public: MOCK_METHOD(void*, Alloc, (size_t)); MOCK_METHOD(void, Free, (void*, size_t)); - void* DefaultAlloc(size_t size) { return std_support::calloc(1, size); } + void* DefaultAlloc(size_t size) { return std::calloc(1, size); } - void DefaultFree(void* instance, size_t size) { std_support::free(instance); } + void DefaultFree(void* instance, size_t size) { std::free(instance); } }; class GlobalMockAllocator { @@ -1067,7 +1067,7 @@ TEST(ObjectFactoryTest, RunFinalizers) { ObjectFactory::ThreadQueue threadQueue(objectFactory, GlobalMockAllocator()); ObjectFactory::FinalizerQueue finalizerQueue; - std_support::vector objects; + std::vector objects; EXPECT_CALL(allocator, Alloc(_)).Times(10); for (int i = 0; i < 10; ++i) { objects.push_back(threadQueue.CreateObject(objectType.typeInfo())); @@ -1100,9 +1100,9 @@ TEST(ObjectFactoryTest, ConcurrentPublish) { constexpr int kThreadCount = kDefaultThreadCount; std::atomic canStart(false); std::atomic readyCount(0); - std_support::vector threads; + std::vector threads; std::mutex expectedMutex; - std_support::vector expected; + std::vector expected; EXPECT_CALL(allocator, Alloc(_)).Times(kThreadCount); for (int i = 0; i < kThreadCount; ++i) { @@ -1127,7 +1127,7 @@ TEST(ObjectFactoryTest, ConcurrentPublish) { threads.clear(); auto iter = objectFactory.LockForIter(); - std_support::vector actual; + std::vector actual; for (auto it = iter.begin(); it != iter.end(); ++it) { actual.push_back(it->GetObjHeader()); } diff --git a/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweep.hpp b/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweep.hpp index 36e17824374..05cb218e3e6 100644 --- a/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweep.hpp +++ b/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweep.hpp @@ -7,6 +7,8 @@ #include #include +#include +#include #include "AllocatorImpl.hpp" #include "Barriers.hpp" @@ -22,7 +24,6 @@ #include "ThreadData.hpp" #include "Types.h" #include "Utils.hpp" -#include "std_support/Memory.hpp" namespace kotlin { namespace gc { @@ -86,7 +87,7 @@ private: mark::ParallelMark markDispatcher_; ScopedThread mainThread_; - std_support::vector auxThreads_; + std::vector auxThreads_; }; } // namespace gc diff --git a/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweepTest.cpp b/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweepTest.cpp index b6da1fa0044..c0e31d2814e 100644 --- a/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweepTest.cpp +++ b/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweepTest.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -26,7 +27,6 @@ #include "TestSupport.hpp" #include "ThreadData.hpp" #include "WeakRef.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -663,7 +663,7 @@ public: StackObjectHolder& AddStackRoot() { RuntimeAssert(std::this_thread::get_id() == executor_.threadId(), "AddStackRoot can only be called in the mutator thread"); auto& context = executor_.context(); - auto holder = std_support::make_unique(*context.memory_->memoryState()->GetThreadData()); + auto holder = std::make_unique(*context.memory_->memoryState()->GetThreadData()); auto& holderRef = *holder; context.stackRoots_.push_back(std::move(holder)); return holderRef; @@ -672,7 +672,7 @@ public: StackObjectHolder& AddStackRoot(ObjHeader* object) { RuntimeAssert(std::this_thread::get_id() == executor_.threadId(), "AddStackRoot can only be called in the mutator thread"); auto& context = executor_.context(); - auto holder = std_support::make_unique(object); + auto holder = std::make_unique(object); auto& holderRef = *holder; context.stackRoots_.push_back(std::move(holder)); return holderRef; @@ -681,7 +681,7 @@ public: GlobalObjectHolder& AddGlobalRoot() { RuntimeAssert(std::this_thread::get_id() == executor_.threadId(), "AddGlobalRoot can only be called in the mutator thread"); auto& context = executor_.context(); - auto holder = std_support::make_unique(*context.memory_->memoryState()->GetThreadData()); + auto holder = std::make_unique(*context.memory_->memoryState()->GetThreadData()); auto& holderRef = *holder; context.globalRoots_.push_back(std::move(holder)); return holderRef; @@ -690,7 +690,7 @@ public: GlobalObjectHolder& AddGlobalRoot(ObjHeader* object) { RuntimeAssert(std::this_thread::get_id() == executor_.threadId(), "AddGlobalRoot can only be called in the mutator thread"); auto& context = executor_.context(); - auto holder = std_support::make_unique(*context.memory_->memoryState()->GetThreadData(), object); + auto holder = std::make_unique(*context.memory_->memoryState()->GetThreadData(), object); auto& holderRef = *holder; context.globalRoots_.push_back(std::move(holder)); return holderRef; @@ -700,11 +700,11 @@ public: private: struct Context { - std_support::unique_ptr memory_; - std_support::vector> stackRoots_; - std_support::vector> globalRoots_; + std::unique_ptr memory_; + std::vector> stackRoots_; + std::vector> globalRoots_; - Context() : memory_(std_support::make_unique()) { + Context() : memory_(std::make_unique()) { // SingleThreadExecutor must work in the runnable state, so that GC does not collect between tasks. AssertThreadState(memory_->memoryState(), ThreadState::kRunnable); } @@ -716,10 +716,10 @@ private: } // namespace TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsCollect) { - std_support::vector mutators(kDefaultThreadCount); - std_support::vector globals(kDefaultThreadCount); - std_support::vector locals(kDefaultThreadCount); - std_support::vector reachables(kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); + std::vector globals(kDefaultThreadCount); + std::vector locals(kDefaultThreadCount); + std::vector reachables(kDefaultThreadCount); auto expandRootSet = [&globals, &locals, &reachables](mm::ThreadData& threadData, Mutator& mutator, int i) { auto& global = mutator.AddGlobalRoot(); @@ -738,7 +738,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsCollect) { .wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; std::atomic gcDone = false; for (auto& mutator : mutators) { @@ -756,7 +756,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsCollect) { future.wait(); } - std_support::vector expectedAlive; + std::vector expectedAlive; for (auto& global : globals) { expectedAlive.push_back(global); } @@ -773,10 +773,10 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsCollect) { } TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAllCollect) { - std_support::vector mutators(kDefaultThreadCount); - std_support::vector globals(kDefaultThreadCount); - std_support::vector locals(kDefaultThreadCount); - std_support::vector reachables(kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); + std::vector globals(kDefaultThreadCount); + std::vector locals(kDefaultThreadCount); + std::vector reachables(kDefaultThreadCount); auto expandRootSet = [&globals, &locals, &reachables](mm::ThreadData& threadData, Mutator& mutator, int i) { auto& global = mutator.AddGlobalRoot(); @@ -795,7 +795,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAllCollect) { .wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; for (auto& mutator : mutators) { gcFutures.emplace_back(mutator.Execute([](mm::ThreadData& threadData, Mutator& mutator) { @@ -818,7 +818,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAllCollect) { .wait(); } - std_support::vector expectedAlive; + std::vector expectedAlive; for (auto& global : globals) { expectedAlive.push_back(global); } @@ -835,10 +835,10 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAllCollect) { } TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRequested) { - std_support::vector mutators(kDefaultThreadCount); - std_support::vector globals(kDefaultThreadCount); - std_support::vector locals(kDefaultThreadCount); - std_support::vector reachables(kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); + std::vector globals(kDefaultThreadCount); + std::vector locals(kDefaultThreadCount); + std::vector reachables(kDefaultThreadCount); auto allocateInHeap = [&globals, &locals, &reachables](mm::ThreadData& threadData, Mutator& mutator, int i) { auto& global = AllocateObject(threadData); @@ -865,7 +865,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRe .wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; auto epoch = mm::GlobalData::Instance().gc().Schedule(); std::atomic gcDone = false; @@ -889,7 +889,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRe future.wait(); } - std_support::vector expectedAlive; + std::vector expectedAlive; for (auto& global : globals) { expectedAlive.push_back(global); } @@ -906,10 +906,10 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRe } TEST_P(ConcurrentMarkAndSweepTest, CrossThreadReference) { - std_support::vector mutators(kDefaultThreadCount); - std_support::vector globals(kDefaultThreadCount); - std_support::vector locals(kDefaultThreadCount); - std_support::vector reachables(2 * kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); + std::vector globals(kDefaultThreadCount); + std::vector locals(kDefaultThreadCount); + std::vector reachables(2 * kDefaultThreadCount); auto expandRootSet = [&globals, &locals, &reachables](mm::ThreadData& threadData, Mutator& mutator, int i) { auto& global = mutator.AddGlobalRoot(); @@ -935,7 +935,7 @@ TEST_P(ConcurrentMarkAndSweepTest, CrossThreadReference) { .wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; std::atomic gcDone = false; for (auto& mutator : mutators) { @@ -953,7 +953,7 @@ TEST_P(ConcurrentMarkAndSweepTest, CrossThreadReference) { future.wait(); } - std_support::vector expectedAlive; + std::vector expectedAlive; for (auto& global : globals) { expectedAlive.push_back(global); } @@ -973,7 +973,7 @@ TEST_P(ConcurrentMarkAndSweepTest, CrossThreadReference) { } TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsWeaks) { - std_support::vector mutators(kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); ObjHeader* globalRoot = nullptr; test_support::RegularWeakReferenceImpl* weak = nullptr; @@ -997,7 +997,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsWeaks) { mutators[i].Execute([](mm::ThreadData& threadData, Mutator& mutator) {}).wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; auto epoch = mm::GlobalData::Instance().gc().Schedule(); std::atomic gcDone = false; @@ -1027,14 +1027,14 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsWeaks) { } TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsWeakNewObj) { - std_support::vector mutators(kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); // Make sure all mutators are initialized. for (int i = 0; i < kDefaultThreadCount; ++i) { mutators[i].Execute([](mm::ThreadData& threadData, Mutator& mutator) {}).wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; auto epoch = mm::GlobalData::Instance().gc().Schedule(); std::atomic gcDone = false; @@ -1073,11 +1073,11 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsWeakNewObj) { } TEST_P(ConcurrentMarkAndSweepTest, NewThreadsWhileRequestingCollection) { - std_support::vector mutators(kDefaultThreadCount); - std_support::vector globals(2 * kDefaultThreadCount); - std_support::vector locals(2 * kDefaultThreadCount); - std_support::vector reachables(2 * kDefaultThreadCount); - std_support::vector unreachables(2 * kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); + std::vector globals(2 * kDefaultThreadCount); + std::vector locals(2 * kDefaultThreadCount); + std::vector reachables(2 * kDefaultThreadCount); + std::vector unreachables(2 * kDefaultThreadCount); auto expandRootSet = [&globals, &locals, &reachables, &unreachables](mm::ThreadData& threadData, Mutator& mutator, int i) { auto& global = mutator.AddGlobalRoot(); @@ -1097,7 +1097,7 @@ TEST_P(ConcurrentMarkAndSweepTest, NewThreadsWhileRequestingCollection) { .wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; auto epoch = mm::GlobalData::Instance().gc().Schedule(); std::atomic gcDone = false; @@ -1106,8 +1106,8 @@ TEST_P(ConcurrentMarkAndSweepTest, NewThreadsWhileRequestingCollection) { } // Now start attaching new threads. - std_support::vector newMutators(kDefaultThreadCount); - std_support::vector> attachFutures(kDefaultThreadCount); + std::vector newMutators(kDefaultThreadCount); + std::vector> attachFutures(kDefaultThreadCount); for (int i = 0; i < kDefaultThreadCount; ++i) { attachFutures[i] = newMutators[i].Execute([&gcDone, i, expandRootSet](mm::ThreadData& threadData, Mutator& mutator) { @@ -1141,7 +1141,7 @@ TEST_P(ConcurrentMarkAndSweepTest, NewThreadsWhileRequestingCollection) { future.wait(); } - std_support::vector expectedAlive; + std::vector expectedAlive; for (int i = 0; i < kDefaultThreadCount; ++i) { expectedAlive.push_back(globals[i]); expectedAlive.push_back(locals[i]); @@ -1155,7 +1155,7 @@ TEST_P(ConcurrentMarkAndSweepTest, NewThreadsWhileRequestingCollection) { // Force mutators to publish their internal heaps // Really only needed for legacy allocators. - std_support::vector> publishFutures; + std::vector> publishFutures; for (auto& mutator: mutators) { publishFutures.emplace_back( mutator.Execute([](mm::ThreadData& threadData, Mutator& mutator) { threadData.allocator().prepareForGC(); })); @@ -1173,7 +1173,7 @@ TEST_P(ConcurrentMarkAndSweepTest, NewThreadsWhileRequestingCollection) { } TEST_P(ConcurrentMarkAndSweepTest, FreeObjectWithFreeWeakReversedOrder) { - std_support::vector mutators(2); + std::vector mutators(2); std::atomic*> object1 = nullptr; std::atomic weak = nullptr; std::atomic done = false; diff --git a/kotlin-native/runtime/src/gc/cms/cpp/GCImpl.cpp b/kotlin-native/runtime/src/gc/cms/cpp/GCImpl.cpp index a5d12725264..e5eb0f51d45 100644 --- a/kotlin-native/runtime/src/gc/cms/cpp/GCImpl.cpp +++ b/kotlin-native/runtime/src/gc/cms/cpp/GCImpl.cpp @@ -5,16 +5,17 @@ #include "GCImpl.hpp" +#include + #include "ConcurrentMarkAndSweep.hpp" #include "GC.hpp" #include "GCStatistics.hpp" #include "MarkAndSweepUtils.hpp" #include "ObjectOps.hpp" -#include "std_support/Memory.hpp" using namespace kotlin; -gc::GC::ThreadData::ThreadData(GC& gc, mm::ThreadData& threadData) noexcept : impl_(std_support::make_unique(gc, threadData)) {} +gc::GC::ThreadData::ThreadData(GC& gc, mm::ThreadData& threadData) noexcept : impl_(std::make_unique(gc, threadData)) {} gc::GC::ThreadData::~ThreadData() = default; @@ -35,7 +36,7 @@ void gc::GC::ThreadData::onThreadRegistration() noexcept { } gc::GC::GC(alloc::Allocator& allocator, gcScheduler::GCScheduler& gcScheduler) noexcept : - impl_(std_support::make_unique(allocator, gcScheduler)) {} + impl_(std::make_unique(allocator, gcScheduler)) {} gc::GC::~GC() = default; diff --git a/kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.cpp b/kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.cpp index 9133f1ed808..6820d972418 100644 --- a/kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.cpp +++ b/kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.cpp @@ -1,9 +1,13 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + #include "ParallelMark.hpp" #include "MarkAndSweepUtils.hpp" #include "GCStatistics.hpp" #include "Utils.hpp" -#include "std_support/Memory.hpp" // required to access gc thread data #include "GCImpl.hpp" diff --git a/kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.hpp b/kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.hpp index 30551c34ef9..6d41d096411 100644 --- a/kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.hpp +++ b/kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.hpp @@ -1,7 +1,12 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + #pragma once -#include #include +#include #include "GCStatistics.hpp" #include "ManuallyScoped.hpp" @@ -9,7 +14,6 @@ #include "ParallelProcessor.hpp" #include "ThreadRegistry.hpp" #include "Utils.hpp" -#include "std_support/Vector.hpp" namespace kotlin::gc::mark { diff --git a/kotlin-native/runtime/src/gc/common/cpp/FinalizerProcessorTest.cpp b/kotlin-native/runtime/src/gc/common/cpp/FinalizerProcessorTest.cpp index 82444edcfd5..913c9c9dbb1 100644 --- a/kotlin-native/runtime/src/gc/common/cpp/FinalizerProcessorTest.cpp +++ b/kotlin-native/runtime/src/gc/common/cpp/FinalizerProcessorTest.cpp @@ -16,7 +16,7 @@ namespace { class FinalizerProcessorTest : public testing::Test { public: - using FinalizerQueue = std_support::vector; + using FinalizerQueue = std::vector; struct FinalizerQueueTraits { static bool isEmpty(const FinalizerQueue& queue) noexcept { return queue.empty(); } diff --git a/kotlin-native/runtime/src/gc/common/cpp/GC.hpp b/kotlin-native/runtime/src/gc/common/cpp/GC.hpp index 5cf0dd79c5f..1451238da9f 100644 --- a/kotlin-native/runtime/src/gc/common/cpp/GC.hpp +++ b/kotlin-native/runtime/src/gc/common/cpp/GC.hpp @@ -7,12 +7,12 @@ #include #include +#include #include "ExtraObjectData.hpp" #include "GCScheduler.hpp" #include "Memory.h" #include "Utils.hpp" -#include "std_support/Memory.hpp" namespace kotlin { @@ -48,7 +48,7 @@ public: void onAllocation(ObjHeader* object) noexcept; private: - std_support::unique_ptr impl_; + std::unique_ptr impl_; }; // Header to be placed before each heap object. GC will use this to keep its data if needed. @@ -80,7 +80,7 @@ public: void WaitFinalizers(int64_t epoch) noexcept; private: - std_support::unique_ptr impl_; + std::unique_ptr impl_; }; bool isMarked(ObjHeader* object) noexcept; diff --git a/kotlin-native/runtime/src/gc/common/cpp/MarkAndSweepUtilsMarkTest.cpp b/kotlin-native/runtime/src/gc/common/cpp/MarkAndSweepUtilsMarkTest.cpp index 6d5e1ed89d3..ec5fd90cb23 100644 --- a/kotlin-native/runtime/src/gc/common/cpp/MarkAndSweepUtilsMarkTest.cpp +++ b/kotlin-native/runtime/src/gc/common/cpp/MarkAndSweepUtilsMarkTest.cpp @@ -6,16 +6,16 @@ #include "MarkAndSweepUtils.hpp" #include -#include +#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" #include "FinalizerHooks.hpp" #include "ObjectTestSupport.hpp" +#include "TestSupport.hpp" #include "Utils.hpp" -#include "std_support/UnorderedSet.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -73,7 +73,7 @@ public: class ScopedMarkTraits : private Pinned { public: - using MarkQueue = std_support::vector; + using MarkQueue = std::vector; ScopedMarkTraits() { RuntimeAssert(instance_ == nullptr, "Only one ScopedMarkTraits is allowed"); @@ -85,7 +85,7 @@ public: instance_ = nullptr; } - const std_support::unordered_set& marked() const { return marked_; } + const std::unordered_set& marked() const { return marked_; } static void clear(MarkQueue& queue) noexcept { queue.clear(); @@ -122,7 +122,7 @@ public: private: static ScopedMarkTraits* instance_; - std_support::unordered_set marked_; + std::unordered_set marked_; }; // static @@ -130,10 +130,10 @@ ScopedMarkTraits* ScopedMarkTraits::instance_ = nullptr; class MarkAndSweepUtilsMarkTest : public ::testing::Test { public: - const std_support::unordered_set& marked() const { return markTraits_.marked(); } + const std::unordered_set& marked() const { return markTraits_.marked(); } auto MarkedMatcher(std::initializer_list> expected) { - std_support::vector objects; + std::vector objects; for (auto& object : expected) { objects.push_back(object.get().header()); } @@ -141,7 +141,7 @@ public: } gc::MarkStats Mark(std::initializer_list> graySet) { - std_support::vector objects; + std::vector objects; for (auto& object : graySet) ScopedMarkTraits::tryEnqueue(objects, object.get().header()); auto handle = gc::GCHandle::create(epoch_++); gc::Mark(handle, objects); diff --git a/kotlin-native/runtime/src/gc/noop/cpp/GCImpl.cpp b/kotlin-native/runtime/src/gc/noop/cpp/GCImpl.cpp index e5ba75a88c3..3c62fff4af4 100644 --- a/kotlin-native/runtime/src/gc/noop/cpp/GCImpl.cpp +++ b/kotlin-native/runtime/src/gc/noop/cpp/GCImpl.cpp @@ -5,6 +5,7 @@ #include "GCImpl.hpp" +#include "Common.h" #include "GCStatistics.hpp" #include "KAssert.h" #include "Logging.hpp" diff --git a/kotlin-native/runtime/src/gc/stms/cpp/GCImpl.cpp b/kotlin-native/runtime/src/gc/stms/cpp/GCImpl.cpp index 1d6796500f9..0778689567a 100644 --- a/kotlin-native/runtime/src/gc/stms/cpp/GCImpl.cpp +++ b/kotlin-native/runtime/src/gc/stms/cpp/GCImpl.cpp @@ -5,17 +5,18 @@ #include "GCImpl.hpp" +#include + #include "GC.hpp" #include "GCStatistics.hpp" #include "GlobalData.hpp" #include "MarkAndSweepUtils.hpp" #include "ObjectOps.hpp" #include "SameThreadMarkAndSweep.hpp" -#include "std_support/Memory.hpp" using namespace kotlin; -gc::GC::ThreadData::ThreadData(GC& gc, mm::ThreadData& threadData) noexcept : impl_(std_support::make_unique(gc, threadData)) {} +gc::GC::ThreadData::ThreadData(GC& gc, mm::ThreadData& threadData) noexcept : impl_(std::make_unique(gc, threadData)) {} gc::GC::ThreadData::~ThreadData() = default; @@ -28,7 +29,7 @@ void gc::GC::ThreadData::safePoint() noexcept {} void gc::GC::ThreadData::onThreadRegistration() noexcept {} gc::GC::GC(alloc::Allocator& allocator, gcScheduler::GCScheduler& gcScheduler) noexcept : - impl_(std_support::make_unique(allocator, gcScheduler)) {} + impl_(std::make_unique(allocator, gcScheduler)) {} gc::GC::~GC() = default; diff --git a/kotlin-native/runtime/src/gc/stms/cpp/SameThreadMarkAndSweepTest.cpp b/kotlin-native/runtime/src/gc/stms/cpp/SameThreadMarkAndSweepTest.cpp index e84e88b5e4d..71fb076fd21 100644 --- a/kotlin-native/runtime/src/gc/stms/cpp/SameThreadMarkAndSweepTest.cpp +++ b/kotlin-native/runtime/src/gc/stms/cpp/SameThreadMarkAndSweepTest.cpp @@ -7,8 +7,10 @@ #include #include +#include #include #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -25,8 +27,6 @@ #include "TestSupport.hpp" #include "ThreadData.hpp" #include "WeakRef.hpp" -#include "std_support/Memory.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -638,7 +638,7 @@ public: StackObjectHolder& AddStackRoot() { RuntimeAssert(std::this_thread::get_id() == executor_.threadId(), "AddStackRoot can only be called in the mutator thread"); auto& context = executor_.context(); - auto holder = std_support::make_unique(*context.memory_->memoryState()->GetThreadData()); + auto holder = std::make_unique(*context.memory_->memoryState()->GetThreadData()); auto& holderRef = *holder; context.stackRoots_.push_back(std::move(holder)); return holderRef; @@ -647,7 +647,7 @@ public: StackObjectHolder& AddStackRoot(ObjHeader* object) { RuntimeAssert(std::this_thread::get_id() == executor_.threadId(), "AddStackRoot can only be called in the mutator thread"); auto& context = executor_.context(); - auto holder = std_support::make_unique(object); + auto holder = std::make_unique(object); auto& holderRef = *holder; context.stackRoots_.push_back(std::move(holder)); return holderRef; @@ -656,7 +656,7 @@ public: GlobalObjectHolder& AddGlobalRoot() { RuntimeAssert(std::this_thread::get_id() == executor_.threadId(), "AddGlobalRoot can only be called in the mutator thread"); auto& context = executor_.context(); - auto holder = std_support::make_unique(*context.memory_->memoryState()->GetThreadData()); + auto holder = std::make_unique(*context.memory_->memoryState()->GetThreadData()); auto& holderRef = *holder; context.globalRoots_.push_back(std::move(holder)); return holderRef; @@ -665,7 +665,7 @@ public: GlobalObjectHolder& AddGlobalRoot(ObjHeader* object) { RuntimeAssert(std::this_thread::get_id() == executor_.threadId(), "AddGlobalRoot can only be called in the mutator thread"); auto& context = executor_.context(); - auto holder = std_support::make_unique(*context.memory_->memoryState()->GetThreadData(), object); + auto holder = std::make_unique(*context.memory_->memoryState()->GetThreadData(), object); auto& holderRef = *holder; context.globalRoots_.push_back(std::move(holder)); return holderRef; @@ -675,11 +675,11 @@ public: private: struct Context { - std_support::unique_ptr memory_; - std_support::vector> stackRoots_; - std_support::vector> globalRoots_; + std::unique_ptr memory_; + std::vector> stackRoots_; + std::vector> globalRoots_; - Context() : memory_(std_support::make_unique()) { + Context() : memory_(std::make_unique()) { // SingleThreadExecutor must work in the runnable state, so that GC does not collect between tasks. AssertThreadState(memory_->memoryState(), ThreadState::kRunnable); } @@ -691,10 +691,10 @@ private: } // namespace TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsCollect) { - std_support::vector mutators(kDefaultThreadCount); - std_support::vector globals(kDefaultThreadCount); - std_support::vector locals(kDefaultThreadCount); - std_support::vector reachables(kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); + std::vector globals(kDefaultThreadCount); + std::vector locals(kDefaultThreadCount); + std::vector reachables(kDefaultThreadCount); auto expandRootSet = [&globals, &locals, &reachables](mm::ThreadData& threadData, Mutator& mutator, int i) { auto& global = mutator.AddGlobalRoot(); @@ -713,7 +713,7 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsCollect) { .wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; std::atomic gcDone = false; for (auto& mutator : mutators) { @@ -731,7 +731,7 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsCollect) { future.wait(); } - std_support::vector expectedAlive; + std::vector expectedAlive; for (auto& global : globals) { expectedAlive.push_back(global); } @@ -748,10 +748,10 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsCollect) { } TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsAllCollect) { - std_support::vector mutators(kDefaultThreadCount); - std_support::vector globals(kDefaultThreadCount); - std_support::vector locals(kDefaultThreadCount); - std_support::vector reachables(kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); + std::vector globals(kDefaultThreadCount); + std::vector locals(kDefaultThreadCount); + std::vector reachables(kDefaultThreadCount); auto expandRootSet = [&globals, &locals, &reachables](mm::ThreadData& threadData, Mutator& mutator, int i) { auto& global = mutator.AddGlobalRoot(); @@ -770,7 +770,7 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsAllCollect) { .wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; for (auto& mutator : mutators) { gcFutures.emplace_back(mutator.Execute([](mm::ThreadData& threadData, Mutator& mutator) { @@ -793,7 +793,7 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsAllCollect) { .wait(); } - std_support::vector expectedAlive; + std::vector expectedAlive; for (auto& global : globals) { expectedAlive.push_back(global); } @@ -810,10 +810,10 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsAllCollect) { } TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRequested) { - std_support::vector mutators(kDefaultThreadCount); - std_support::vector globals(kDefaultThreadCount); - std_support::vector locals(kDefaultThreadCount); - std_support::vector reachables(kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); + std::vector globals(kDefaultThreadCount); + std::vector locals(kDefaultThreadCount); + std::vector reachables(kDefaultThreadCount); auto allocateInHeap = [&globals, &locals, &reachables](mm::ThreadData& threadData, Mutator& mutator, int i) { auto& global = AllocateObject(threadData); @@ -840,7 +840,7 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRe .wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; auto epoch = mm::GlobalData::Instance().gc().Schedule(); std::atomic gcDone = false; @@ -864,7 +864,7 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRe future.wait(); } - std_support::vector expectedAlive; + std::vector expectedAlive; for (auto& global : globals) { expectedAlive.push_back(global); } @@ -881,10 +881,10 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRe } TEST_F(SameThreadMarkAndSweepTest, CrossThreadReference) { - std_support::vector mutators(kDefaultThreadCount); - std_support::vector globals(kDefaultThreadCount); - std_support::vector locals(kDefaultThreadCount); - std_support::vector reachables(2 * kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); + std::vector globals(kDefaultThreadCount); + std::vector locals(kDefaultThreadCount); + std::vector reachables(2 * kDefaultThreadCount); auto expandRootSet = [&globals, &locals, &reachables](mm::ThreadData& threadData, Mutator& mutator, int i) { auto& global = mutator.AddGlobalRoot(); @@ -910,7 +910,7 @@ TEST_F(SameThreadMarkAndSweepTest, CrossThreadReference) { .wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; std::atomic gcDone = false; for (auto& mutator : mutators) { @@ -928,7 +928,7 @@ TEST_F(SameThreadMarkAndSweepTest, CrossThreadReference) { future.wait(); } - std_support::vector expectedAlive; + std::vector expectedAlive; for (auto& global : globals) { expectedAlive.push_back(global); } @@ -948,7 +948,7 @@ TEST_F(SameThreadMarkAndSweepTest, CrossThreadReference) { } TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsWeaks) { - std_support::vector mutators(kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); ObjHeader* globalRoot = nullptr; test_support::RegularWeakReferenceImpl* weak = nullptr; @@ -972,7 +972,7 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsWeaks) { mutators[i].Execute([](mm::ThreadData& threadData, Mutator& mutator) {}).wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; auto epoch = mm::GlobalData::Instance().gc().Schedule(); std::atomic gcDone = false; @@ -1002,14 +1002,14 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsWeaks) { } TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsWeakNewObj) { - std_support::vector mutators(kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); // Make sure all mutators are initialized. for (int i = 0; i < kDefaultThreadCount; ++i) { mutators[i].Execute([](mm::ThreadData& threadData, Mutator& mutator) {}).wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; auto epoch = mm::GlobalData::Instance().gc().Schedule(); std::atomic gcDone = false; @@ -1048,11 +1048,11 @@ TEST_F(SameThreadMarkAndSweepTest, MultipleMutatorsWeakNewObj) { } TEST_F(SameThreadMarkAndSweepTest, NewThreadsWhileRequestingCollection) { - std_support::vector mutators(kDefaultThreadCount); - std_support::vector globals(2 * kDefaultThreadCount); - std_support::vector locals(2 * kDefaultThreadCount); - std_support::vector reachables(2 * kDefaultThreadCount); - std_support::vector unreachables(2 * kDefaultThreadCount); + std::vector mutators(kDefaultThreadCount); + std::vector globals(2 * kDefaultThreadCount); + std::vector locals(2 * kDefaultThreadCount); + std::vector reachables(2 * kDefaultThreadCount); + std::vector unreachables(2 * kDefaultThreadCount); auto expandRootSet = [&globals, &locals, &reachables, &unreachables](mm::ThreadData& threadData, Mutator& mutator, int i) { auto& global = mutator.AddGlobalRoot(); @@ -1072,7 +1072,7 @@ TEST_F(SameThreadMarkAndSweepTest, NewThreadsWhileRequestingCollection) { .wait(); } - std_support::vector> gcFutures; + std::vector> gcFutures; auto epoch = mm::GlobalData::Instance().gc().Schedule(); std::atomic gcDone = false; @@ -1081,8 +1081,8 @@ TEST_F(SameThreadMarkAndSweepTest, NewThreadsWhileRequestingCollection) { } // Now start attaching new threads. - std_support::vector newMutators(kDefaultThreadCount); - std_support::vector> attachFutures(kDefaultThreadCount); + std::vector newMutators(kDefaultThreadCount); + std::vector> attachFutures(kDefaultThreadCount); for (int i = 0; i < kDefaultThreadCount; ++i) { attachFutures[i] = newMutators[i].Execute([&gcDone, i, expandRootSet](mm::ThreadData& threadData, Mutator& mutator) { @@ -1116,7 +1116,7 @@ TEST_F(SameThreadMarkAndSweepTest, NewThreadsWhileRequestingCollection) { future.wait(); } - std_support::vector expectedAlive; + std::vector expectedAlive; for (int i = 0; i < kDefaultThreadCount; ++i) { expectedAlive.push_back(globals[i]); expectedAlive.push_back(locals[i]); @@ -1129,7 +1129,7 @@ TEST_F(SameThreadMarkAndSweepTest, NewThreadsWhileRequestingCollection) { } // Force mutators to publish their internal heaps - std_support::vector> publishFutures; + std::vector> publishFutures; for (auto& mutator: mutators) { publishFutures.emplace_back( mutator.Execute([](mm::ThreadData& threadData, Mutator& mutator) { threadData.allocator().prepareForGC(); })); @@ -1148,7 +1148,7 @@ TEST_F(SameThreadMarkAndSweepTest, NewThreadsWhileRequestingCollection) { TEST_F(SameThreadMarkAndSweepTest, FreeObjectWithFreeWeakReversedOrder) { - std_support::vector mutators(2); + std::vector mutators(2); std::atomic*> object1 = nullptr; std::atomic weak = nullptr; std::atomic done = false; diff --git a/kotlin-native/runtime/src/gcScheduler/adaptive/cpp/GCSchedulerImpl.cpp b/kotlin-native/runtime/src/gcScheduler/adaptive/cpp/GCSchedulerImpl.cpp index bdc49a32af9..06041541297 100644 --- a/kotlin-native/runtime/src/gcScheduler/adaptive/cpp/GCSchedulerImpl.cpp +++ b/kotlin-native/runtime/src/gcScheduler/adaptive/cpp/GCSchedulerImpl.cpp @@ -16,7 +16,7 @@ gcScheduler::GCScheduler::ThreadData::Impl::Impl(GCScheduler& scheduler, mm::Thr scheduler_(scheduler.impl().impl()), mutatorAssists_(scheduler_.mutatorAssists(), thread) {} gcScheduler::GCScheduler::ThreadData::ThreadData(gcScheduler::GCScheduler& scheduler, mm::ThreadData& thread) noexcept : - impl_(std_support::make_unique(scheduler, thread)) {} + impl_(std::make_unique(scheduler, thread)) {} gcScheduler::GCScheduler::ThreadData::~ThreadData() = default; @@ -25,7 +25,7 @@ gcScheduler::GCScheduler::Impl::Impl(gcScheduler::GCSchedulerConfig& config) noe return mm::GlobalData::Instance().gc().Schedule(); }) {} -gcScheduler::GCScheduler::GCScheduler() noexcept : impl_(std_support::make_unique(config_)) {} +gcScheduler::GCScheduler::GCScheduler() noexcept : impl_(std::make_unique(config_)) {} gcScheduler::GCScheduler::~GCScheduler() = default; diff --git a/kotlin-native/runtime/src/gcScheduler/adaptive/cpp/GCSchedulerImplTest.cpp b/kotlin-native/runtime/src/gcScheduler/adaptive/cpp/GCSchedulerImplTest.cpp index 68d16b0546f..3efebbaab32 100644 --- a/kotlin-native/runtime/src/gcScheduler/adaptive/cpp/GCSchedulerImplTest.cpp +++ b/kotlin-native/runtime/src/gcScheduler/adaptive/cpp/GCSchedulerImplTest.cpp @@ -5,6 +5,8 @@ #include "GCSchedulerImpl.hpp" +#include + #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -12,7 +14,6 @@ #include "ClockTestSupport.hpp" #include "SingleThreadExecutor.hpp" #include "TestSupport.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -44,7 +45,7 @@ public: explicit GCSchedulerDataTestApi(gcScheduler::GCSchedulerConfig& config) : scheduler_(config, scheduleGC_.AsStdFunction()) { mutators_.reserve(MutatorCount); for (int i = 0; i < MutatorCount; ++i) { - mutators_.emplace_back(std_support::make_unique(scheduler_)); + mutators_.emplace_back(std::make_unique(scheduler_)); } } @@ -72,7 +73,7 @@ public: private: std::atomic allocatedBytes_ = 0; - std_support::vector> mutators_; + std::vector> mutators_; testing::MockFunction scheduleGC_; gcScheduler::internal::GCSchedulerDataAdaptive scheduler_; }; @@ -96,7 +97,7 @@ TEST_F(AdaptiveSchedulerTest, CollectOnTargetHeapReached) { GCSchedulerDataTestApi schedulerTestApi(config); EXPECT_CALL(schedulerTestApi.scheduleGC(), Call()).Times(0); - std_support::vector> futures; + std::vector> futures; for (int i = 0; i < mutatorsCount; ++i) { futures.push_back(schedulerTestApi.Allocate(i, 9)); } @@ -136,7 +137,7 @@ TEST_F(AdaptiveSchedulerTest, CollectOnTargetHeapReachedWithoutAssists) { GCSchedulerDataTestApi schedulerTestApi(config); EXPECT_CALL(schedulerTestApi.scheduleGC(), Call()).Times(0); - std_support::vector> futures; + std::vector> futures; for (int i = 0; i < mutatorsCount; ++i) { futures.push_back(schedulerTestApi.Allocate(i, 9)); } diff --git a/kotlin-native/runtime/src/gcScheduler/aggressive/cpp/GCSchedulerImpl.cpp b/kotlin-native/runtime/src/gcScheduler/aggressive/cpp/GCSchedulerImpl.cpp index c3b21c09f66..cb01f976c34 100644 --- a/kotlin-native/runtime/src/gcScheduler/aggressive/cpp/GCSchedulerImpl.cpp +++ b/kotlin-native/runtime/src/gcScheduler/aggressive/cpp/GCSchedulerImpl.cpp @@ -16,7 +16,7 @@ gcScheduler::GCScheduler::ThreadData::Impl::Impl(GCScheduler& scheduler, mm::Thr scheduler_(scheduler.impl().impl()), mutatorAssists_(scheduler_.mutatorAssists(), thread) {} gcScheduler::GCScheduler::ThreadData::ThreadData(gcScheduler::GCScheduler& gcScheduler, mm::ThreadData& thread) noexcept : - impl_(std_support::make_unique(gcScheduler, thread)) {} + impl_(std::make_unique(gcScheduler, thread)) {} gcScheduler::GCScheduler::ThreadData::~ThreadData() = default; @@ -25,7 +25,7 @@ gcScheduler::GCScheduler::Impl::Impl(gcScheduler::GCSchedulerConfig& config) noe return mm::GlobalData::Instance().gc().Schedule(); }) {} -gcScheduler::GCScheduler::GCScheduler() noexcept : impl_(std_support::make_unique(config_)) {} +gcScheduler::GCScheduler::GCScheduler() noexcept : impl_(std::make_unique(config_)) {} gcScheduler::GCScheduler::~GCScheduler() = default; diff --git a/kotlin-native/runtime/src/gcScheduler/aggressive/cpp/SafePointTracker.hpp b/kotlin-native/runtime/src/gcScheduler/aggressive/cpp/SafePointTracker.hpp index 2520b7490b6..72493a73f8f 100644 --- a/kotlin-native/runtime/src/gcScheduler/aggressive/cpp/SafePointTracker.hpp +++ b/kotlin-native/runtime/src/gcScheduler/aggressive/cpp/SafePointTracker.hpp @@ -6,13 +6,13 @@ #pragma once #include +#include #include "CallsChecker.hpp" #include "KAssert.h" #include "Logging.hpp" #include "Mutex.hpp" #include "StackTrace.hpp" -#include "std_support/UnorderedSet.hpp" namespace kotlin::gcScheduler::internal { @@ -49,7 +49,7 @@ private: // TODO: Consider replacing mutex + global set with thread local sets sychronized on STW. SpinLock mutex_; - std_support::unordered_set metSafePoints_; + std::unordered_set metSafePoints_; }; } // namespace kotlin::gcScheduler::internal diff --git a/kotlin-native/runtime/src/gcScheduler/common/cpp/EpochSchedulerTest.cpp b/kotlin-native/runtime/src/gcScheduler/common/cpp/EpochSchedulerTest.cpp index 3237ecaf765..47aaceab307 100644 --- a/kotlin-native/runtime/src/gcScheduler/common/cpp/EpochSchedulerTest.cpp +++ b/kotlin-native/runtime/src/gcScheduler/common/cpp/EpochSchedulerTest.cpp @@ -146,7 +146,7 @@ TEST(EpochSchedulerTest, StressScheduleNext) { }; std::atomic canStop = false; - std_support::vector threads; + std::vector threads; for (int i = 0; i < kDefaultThreadCount; ++i) { threads.emplace_back([&, i] { Epoch pastEpoch = 0; diff --git a/kotlin-native/runtime/src/gcScheduler/common/cpp/GCScheduler.hpp b/kotlin-native/runtime/src/gcScheduler/common/cpp/GCScheduler.hpp index 1e427095d63..4ea9af50249 100644 --- a/kotlin-native/runtime/src/gcScheduler/common/cpp/GCScheduler.hpp +++ b/kotlin-native/runtime/src/gcScheduler/common/cpp/GCScheduler.hpp @@ -6,13 +6,13 @@ #pragma once #include +#include #include #include #include "GCSchedulerConfig.hpp" #include "KAssert.h" #include "Utils.hpp" -#include "std_support/Memory.hpp" namespace kotlin::mm { class ThreadData; @@ -36,7 +36,7 @@ public: void safePoint() noexcept; private: - std_support::unique_ptr impl_; + std::unique_ptr impl_; }; GCScheduler() noexcept; @@ -66,7 +66,7 @@ public: private: GCSchedulerConfig config_; - std_support::unique_ptr impl_; + std::unique_ptr impl_; }; } // namespace kotlin::gcScheduler diff --git a/kotlin-native/runtime/src/gcScheduler/common/cpp/MutatorAssistsTest.cpp b/kotlin-native/runtime/src/gcScheduler/common/cpp/MutatorAssistsTest.cpp index 859e8424d38..5ee6f094305 100644 --- a/kotlin-native/runtime/src/gcScheduler/common/cpp/MutatorAssistsTest.cpp +++ b/kotlin-native/runtime/src/gcScheduler/common/cpp/MutatorAssistsTest.cpp @@ -5,6 +5,7 @@ #include "MutatorAssists.hpp" +#include #include #include @@ -13,7 +14,6 @@ #include "SafePoint.hpp" #include "TestSupport.hpp" -#include "std_support/Map.hpp" using namespace kotlin; @@ -96,7 +96,7 @@ private: MutatorAssists assists_; RWSpinLock mutatorMapMutex_; - std_support::map mutatorMap_; + std::map mutatorMap_; }; TEST_F(MutatorAssistsTest, EnableSafePointsWhenRequestingAssists) { @@ -124,9 +124,9 @@ TEST_F(MutatorAssistsTest, StressEnableSafePointsByMutators) { std::array, epochsCount> enabled = {false}; std::atomic canStart = false; std::atomic canStop = false; - std_support::vector> mutators; + std::vector> mutators; for (int i = 0; i < kDefaultThreadCount; ++i) { - mutators.emplace_back(std_support::make_unique(*this, [&, i](Mutator&) noexcept { + mutators.emplace_back(std::make_unique(*this, [&, i](Mutator&) noexcept { while (!canStart.load(std::memory_order_relaxed)) { std::this_thread::yield(); } @@ -157,9 +157,9 @@ TEST_F(MutatorAssistsTest, Assist) { std::array, epochsCount> started = {0}; std::array, epochsCount> finished = {0}; std::atomic gcCompleted = 0; - std_support::vector> mutators; + std::vector> mutators; for (int i = 0; i < kDefaultThreadCount; ++i) { - mutators.emplace_back(std_support::make_unique(*this, [&](Mutator&) noexcept { + mutators.emplace_back(std::make_unique(*this, [&](Mutator&) noexcept { for (Epoch epoch = 0; epoch < epochsCount; ++epoch) { while (!canStart[epoch].load(std::memory_order_relaxed)) { std::this_thread::yield(); @@ -213,9 +213,9 @@ TEST_F(MutatorAssistsTest, AssistNoSync) { constexpr Epoch epochsCount = 10000; std::atomic canStop = false; std::atomic finished = 0; - std_support::vector> mutators; + std::vector> mutators; for (int i = 0; i < kDefaultThreadCount; ++i) { - mutators.emplace_back(std_support::make_unique(*this, [&](Mutator&) noexcept { + mutators.emplace_back(std::make_unique(*this, [&](Mutator&) noexcept { while (!canStop.load(std::memory_order_relaxed)) { safePoint(); std::this_thread::yield(); @@ -247,9 +247,9 @@ TEST_F(MutatorAssistsTest, AssistWithNativeMutators) { constexpr Epoch epochsCount = 10000; std::atomic canStop = false; std::atomic finished = 0; - std_support::vector> mutators; + std::vector> mutators; for (int i = 0; i < kDefaultThreadCount; ++i) { - mutators.emplace_back(std_support::make_unique(*this, [&, i](Mutator&) noexcept { + mutators.emplace_back(std::make_unique(*this, [&, i](Mutator&) noexcept { if (i % 2 == 0) { ThreadStateGuard guard(ThreadState::kNative); while (!canStop.load(std::memory_order_relaxed)) { @@ -290,9 +290,9 @@ TEST_F(MutatorAssistsTest, AssistNoRequests) { std::atomic canStop = false; std::atomic started = 0; std::atomic finished = 0; - std_support::vector> mutators; + std::vector> mutators; for (int i = 0; i < kDefaultThreadCount; ++i) { - mutators.emplace_back(std_support::make_unique(*this, [&](Mutator&) noexcept { + mutators.emplace_back(std::make_unique(*this, [&](Mutator&) noexcept { while (!canStart.load(std::memory_order_relaxed)) { std::this_thread::yield(); } @@ -331,9 +331,9 @@ TEST_F(MutatorAssistsTest, AssistRequestsByMutators) { std::atomic started = 0; std::atomic finished = 0; std::atomic currentEpoch = 0; - std_support::vector> mutators; + std::vector> mutators; for (int i = 0; i < kDefaultThreadCount; ++i) { - mutators.emplace_back(std_support::make_unique(*this, [&, i](Mutator&) noexcept { + mutators.emplace_back(std::make_unique(*this, [&, i](Mutator&) noexcept { while (!canStart.load(std::memory_order_relaxed)) { std::this_thread::yield(); } @@ -385,9 +385,9 @@ TEST_F(MutatorAssistsTest, AssistRequestsByMutatorsIntoTheFuture) { scheduledEpoch = currentEpoch + 1; return scheduledEpoch; }; - std_support::vector> mutators; + std::vector> mutators; for (int i = 0; i < kDefaultThreadCount; ++i) { - mutators.emplace_back(std_support::make_unique(*this, [&, i](Mutator&) noexcept { + mutators.emplace_back(std::make_unique(*this, [&, i](Mutator&) noexcept { while (!canStart.load(std::memory_order_relaxed)) { std::this_thread::yield(); } diff --git a/kotlin-native/runtime/src/gcScheduler/manual/cpp/GCSchedulerImpl.cpp b/kotlin-native/runtime/src/gcScheduler/manual/cpp/GCSchedulerImpl.cpp index 664c0af1f96..110077d6228 100644 --- a/kotlin-native/runtime/src/gcScheduler/manual/cpp/GCSchedulerImpl.cpp +++ b/kotlin-native/runtime/src/gcScheduler/manual/cpp/GCSchedulerImpl.cpp @@ -12,11 +12,11 @@ using namespace kotlin; gcScheduler::GCScheduler::ThreadData::ThreadData(gcScheduler::GCScheduler&, mm::ThreadData&) noexcept : - impl_(std_support::make_unique()) {} + impl_(std::make_unique()) {} gcScheduler::GCScheduler::ThreadData::~ThreadData() = default; -gcScheduler::GCScheduler::GCScheduler() noexcept : impl_(std_support::make_unique()) {} +gcScheduler::GCScheduler::GCScheduler() noexcept : impl_(std::make_unique()) {} gcScheduler::GCScheduler::~GCScheduler() = default; diff --git a/kotlin-native/runtime/src/launcher/cpp/androidLauncher.cpp b/kotlin-native/runtime/src/launcher/cpp/androidLauncher.cpp index e4897489637..27870495441 100644 --- a/kotlin-native/runtime/src/launcher/cpp/androidLauncher.cpp +++ b/kotlin-native/runtime/src/launcher/cpp/androidLauncher.cpp @@ -14,13 +14,14 @@ * limitations under the License. */ +#include + #include "KString.h" #include "Memory.h" #include "Natives.h" #include "Porting.h" #include "Runtime.h" #include "Types.h" -#include "std_support/CStdlib.hpp" #ifdef KONAN_ANDROID @@ -218,7 +219,7 @@ extern "C" void RUNTIME_USED Konan_main( ANativeActivity* activity, void* savedState, size_t savedStateSize) { bool launchThread = activity->instance == nullptr; if (launchThread) { - launcherState = (LauncherState*)std_support::calloc(sizeof(LauncherState), 1); + launcherState = (LauncherState*)std::calloc(sizeof(LauncherState), 1); launcherState->nativeActivityState = {activity, savedState, savedStateSize, nullptr}; activity->instance = launcherState; activity->callbacks->onDestroy = onDestroy; diff --git a/kotlin-native/runtime/src/launcher/cpp/launcher.cpp b/kotlin-native/runtime/src/launcher/cpp/launcher.cpp index 62bf032bd91..b3f82fe6573 100644 --- a/kotlin-native/runtime/src/launcher/cpp/launcher.cpp +++ b/kotlin-native/runtime/src/launcher/cpp/launcher.cpp @@ -14,13 +14,14 @@ * limitations under the License. */ +#include + #include "Memory.h" #include "Natives.h" #include "Runtime.h" #include "KString.h" #include "Types.h" #include "Worker.h" -#include "std_support/CStdlib.hpp" #include "launcher.h" diff --git a/kotlin-native/runtime/src/main/cpp/BoundedQueue.hpp b/kotlin-native/runtime/src/main/cpp/BoundedQueue.hpp index a0688cbe6a0..15355ef75e3 100644 --- a/kotlin-native/runtime/src/main/cpp/BoundedQueue.hpp +++ b/kotlin-native/runtime/src/main/cpp/BoundedQueue.hpp @@ -26,6 +26,7 @@ #pragma once #include +#include #include "Utils.hpp" #include "ManuallyScoped.hpp" diff --git a/kotlin-native/runtime/src/main/cpp/BoundedQueueTest.cpp b/kotlin-native/runtime/src/main/cpp/BoundedQueueTest.cpp index 30bb7178f99..68b44983770 100644 --- a/kotlin-native/runtime/src/main/cpp/BoundedQueueTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/BoundedQueueTest.cpp @@ -7,12 +7,12 @@ #include "gtest/gtest.h" #include +#include #include "IntrusiveList.hpp" #include "ParallelProcessor.hpp" -#include "std_support/Vector.hpp" #include "SingleThreadExecutor.hpp" #include "TestSupport.hpp" diff --git a/kotlin-native/runtime/src/main/cpp/CleanerTest.cpp b/kotlin-native/runtime/src/main/cpp/CleanerTest.cpp index a57028add38..a2148aeba1f 100644 --- a/kotlin-native/runtime/src/main/cpp/CleanerTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/CleanerTest.cpp @@ -6,6 +6,7 @@ #include "Cleaner.h" #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -14,7 +15,6 @@ #include "TestSupport.hpp" #include "TestSupportCompilerGenerated.hpp" #include "Types.h" -#include "std_support/Vector.hpp" using namespace kotlin; using namespace kotlin::test_support; @@ -40,7 +40,7 @@ TEST_F(CleanerTest, ConcurrentCreation) { int startedThreads = 0; bool allowRunning = false; - std_support::vector> futures; + std::vector> futures; for (int i = 0; i < threadCount; ++i) { auto future = std::async(std::launch::async, [&startedThreads, &allowRunning]() { // Thread state switching requires initilized memory subsystem. @@ -55,7 +55,7 @@ TEST_F(CleanerTest, ConcurrentCreation) { while (atomicGet(&startedThreads) != threadCount) { } atomicSet(&allowRunning, true); - std_support::vector values; + std::vector values; for (auto& future : futures) { values.push_back(future.get()); } diff --git a/kotlin-native/runtime/src/main/cpp/ClockTest.cpp b/kotlin-native/runtime/src/main/cpp/ClockTest.cpp index bf79920b9f4..7a0a2961fb7 100644 --- a/kotlin-native/runtime/src/main/cpp/ClockTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/ClockTest.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -18,7 +19,6 @@ #include "ClockTestSupport.hpp" #include "ScopedThread.hpp" #include "TestSupport.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -1078,7 +1078,7 @@ TEST(ManualClockTest, ConcurrentSleepUntil) { test_support::manual_clock::reset(); constexpr auto threadCount = kDefaultThreadCount; - std_support::vector threads; + std::vector threads; std::atomic run = false; std::atomic ready = 0; for (int i = 0; i < threadCount; ++i) { @@ -1103,7 +1103,7 @@ TEST(ManualClockTest, ConcurrentWaits) { test_support::manual_clock::reset(); constexpr auto threadCount = kDefaultThreadCount; - std_support::vector threads; + std::vector threads; std::mutex mutex; std::condition_variable cv; std::condition_variable_any cvAny; diff --git a/kotlin-native/runtime/src/main/cpp/ClockTestSupport.cpp b/kotlin-native/runtime/src/main/cpp/ClockTestSupport.cpp index 71b84293f3e..08180a51df4 100644 --- a/kotlin-native/runtime/src/main/cpp/ClockTestSupport.cpp +++ b/kotlin-native/runtime/src/main/cpp/ClockTestSupport.cpp @@ -14,4 +14,4 @@ std::atomic test_support::manual_clock:: std::mutex test_support::manual_clock::pendingWaitsMutex_; // static -std_support::multiset test_support::manual_clock::pendingWaits_; +std::multiset test_support::manual_clock::pendingWaits_; diff --git a/kotlin-native/runtime/src/main/cpp/ClockTestSupport.hpp b/kotlin-native/runtime/src/main/cpp/ClockTestSupport.hpp index 61be7ef53c7..66408604b3d 100644 --- a/kotlin-native/runtime/src/main/cpp/ClockTestSupport.hpp +++ b/kotlin-native/runtime/src/main/cpp/ClockTestSupport.hpp @@ -8,12 +8,12 @@ #include "Clock.hpp" #include +#include #include "gtest/gtest.h" #include "KAssert.h" #include "Utils.hpp" -#include "std_support/Set.hpp" namespace kotlin::test_support { @@ -89,9 +89,9 @@ private: private: friend class manual_clock; - explicit PendingWaitRegistration(std_support::multiset::iterator it) noexcept : it_(it) {} + explicit PendingWaitRegistration(std::multiset::iterator it) noexcept : it_(it) {} - std_support::multiset::iterator it_; + std::multiset::iterator it_; }; template @@ -104,7 +104,7 @@ private: static std::atomic now_; static std::mutex pendingWaitsMutex_; - static std_support::multiset pendingWaits_; + static std::multiset pendingWaits_; }; } // namespace kotlin::test_support diff --git a/kotlin-native/runtime/src/main/cpp/ConditionVariableTest.cpp b/kotlin-native/runtime/src/main/cpp/ConditionVariableTest.cpp index a94e93176fa..c906a8856e5 100644 --- a/kotlin-native/runtime/src/main/cpp/ConditionVariableTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/ConditionVariableTest.cpp @@ -7,13 +7,13 @@ #include #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" #include "ScopedThread.hpp" #include "TestSupport.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -115,7 +115,7 @@ TYPED_TEST(ConditionVariableTest, WaitAll) { CVUnderTest cv; std::atomic waiting = 0; - std_support::vector threads; + std::vector threads; for (int i = 0; i < kDefaultThreadCount; ++i) { threads.emplace_back([&] { std::unique_lock guard(m); @@ -147,7 +147,7 @@ TYPED_TEST(ConditionVariableTest, WaitAllNotifyUnderLock) { CVUnderTest cv; std::atomic waiting = 0; - std_support::vector threads; + std::vector threads; for (int i = 0; i < kDefaultThreadCount; ++i) { threads.emplace_back([&] { std::unique_lock guard(m); @@ -235,7 +235,7 @@ TYPED_TEST(ConditionVariableTest, WaitPredicateAll) { CVUnderTest cv; std::atomic waiting = 0; - std_support::vector threads; + std::vector threads; for (int i = 0; i < kDefaultThreadCount; ++i) { threads.emplace_back([&] { std::unique_lock guard(m); @@ -266,7 +266,7 @@ TYPED_TEST(ConditionVariableTest, WaitPredicateAllNotifyUnderLock) { CVUnderTest cv; std::atomic waiting = 0; - std_support::vector threads; + std::vector threads; for (int i = 0; i < kDefaultThreadCount; ++i) { threads.emplace_back([&] { std::unique_lock guard(m); @@ -308,7 +308,7 @@ TYPED_TEST(ConditionVariableTest, Checkpoint) { return epochScheduled; }; - std_support::vector threads; + std::vector threads; std::array, kDefaultThreadCount> checkpoints = {0}; for (int i = 0; i < kDefaultThreadCount; ++i) { threads.emplace_back([&, i] { diff --git a/kotlin-native/runtime/src/main/cpp/Console.cpp b/kotlin-native/runtime/src/main/cpp/Console.cpp index fea60f2b4a4..b0ab778c49f 100644 --- a/kotlin-native/runtime/src/main/cpp/Console.cpp +++ b/kotlin-native/runtime/src/main/cpp/Console.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ #include +#include +#include #include "KAssert.h" #include "Memory.h" @@ -25,8 +27,6 @@ #ifdef KONAN_ANDROID #include "CompilerConstants.hpp" #endif -#include "std_support/String.hpp" -#include "std_support/Vector.hpp" #include "utf8.h" @@ -34,12 +34,12 @@ using namespace kotlin; namespace { -std_support::string kStringToUtf8(KString message) { +std::string kStringToUtf8(KString message) { if (message->type_info() != theStringTypeInfo) { ThrowClassCastException(message->obj(), theStringTypeInfo); } const KChar* utf16 = CharArrayAddressOfElementAt(message, 0); - std_support::string utf8; + std::string utf8; utf8.reserve(message->count_); // Replace incorrect sequences with a default codepoint (see utf8::with_replacement::default_replacement) utf8::with_replacement::utf16to8(utf16, utf16 + message->count_, back_inserter(utf8)); @@ -114,7 +114,7 @@ OBJ_GETTER0(Kotlin_io_Console_readLine) { } OBJ_GETTER0(Kotlin_io_Console_readlnOrNull) { - std_support::vector data; + std::vector data; data.reserve(16); bool isEOF = false; bool isError = false; diff --git a/kotlin-native/runtime/src/main/cpp/ExceptionsTest.cpp b/kotlin-native/runtime/src/main/cpp/ExceptionsTest.cpp index f2d2bb9dd6d..127c828008a 100644 --- a/kotlin-native/runtime/src/main/cpp/ExceptionsTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/ExceptionsTest.cpp @@ -16,7 +16,6 @@ #include "ScopedThread.hpp" #include "TestSupportCompilerGenerated.hpp" #include "TestSupport.hpp" -#include "std_support/Memory.hpp" using namespace kotlin; using namespace testing; @@ -306,8 +305,8 @@ namespace { using NativeHandlerMock = NiceMock>; using OnUnhandledExceptionMock = NiceMock>; -std_support::unique_ptr gNativeHandlerMock = nullptr; -std_support::unique_ptr> gOnUnhandledExceptionMock = nullptr; +std::unique_ptr gNativeHandlerMock = nullptr; +std::unique_ptr> gOnUnhandledExceptionMock = nullptr; // Google Test's death tests do not fail in case of a failed EXPECT_*/ASSERT_* check in a death statement. // To workaround it, manually check the conditions to be asserted, log all failed conditions and then @@ -323,7 +322,7 @@ void log(const char* message) noexcept { } NativeHandlerMock& setNativeTerminateHandler() noexcept { - gNativeHandlerMock = std_support::make_unique(); + gNativeHandlerMock = std::make_unique(); std::set_terminate([]() { gNativeHandlerMock->Call(); std::abort(); @@ -332,7 +331,7 @@ NativeHandlerMock& setNativeTerminateHandler() noexcept { } OnUnhandledExceptionMock& setKotlinTerminationHandler() noexcept { - gOnUnhandledExceptionMock = std_support::make_unique>( + gOnUnhandledExceptionMock = std::make_unique>( ScopedKotlin_runUnhandledExceptionHookMock()); SetKonanTerminateHandler(); return gOnUnhandledExceptionMock->get(); diff --git a/kotlin-native/runtime/src/main/cpp/ExecFormat.cpp b/kotlin-native/runtime/src/main/cpp/ExecFormat.cpp index 6997b7587ef..43078d483c0 100644 --- a/kotlin-native/runtime/src/main/cpp/ExecFormat.cpp +++ b/kotlin-native/runtime/src/main/cpp/ExecFormat.cpp @@ -17,13 +17,10 @@ #include "ExecFormat.h" #include +#include +#include #include "Porting.h" -#include "std_support/CStdlib.hpp" -#include "std_support/New.hpp" -#include "std_support/Vector.hpp" - -using namespace kotlin; #if USE_ELF_SYMBOLS @@ -64,7 +61,7 @@ struct SymRecord { char* strtab; }; -typedef std_support::vector SymRecordList; +typedef std::vector SymRecordList; SymRecordList* symbols = nullptr; @@ -82,7 +79,7 @@ Elf_Ehdr* findElfHeader() { void initSymbols() { RuntimeAssert(symbols == nullptr, "Init twice"); - symbols = new (std_support::kalloc) SymRecordList(); + symbols = new SymRecordList(); Elf_Ehdr* ehdr = findElfHeader(); if (ehdr == nullptr) return; RuntimeAssert(strncmp((const char*)ehdr->e_ident, ELFMAG, SELFMAG) == 0, "Must be an ELF"); @@ -165,10 +162,10 @@ static void* mapModuleFile(HMODULE hModule) { DWORD bufferLength = 64; wchar_t* buffer = nullptr; for (;;) { - auto newBuffer = (wchar_t*)std_support::calloc(bufferLength, sizeof(wchar_t)); + auto newBuffer = (wchar_t*)std::calloc(bufferLength, sizeof(wchar_t)); RuntimeAssert(newBuffer != nullptr, "Out of memory"); if (buffer != nullptr) { - std_support::free(buffer); + std::free(buffer); } buffer = newBuffer; @@ -184,7 +181,7 @@ static void* mapModuleFile(HMODULE hModule) { } // Invalid result. - std_support::free(buffer); + std::free(buffer); return nullptr; } @@ -197,7 +194,7 @@ static void* mapModuleFile(HMODULE hModule) { /* dwFlagsAndAttributes = */ FILE_ATTRIBUTE_NORMAL, /* hTemplateFile = */ nullptr ); - std_support::free(buffer); + std::free(buffer); if (hFile == INVALID_HANDLE_VALUE) { // Can't open module file. return nullptr; @@ -337,7 +334,7 @@ extern "C" bool AddressToSymbol(const void* address, char* resultBuffer, size_t int rv = GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, reinterpret_cast(&AddressToSymbol), &hModule); RuntimeAssert(rv != 0, "GetModuleHandleExW fails"); - theExeSymbolTable = new (std_support::kalloc) SymbolTable(hModule); + theExeSymbolTable = new SymbolTable(hModule); } return theExeSymbolTable->functionAddressToSymbol(address, resultBuffer, resultBufferSize, resultOffset); } diff --git a/kotlin-native/runtime/src/main/cpp/Interop.cpp b/kotlin-native/runtime/src/main/cpp/Interop.cpp index 0a38b6a2d2b..f4359a018cd 100644 --- a/kotlin-native/runtime/src/main/cpp/Interop.cpp +++ b/kotlin-native/runtime/src/main/cpp/Interop.cpp @@ -23,14 +23,13 @@ #include "Memory.h" #include "MemorySharedRefs.hpp" #include "Types.h" -#include "std_support/New.hpp" using namespace kotlin; extern "C" { KNativePtr Kotlin_Interop_createStablePointer(KRef any) { - KRefSharedHolder* holder = new (std_support::kalloc) KRefSharedHolder(); + KRefSharedHolder* holder = new KRefSharedHolder(); holder->init(any); return holder; } @@ -38,7 +37,7 @@ KNativePtr Kotlin_Interop_createStablePointer(KRef any) { void Kotlin_Interop_disposeStablePointer(KNativePtr pointer) { KRefSharedHolder* holder = reinterpret_cast(pointer); holder->dispose(); - std_support::kdelete(holder); + delete holder; } OBJ_GETTER(Kotlin_Interop_derefStablePointer, KNativePtr pointer) { diff --git a/kotlin-native/runtime/src/main/cpp/IntrusiveListTest.cpp b/kotlin-native/runtime/src/main/cpp/IntrusiveListTest.cpp index b5d83df8db2..059b927f26f 100644 --- a/kotlin-native/runtime/src/main/cpp/IntrusiveListTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/IntrusiveListTest.cpp @@ -6,13 +6,13 @@ #include "IntrusiveList.hpp" #include +#include #include #include "gmock/gmock.h" #include "gtest/gtest.h" #include "Utils.hpp" -#include "std_support/List.hpp" using namespace kotlin; @@ -68,8 +68,8 @@ private: }; template -std_support::list create(std::initializer_list list) { - std_support::list result; +std::list create(std::initializer_list list) { + std::list result; for (auto x : list) { result.emplace_back(x); } diff --git a/kotlin-native/runtime/src/main/cpp/KString.cpp b/kotlin-native/runtime/src/main/cpp/KString.cpp index 13c0caf894c..1b5ba9668f2 100644 --- a/kotlin-native/runtime/src/main/cpp/KString.cpp +++ b/kotlin-native/runtime/src/main/cpp/KString.cpp @@ -15,8 +15,10 @@ */ #include +#include #include #include +#include #include "KAssert.h" #include "Exceptions.h" @@ -25,8 +27,6 @@ #include "KString.h" #include "Porting.h" #include "Types.h" -#include "std_support/CStdlib.hpp" -#include "std_support/String.hpp" #include "utf8.h" @@ -36,7 +36,7 @@ using namespace kotlin; namespace { -typedef std::back_insert_iterator KStdStringInserter; +typedef std::back_insert_iterator KStdStringInserter; typedef KChar* utf8to16(const char*, const char*, KChar*); typedef KStdStringInserter utf16to8(const KChar*,const KChar*, KStdStringInserter); @@ -62,7 +62,7 @@ template OBJ_GETTER(unsafeUtf16ToUtf8Impl, KString thiz, KInt start, KInt size) { RuntimeAssert(thiz->type_info() == theStringTypeInfo, "Must use String"); const KChar* utf16 = CharArrayAddressOfElementAt(thiz, start); - std_support::string utf8; + std::string utf8; utf8.reserve(size); conversion(utf16, utf16 + size, back_inserter(utf8)); ArrayHeader* result = AllocArrayInstance(theByteArrayTypeInfo, utf8.size(), OBJ_RESULT)->array(); @@ -127,16 +127,16 @@ char* CreateCStringFromString(KConstRef kref) { if (kref == nullptr) return nullptr; KString kstring = kref->array(); const KChar* utf16 = CharArrayAddressOfElementAt(kstring, 0); - std_support::string utf8; + std::string utf8; utf8.reserve(kstring->count_); utf8::unchecked::utf16to8(utf16, utf16 + kstring->count_, back_inserter(utf8)); - char* result = reinterpret_cast(std_support::calloc(1, utf8.size() + 1)); + char* result = reinterpret_cast(std::calloc(1, utf8.size() + 1)); ::memcpy(result, utf8.c_str(), utf8.size()); return result; } void DisposeCString(char* cstring) { - if (cstring) std_support::free(cstring); + if (cstring) std::free(cstring); } ObjHeader* CreatePermanentStringFromCString(const char* nullTerminatedUTF8) { @@ -148,7 +148,7 @@ ObjHeader* CreatePermanentStringFromCString(const char* nullTerminatedUTF8) { size_t headerSize = alignUp(sizeof(ArrayHeader), alignof(char16_t)); size_t arraySize = headerSize + count * sizeof(char16_t); - ArrayHeader* header = (ArrayHeader*)std_support::calloc(arraySize, 1); + ArrayHeader* header = (ArrayHeader*)std::calloc(arraySize, 1); header->obj()->typeInfoOrMeta_ = setPointerBits((TypeInfo *)theStringTypeInfo, OBJECT_TAG_PERMANENT_CONTAINER); header->count_ = count; utf8::with_replacement::utf8to16(nullTerminatedUTF8, end, CharArrayAddressOfElementAt(header, 0)); @@ -157,7 +157,7 @@ ObjHeader* CreatePermanentStringFromCString(const char* nullTerminatedUTF8) { } void FreePermanentStringForTests(ArrayHeader* header) { - std_support::free(header); + std::free(header); } // String.kt diff --git a/kotlin-native/runtime/src/main/cpp/KStringTest.cpp b/kotlin-native/runtime/src/main/cpp/KStringTest.cpp index c3fa17130ce..58c2cf33cbf 100644 --- a/kotlin-native/runtime/src/main/cpp/KStringTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/KStringTest.cpp @@ -4,11 +4,13 @@ */ #include "KString.h" -#include "Natives.h" + +#include #include "gtest/gtest.h" #include "gmock/gmock.h" -#include "std_support/CStdlib.hpp" + +#include "Natives.h" using namespace kotlin; diff --git a/kotlin-native/runtime/src/main/cpp/Logging.cpp b/kotlin-native/runtime/src/main/cpp/Logging.cpp index 4caceb65e3b..79ba6b72b82 100644 --- a/kotlin-native/runtime/src/main/cpp/Logging.cpp +++ b/kotlin-native/runtime/src/main/cpp/Logging.cpp @@ -7,14 +7,14 @@ #include #include +#include #include +#include #include "CallsChecker.hpp" #include "Format.h" #include "KAssert.h" #include "Porting.h" -#include "std_support/Map.hpp" -#include "std_support/String.hpp" using namespace kotlin; @@ -53,9 +53,9 @@ std::optional ParseLevel(std::string_view levelString) noexcept return std::nullopt; } -std_support::map ParseTagsFilter(std::string_view tagsFilter) noexcept { +std::map ParseTagsFilter(std::string_view tagsFilter) noexcept { if (tagsFilter.empty()) return {}; - std_support::map result; + std::map result; std::string_view rest = tagsFilter; while (!rest.empty()) { auto tag = ParseTag(rest); @@ -75,7 +75,7 @@ std_support::map ParseTagsFilter(std::strin konan::consoleErrorf("'. No logging will be performed\n"); return {}; } - result.emplace(std_support::string(tag.value->data(), tag.value->size()), *level); + result.emplace(std::string(tag.value->data(), tag.value->size()), *level); } return result; } @@ -100,7 +100,7 @@ public: private: // TODO: Make it more efficient. - std_support::map tagLevelMap_; + std::map tagLevelMap_; }; class StderrLogger : public logging::internal::Logger { @@ -153,12 +153,12 @@ struct DefaultLogContext { } // namespace -std_support::unique_ptr logging::internal::CreateLogFilter(std::string_view tagsFilter) noexcept { - return std_support::make_unique<::LogFilter>(tagsFilter); +std::unique_ptr logging::internal::CreateLogFilter(std::string_view tagsFilter) noexcept { + return std::make_unique<::LogFilter>(tagsFilter); } -std_support::unique_ptr logging::internal::CreateStderrLogger() noexcept { - return std_support::make_unique(); +std::unique_ptr logging::internal::CreateStderrLogger() noexcept { + return std::make_unique(); } std_support::span logging::internal::FormatLogEntry( diff --git a/kotlin-native/runtime/src/main/cpp/Logging.hpp b/kotlin-native/runtime/src/main/cpp/Logging.hpp index e2bfb9788be..82a1f7773a1 100644 --- a/kotlin-native/runtime/src/main/cpp/Logging.hpp +++ b/kotlin-native/runtime/src/main/cpp/Logging.hpp @@ -8,11 +8,11 @@ #include #include +#include #include #include "Clock.hpp" #include "CompilerConstants.hpp" -#include "std_support/Memory.hpp" #include "std_support/Span.hpp" namespace kotlin { @@ -35,7 +35,7 @@ public: virtual bool Enabled(Level level, std_support::span tags) const noexcept = 0; }; -std_support::unique_ptr CreateLogFilter(std::string_view tagsFilter) noexcept; +std::unique_ptr CreateLogFilter(std::string_view tagsFilter) noexcept; class Logger { public: @@ -44,7 +44,7 @@ public: virtual void Log(Level level, std_support::span tags, std::string_view message) const noexcept = 0; }; -std_support::unique_ptr CreateStderrLogger() noexcept; +std::unique_ptr CreateStderrLogger() noexcept; std_support::span FormatLogEntry( std_support::span buffer, diff --git a/kotlin-native/runtime/src/main/cpp/LoggingTest.cpp b/kotlin-native/runtime/src/main/cpp/LoggingTest.cpp index af7a45fe523..6d35fe21210 100644 --- a/kotlin-native/runtime/src/main/cpp/LoggingTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/LoggingTest.cpp @@ -5,11 +5,11 @@ #include "Logging.hpp" +#include + #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "std_support/Vector.hpp" - using namespace kotlin; using ::testing::_; @@ -44,7 +44,7 @@ public: } private: - std_support::unique_ptr logFilter_; + std::unique_ptr logFilter_; }; class MockLogFilter : public logging::internal::LogFilter { @@ -217,7 +217,7 @@ private: }; MATCHER_P(TagsAre, tags, "") { - std_support::vector actualTags; + std::vector actualTags; for (auto tag : arg) { actualTags.push_back(tag); } diff --git a/kotlin-native/runtime/src/main/cpp/MultiSourceQueue.hpp b/kotlin-native/runtime/src/main/cpp/MultiSourceQueue.hpp index b591d6914f0..144fc739129 100644 --- a/kotlin-native/runtime/src/main/cpp/MultiSourceQueue.hpp +++ b/kotlin-native/runtime/src/main/cpp/MultiSourceQueue.hpp @@ -8,27 +8,26 @@ #include #include +#include #include #include "Mutex.hpp" #include "Utils.hpp" -#include "std_support/List.hpp" -#include "std_support/Memory.hpp" namespace kotlin { // A queue that is constructed by collecting subqueues from several `Producer`s. -template > +template > class MultiSourceQueue { - // Using `std_support::list` as it allows to implement `Collect` without memory allocations, + // Using `std::list` as it allows to implement `Collect` without memory allocations, // which is important for GC mark phase. template - using List = std_support::list::template rebind_alloc>; + using List = std::list::template rebind_alloc>; public: class Producer; - // TODO: Consider switching from `std_support::list` to `SingleLockList` to hide the constructor + // TODO: Consider switching from `std::list` to `SingleLockList` to hide the constructor // and to not store the iterator. class Node : private Pinned { public: diff --git a/kotlin-native/runtime/src/main/cpp/MultiSourceQueueTest.cpp b/kotlin-native/runtime/src/main/cpp/MultiSourceQueueTest.cpp index 0edce0e3e1a..780a9a6af08 100644 --- a/kotlin-native/runtime/src/main/cpp/MultiSourceQueueTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/MultiSourceQueueTest.cpp @@ -6,6 +6,7 @@ #include "MultiSourceQueue.hpp" #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -13,7 +14,6 @@ #include "StdAllocatorTestSupport.hpp" #include "ScopedThread.hpp" #include "TestSupport.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -22,8 +22,8 @@ using ::testing::_; namespace { template -std_support::vector Collect(MultiSourceQueue& queue) { - std_support::vector result; +std::vector Collect(MultiSourceQueue& queue) { + std::vector result; for (const auto& element : queue.LockForIter()) { result.push_back(element); } @@ -196,8 +196,8 @@ TEST(MultiSourceQueueTest, ConcurrentPublish) { constexpr int kThreadCount = kDefaultThreadCount; std::atomic canStart(false); std::atomic readyCount(0); - std_support::vector threads; - std_support::vector expected; + std::vector threads; + std::vector expected; for (int i = 0; i < kThreadCount; ++i) { expected.push_back(i); @@ -225,8 +225,8 @@ TEST(MultiSourceQueueTest, IterWhileConcurrentPublish) { constexpr int kStartCount = 50; constexpr int kThreadCount = kDefaultThreadCount; - std_support::vector expectedBefore; - std_support::vector expectedAfter; + std::vector expectedBefore; + std::vector expectedAfter; IntQueue::Producer producer(queue); for (int i = 0; i < kStartCount; ++i) { expectedBefore.push_back(i); @@ -238,7 +238,7 @@ TEST(MultiSourceQueueTest, IterWhileConcurrentPublish) { std::atomic canStart(false); std::atomic readyCount(0); std::atomic startedCount(0); - std_support::vector threads; + std::vector threads; for (int i = 0; i < kThreadCount; ++i) { int j = i + kStartCount; expectedAfter.push_back(j); @@ -253,7 +253,7 @@ TEST(MultiSourceQueueTest, IterWhileConcurrentPublish) { }); } - std_support::vector actualBefore; + std::vector actualBefore; { auto iter = queue.LockForIter(); while (readyCount < kThreadCount) { @@ -282,7 +282,7 @@ TEST(MultiSourceQueueTest, ConcurrentPublishAndApplyDeletions) { std::atomic canStart(false); std::atomic readyCount(0); std::atomic startedCount(0); - std_support::vector threads; + std::vector threads; for (int i = 0; i < kThreadCount; ++i) { threads.emplace_back([&queue, i, &canStart, &readyCount, &startedCount]() { IntQueue::Producer producer(queue); diff --git a/kotlin-native/runtime/src/main/cpp/ObjCExport.mm b/kotlin-native/runtime/src/main/cpp/ObjCExport.mm index 165fb4eb10c..d0b94376f1e 100644 --- a/kotlin-native/runtime/src/main/cpp/ObjCExport.mm +++ b/kotlin-native/runtime/src/main/cpp/ObjCExport.mm @@ -10,7 +10,12 @@ #if KONAN_OBJC_INTEROP +#include +#include #import +#include +#include +#include #import #import @@ -33,11 +38,6 @@ #import "Mutex.hpp" #import "Exceptions.h" #import "Natives.h" -#include "std_support/CStdlib.hpp" -#include "std_support/Map.hpp" -#include "std_support/String.hpp" -#include "std_support/UnorderedSet.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -45,7 +45,7 @@ namespace { template inline T* konanAllocArray(size_t length) { - return reinterpret_cast(std_support::calloc(length, sizeof(T))); + return reinterpret_cast(std::calloc(length, sizeof(T))); } } @@ -563,7 +563,7 @@ static id Kotlin_ObjCExport_refToRetainedObjC_slowpath(ObjHeader* obj) { return convertToRetained(obj); } -static void buildITable(TypeInfo* result, const std_support::map>& interfaceVTables) { +static void buildITable(TypeInfo* result, const std::map>& interfaceVTables) { // Check if can use fast optimistic version - check if the size of the itable could be 2^k and <= 32. bool useFastITable; int itableSize = 1; @@ -597,7 +597,7 @@ static void buildITable(TypeInfo* result, const std_support::map& superInterfaces, - const std_support::vector& vtable, - const std_support::map>& interfaceVTables, + const std::vector& superInterfaces, + const std::vector& vtable, + const std::map>& interfaceVTables, const InterfaceTableRecord* superItable, int superItableSize, bool itableEqualsSuper, const TypeInfo* fieldsInfo ) { - TypeInfo* result = (TypeInfo*)std_support::calloc(1, sizeof(TypeInfo) + vtable.size() * sizeof(void*)); + TypeInfo* result = (TypeInfo*)std::calloc(1, sizeof(TypeInfo) + vtable.size() * sizeof(void*)); result->typeInfo_ = result; result->flags_ = TF_OBJC_DYNAMIC; @@ -656,10 +656,10 @@ static const TypeInfo* createTypeInfo( result->classId_ = superType->classId_; - std_support::vector implementedInterfaces( + std::vector implementedInterfaces( superType->implementedInterfaces_, superType->implementedInterfaces_ + superType->implementedInterfacesCount_ ); - std_support::unordered_set usedInterfaces(implementedInterfaces.begin(), implementedInterfaces.end()); + std::unordered_set usedInterfaces(implementedInterfaces.begin(), implementedInterfaces.end()); for (const TypeInfo* interface : superInterfaces) { if (usedInterfaces.insert(interface).second) { @@ -685,14 +685,14 @@ static const TypeInfo* createTypeInfo( result->packageName_ = nullptr; result->relativeName_ = CreatePermanentStringFromCString(className); - result->writableInfo_ = (WritableTypeInfo*)std_support::calloc(1, sizeof(WritableTypeInfo)); + result->writableInfo_ = (WritableTypeInfo*)std::calloc(1, sizeof(WritableTypeInfo)); for (size_t i = 0; i < vtable.size(); ++i) result->vtable()[i] = vtable[i]; return result; } -static void addDefinedSelectors(Class clazz, std_support::unordered_set& result) { +static void addDefinedSelectors(Class clazz, std::unordered_set& result) { unsigned int objcMethodCount; Method* objcMethods = class_copyMethodList(clazz, &objcMethodCount); @@ -703,10 +703,10 @@ static void addDefinedSelectors(Class clazz, std_support::unordered_set& re if (objcMethods != nullptr) free(objcMethods); } -static std_support::vector getProtocolsAsInterfaces(Class clazz) { - std_support::vector result; - std_support::unordered_set handledProtocols; - std_support::vector protocolsToHandle; +static std::vector getProtocolsAsInterfaces(Class clazz) { + std::vector result; + std::unordered_set handledProtocols; + std::vector protocolsToHandle; { unsigned int protocolCount; @@ -764,7 +764,7 @@ static void throwIfCantBeOverridden(Class clazz, const KotlinToObjCMethodAdapter static const TypeInfo* createTypeInfo(Class clazz, const TypeInfo* superType, const TypeInfo* fieldsInfo) { kotlin::NativeOrUnregisteredThreadGuard threadStateGuard(/* reentrant = */ true); - std_support::unordered_set definedSelectors; + std::unordered_set definedSelectors; addDefinedSelectors(clazz, definedSelectors); const ObjCTypeAdapter* superTypeAdapter = getTypeAdapter(superType); @@ -787,7 +787,7 @@ static const TypeInfo* createTypeInfo(Class clazz, const TypeInfo* superType, co if (superVtable == nullptr) superVtable = superType->vtable(); - std_support::vector vtable( + std::vector vtable( superVtable, superVtable + superVtableSize ); @@ -796,7 +796,7 @@ static const TypeInfo* createTypeInfo(Class clazz, const TypeInfo* superType, co superITable = superType->interfaceTable_; superITableSize = superType->interfaceTableSize_; } - std_support::map> interfaceVTables; + std::map> interfaceVTables; if (superITable != nullptr) { int actualItableSize = superITableSize >= 0 ? superITableSize + 1 : -superITableSize; for (int i = 0; i < actualItableSize; ++i) { @@ -804,16 +804,16 @@ static const TypeInfo* createTypeInfo(Class clazz, const TypeInfo* superType, co auto interfaceId = record.id; if (interfaceId == kInvalidInterfaceId) continue; int vtableSize = record.vtableSize; - std_support::vector interfaceVTable(vtableSize); + std::vector interfaceVTable(vtableSize); for (int j = 0; j < vtableSize; ++j) interfaceVTable[j] = record.vtable[j]; interfaceVTables.emplace(interfaceId, std::move(interfaceVTable)); } } - std_support::vector addedInterfaces = getProtocolsAsInterfaces(clazz); + std::vector addedInterfaces = getProtocolsAsInterfaces(clazz); - std_support::vector supers( + std::vector supers( superType->implementedInterfaces_, superType->implementedInterfaces_ + superType->implementedInterfacesCount_ ); @@ -838,7 +838,7 @@ static const TypeInfo* createTypeInfo(Class clazz, const TypeInfo* superType, co auto interfaceVTablesIt = interfaceVTables.find(interfaceId); if (interfaceVTablesIt == interfaceVTables.end()) { itableEqualsSuper = false; - interfaceVTables.emplace(interfaceId, std_support::vector(itableSize)); + interfaceVTables.emplace(interfaceId, std::vector(itableSize)); } else { auto const& interfaceVTable = interfaceVTablesIt->second; RuntimeAssert(interfaceVTable.size() == static_cast(itableSize), ""); @@ -955,7 +955,7 @@ static Class createClass(const TypeInfo* typeInfo, Class superClass) { kotlin::NativeOrUnregisteredThreadGuard threadStateGuard(/* reentrant = */ true); int classIndex = (anonymousClassNextId++); - std_support::string className = Kotlin_ObjCInterop_getUniquePrefix(); + std::string className = Kotlin_ObjCInterop_getUniquePrefix(); className += "_kobjcc"; className += std::to_string(classIndex); @@ -975,7 +975,7 @@ static Class createClass(const TypeInfo* typeInfo, Class superClass) { } } - std_support::unordered_set superImplementedInterfaces( + std::unordered_set superImplementedInterfaces( typeInfo->superType_->implementedInterfaces_, typeInfo->superType_->implementedInterfaces_ + typeInfo->superType_->implementedInterfacesCount_ ); diff --git a/kotlin-native/runtime/src/main/cpp/ObjCInterop.mm b/kotlin-native/runtime/src/main/cpp/ObjCInterop.mm index bfe04e67951..42476a023ea 100644 --- a/kotlin-native/runtime/src/main/cpp/ObjCInterop.mm +++ b/kotlin-native/runtime/src/main/cpp/ObjCInterop.mm @@ -14,6 +14,7 @@ #include #include #include +#include #include "Memory.h" #include "MemorySharedRefs.hpp" @@ -25,7 +26,6 @@ #include "StackTrace.hpp" #include "Types.h" #include "Mutex.hpp" -#include "std_support/String.hpp" using namespace kotlin; @@ -240,7 +240,7 @@ NO_EXTERNAL_CALLS_CHECK static Class allocateClass(const KotlinObjCClassInfo* in fprintf(stderr, "Class %s has multiple implementations. Which one will be used is undefined.\n", info->name); } - std_support::string className = Kotlin_ObjCInterop_getUniquePrefix(); + std::string className = Kotlin_ObjCInterop_getUniquePrefix(); if (info->name != nullptr) { className += info->name; diff --git a/kotlin-native/runtime/src/main/cpp/ObjectTestSupport.hpp b/kotlin-native/runtime/src/main/cpp/ObjectTestSupport.hpp index ff36d47ab2e..4460b398bea 100644 --- a/kotlin-native/runtime/src/main/cpp/ObjectTestSupport.hpp +++ b/kotlin-native/runtime/src/main/cpp/ObjectTestSupport.hpp @@ -5,13 +5,13 @@ #include #include +#include #include "KAssert.h" #include "Memory.h" #include "TypeInfo.h" #include "Types.h" #include "Utils.hpp" -#include "std_support/Vector.hpp" namespace kotlin { namespace test_support { @@ -27,7 +27,7 @@ private: virtual ~Builder() = default; int32_t instanceSize_ = 0; - std_support::vector objOffsets_; + std::vector objOffsets_; int32_t objOffsetsCount_ = 0; int32_t flags_ = 0; int32_t instanceAlignment_ = 8; @@ -98,7 +98,7 @@ public: private: TypeInfo typeInfo_{}; - std_support::vector objOffsets_; + std::vector objOffsets_; }; class Any : private Pinned { diff --git a/kotlin-native/runtime/src/main/cpp/ObjectTestSupportTest.cpp b/kotlin-native/runtime/src/main/cpp/ObjectTestSupportTest.cpp index 45679da3a37..498dc6ccebd 100644 --- a/kotlin-native/runtime/src/main/cpp/ObjectTestSupportTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/ObjectTestSupportTest.cpp @@ -5,12 +5,13 @@ #include "ObjectTestSupport.hpp" +#include + #include "gmock/gmock.h" #include "gtest/gtest.h" #include "Natives.h" #include "TestSupport.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -69,8 +70,8 @@ using ObjectTestCases = testing::Types -std_support::vector Collect(test_support::Object& object) { - std_support::vector result; +std::vector Collect(test_support::Object& object) { + std::vector result; for (auto& field : object.fields()) { result.push_back(&field); } @@ -308,8 +309,8 @@ using ArrayTestCases = testing::Types< TYPED_TEST_SUITE(ObjectTestSupportArrayTest, ArrayTestCases, ArrayTestCaseNames); template -std_support::vector Collect(test_support::internal::Array& array) { - std_support::vector result; +std::vector Collect(test_support::internal::Array& array) { + std::vector result; for (auto& element : array.elements()) { result.push_back(&element); } @@ -330,7 +331,7 @@ TYPED_TEST(ObjectTestSupportArrayTest, Local) { EXPECT_THAT(array.arrayHeader()->count_, size); EXPECT_THAT(array.elements().size(), size); - std_support::vector expected; + std::vector expected; for (size_t i = 0; i < size; ++i) { auto* element = AddressOfElementAt(array.arrayHeader(), i); EXPECT_THAT(&array.elements()[i], element); @@ -361,7 +362,7 @@ TYPED_TEST(ObjectTestSupportArrayTest, Heap) { EXPECT_THAT(array.arrayHeader()->count_, size); EXPECT_THAT(array.elements().size(), size); - std_support::vector expected; + std::vector expected; for (size_t i = 0; i < size; ++i) { auto* element = AddressOfElementAt(array.arrayHeader(), i); EXPECT_THAT(&array.elements()[i], element); diff --git a/kotlin-native/runtime/src/main/cpp/ParallelProcessorTest.cpp b/kotlin-native/runtime/src/main/cpp/ParallelProcessorTest.cpp index 750eeea474b..a6e53da15f5 100644 --- a/kotlin-native/runtime/src/main/cpp/ParallelProcessorTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/ParallelProcessorTest.cpp @@ -3,16 +3,15 @@ * that can be found in the LICENSE file. */ +#include "ParallelProcessor.hpp" + #include "gmock/gmock.h" #include "gtest/gtest.h" #include +#include #include "IntrusiveList.hpp" - -#include "ParallelProcessor.hpp" - -#include "std_support/Vector.hpp" #include "SingleThreadExecutor.hpp" #include "TestSupport.hpp" diff --git a/kotlin-native/runtime/src/main/cpp/Porting.cpp b/kotlin-native/runtime/src/main/cpp/Porting.cpp index a95f02d2d71..7c0179ceb8c 100644 --- a/kotlin-native/runtime/src/main/cpp/Porting.cpp +++ b/kotlin-native/runtime/src/main/cpp/Porting.cpp @@ -18,9 +18,9 @@ #include #endif #include +#include #include #include -#include #include #include #include @@ -34,7 +34,6 @@ #include "CompilerConstants.hpp" #include "Porting.h" #include "KAssert.h" -#include "std_support/CStdlib.hpp" using namespace kotlin; @@ -185,7 +184,7 @@ static void onThreadExitCallback(void* value) { while (record != nullptr) { record->destructor(record->destructorParameter); auto next = record->next; - std_support::free(record); + std::free(record); record = next; } } @@ -213,7 +212,7 @@ static void onThreadExitInit() { void onThreadExit(void (*destructor)(void*), void* destructorParameter) { // We cannot use pthread_cleanup_push() as it is lexical scope bound. pthread_once(&terminationKeyOnceControl, onThreadExitInit); - DestructorRecord* destructorRecord = (DestructorRecord*)std_support::calloc(1, sizeof(DestructorRecord)); + DestructorRecord* destructorRecord = (DestructorRecord*)std::calloc(1, sizeof(DestructorRecord)); destructorRecord->destructor = destructor; destructorRecord->destructorParameter = destructorParameter; destructorRecord->next = diff --git a/kotlin-native/runtime/src/main/cpp/Runtime.cpp b/kotlin-native/runtime/src/main/cpp/Runtime.cpp index c42d0dd2473..e45b9d01159 100644 --- a/kotlin-native/runtime/src/main/cpp/Runtime.cpp +++ b/kotlin-native/runtime/src/main/cpp/Runtime.cpp @@ -16,7 +16,6 @@ #include "RuntimePrivate.hpp" #include "Worker.h" #include "KString.h" -#include "std_support/New.hpp" #include #include #include @@ -86,7 +85,7 @@ volatile GlobalRuntimeStatus globalRuntimeStatus = kGlobalRuntimeUninitialized; RuntimeState* initRuntime() { SetKonanTerminateHandler(); initObjectPool(); - RuntimeState* result = new (std_support::kalloc) RuntimeState(); + RuntimeState* result = new RuntimeState(); if (!result) return kInvalidRuntime; RuntimeCheck(!isValidRuntime(), "No active runtimes allowed"); ::runtimeState = result; @@ -177,7 +176,7 @@ void deinitRuntime(RuntimeState* state, bool destroyRuntime) { // Do not use ThreadStateGuard because memoryState will be destroyed during DeinitMemory. kotlin::SwitchThreadState(state->memoryState, kotlin::ThreadState::kNative); DeinitMemory(state->memoryState, destroyRuntime); - std_support::kdelete(state); + delete state; WorkerDestroyThreadDataIfNeeded(workerId); ::runtimeState = kInvalidRuntime; } diff --git a/kotlin-native/runtime/src/main/cpp/ScopedThread.hpp b/kotlin-native/runtime/src/main/cpp/ScopedThread.hpp index 90700269d27..deb512eeeb4 100644 --- a/kotlin-native/runtime/src/main/cpp/ScopedThread.hpp +++ b/kotlin-native/runtime/src/main/cpp/ScopedThread.hpp @@ -7,11 +7,11 @@ #include #include +#include #include #include #include "Utils.hpp" -#include "std_support/String.hpp" namespace kotlin { namespace internal { @@ -44,7 +44,7 @@ public: private: friend class ScopedThread; - std::optional name_; + std::optional name_; }; ScopedThread() noexcept = default; diff --git a/kotlin-native/runtime/src/main/cpp/SingleLockList.hpp b/kotlin-native/runtime/src/main/cpp/SingleLockList.hpp index 3d264e46682..8d5400948a6 100644 --- a/kotlin-native/runtime/src/main/cpp/SingleLockList.hpp +++ b/kotlin-native/runtime/src/main/cpp/SingleLockList.hpp @@ -19,14 +19,14 @@ namespace kotlin { // TODO: Consider different locking mechanisms. -template > +template > class SingleLockList : private Pinned { public: class Node; private: using NodeAllocator = typename std::allocator_traits::template rebind_alloc; - using NodeOwner = std_support::unique_ptr>; + using NodeOwner = std::unique_ptr>; public: // TODO: Maybe just hide `Node` altogether? diff --git a/kotlin-native/runtime/src/main/cpp/SingleLockListTest.cpp b/kotlin-native/runtime/src/main/cpp/SingleLockListTest.cpp index 772c90d1197..b59c9c2ebc1 100644 --- a/kotlin-native/runtime/src/main/cpp/SingleLockListTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/SingleLockListTest.cpp @@ -6,7 +6,9 @@ #include "SingleLockList.hpp" #include +#include #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -14,8 +16,6 @@ #include "StdAllocatorTestSupport.hpp" #include "ScopedThread.hpp" #include "TestSupport.hpp" -#include "std_support/Deque.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -52,7 +52,7 @@ TEST(SingleLockListTest, EmplaceAndIter) { list.Emplace(kSecond); list.Emplace(kThird); - std_support::vector actual; + std::vector actual; for (int element : list.LockForIter()) { actual.push_back(element); } @@ -70,7 +70,7 @@ TEST(SingleLockListTest, EmplaceEraseAndIter) { list.Emplace(kThird); list.Erase(secondNode); - std_support::vector actual; + std::vector actual; for (int element : list.LockForIter()) { actual.push_back(element); } @@ -81,7 +81,7 @@ TEST(SingleLockListTest, EmplaceEraseAndIter) { TEST(SingleLockListTest, IterEmpty) { IntList list; - std_support::vector actual; + std::vector actual; for (int element : list.LockForIter()) { actual.push_back(element); } @@ -102,7 +102,7 @@ TEST(SingleLockListTest, EraseToEmptyEmplaceAndIter) { list.Emplace(kThird); list.Emplace(kFourth); - std_support::vector actual; + std::vector actual; for (int element : list.LockForIter()) { actual.push_back(element); } @@ -115,8 +115,8 @@ TEST(SingleLockListTest, ConcurrentEmplace) { constexpr int kThreadCount = kDefaultThreadCount; std::atomic canStart(false); std::atomic readyCount(0); - std_support::vector threads; - std_support::vector expected; + std::vector threads; + std::vector expected; for (int i = 0; i < kThreadCount; ++i) { expected.push_back(i); threads.emplace_back([i, &list, &canStart, &readyCount]() { @@ -132,7 +132,7 @@ TEST(SingleLockListTest, ConcurrentEmplace) { canStart = true; threads.clear(); - std_support::vector actual; + std::vector actual; for (int element : list.LockForIter()) { actual.push_back(element); } @@ -143,14 +143,14 @@ TEST(SingleLockListTest, ConcurrentEmplace) { TEST(SingleLockListTest, ConcurrentErase) { IntList list; constexpr int kThreadCount = kDefaultThreadCount; - std_support::vector items; + std::vector items; for (int i = 0; i < kThreadCount; ++i) { items.push_back(list.Emplace(i)); } std::atomic canStart(false); std::atomic readyCount(0); - std_support::vector threads; + std::vector threads; for (auto* item : items) { threads.emplace_back([item, &list, &canStart, &readyCount]() { ++readyCount; @@ -165,7 +165,7 @@ TEST(SingleLockListTest, ConcurrentErase) { canStart = true; threads.clear(); - std_support::vector actual; + std::vector actual; for (int element : list.LockForIter()) { actual.push_back(element); } @@ -178,8 +178,8 @@ TEST(SingleLockListTest, IterWhileConcurrentEmplace) { constexpr int kStartCount = 50; constexpr int kThreadCount = kDefaultThreadCount; - std_support::deque expectedBefore; - std_support::vector expectedAfter; + std::deque expectedBefore; + std::vector expectedAfter; for (int i = 0; i < kStartCount; ++i) { expectedBefore.push_front(i); expectedAfter.push_back(i); @@ -188,7 +188,7 @@ TEST(SingleLockListTest, IterWhileConcurrentEmplace) { std::atomic canStart(false); std::atomic startedCount(0); - std_support::vector threads; + std::vector threads; for (int i = 0; i < kThreadCount; ++i) { int j = i + kStartCount; expectedAfter.push_back(j); @@ -200,7 +200,7 @@ TEST(SingleLockListTest, IterWhileConcurrentEmplace) { }); } - std_support::vector actualBefore; + std::vector actualBefore; { auto iter = list.LockForIter(); canStart = true; @@ -216,7 +216,7 @@ TEST(SingleLockListTest, IterWhileConcurrentEmplace) { EXPECT_THAT(actualBefore, testing::ElementsAreArray(expectedBefore)); - std_support::vector actualAfter; + std::vector actualAfter; for (int element : list.LockForIter()) { actualAfter.push_back(element); } @@ -228,8 +228,8 @@ TEST(SingleLockListTest, IterWhileConcurrentErase) { IntList list; constexpr int kThreadCount = kDefaultThreadCount; - std_support::deque expectedBefore; - std_support::vector items; + std::deque expectedBefore; + std::vector items; for (int i = 0; i < kThreadCount; ++i) { expectedBefore.push_front(i); items.push_back(list.Emplace(i)); @@ -237,7 +237,7 @@ TEST(SingleLockListTest, IterWhileConcurrentErase) { std::atomic canStart(false); std::atomic startedCount(0); - std_support::vector threads; + std::vector threads; for (auto* item : items) { threads.emplace_back([item, &list, &canStart, &startedCount]() { while (!canStart) { @@ -247,7 +247,7 @@ TEST(SingleLockListTest, IterWhileConcurrentErase) { }); } - std_support::vector actualBefore; + std::vector actualBefore; { auto iter = list.LockForIter(); canStart = true; @@ -263,7 +263,7 @@ TEST(SingleLockListTest, IterWhileConcurrentErase) { EXPECT_THAT(actualBefore, testing::ElementsAreArray(expectedBefore)); - std_support::vector actualAfter; + std::vector actualAfter; for (int element : list.LockForIter()) { actualAfter.push_back(element); } @@ -275,10 +275,10 @@ TEST(SingleLockListTest, LockAndEmplace) { SingleLockList list; constexpr int kThreadCount = kDefaultThreadCount; - std_support::vector threads; - std_support::vector actualLocked; - std_support::vector actualUnlocked; - std_support::vector expectedUnlocked; + std::vector threads; + std::vector actualLocked; + std::vector actualUnlocked; + std::vector expectedUnlocked; for (int i = 0; i < kThreadCount; i++) { expectedUnlocked.push_back(i); } @@ -314,11 +314,11 @@ TEST(SingleLockListTest, LockAndErase) { SingleLockList list; constexpr int kThreadCount = kDefaultThreadCount; - std_support::vector::Node*> items; - std_support::vector expectedLocked; - std_support::vector threads; - std_support::vector actualLocked; - std_support::vector actualUnlocked; + std::vector::Node*> items; + std::vector expectedLocked; + std::vector threads; + std::vector actualLocked; + std::vector actualUnlocked; std::atomic startedCount(0); for (int i = 0; i < kThreadCount; i++) { @@ -377,7 +377,7 @@ TEST(SingleLockListTest, PinnedType) { list.Erase(itemNode); - std_support::vector actualAfter; + std::vector actualAfter; for (auto& element : list.LockForIter()) { actualAfter.push_back(&element); } diff --git a/kotlin-native/runtime/src/main/cpp/SingleThreadExecutor.hpp b/kotlin-native/runtime/src/main/cpp/SingleThreadExecutor.hpp index 0adf0a014a0..cabebb2fac4 100644 --- a/kotlin-native/runtime/src/main/cpp/SingleThreadExecutor.hpp +++ b/kotlin-native/runtime/src/main/cpp/SingleThreadExecutor.hpp @@ -6,6 +6,7 @@ #pragma once #include +#include #include #include #include @@ -13,7 +14,6 @@ #include "ScopedThread.hpp" #include "Utils.hpp" -#include "std_support/Deque.hpp" namespace kotlin { @@ -101,7 +101,7 @@ private: std::condition_variable workCV_; std::mutex workMutex_; - std_support::deque> queue_; + std::deque> queue_; bool shutdownRequested_ = false; ScopedThread thread_; diff --git a/kotlin-native/runtime/src/main/cpp/SingleThreadExecutorTest.cpp b/kotlin-native/runtime/src/main/cpp/SingleThreadExecutorTest.cpp index b926b96490c..5908c7164ed 100644 --- a/kotlin-native/runtime/src/main/cpp/SingleThreadExecutorTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/SingleThreadExecutorTest.cpp @@ -5,13 +5,14 @@ #include "SingleThreadExecutor.hpp" +#include +#include + #include "gmock/gmock.h" #include "gtest/gtest.h" #include "KAssert.h" #include "TestSupport.hpp" -#include "std_support/Memory.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -62,7 +63,7 @@ TEST(SingleThreadExecutorTest, ContextThreadBound) { createdContext = &context; createdThread = std::this_thread::get_id(); }); - auto executor = std_support::make_unique>(); + auto executor = std::make_unique>(); // Make sure context is created. executor->context(); testing::Mock::VerifyAndClearExpectations(&mocks.ctorMock); @@ -129,7 +130,7 @@ TEST(SingleThreadExecutorTest, execute) { TEST(SingleThreadExecutorTest, DropExecutorWithTasks) { struct Context {}; - auto executor = std_support::make_unique>(); + auto executor = std::make_unique>(); std::mutex taskMutex; testing::StrictMock> task; @@ -143,7 +144,7 @@ TEST(SingleThreadExecutorTest, DropExecutorWithTasks) { auto future = executor->execute(task.AsStdFunction()); while (!taskStarted) {} - std_support::vector, bool>> newTasks; + std::vector, bool>> newTasks; constexpr size_t tasksCount = 100; for (size_t i = 0; i < tasksCount; ++i) { newTasks.push_back(std::make_pair(executor->execute([&newTasks, i] { newTasks[i].second = true; }), false)); @@ -167,14 +168,14 @@ TEST(SingleThreadExecutorTest, DropExecutorWithTasks) { TEST(SingleThreadExecutorTest, ExecuteFromManyThreads) { struct Context { - std_support::vector result; + std::vector result; }; SingleThreadExecutor executor; std::atomic_bool canStart = false; - std_support::vector expected; - std_support::vector threads; + std::vector expected; + std::vector threads; for (int i = 0; i < kDefaultThreadCount; ++i) { expected.push_back(i); threads.emplace_back([&, i] { diff --git a/kotlin-native/runtime/src/main/cpp/StackTrace.cpp b/kotlin-native/runtime/src/main/cpp/StackTrace.cpp index faf6d079a56..1610c766238 100644 --- a/kotlin-native/runtime/src/main/cpp/StackTrace.cpp +++ b/kotlin-native/runtime/src/main/cpp/StackTrace.cpp @@ -124,11 +124,11 @@ int getSourceInfo(void* symbol, SourceInfo *result, int result_len) { // TODO: this implementation is just a hack, e.g. the result is inexact; // however it is better to have an inexact stacktrace than not to have any. -NO_INLINE std_support::vector kotlin::internal::GetCurrentStackTrace(size_t skipFrames) noexcept { +NO_INLINE std::vector kotlin::internal::GetCurrentStackTrace(size_t skipFrames) noexcept { // Skip GetCurrentStackTrace + anything asked by the caller. const size_t kSkipFrames = 1 + skipFrames; - std_support::vector result; + std::vector result; #if USE_GCC_UNWIND size_t depth = 0; _Unwind_Backtrace(depthCountCallback, static_cast(&depth)); @@ -257,9 +257,9 @@ KNativePtr adjustAddressForSourceInfo(KNativePtr address) { KNativePtr adjustAddressForSourceInfo(KNativePtr address) { return address; } #endif -std_support::vector kotlin::GetStackTraceStrings(std_support::span stackTrace) noexcept { +std::vector kotlin::GetStackTraceStrings(std_support::span stackTrace) noexcept { size_t size = stackTrace.size(); - std_support::vector strings; + std::vector strings; strings.reserve(size); if (size > 0) { SourceInfo buffer[10]; // outside of the loop to avoid calling constructors and destructors each time diff --git a/kotlin-native/runtime/src/main/cpp/StackTrace.hpp b/kotlin-native/runtime/src/main/cpp/StackTrace.hpp index a0a58e0b695..354806360c5 100644 --- a/kotlin-native/runtime/src/main/cpp/StackTrace.hpp +++ b/kotlin-native/runtime/src/main/cpp/StackTrace.hpp @@ -6,16 +6,19 @@ #ifndef RUNTIME_STACK_TRACE_H #define RUNTIME_STACK_TRACE_H +#include +#include +#include + +#include "Common.h" +#include "Utils.hpp" #include "std_support/Span.hpp" -#include "Memory.h" -#include "std_support/String.hpp" -#include "std_support/Vector.hpp" namespace kotlin { namespace internal { -NO_INLINE std_support::vector GetCurrentStackTrace(size_t skipFrames) noexcept; +NO_INLINE std::vector GetCurrentStackTrace(size_t skipFrames) noexcept; NO_INLINE size_t GetCurrentStackTrace(size_t skipFrames, std_support::span buffer) noexcept; enum class StackTraceCapacityKind { @@ -180,18 +183,18 @@ public: struct TestSupport : private Pinned { static StackTrace constructFrom(std::initializer_list values) { - std_support::vector traceElements(values); + std::vector traceElements(values); return StackTrace(std::move(traceElements)); } }; private: - explicit StackTrace(std_support::vector&& buffer) noexcept : buffer_(buffer) {} + explicit StackTrace(std::vector&& buffer) noexcept : buffer_(buffer) {} - std_support::vector buffer_; + std::vector buffer_; }; -std_support::vector GetStackTraceStrings(std_support::span stackTrace) noexcept; +std::vector GetStackTraceStrings(std_support::span stackTrace) noexcept; // It's not always safe to extract SourceInfo during unhandled exception termination. void DisallowSourceInfo(); diff --git a/kotlin-native/runtime/src/main/cpp/StackTraceTest.cpp b/kotlin-native/runtime/src/main/cpp/StackTraceTest.cpp index c59bb3a55dd..67a9226346d 100644 --- a/kotlin-native/runtime/src/main/cpp/StackTraceTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/StackTraceTest.cpp @@ -7,6 +7,7 @@ #include #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -14,9 +15,6 @@ #include "Common.h" #include "Porting.h" #include "TestSupport.hpp" -#include "std_support/UnorderedSet.hpp" - -#include using namespace kotlin; @@ -189,7 +187,7 @@ TEST(StackTraceTest, StackAllocatedDeepTraceWithEnoughCapacity) { TEST(StackTraceTest, Iteration) { auto stackTrace = GetStackTrace2(); - std_support::vector actualAddresses; + std::vector actualAddresses; for (auto addr : stackTrace) { actualAddresses.push_back(addr); } @@ -205,7 +203,7 @@ TEST(StackTraceTest, Iteration) { TEST(StackTraceTest, StackAllocatedIteration) { auto stackTrace = GetStackTrace2<2>(); - std_support::vector actualAddresses; + std::vector actualAddresses; for (auto addr : stackTrace) { actualAddresses.push_back(addr); } @@ -221,7 +219,7 @@ TEST(StackTraceTest, StackAllocatedIteration) { TEST(StackTraceTest, IndexedAccess) { auto stackTrace = GetStackTrace2(); - std_support::vector actualAddresses; + std::vector actualAddresses; for (size_t i = 0; i < stackTrace.size(); i++) { actualAddresses.push_back(stackTrace[i]); } @@ -235,7 +233,7 @@ TEST(StackTraceTest, IndexedAccess) { TEST(StackTraceTest, StackAllocatedIndexedAccess) { auto stackTrace = GetStackTrace2<2>(); - std_support::vector actualAddresses; + std::vector actualAddresses; for (size_t i = 0; i < stackTrace.size(); i++) { actualAddresses.push_back(stackTrace[i]); } @@ -336,7 +334,7 @@ TEST(StackTraceTest, StackAllocatedEqualsAndHash) { TEST(StackTraceTest, StoreInHashSet) { constexpr size_t capacity = 10; - std_support::unordered_set> set; + std::unordered_set> set; StackTrace empty; StackTrace trace1 = GetStackTrace1(); StackTrace trace2 = GetStackTrace2(); @@ -361,7 +359,7 @@ TEST(StackTraceTest, StoreInHashSet) { } TEST(StackTraceTest, StackAllocatedStoreInHashSet) { - std_support::unordered_set> set; + std::unordered_set> set; StackTrace<> empty; StackTrace<> trace1 = GetStackTrace1(); StackTrace<> trace2 = GetStackTrace2(); diff --git a/kotlin-native/runtime/src/main/cpp/StdAllocatorTestSupport.hpp b/kotlin-native/runtime/src/main/cpp/StdAllocatorTestSupport.hpp index 52a256ee2df..6a283ac4be5 100644 --- a/kotlin-native/runtime/src/main/cpp/StdAllocatorTestSupport.hpp +++ b/kotlin-native/runtime/src/main/cpp/StdAllocatorTestSupport.hpp @@ -5,6 +5,8 @@ #pragma once +#include +#include #include #include @@ -12,8 +14,6 @@ #include "gtest/gtest.h" #include "Utils.hpp" -#include "std_support/CStdlib.hpp" -#include "std_support/Map.hpp" namespace kotlin::test_support { @@ -26,8 +26,8 @@ public: class SpyAllocatorCore : private Pinned { public: SpyAllocatorCore() noexcept { - ON_CALL(*this, allocate(testing::_)).WillByDefault([](std::size_t size) { return std_support::malloc(size); }); - ON_CALL(*this, deallocate(testing::_, testing::_)).WillByDefault([](void* ptr, std::size_t size) { std_support::free(ptr); }); + ON_CALL(*this, allocate(testing::_)).WillByDefault([](std::size_t size) { return std::malloc(size); }); + ON_CALL(*this, deallocate(testing::_, testing::_)).WillByDefault([](void* ptr, std::size_t size) { std::free(ptr); }); } MOCK_METHOD(void*, allocate, (std::size_t), (noexcept)); diff --git a/kotlin-native/runtime/src/main/cpp/TestSupportCompilerGenerated.hpp b/kotlin-native/runtime/src/main/cpp/TestSupportCompilerGenerated.hpp index 500d56cb1b3..a3c3c9c531c 100644 --- a/kotlin-native/runtime/src/main/cpp/TestSupportCompilerGenerated.hpp +++ b/kotlin-native/runtime/src/main/cpp/TestSupportCompilerGenerated.hpp @@ -11,7 +11,6 @@ #include "Types.h" #include "Utils.hpp" -#include "std_support/Memory.hpp" namespace kotlin { namespace test_support { @@ -35,7 +34,7 @@ public: explicit ScopedMockFunction(testing::MockFunction** globalMockLocation) : globalMockLocation_(globalMockLocation) { RuntimeCheck(globalMockLocation != nullptr, "ScopedMockFunction needs non-null global mock location"); RuntimeCheck(*globalMockLocation == nullptr, "ScopedMockFunction needs null global mock"); - mock_ = std_support::make_unique(); + mock_ = std::make_unique(); *globalMockLocation_ = mock_.get(); } @@ -70,7 +69,7 @@ public: private: // Can be null if moved-out of. testing::MockFunction** globalMockLocation_; - std_support::unique_ptr mock_; + std::unique_ptr mock_; }; template diff --git a/kotlin-native/runtime/src/main/cpp/Worker.cpp b/kotlin-native/runtime/src/main/cpp/Worker.cpp index 24075e1fc39..aaca9156c3f 100644 --- a/kotlin-native/runtime/src/main/cpp/Worker.cpp +++ b/kotlin-native/runtime/src/main/cpp/Worker.cpp @@ -15,8 +15,12 @@ */ #include +#include +#include #include #include +#include +#include #include #include "PthreadUtils.h" @@ -29,11 +33,6 @@ #include "Runtime.h" #include "Types.h" #include "Worker.h" -#include "std_support/Deque.hpp" -#include "std_support/New.hpp" -#include "std_support/Set.hpp" -#include "std_support/UnorderedMap.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -129,7 +128,7 @@ struct JobCompare { // Using multiset instead of regular set, because we compare the jobs only by `whenExecute`. // So if `whenExecute` of two different jobs is the same, the jobs are considered equivalent, // and set would simply drop one of them. -typedef std_support::multiset DelayedJobSet; +typedef std::multiset DelayedJobSet; } // namespace @@ -196,7 +195,7 @@ class Worker { KInt id_; WorkerKind kind_; - std_support::deque queue_; + std::deque queue_; DelayedJobSet delayed_; // Stable pointer with worker's name. KNativePtr name_; @@ -364,7 +363,7 @@ class State { Worker* worker = nullptr; { Locker locker(&lock_); - worker = new (std_support::kalloc) Worker(nextWorkerId(), exceptionHandling, customName, kind); + worker = new Worker(nextWorkerId(), exceptionHandling, customName, kind); if (worker == nullptr) return nullptr; workers_[worker->id()] = worker; } @@ -397,7 +396,7 @@ class State { } } GC_UnregisterWorker(worker); - std_support::kdelete(worker); + delete worker; } Future* addJobToWorkerUnlocked( @@ -410,7 +409,7 @@ class State { if (it == workers_.end()) return nullptr; worker = it->second; - future = new (std_support::kalloc) Future(nextFutureId()); + future = new Future(nextFutureId()); futures_[future->id()] = future; Job job; @@ -512,7 +511,7 @@ class State { auto it = futures_.find(id); if (it != futures_.end()) { futures_.erase(it); - std_support::kdelete(future); + delete future; } } @@ -586,7 +585,7 @@ class State { template void waitNativeWorkersTerminationUnlocked(bool checkLeaks, F waitForWorker) { - std_support::vector> workersToWait; + std::vector> workersToWait; { Locker locker(&lock_); @@ -640,7 +639,7 @@ class State { } OBJ_GETTER0(getActiveWorkers) { - std_support::vector workers; + std::vector workers; { Locker locker(&lock_); @@ -658,9 +657,9 @@ class State { private: pthread_mutex_t lock_; pthread_cond_t cond_; - std_support::unordered_map futures_; - std_support::unordered_map workers_; - std_support::unordered_map terminating_native_workers_; + std::unordered_map futures_; + std::unordered_map workers_; + std::unordered_map terminating_native_workers_; KInt currentWorkerId_; KInt currentFutureId_; KInt currentVersion_; @@ -673,11 +672,11 @@ State* theState() { return state; } - State* result = new (std_support::kalloc) State(); + State* result = new State(); State* old = __sync_val_compare_and_swap(&state, nullptr, result); if (old != nullptr) { - std_support::kdelete(result); + delete result; // Someone else inited this data. return old; } diff --git a/kotlin-native/runtime/src/main/cpp/WorkerBoundReference.cpp b/kotlin-native/runtime/src/main/cpp/WorkerBoundReference.cpp index 8cc87269528..144cb6f2da0 100644 --- a/kotlin-native/runtime/src/main/cpp/WorkerBoundReference.cpp +++ b/kotlin-native/runtime/src/main/cpp/WorkerBoundReference.cpp @@ -7,7 +7,6 @@ #include "Memory.h" #include "MemorySharedRefs.hpp" -#include "std_support/New.hpp" using namespace kotlin; @@ -29,7 +28,7 @@ RUNTIME_NOTHROW void DisposeWorkerBoundReference(KRef thiz) { // Can be null if WorkerBoundReference wasn't frozen. if (auto* holder = asWorkerBoundReference(thiz)->holder) { holder->dispose(); - std_support::kdelete(holder); + delete holder; } } @@ -43,7 +42,7 @@ RUNTIME_NOTHROW void WorkerBoundReferenceFreezeHook(KRef thiz) { extern "C" { KNativePtr Kotlin_WorkerBoundReference_create(KRef value) { - auto* holder = new (std_support::kalloc) KRefSharedHolder(); + auto* holder = new KRefSharedHolder(); holder->init(value); return holder; } diff --git a/kotlin-native/runtime/src/main/cpp/dtoa/dblparse.cpp b/kotlin-native/runtime/src/main/cpp/dtoa/dblparse.cpp index 8125152231c..6dc07d76e66 100644 --- a/kotlin-native/runtime/src/main/cpp/dtoa/dblparse.cpp +++ b/kotlin-native/runtime/src/main/cpp/dtoa/dblparse.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "cbigint.h" #include "../Exceptions.h" @@ -26,8 +27,6 @@ #include "../Porting.h" #include "../utf8.h" #include "../DoubleConversions.h" -#include "../std_support/CStdlib.hpp" -#include "../std_support/String.hpp" using namespace kotlin; @@ -179,8 +178,8 @@ static const KDouble tens[] = { } #define ERROR_OCCURED(x) (HIGH_I32_FROM_VAR(x) < 0) -#define allocateU64(x, n) if (!((x) = (U_64*) std_support::calloc(1, (n) * sizeof(U_64)))) goto OutOfMemory; -#define release(r) if ((r)) std_support::free((r)); +#define allocateU64(x, n) if (!((x) = (U_64*) std::calloc(1, (n) * sizeof(U_64)))) goto OutOfMemory; +#define release(r) if ((r)) std::free((r)); /*NB the Number converter methods are synchronized so it is possible to *have global data for use by bigIntDigitGenerator */ @@ -647,7 +646,7 @@ OutOfMemory: KDouble Kotlin_native_FloatingPointParser_parseDoubleImpl (KString s, KInt e) { const KChar* utf16 = CharArrayAddressOfElementAt(s, 0); - std_support::string utf8; + std::string utf8; utf8.reserve(s->count_); try { utf8::utf16to8(utf16, utf16 + s->count_, back_inserter(utf8)); diff --git a/kotlin-native/runtime/src/main/cpp/dtoa/fltparse.cpp b/kotlin-native/runtime/src/main/cpp/dtoa/fltparse.cpp index c876ecff8c7..13367b598c9 100644 --- a/kotlin-native/runtime/src/main/cpp/dtoa/fltparse.cpp +++ b/kotlin-native/runtime/src/main/cpp/dtoa/fltparse.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "cbigint.h" #include "../Exceptions.h" @@ -25,8 +26,6 @@ #include "../Natives.h" #include "../Porting.h" #include "../utf8.h" -#include "../std_support/CStdlib.hpp" -#include "../std_support/String.hpp" using namespace kotlin; @@ -121,8 +120,8 @@ static const U_32 tens[] = { } \ } -#define allocateU64(x, n) if (!((x) = (U_64*) std_support::calloc(1, (n) * sizeof(U_64)))) goto OutOfMemory; -#define release(r) if ((r)) std_support::free((r)); +#define allocateU64(x, n) if (!((x) = (U_64*) std::calloc(1, (n) * sizeof(U_64)))) goto OutOfMemory; +#define release(r) if ((r)) std::free((r)); KFloat createFloat(const char *s, KInt e) { /* assumes s is a null terminated string with at least one @@ -546,7 +545,7 @@ extern "C" KFloat Kotlin_native_FloatingPointParser_parseFloatImpl(KString s, KInt e) { const KChar* utf16 = CharArrayAddressOfElementAt(s, 0); - std_support::string utf8; + std::string utf8; utf8.reserve(s->count_); try { utf8::utf16to8(utf16, utf16 + s->count_, back_inserter(utf8)); diff --git a/kotlin-native/runtime/src/main/cpp/objc_support/NSNotificationSubscriptionTest.mm b/kotlin-native/runtime/src/main/cpp/objc_support/NSNotificationSubscriptionTest.mm index efc5ae80891..bb4c0d56fa4 100644 --- a/kotlin-native/runtime/src/main/cpp/objc_support/NSNotificationSubscriptionTest.mm +++ b/kotlin-native/runtime/src/main/cpp/objc_support/NSNotificationSubscriptionTest.mm @@ -9,12 +9,11 @@ #import #import +#include #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "std_support/Memory.hpp" - using namespace kotlin; using testing::_; @@ -216,7 +215,7 @@ TEST_F(NSNotificationSubscriptionTest, DestroysHandler) { EXPECT_CALL(destructorHook, Call(_)).Times(0); auto subscription = - subscribe(name, [withDestructorHook = std_support::make_shared(destructorHook.AsStdFunction())] {}); + subscribe(name, [withDestructorHook = std::make_shared(destructorHook.AsStdFunction())] {}); post(name); testing::Mock::VerifyAndClearExpectations(&destructorHook); diff --git a/kotlin-native/runtime/src/main/cpp/objc_support/ObjectPtrTest.mm b/kotlin-native/runtime/src/main/cpp/objc_support/ObjectPtrTest.mm index ca68857d5f7..6300351f51b 100644 --- a/kotlin-native/runtime/src/main/cpp/objc_support/ObjectPtrTest.mm +++ b/kotlin-native/runtime/src/main/cpp/objc_support/ObjectPtrTest.mm @@ -7,14 +7,13 @@ #include "ObjectPtr.hpp" -#include - #import +#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "std_support/Memory.hpp" #include "Utils.hpp" using namespace kotlin; @@ -38,7 +37,7 @@ private: } // namespace @interface WithDestructorHookObjC : NSObject { - std_support::unique_ptr impl_; + std::unique_ptr impl_; } @property(readonly) WithDestructorHook* impl; @@ -51,7 +50,7 @@ private: - (instancetype)initWithDestructorHook:(std::function)hook { if ((self = [super init])) { - impl_ = std_support::make_unique(hook); + impl_ = std::make_unique(hook); } return self; } diff --git a/kotlin-native/runtime/src/main/cpp/std_support/CStdlib.cpp b/kotlin-native/runtime/src/main/cpp/std_support/CStdlib.cpp index f69514407e0..6ef900925d2 100644 --- a/kotlin-native/runtime/src/main/cpp/std_support/CStdlib.cpp +++ b/kotlin-native/runtime/src/main/cpp/std_support/CStdlib.cpp @@ -5,20 +5,13 @@ #include "std_support/CStdlib.hpp" -#include -#include #include -#include #include "Alignment.hpp" #include "KAssert.h" using namespace kotlin; -void* std_support::malloc(std::size_t size) noexcept { - return std::malloc(size); -} - void* std_support::aligned_malloc(std::size_t alignment, std::size_t size) noexcept { // Enforcing alignment requirements of std::aligned_alloc. RuntimeAssert(IsValidAlignment(alignment), "Invalid alignment %zu", alignment); @@ -26,18 +19,6 @@ void* std_support::aligned_malloc(std::size_t alignment, std::size_t size) noexc return ::_mm_malloc(size, alignment); } -void* std_support::calloc(std::size_t num, std::size_t size) noexcept { - return std::calloc(num, size); -} - -void* std_support::realloc(void* ptr, std::size_t size) noexcept { - return std::realloc(ptr, size); -} - -void std_support::free(void* ptr) noexcept { - return std::free(ptr); -} - void std_support::aligned_free(void* ptr) noexcept { return ::_mm_free(ptr); } diff --git a/kotlin-native/runtime/src/main/cpp/std_support/CStdlib.hpp b/kotlin-native/runtime/src/main/cpp/std_support/CStdlib.hpp index 004322dc308..cbe4835939f 100644 --- a/kotlin-native/runtime/src/main/cpp/std_support/CStdlib.hpp +++ b/kotlin-native/runtime/src/main/cpp/std_support/CStdlib.hpp @@ -9,17 +9,11 @@ namespace kotlin::std_support { -void* malloc(std::size_t size) noexcept; // TODO: Replace with `aligned_alloc` that's compatible with normal `free`. // Allocate aligned memory. Must be freed with `aligned_free`. void* aligned_malloc(std::size_t alignment, std::size_t size) noexcept; -void* calloc(std::size_t num, std::size_t size) noexcept; - -void* realloc(void* ptr, std::size_t size) noexcept; - -void free(void* ptr) noexcept; -// Free memory allocated with aligned_malloc. +// Free memory allocated with `aligned_malloc`. void aligned_free(void* ptr) noexcept; } // namespace kotlin::std_support diff --git a/kotlin-native/runtime/src/main/cpp/std_support/CStdlibTest.cpp b/kotlin-native/runtime/src/main/cpp/std_support/CStdlibTest.cpp index bccedab04cf..27b11c0762e 100644 --- a/kotlin-native/runtime/src/main/cpp/std_support/CStdlibTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/std_support/CStdlibTest.cpp @@ -33,79 +33,6 @@ static_assert( } // namespace -TEST(StdSupportCStdlibTest, Malloc) { - { - Struct* ptr = (Struct*)std_support::malloc(sizeof(Struct)); - EXPECT_TRUE(IsAligned(ptr, mallocAlignment)); - ptr->x = 123; - EXPECT_THAT(ptr->x, 123); - std_support::free(ptr); - } - { - void* ptr = std_support::malloc(0); - EXPECT_TRUE(IsAligned(ptr, mallocAlignment)); - std_support::free(ptr); - } -} - -TEST(StdSupportCStdlibTest, Free) { - std_support::free(nullptr); -} - -TEST(StdSupportCStdlibTest, Calloc) { - { - Struct* ptr = (Struct*)std_support::calloc(sizeof(Struct), 2); - EXPECT_TRUE(IsAligned(ptr, mallocAlignment)); - EXPECT_THAT(ptr[0].x, 0); - EXPECT_THAT(ptr[1].x, 0); - ptr[0].x = 123; - ptr[1].x = 42; - EXPECT_THAT(ptr[0].x, 123); - EXPECT_THAT(ptr[1].x, 42); - std_support::free(ptr); - } - { - void* ptr = std_support::calloc(0, 2); - EXPECT_TRUE(IsAligned(ptr, mallocAlignment)); - std_support::free(ptr); - } - { - void* ptr = std_support::calloc(sizeof(Struct), 0); - EXPECT_TRUE(IsAligned(ptr, mallocAlignment)); - std_support::free(ptr); - } -} - -TEST(StdSupportCStdlibTest, Realloc) { - { - Struct* ptr = (Struct*)std_support::malloc(sizeof(Struct)); - ptr->x = 123; - Struct* newPtr = (Struct*)std_support::realloc(ptr, sizeof(Struct) * 3); - EXPECT_TRUE(IsAligned(newPtr, mallocAlignment)); - EXPECT_THAT(newPtr[0].x, 123); - newPtr[1].x = 42; - newPtr[2].x = 13; - EXPECT_THAT(newPtr[1].x, 42); - EXPECT_THAT(newPtr[2].x, 13); - std_support::free(newPtr); - } - { - Struct* ptr = (Struct*)std_support::calloc(sizeof(Struct), 2); - EXPECT_TRUE(IsAligned(ptr, mallocAlignment)); - ptr[0].x = 123; - ptr[1].x = 42; - EXPECT_THAT(ptr[0].x, 123); - EXPECT_THAT(ptr[1].x, 42); - Struct* newPtr = (Struct*)std_support::realloc(ptr, sizeof(Struct) * 3); - EXPECT_TRUE(IsAligned(newPtr, mallocAlignment)); - EXPECT_THAT(newPtr[0].x, 123); - EXPECT_THAT(newPtr[1].x, 42); - newPtr[2].x = 13; - EXPECT_THAT(newPtr[2].x, 13); - std_support::free(newPtr); - } -} - TEST(StdSupportCStdlibTest, AlignedMalloc) { { Struct* ptr = (Struct*)std_support::aligned_malloc(alignof(Struct), sizeof(Struct)); diff --git a/kotlin-native/runtime/src/main/cpp/std_support/Deque.hpp b/kotlin-native/runtime/src/main/cpp/std_support/Deque.hpp deleted file mode 100644 index e3134ac1acc..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/Deque.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#pragma once - -#include - -#include "std_support/Memory.hpp" - -namespace kotlin::std_support { - -template > -using deque = std::deque; - -} // namespace kotlin::std_support diff --git a/kotlin-native/runtime/src/main/cpp/std_support/ForwardList.hpp b/kotlin-native/runtime/src/main/cpp/std_support/ForwardList.hpp deleted file mode 100644 index 24c9aeb76a8..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/ForwardList.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#pragma once - -#include - -#include "std_support/Memory.hpp" - -namespace kotlin::std_support { - -template > -using forward_list = std::forward_list; - -} // namespace kotlin::std_support diff --git a/kotlin-native/runtime/src/main/cpp/std_support/List.hpp b/kotlin-native/runtime/src/main/cpp/std_support/List.hpp deleted file mode 100644 index a4c1fbc6d3b..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/List.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#pragma once - -#include - -#include "std_support/Memory.hpp" - -namespace kotlin::std_support { - -template > -using list = std::list; - -} // namespace kotlin::std_support diff --git a/kotlin-native/runtime/src/main/cpp/std_support/Map.hpp b/kotlin-native/runtime/src/main/cpp/std_support/Map.hpp deleted file mode 100644 index 68696164dba..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/Map.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#pragma once - -#include - -#include "std_support/Memory.hpp" - -namespace kotlin::std_support { - -template , typename Allocator = allocator>> -using map = std::map; - -template , typename Allocator = allocator>> -using multimap = std::multimap; - -} // namespace kotlin::std_support diff --git a/kotlin-native/runtime/src/main/cpp/std_support/Memory.hpp b/kotlin-native/runtime/src/main/cpp/std_support/Memory.hpp index 85a95c862b1..27761c9f7a8 100644 --- a/kotlin-native/runtime/src/main/cpp/std_support/Memory.hpp +++ b/kotlin-native/runtime/src/main/cpp/std_support/Memory.hpp @@ -9,44 +9,8 @@ #include #include -#include "std_support/CStdlib.hpp" - namespace kotlin::std_support { -// Default allocator for Kotlin. -// TODO: Consider overriding global operator new and operator delete instead. However, make sure this does -// not extend over to interop. -template -struct allocator { - using value_type = T; - using size_type = std::size_t; - using difference_type = std::ptrdiff_t; - using propagate_on_container_move_assignment = std::true_type; - using is_always_equal = std::true_type; - - allocator() noexcept = default; - - allocator(const allocator&) noexcept = default; - - template - allocator(const allocator&) noexcept {} - - // TODO: maybe malloc, actually? - T* allocate(std::size_t n) noexcept { return static_cast(std_support::calloc(n, sizeof(T))); } - - void deallocate(T* p, std::size_t n) noexcept { std_support::free(p); } -}; - -template -bool operator==(const allocator&, const allocator&) noexcept { - return true; -} - -template -bool operator!=(const allocator&, const allocator&) noexcept { - return false; -} - template T* allocator_new(const Allocator& allocator, Args&&... args) { static_assert(!std::is_array_v, "T cannot be an array"); @@ -113,26 +77,6 @@ auto allocate_unique(const Allocator& allocator, Args&&... args) { return std::unique_ptr(allocator_new(allocator, std::forward(args)...), TDeleter(allocator)); } -template -using default_delete = allocator_deleter>; - -template > -using unique_ptr = std::unique_ptr; - -template -auto make_unique(Args&&... args) { - static_assert(!std::is_array_v, "T cannot be an array"); - - return allocate_unique(allocator(), std::forward(args)...); -} - -template -auto make_shared(Args&&... args) { - static_assert(!std::is_array_v, "T cannot be an array"); - - return std::allocate_shared(allocator(), std::forward(args)...); -} - template auto nullptr_unique(const Allocator& allocator = Allocator()) noexcept { static_assert(!std::is_array_v, "T cannot be an array"); diff --git a/kotlin-native/runtime/src/main/cpp/std_support/MemoryTest.cpp b/kotlin-native/runtime/src/main/cpp/std_support/MemoryTest.cpp index e4e4d94a8c2..bf72a5e63f2 100644 --- a/kotlin-native/runtime/src/main/cpp/std_support/MemoryTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/std_support/MemoryTest.cpp @@ -88,46 +88,6 @@ MockClass::Mocker* MockClass::Mocker::instance_ = nullptr; } // namespace -TEST(StdSupportMemoryTest, Allocator) { - using Allocator = std_support::allocator; - using Traits = std::allocator_traits; - Allocator allocator; - Class* ptr = Traits::allocate(allocator, 1); - new (ptr) Class(42); - EXPECT_THAT(ptr->x(), 42); - Traits::deallocate(allocator, ptr, 1); -} - -TEST(StdSupportMemoryTest, AllocatorFromWrongClass) { - using WrongClassAllocator = std_support::allocator; - WrongClassAllocator base; - using Allocator = typename std::allocator_traits::template rebind_alloc; - using Traits = typename std::allocator_traits::template rebind_traits; - Allocator allocator = Allocator(base); - Class* ptr = Traits::allocate(allocator, 1); - new (ptr) Class(42); - EXPECT_THAT(ptr->x(), 42); - Traits::deallocate(allocator, ptr, 1); -} - -TEST(StdSupportMemoryTest, MakeUnique) { - auto ptr = std_support::make_unique(42); - EXPECT_THAT(ptr->x(), 42); -} - -TEST(StdSupportMemoryTest, MakeUniqueThrows) { - EXPECT_THROW(std_support::make_unique(42), int); -} - -TEST(StdSupportMemoryTest, MakeShared) { - auto ptr = std_support::make_shared(42); - EXPECT_THAT(ptr->x(), 42); -} - -TEST(StdSupportMemoryTest, MakeSharedThrows) { - EXPECT_THROW(std_support::make_shared(42), int); -} - TEST(StdSupportMemoryTest, AllocatorNew) { testing::StrictMock allocatorCore; testing::StrictMock mocker; @@ -260,56 +220,11 @@ TEST(StdSupportMemoryTest, AllocateUniqueWrongType) { ptr.reset(); } -template -using UniquePtr = std_support::unique_ptr>; - -TEST(StdSupportMemoryTest, UniquePtrConversions) { - static_assert(std::is_convertible_v, std_support::unique_ptr>); - static_assert(!std::is_convertible_v, std_support::unique_ptr>); - static_assert(!std::is_convertible_v, std_support::unique_ptr>); - static_assert(!std::is_convertible_v, std_support::unique_ptr>); - - static_assert(!std::is_assignable_v, std_support::unique_ptr>); - static_assert(std::is_assignable_v, std_support::unique_ptr>); - static_assert(!std::is_assignable_v, std_support::unique_ptr>); - static_assert(!std::is_assignable_v, std_support::unique_ptr>); - - using AllocatorClass = test_support::Allocator; - using AllocatorDerivedClass = test_support::Allocator; - using AllocatorInt = test_support::Allocator; - - static_assert(std::is_convertible_v, UniquePtr>); - static_assert(std::is_convertible_v, UniquePtr>); - static_assert(std::is_convertible_v, UniquePtr>); - static_assert(std::is_convertible_v, UniquePtr>); - static_assert(!std::is_convertible_v, UniquePtr>); - static_assert(!std::is_convertible_v, UniquePtr>); - static_assert(!std::is_convertible_v, UniquePtr>); - static_assert(!std::is_convertible_v, UniquePtr>); - static_assert(!std::is_convertible_v, UniquePtr>); - static_assert(!std::is_convertible_v, UniquePtr>); - static_assert(!std::is_convertible_v, UniquePtr>); - static_assert(!std::is_convertible_v, UniquePtr>); - - static_assert(!std::is_assignable_v, UniquePtr>); - static_assert(!std::is_assignable_v, UniquePtr>); - static_assert(!std::is_assignable_v, UniquePtr>); - static_assert(!std::is_assignable_v, UniquePtr>); - static_assert(std::is_assignable_v, UniquePtr>); - static_assert(std::is_assignable_v, UniquePtr>); - static_assert(std::is_assignable_v, UniquePtr>); - static_assert(std::is_assignable_v, UniquePtr>); - static_assert(!std::is_assignable_v, UniquePtr>); - static_assert(!std::is_assignable_v, UniquePtr>); - static_assert(!std::is_assignable_v, UniquePtr>); - static_assert(!std::is_assignable_v, UniquePtr>); -} - TEST(StdSupportMemoryTest, NullptrUnique) { testing::StrictMock allocatorCore; auto allocator = test_support::MakeAllocator(allocatorCore); - std_support::unique_ptr> ptr = + std::unique_ptr> ptr = std_support::nullptr_unique(allocator); EXPECT_THAT(ptr.get(), nullptr); } diff --git a/kotlin-native/runtime/src/main/cpp/std_support/New.cpp b/kotlin-native/runtime/src/main/cpp/std_support/New.cpp deleted file mode 100644 index f0d3a007e75..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/New.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#include "std_support/New.hpp" - -#include "std_support/CStdlib.hpp" - -using namespace kotlin; - -// TODO: Maybe malloc instead of calloc? - -void* operator new(std::size_t count, kotlin::std_support::kalloc_t) noexcept { - return std_support::calloc(1, count); -} - -void operator delete(void* ptr, kotlin::std_support::kalloc_t) noexcept { - std_support::free(ptr); -} diff --git a/kotlin-native/runtime/src/main/cpp/std_support/New.hpp b/kotlin-native/runtime/src/main/cpp/std_support/New.hpp deleted file mode 100644 index 0eacb333f7d..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/New.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#pragma once - -#include - -namespace kotlin::std_support { - -struct kalloc_t {}; -inline constexpr kalloc_t kalloc = kotlin::std_support::kalloc_t{}; - -} // namespace kotlin::std_support - -// TODO: Add align_val_t overloads once we make sure all targets support aligned allocation. -// (also requires removing `-fno-aligned-allocation` compiler flag). - -void* operator new(std::size_t count, kotlin::std_support::kalloc_t) noexcept; -void operator delete(void* ptr, kotlin::std_support::kalloc_t) noexcept; - -namespace kotlin::std_support { - -template -void kdelete(T* ptr) noexcept { - ptr->~T(); - ::operator delete(ptr, kalloc); -} - -} // namespace kotlin::std_support diff --git a/kotlin-native/runtime/src/main/cpp/std_support/NewTest.cpp b/kotlin-native/runtime/src/main/cpp/std_support/NewTest.cpp deleted file mode 100644 index 9b5f2dc9236..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/NewTest.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#include "std_support/New.hpp" - -#include "gmock/gmock.h" -#include "gtest/gtest.h" - -using namespace kotlin; - -namespace { - -class Class { -public: - explicit Class(int32_t x = 17) : x_(x) {} - - int32_t x() const { return x_; } - -private: - int32_t x_; -}; - -class ClassThrows { -public: - explicit ClassThrows(int32_t x = 17) : x_(x) { throw 13; } - - int32_t x() const { return x_; } - -private: - int32_t x_; -}; - -} // namespace - -TEST(NewTest, NewDelete) { - Class* ptr = new (std_support::kalloc) Class(42); - EXPECT_THAT(ptr->x(), 42); - std_support::kdelete(ptr); -} - -TEST(NewTest, NewThrows) { - EXPECT_THROW(new (std_support::kalloc) ClassThrows(42), int); -} diff --git a/kotlin-native/runtime/src/main/cpp/std_support/README.md b/kotlin-native/runtime/src/main/cpp/std_support/README.md index 47babf6d681..ce4005e24e0 100644 --- a/kotlin-native/runtime/src/main/cpp/std_support/README.md +++ b/kotlin-native/runtime/src/main/cpp/std_support/README.md @@ -12,16 +12,6 @@ Proposals: Adjustments: * `CStdlib.hpp` - - `std_support::malloc`, `std_support::calloc`, `std_support::realloc`, `std_support::free` that use custom allocation scheme, `std_support::aligned_malloc` and `std_support::aligned_free` as a version of `malloc` and `free` that allows changing alignment. * `Memory.hpp` - - `std_support::allocator` using `std_support::calloc`/`std_support::free`, - `std_support::default_delete` that uses `std_support::free`, - `std_support::unique_ptr` that uses `std_support::default_delete`, - `std_support::make_unique` and `std_support::make_shared` that use `std_support::allocator`, `std_support::nullptr_unique` - `nullptr` replacement for `unique_ptr` that takes an allocator. -* `New.hpp` - - custom operator `new` with `std_support::kalloc` marker argument that delegates to `std_support` allocator, - `std_support::kdelete` as a replacement for operator `delete` for objects created with custom `new`. -* `Deque.hpp`, `ForwardList.hpp`, `List.hpp`, `Map.hpp`, `Set.hpp`, `String.hpp`, `UnorderedMap.hpp`, `UnorderedSet.hpp`, `Vector.hpp` - - standard containers and `std_support::string` that default to using `std_support::allocator`. diff --git a/kotlin-native/runtime/src/main/cpp/std_support/Set.hpp b/kotlin-native/runtime/src/main/cpp/std_support/Set.hpp deleted file mode 100644 index c67732cc48f..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/Set.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#pragma once - -#include - -#include "std_support/Memory.hpp" - -namespace kotlin::std_support { - -template , typename Allocator = allocator> -using set = std::set; - -template , typename Allocator = allocator> -using multiset = std::multiset; - -} // namespace kotlin::std_support diff --git a/kotlin-native/runtime/src/main/cpp/std_support/String.hpp b/kotlin-native/runtime/src/main/cpp/std_support/String.hpp deleted file mode 100644 index 8404013932f..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/String.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#pragma once - -#include - -#include "std_support/Memory.hpp" - -namespace kotlin::std_support { - -template , typename Allocator = allocator> -using basic_string = std::basic_string; - -using string = basic_string; -using wstring = basic_string; -using u16string = basic_string; -using u32string = basic_string; - -} // namespace kotlin::std_support diff --git a/kotlin-native/runtime/src/main/cpp/std_support/UnorderedMap.hpp b/kotlin-native/runtime/src/main/cpp/std_support/UnorderedMap.hpp deleted file mode 100644 index 2e166dd6c16..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/UnorderedMap.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#pragma once - -#include - -#include "std_support/Memory.hpp" - -namespace kotlin::std_support { - -template < - typename Key, - typename T, - typename Hash = std::hash, - typename KeyEqual = std::equal_to, - typename Allocator = allocator>> -using unordered_map = std::unordered_map; - -template < - typename Key, - typename T, - typename Hash = std::hash, - typename KeyEqual = std::equal_to, - typename Allocator = allocator>> -using unordered_multimap = std::unordered_multimap; - -} // namespace kotlin::std_support diff --git a/kotlin-native/runtime/src/main/cpp/std_support/UnorderedSet.hpp b/kotlin-native/runtime/src/main/cpp/std_support/UnorderedSet.hpp deleted file mode 100644 index ce49fbfacb0..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/UnorderedSet.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#pragma once - -#include - -#include "std_support/Memory.hpp" - -namespace kotlin::std_support { - -template , typename KeyEqual = std::equal_to, typename Allocator = allocator> -using unordered_set = std::unordered_set; - -template , typename KeyEqual = std::equal_to, typename Allocator = allocator> -using unordered_multiset = std::unordered_multiset; - -} // namespace kotlin::std_support diff --git a/kotlin-native/runtime/src/main/cpp/std_support/Vector.hpp b/kotlin-native/runtime/src/main/cpp/std_support/Vector.hpp deleted file mode 100644 index c528fc45d40..00000000000 --- a/kotlin-native/runtime/src/main/cpp/std_support/Vector.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#pragma once - -#include - -#include "std_support/Memory.hpp" - -namespace kotlin::std_support { - -template > -using vector = std::vector; - -} // namespace kotlin::std_support diff --git a/kotlin-native/runtime/src/mm/cpp/AppStateTracking.hpp b/kotlin-native/runtime/src/mm/cpp/AppStateTracking.hpp index a5235dbb5e5..721892a5f07 100644 --- a/kotlin-native/runtime/src/mm/cpp/AppStateTracking.hpp +++ b/kotlin-native/runtime/src/mm/cpp/AppStateTracking.hpp @@ -6,9 +6,9 @@ #pragma once #include +#include #include "Utils.hpp" -#include "std_support/Memory.hpp" namespace kotlin::mm { @@ -33,7 +33,7 @@ private: // TODO: The initial value might be incorrect. std::atomic state_ = State::kForeground; - std_support::unique_ptr impl_; + std::unique_ptr impl_; }; } // namespace kotlin::mm diff --git a/kotlin-native/runtime/src/mm/cpp/AppStateTrackingUIKit.mm b/kotlin-native/runtime/src/mm/cpp/AppStateTrackingUIKit.mm index e2e1bf04da0..942b055a9e7 100644 --- a/kotlin-native/runtime/src/mm/cpp/AppStateTrackingUIKit.mm +++ b/kotlin-native/runtime/src/mm/cpp/AppStateTrackingUIKit.mm @@ -34,7 +34,7 @@ mm::AppStateTracking::AppStateTracking() noexcept { case compiler::AppStateTracking::kDisabled: break; case compiler::AppStateTracking::kEnabled: - impl_ = std_support::make_unique([this](State state) noexcept { setState(state); }); + impl_ = std::make_unique([this](State state) noexcept { setState(state); }); break; } } diff --git a/kotlin-native/runtime/src/mm/cpp/CallsChecker.cpp b/kotlin-native/runtime/src/mm/cpp/CallsChecker.cpp index 6c70ba0d176..9f76d359c2c 100644 --- a/kotlin-native/runtime/src/mm/cpp/CallsChecker.cpp +++ b/kotlin-native/runtime/src/mm/cpp/CallsChecker.cpp @@ -7,6 +7,7 @@ #include #include +#include #include "KAssert.h" #include "Memory.h" @@ -15,7 +16,6 @@ #include "ThreadData.hpp" #include "ThreadRegistry.hpp" #include "ExecFormat.h" -#include "std_support/UnorderedSet.hpp" using namespace kotlin; @@ -313,7 +313,7 @@ public: ~KnownFunctionChecker() = delete; private: - std_support::unordered_set known_functions_; + std::unordered_set known_functions_; std::string_view good_names_copy_[sizeof(Kotlin_callsCheckerGoodFunctionNames) / sizeof(Kotlin_callsCheckerGoodFunctionNames[0])]; }; diff --git a/kotlin-native/runtime/src/mm/cpp/ExceptionObjHolderTest.cpp b/kotlin-native/runtime/src/mm/cpp/ExceptionObjHolderTest.cpp index 056c7f89f5c..c914e1a4bb3 100644 --- a/kotlin-native/runtime/src/mm/cpp/ExceptionObjHolderTest.cpp +++ b/kotlin-native/runtime/src/mm/cpp/ExceptionObjHolderTest.cpp @@ -4,6 +4,7 @@ */ #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -12,7 +13,6 @@ #include "TestSupport.hpp" #include "ThreadData.hpp" #include "Types.h" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -20,9 +20,9 @@ namespace { class ExceptionObjHolderTest : public ::testing::Test { public: - static std_support::vector Collect(mm::ThreadData& threadData) { + static std::vector Collect(mm::ThreadData& threadData) { threadData.specialRefRegistry().publish(); - std_support::vector result; + std::vector result; for (const auto& obj : mm::SpecialRefRegistry::instance().roots()) { result.push_back(obj); } diff --git a/kotlin-native/runtime/src/mm/cpp/Freezing.cpp b/kotlin-native/runtime/src/mm/cpp/Freezing.cpp index a815426e63c..1fdd34a4a17 100644 --- a/kotlin-native/runtime/src/mm/cpp/Freezing.cpp +++ b/kotlin-native/runtime/src/mm/cpp/Freezing.cpp @@ -5,14 +5,15 @@ #include "Freezing.hpp" +#include +#include + #include "ExtraObjectData.hpp" #include "FreezeHooks.hpp" #include "Memory.h" #include "Natives.h" #include "ObjectTraversal.hpp" #include "Types.h" -#include "std_support/UnorderedSet.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -31,10 +32,10 @@ bool mm::IsFrozen(const ObjHeader* object) noexcept { ObjHeader* mm::FreezeSubgraph(ObjHeader* root) noexcept { if (IsFrozen(root)) return nullptr; - std_support::vector objects; - std_support::vector stack; + std::vector objects; + std::vector stack; // TODO: This may be a suboptimal container for the job. - std_support::unordered_set visited; + std::unordered_set visited; stack.push_back(root); while (!stack.empty()) { ObjHeader* object = stack.back(); diff --git a/kotlin-native/runtime/src/mm/cpp/GlobalsRegistry.hpp b/kotlin-native/runtime/src/mm/cpp/GlobalsRegistry.hpp index a38c73ed387..d951e7653cf 100644 --- a/kotlin-native/runtime/src/mm/cpp/GlobalsRegistry.hpp +++ b/kotlin-native/runtime/src/mm/cpp/GlobalsRegistry.hpp @@ -40,7 +40,7 @@ public: void ProcessThread(mm::ThreadData* threadData) noexcept; // Lock registry for safe iteration. - // TODO: Iteration over `globals_` will be slow, because it's `std_support::list` collected at different times from + // TODO: Iteration over `globals_` will be slow, because it's `std::list` collected at different times from // different threads, and so the nodes are all over the memory. Use metrics to understand how // much of a problem is it. Iterable LockForIter() noexcept { return globals_.LockForIter(); } diff --git a/kotlin-native/runtime/src/mm/cpp/RootSetTest.cpp b/kotlin-native/runtime/src/mm/cpp/RootSetTest.cpp index 84c7a472d5f..aab4dca2347 100644 --- a/kotlin-native/runtime/src/mm/cpp/RootSetTest.cpp +++ b/kotlin-native/runtime/src/mm/cpp/RootSetTest.cpp @@ -5,13 +5,14 @@ #include "RootSet.hpp" +#include +#include + #include "gmock/gmock.h" #include "gtest/gtest.h" #include "ShadowStack.hpp" #include "StableRef.hpp" -#include "std_support/Memory.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -24,7 +25,7 @@ class StackEntry : private Pinned { public: static_assert(LocalsCount > 0, "Must have at least 1 object on stack"); - explicit StackEntry(mm::ShadowStack& shadowStack) : shadowStack_(shadowStack), value_(std_support::make_unique()) { + explicit StackEntry(mm::ShadowStack& shadowStack) : shadowStack_(shadowStack), value_(std::make_unique()) { // Fill `locals_` with some values. for (size_t i = 0; i < LocalsCount; ++i) { (*this)[i] = value_.get() + i; @@ -39,7 +40,7 @@ public: private: mm::ShadowStack& shadowStack_; - std_support::unique_ptr value_; + std::unique_ptr value_; // The following is what the compiler creates on the stack. static inline constexpr int kFrameOverlayCount = sizeof(FrameOverlay) / sizeof(ObjHeader**); @@ -62,7 +63,7 @@ TEST(ThreadRootSetTest, Basic) { mm::ThreadRootSet iter(stack, tls); - std_support::vector actual; + std::vector actual; for (auto object : iter) { actual.push_back(object); } @@ -82,7 +83,7 @@ TEST(ThreadRootSetTest, Empty) { mm::ThreadRootSet iter(stack, tls); - std_support::vector actual; + std::vector actual; for (auto object : iter) { actual.push_back(object); } @@ -112,7 +113,7 @@ TEST(GlobalRootSetTest, Basic) { mm::GlobalRootSet iter(globals, specialRefsRegistry); - std_support::vector actual; + std::vector actual; for (auto object : iter) { actual.push_back(object); } @@ -135,7 +136,7 @@ TEST(GlobalRootSetTest, Empty) { mm::GlobalRootSet iter(globals, specialRefsRegistry); - std_support::vector actual; + std::vector actual; for (auto object : iter) { actual.push_back(object); } diff --git a/kotlin-native/runtime/src/mm/cpp/SafePointTest.cpp b/kotlin-native/runtime/src/mm/cpp/SafePointTest.cpp index 205138c6136..57d563f9d05 100644 --- a/kotlin-native/runtime/src/mm/cpp/SafePointTest.cpp +++ b/kotlin-native/runtime/src/mm/cpp/SafePointTest.cpp @@ -6,13 +6,14 @@ #include "SafePoint.hpp" #include +#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" #include "ScopedThread.hpp" #include "TestSupport.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -60,7 +61,7 @@ TEST(SafePointTest, StressSafePointActivator) { std::atomic started = 0; std::atomic canStop = false; std::atomic stopped = 0; - std_support::vector threads; + std::vector threads; for (int i = 0; i < kDefaultThreadCount; ++i) { threads.emplace_back([&]() noexcept { initialized.fetch_add(1, std::memory_order_relaxed); diff --git a/kotlin-native/runtime/src/mm/cpp/ShadowStackTest.cpp b/kotlin-native/runtime/src/mm/cpp/ShadowStackTest.cpp index 53bbeee0e41..e1a6e8f927d 100644 --- a/kotlin-native/runtime/src/mm/cpp/ShadowStackTest.cpp +++ b/kotlin-native/runtime/src/mm/cpp/ShadowStackTest.cpp @@ -5,14 +5,15 @@ #include "ShadowStack.hpp" +#include +#include + #include "gmock/gmock.h" #include "gtest/gtest.h" #include "Memory.h" #include "Types.h" #include "Utils.hpp" -#include "std_support/Memory.hpp" -#include "std_support/Vector.hpp" using namespace kotlin; @@ -23,7 +24,7 @@ class StackEntry : private Pinned { public: static_assert(ParametersCount + LocalsCount > 0, "Must have at least 1 object on stack"); - explicit StackEntry(mm::ShadowStack& shadowStack) : shadowStack_(shadowStack), value_(std_support::make_unique()) { + explicit StackEntry(mm::ShadowStack& shadowStack) : shadowStack_(shadowStack), value_(std::make_unique()) { // Fill `locals_` with some values. for (size_t i = 0; i < LocalsCount; ++i) { (*this)[i] = value_.get() + i; @@ -38,7 +39,7 @@ public: private: mm::ShadowStack& shadowStack_; - std_support::unique_ptr value_; + std::unique_ptr value_; // The following is what the compiler creates on the stack. static inline constexpr int kFrameOverlayCount = sizeof(FrameOverlay) / sizeof(ObjHeader**); @@ -46,8 +47,8 @@ private: std::array data_; }; -std_support::vector Collect(mm::ShadowStack& shadowStack) { - std_support::vector result; +std::vector Collect(mm::ShadowStack& shadowStack) { + std::vector result; for (ObjHeader* local : shadowStack) { result.push_back(local); } diff --git a/kotlin-native/runtime/src/mm/cpp/SpecialRefRegistry.cpp b/kotlin-native/runtime/src/mm/cpp/SpecialRefRegistry.cpp index bf7e94a6c92..3aabc7f2506 100644 --- a/kotlin-native/runtime/src/mm/cpp/SpecialRefRegistry.cpp +++ b/kotlin-native/runtime/src/mm/cpp/SpecialRefRegistry.cpp @@ -132,8 +132,8 @@ void mm::SpecialRefRegistry::insertIntoRootsHead(Node& node) noexcept { } while (!rootsHead()->nextRoot_.compare_exchange_weak(next, &node, std::memory_order_release, std::memory_order_acquire)); } -std_support::list::iterator mm::SpecialRefRegistry::findAliveNode( - std_support::list::iterator it) noexcept { +std::list::iterator mm::SpecialRefRegistry::findAliveNode( + std::list::iterator it) noexcept { while (it != all_.end() && it->rc_.load(std::memory_order_relaxed) == Node::disposedMarker) { // Synchronization with `Node::dispose()` std::atomic_thread_fence(std::memory_order_acquire); diff --git a/kotlin-native/runtime/src/mm/cpp/SpecialRefRegistry.hpp b/kotlin-native/runtime/src/mm/cpp/SpecialRefRegistry.hpp index cd53b34f110..d42712a54f4 100644 --- a/kotlin-native/runtime/src/mm/cpp/SpecialRefRegistry.hpp +++ b/kotlin-native/runtime/src/mm/cpp/SpecialRefRegistry.hpp @@ -6,12 +6,12 @@ #pragma once #include +#include #include "GC.hpp" #include "Memory.h" #include "RawPtr.hpp" #include "ThreadRegistry.hpp" -#include "std_support/List.hpp" namespace kotlin::mm { @@ -110,7 +110,7 @@ class SpecialRefRegistry : private Pinned { RuntimeAssert(rc >= 0, "Retaining StableRef@%p with rc %d", this, rc); if (rc == 0) { RuntimeAssert( - position_ == std_support::list::iterator{}, + position_ == std::list::iterator{}, "Retaining StableRef@%p with fast deletion optimization is disallowed", this); if (!obj_.load(std::memory_order_relaxed)) { @@ -175,7 +175,7 @@ class SpecialRefRegistry : private Pinned { // be only deleted in the sweep anyway. // Alternative: keep stable refs completely separate. void* owner_ = nullptr; - std_support::list::iterator position_{}; + std::list::iterator position_{}; }; public: @@ -192,7 +192,7 @@ public: // the whole queue here and just have the nodes inserted into the roots // when they're created. node.owner_ = nullptr; - node.position_ = std_support::list::iterator(); + node.position_ = std::list::iterator(); RuntimeAssert(node.obj_ != nullptr, "Publishing Node with null obj_"); // If the node was created with a positive refcount, we must ensure its put into // the roots. @@ -243,7 +243,7 @@ public: void deleteNodeIfLocal(Node& node) noexcept; SpecialRefRegistry& owner_; - std_support::list queue_; + std::list queue_; }; class RootsIterator { @@ -303,10 +303,10 @@ public: friend class SpecialRefRegistry; friend class SpecialRefRegistryTest; - Iterator(SpecialRefRegistry& owner, std_support::list::iterator iterator) noexcept : owner_(&owner), iterator_(iterator) {} + Iterator(SpecialRefRegistry& owner, std::list::iterator iterator) noexcept : owner_(&owner), iterator_(iterator) {} SpecialRefRegistry* owner_; - std_support::list::iterator iterator_; + std::list::iterator iterator_; }; class Iterable : private MoveOnly { @@ -356,16 +356,16 @@ private: // previous to `node`. Returns two nodes between which `node` was deleted. std::pair eraseFromRoots(Node* prev, Node* node) noexcept; void insertIntoRootsHead(Node& node) noexcept; - std_support::list::iterator findAliveNode(std_support::list::iterator it) noexcept; + std::list::iterator findAliveNode(std::list::iterator it) noexcept; Node* rootsHead() noexcept { return reinterpret_cast(rootsHeadStorage_); } const Node* rootsHead() const noexcept { return reinterpret_cast(rootsHeadStorage_); } static Node* rootsTail() noexcept { return reinterpret_cast(rootsTailStorage_); } - // TODO: Iteration over `all_` will be slow, because it's `std_support::list` + // TODO: Iteration over `all_` will be slow, because it's `std::list` // collected at different times from different threads, and so the nodes // are all over the memory. Consider using custom allocator for that. - std_support::list all_; + std::list all_; Mutex mutex_; alignas(Node) char rootsHeadStorage_[sizeof(Node)] = {0}; alignas(Node) static inline char rootsTailStorage_[sizeof(Node)] = {0}; diff --git a/kotlin-native/runtime/src/mm/cpp/ThreadData.hpp b/kotlin-native/runtime/src/mm/cpp/ThreadData.hpp index 503423a1bb0..3dee3800321 100644 --- a/kotlin-native/runtime/src/mm/cpp/ThreadData.hpp +++ b/kotlin-native/runtime/src/mm/cpp/ThreadData.hpp @@ -7,6 +7,7 @@ #define RUNTIME_MM_THREAD_DATA_H #include +#include #include "GlobalData.hpp" #include "GlobalsRegistry.hpp" @@ -16,7 +17,6 @@ #include "ThreadLocalStorage.hpp" #include "Utils.hpp" #include "ThreadSuspension.hpp" -#include "std_support/Vector.hpp" struct ObjHeader; @@ -52,7 +52,7 @@ public: ShadowStack& shadowStack() noexcept { return shadowStack_; } - std_support::vector>& initializingSingletons() noexcept { return initializingSingletons_; } + std::vector>& initializingSingletons() noexcept { return initializingSingletons_; } gcScheduler::GCScheduler::ThreadData& gcScheduler() noexcept { return gcScheduler_; } @@ -83,7 +83,7 @@ private: gcScheduler::GCScheduler::ThreadData gcScheduler_; alloc::Allocator::ThreadData allocator_; gc::GC::ThreadData gc_; - std_support::vector> initializingSingletons_; + std::vector> initializingSingletons_; ThreadSuspensionData suspensionData_; }; diff --git a/kotlin-native/runtime/src/mm/cpp/ThreadLocalStorage.hpp b/kotlin-native/runtime/src/mm/cpp/ThreadLocalStorage.hpp index f5820abb7a5..7e941e97bf6 100644 --- a/kotlin-native/runtime/src/mm/cpp/ThreadLocalStorage.hpp +++ b/kotlin-native/runtime/src/mm/cpp/ThreadLocalStorage.hpp @@ -13,8 +13,6 @@ #include "Memory.h" #include "Types.h" #include "Utils.hpp" -#include "std_support/UnorderedMap.hpp" -#include "std_support/Vector.hpp" namespace kotlin { namespace mm { @@ -25,7 +23,7 @@ public: class Iterator { public: - explicit Iterator(std_support::vector::iterator iterator) : iterator_(iterator) {} + explicit Iterator(std::vector::iterator iterator) : iterator_(iterator) {} ObjHeader** operator*() noexcept { return &*iterator_; } @@ -38,7 +36,7 @@ public: bool operator!=(const Iterator& rhs) const noexcept { return iterator_ != rhs.iterator_; } private: - std_support::vector::iterator iterator_; + std::vector::iterator iterator_; }; // Add TLS record. Can only be called before `Commit`. @@ -67,9 +65,9 @@ private: ObjHeader** Lookup(Entry entry, int index) noexcept; - std_support::vector storage_; - // TODO: `std_support::unordered_map` is probably the wrong container here. - std_support::unordered_map map_; + std::vector storage_; + // TODO: `std::unordered_map` is probably the wrong container here. + std::unordered_map map_; State state_ = State::kBuilding; int size_ = 0; // Only used in `State::kBuilding` std::pair lastKeyAndEntry_; diff --git a/kotlin-native/runtime/src/mm/cpp/ThreadLocalStorageTest.cpp b/kotlin-native/runtime/src/mm/cpp/ThreadLocalStorageTest.cpp index cdd81e553c7..c07052b1ed7 100644 --- a/kotlin-native/runtime/src/mm/cpp/ThreadLocalStorageTest.cpp +++ b/kotlin-native/runtime/src/mm/cpp/ThreadLocalStorageTest.cpp @@ -56,12 +56,12 @@ TEST(ThreadLocalStorageTest, Iterate) { tls.AddRecord(&key2, 2); tls.Commit(); - std_support::vector expected; + std::vector expected; expected.push_back(tls.Lookup(&key1, 0)); expected.push_back(tls.Lookup(&key2, 0)); expected.push_back(tls.Lookup(&key2, 1)); - std_support::vector actual; + std::vector actual; for (auto item : tls) { actual.push_back(item); } @@ -80,12 +80,12 @@ TEST(ThreadLocalStorageTest, AddRecordEmpty) { tls.AddRecord(&key3, 2); tls.Commit(); - std_support::vector expected; + std::vector expected; expected.push_back(tls.Lookup(&key1, 0)); expected.push_back(tls.Lookup(&key3, 0)); expected.push_back(tls.Lookup(&key3, 1)); - std_support::vector actual; + std::vector actual; for (auto item : tls) { actual.push_back(item); } @@ -101,10 +101,10 @@ TEST(ThreadLocalStorageTest, AddRecordSameSize) { tls.AddRecord(&key1, 1); tls.Commit(); - std_support::vector expected; + std::vector expected; expected.push_back(tls.Lookup(&key1, 0)); - std_support::vector actual; + std::vector actual; for (auto item : tls) { actual.push_back(item); } @@ -117,7 +117,7 @@ TEST(ThreadLocalStorageTest, NoRecords) { tls.Commit(); - std_support::vector actual; + std::vector actual; for (auto item : tls) { actual.push_back(item); } @@ -132,7 +132,7 @@ TEST(ThreadLocalStorageTest, ClearEmpty) { tls.Clear(); - std_support::vector actual; + std::vector actual; for (auto item : tls) { actual.push_back(item); } @@ -149,7 +149,7 @@ TEST(ThreadLocalStorageTest, ClearNonEmpty) { tls.Clear(); - std_support::vector actual; + std::vector actual; for (auto item : tls) { actual.push_back(item); } diff --git a/kotlin-native/runtime/src/mm/cpp/ThreadSuspensionTest.cpp b/kotlin-native/runtime/src/mm/cpp/ThreadSuspensionTest.cpp index b1f1c57c39f..3bdd90ae458 100644 --- a/kotlin-native/runtime/src/mm/cpp/ThreadSuspensionTest.cpp +++ b/kotlin-native/runtime/src/mm/cpp/ThreadSuspensionTest.cpp @@ -3,23 +3,23 @@ * that can be found in the LICENSE file. */ +#include "ThreadSuspension.hpp" + +#include +#include +#include + +#include "gtest/gtest.h" +#include "gmock/gmock.h" + #include "MemoryPrivate.hpp" #include "Runtime.h" #include "RuntimePrivate.hpp" #include "SafePoint.hpp" #include "ScopedThread.hpp" -#include "ThreadSuspension.hpp" +#include "TestSupport.hpp" +#include "TestSupportCompilerGenerated.hpp" #include "ThreadState.hpp" -#include "std_support/Vector.hpp" - -#include -#include - -#include -#include -#include - -#include using namespace kotlin; @@ -33,8 +33,8 @@ constexpr size_t kDefaultIterations = 200; constexpr size_t kDefaultReportingStep = 20; #endif // #ifdef KONAN_WINDOWS -std_support::vector collectThreadData() { - std_support::vector result; +std::vector collectThreadData() { + std::vector result; auto iter = mm::ThreadRegistry::Instance().LockForIter(); for (auto& thread : iter) { result.push_back(&thread); @@ -43,14 +43,14 @@ std_support::vector collectThreadData() { } template -std_support::vector collectFromThreadData(F extractFunction) { - std_support::vector result; +std::vector collectFromThreadData(F extractFunction) { + std::vector result; auto threadData = collectThreadData(); std::transform(threadData.begin(), threadData.end(), std::back_inserter(result), extractFunction); return result; } -std_support::vector collectSuspended() { +std::vector collectSuspended() { return collectFromThreadData( [](mm::ThreadData* threadData) { return threadData->suspensionData().suspendedOrNative(); }); } @@ -84,7 +84,7 @@ public: static constexpr size_t kThreadCount = kDefaultThreadCount; static constexpr size_t kIterations = kDefaultIterations; - std_support::vector threads; + std::vector threads; std::array, kThreadCount> ready{false}; std::atomic canStart{false}; std::atomic shouldStop{false};