diff --git a/compiler/optimizer/code_generator/codegen.cpp b/compiler/optimizer/code_generator/codegen.cpp index 163e08967769de14853bf18765e7fe44901fbbcb..25757a92df66d1456aa4408ca149430bc1df8bab 100644 --- a/compiler/optimizer/code_generator/codegen.cpp +++ b/compiler/optimizer/code_generator/codegen.cpp @@ -3449,7 +3449,7 @@ void EncodeVisitor::VisitLoadString(GraphVisitor *visitor, Inst *inst) // Static constructor invoked only once, so there is no sense in replacing regular // ResolveString runtime call with optimized version that will only slow down constructor's execution. auto is_cctor = graph->GetRuntime()->IsMethodStaticConstructor(method); - object_pointer_type string_ptr {0}; + ObjectPointerType string_ptr {0}; if (graph->IsAotMode() && OPTIONS.IsCompilerAotLoadStringPlt() && !is_cctor) { auto aot_data = graph->GetAotData(); diff --git a/compiler/optimizer/ir/runtime_interface.h b/compiler/optimizer/ir/runtime_interface.h index f526f32ac102d4131efdd880b34ac7e136f13992..57b31510b638b68b679a0e0bb4aac72fb8db56ff 100644 --- a/compiler/optimizer/ir/runtime_interface.h +++ b/compiler/optimizer/ir/runtime_interface.h @@ -515,8 +515,7 @@ public: return 1; } - virtual object_pointer_type GetNonMovableString([[maybe_unused]] MethodPtr method, - [[maybe_unused]] StringId id) const + virtual ObjectPointerType GetNonMovableString([[maybe_unused]] MethodPtr method, [[maybe_unused]] StringId id) const { return 0; } diff --git a/compiler/tests/codegen_test.cpp b/compiler/tests/codegen_test.cpp index 0cb45bdb8f7db4070061d58d45327bc60bc2fa3c..cfa9f42a3870e8a4c41d6f1721df855fafc55071 100644 --- a/compiler/tests/codegen_test.cpp +++ b/compiler/tests/codegen_test.cpp @@ -789,10 +789,10 @@ TEST_F(CodegenTest, StoreArray) GetExecModule().SetDump(false); - object_pointer_type array[4] = {0, 0, 0, 0}; + ObjectPointerType array[4] = {0, 0, 0, 0}; auto param_1 = GetExecModule().CreateArray(array, 4, GetObjectAllocator()); auto param_2 = CutValue(2, DataType::INT32); - auto param_3 = CutValue(10, DataType::UINT64); + auto param_3 = CutValue(10, DataType::UINT64); GetExecModule().SetParameter(0U, reinterpret_cast(param_1)); GetExecModule().SetParameter(1U, param_2); GetExecModule().SetParameter(2U, param_3); @@ -1513,7 +1513,7 @@ TEST_F(CodegenTest, LoadArray) GetExecModule().SetDump(false); - object_pointer_type array[4] = {0xffffaaaa, 0xffffbbbb, 0xffffcccc, 0xffffdddd}; + ObjectPointerType array[4] = {0xffffaaaa, 0xffffbbbb, 0xffffcccc, 0xffffdddd}; auto param_1 = GetExecModule().CreateArray(array, 4, GetObjectAllocator()); auto param_2 = CutValue(2, DataType::INT32); GetExecModule().SetParameter(0U, reinterpret_cast(param_1)); diff --git a/libpandabase/mem/arena-inl.h b/libpandabase/mem/arena-inl.h index 6465ad52eb9a9b3984856ee005dd879e772d3703..00bc2263d63b2186e5915589b2c68669956ab61c 100644 --- a/libpandabase/mem/arena-inl.h +++ b/libpandabase/mem/arena-inl.h @@ -28,8 +28,8 @@ inline Arena::Arena(size_t buff_size, void *buff) : Arena(buff_size, buff, ARENA inline Arena::Arena(size_t buff_size, void *buff, Alignment start_alignment) : buff_(buff), - startPos_(ToVoidPtr(AlignUp(ToUintPtr(buff), GetAlignmentInBytes(start_alignment)))), - curPos_(startPos_), + start_pos_(ToVoidPtr(AlignUp(ToUintPtr(buff), GetAlignmentInBytes(start_alignment)))), + cur_pos_(start_pos_), size_(buff_size) { ASSERT(ToUintPtr(buff) == AlignUp(ToUintPtr(buff), GetAlignmentInBytes(ARENA_DEFAULT_ALIGNMENT))); @@ -47,10 +47,10 @@ inline void *Arena::Alloc(size_t size, Alignment alignment) { void *ret = nullptr; size_t free_size = GetFreeSize(); - ret = std::align(GetAlignmentInBytes(alignment), size, curPos_, free_size); + ret = std::align(GetAlignmentInBytes(alignment), size, cur_pos_, free_size); if (ret != nullptr) { ASAN_UNPOISON_MEMORY_REGION(ret, size); - curPos_ = ToVoidPtr(ToUintPtr(ret) + size); + cur_pos_ = ToVoidPtr(ToUintPtr(ret) + size); } LOG(DEBUG, ALLOC) << "Arena::Alloc size = " << size << " alignment = " << alignment << " at addr = " << ret; return ret; @@ -58,13 +58,13 @@ inline void *Arena::Alloc(size_t size, Alignment alignment) inline void *Arena::AlignedAlloc(size_t size, [[maybe_unused]] Alignment alignment) { - ASSERT(AlignUp(ToUintPtr(curPos_), GetAlignmentInBytes(alignment)) == ToUintPtr(curPos_)); + ASSERT(AlignUp(ToUintPtr(cur_pos_), GetAlignmentInBytes(alignment)) == ToUintPtr(cur_pos_)); ASSERT(AlignUp(size, GetAlignmentInBytes(alignment)) == size); void *ret = nullptr; - uintptr_t new_cur_pos = ToUintPtr(curPos_) + size; + uintptr_t new_cur_pos = ToUintPtr(cur_pos_) + size; if (new_cur_pos <= (ToUintPtr(buff_) + size_)) { - ret = curPos_; - curPos_ = ToVoidPtr(new_cur_pos); + ret = cur_pos_; + cur_pos_ = ToVoidPtr(new_cur_pos); ASAN_UNPOISON_MEMORY_REGION(ret, size); } return ret; @@ -89,14 +89,14 @@ inline Arena *Arena::GetNextArena() const inline size_t Arena::GetFreeSize() const { - ASSERT(ToUintPtr(curPos_) >= ToUintPtr(GetStartPos())); - return size_ - (ToUintPtr(curPos_) - ToUintPtr(GetStartPos())); + ASSERT(ToUintPtr(cur_pos_) >= ToUintPtr(GetStartPos())); + return size_ - (ToUintPtr(cur_pos_) - ToUintPtr(GetStartPos())); } inline size_t Arena::GetOccupiedSize() const { - ASSERT(ToUintPtr(curPos_) >= ToUintPtr(GetStartPos())); - return ToUintPtr(curPos_) - ToUintPtr(GetStartPos()); + ASSERT(ToUintPtr(cur_pos_) >= ToUintPtr(GetStartPos())); + return ToUintPtr(cur_pos_) - ToUintPtr(GetStartPos()); } inline void *Arena::GetArenaEnd() const @@ -116,22 +116,22 @@ inline void *Arena::GetAllocatedStart() const inline bool Arena::InArena(const void *mem) const { - return (ToUintPtr(curPos_) > ToUintPtr(mem)) && (ToUintPtr(GetStartPos()) <= ToUintPtr(mem)); + return (ToUintPtr(cur_pos_) > ToUintPtr(mem)) && (ToUintPtr(GetStartPos()) <= ToUintPtr(mem)); } inline void Arena::Free(void *mem) { ASSERT(InArena(mem)); - ASAN_POISON_MEMORY_REGION(mem, ToUintPtr(curPos_) - ToUintPtr(mem)); - curPos_ = mem; + ASAN_POISON_MEMORY_REGION(mem, ToUintPtr(cur_pos_) - ToUintPtr(mem)); + cur_pos_ = mem; } inline void Arena::Resize(size_t new_size) { size_t old_size = GetOccupiedSize(); ASSERT(new_size <= old_size); - curPos_ = ToVoidPtr(ToUintPtr(GetStartPos()) + new_size); - ASAN_POISON_MEMORY_REGION(curPos_, old_size - new_size); + cur_pos_ = ToVoidPtr(ToUintPtr(GetStartPos()) + new_size); + ASAN_POISON_MEMORY_REGION(cur_pos_, old_size - new_size); } inline void Arena::Reset() diff --git a/libpandabase/mem/arena.h b/libpandabase/mem/arena.h index 18a66ecce148db788e861538cb06e5c3894d0e45..c6cd1cff963b7c5bb4c0a89a2698e4ca5463e3b1 100644 --- a/libpandabase/mem/arena.h +++ b/libpandabase/mem/arena.h @@ -92,7 +92,7 @@ public: void *GetTop() const { - return curPos_; + return cur_pos_; } size_t GetSize() const @@ -140,27 +140,27 @@ protected: void *GetStartPos() const { - return startPos_; + return start_pos_; } private: Arena *next_ = nullptr; void *buff_ = nullptr; - void *startPos_ = nullptr; - void *curPos_ = nullptr; + void *start_pos_ = nullptr; + void *cur_pos_ = nullptr; size_t size_ = 0; }; -template +template class AlignedArena : public Arena { public: - AlignedArena(size_t buff_size, void *buff) : Arena(buff_size, buff, AlignmentT) {} + AlignedArena(size_t buff_size, void *buff) : Arena(buff_size, buff, ALIGNMENT_T) {} ~AlignedArena() override = default; void *Alloc(size_t size) { - return Arena::AlignedAlloc(size, AlignmentT); + return Arena::AlignedAlloc(size, ALIGNMENT_T); } private: @@ -168,10 +168,10 @@ private: DEFAULT_COPY_SEMANTIC(AlignedArena); }; -template -class DoubleLinkedAlignedArena : public AlignedArena { +template +class DoubleLinkedAlignedArena : public AlignedArena { public: - DoubleLinkedAlignedArena(size_t buff_size, void *buff) : AlignedArena(buff_size, buff) {} + DoubleLinkedAlignedArena(size_t buff_size, void *buff) : AlignedArena(buff_size, buff) {} /** * \brief Links this Arena to the next \param arena diff --git a/libpandabase/mem/arena_allocator.cpp b/libpandabase/mem/arena_allocator.cpp index b7090327b56712961c5886fd0317f048e2a6deb7..6d8063c4e18a2c09d73ff8bb3c5801645b31c16f 100644 --- a/libpandabase/mem/arena_allocator.cpp +++ b/libpandabase/mem/arena_allocator.cpp @@ -24,12 +24,12 @@ namespace panda { -template -ArenaAllocatorT::ArenaAllocatorT(SpaceType space_type, BaseMemStats *mem_stats, +template +ArenaAllocatorT::ArenaAllocatorT(SpaceType space_type, BaseMemStats *mem_stats, bool limit_alloc_size_by_pool) - : memStats_(mem_stats), space_type_(space_type), limit_alloc_size_by_pool_(limit_alloc_size_by_pool) + : mem_stats_(mem_stats), space_type_(space_type), limit_alloc_size_by_pool_(limit_alloc_size_by_pool) { - ASSERT(!use_oom_handler); + ASSERT(!USE_OOM_HANDLER); if (!ON_STACK_ALLOCATION_ENABLED) { arenas_ = PoolManager::AllocArena(DEFAULT_ARENA_SIZE, space_type_, AllocatorType::ARENA_ALLOCATOR, this); ASSERT(arenas_ != nullptr); @@ -37,15 +37,15 @@ ArenaAllocatorT::ArenaAllocatorT(SpaceType space_type, BaseMemS } } -template -ArenaAllocatorT::ArenaAllocatorT(OOMHandler oom_handler, SpaceType space_type, BaseMemStats *mem_stats, +template +ArenaAllocatorT::ArenaAllocatorT(OOMHandler oom_handler, SpaceType space_type, BaseMemStats *mem_stats, bool limit_alloc_size_by_pool) - : memStats_(mem_stats), + : mem_stats_(mem_stats), space_type_(space_type), oom_handler_(oom_handler), limit_alloc_size_by_pool_(limit_alloc_size_by_pool) { - ASSERT(use_oom_handler); + ASSERT(USE_OOM_HANDLER); if (!ON_STACK_ALLOCATION_ENABLED) { arenas_ = PoolManager::AllocArena(DEFAULT_ARENA_SIZE, space_type_, AllocatorType::ARENA_ALLOCATOR, this); ASSERT(arenas_ != nullptr); @@ -53,8 +53,8 @@ ArenaAllocatorT::ArenaAllocatorT(OOMHandler oom_handler, SpaceT } } -template -ArenaAllocatorT::~ArenaAllocatorT() +template +ArenaAllocatorT::~ArenaAllocatorT() { Arena *cur = arenas_; while (cur != nullptr) { @@ -65,8 +65,8 @@ ArenaAllocatorT::~ArenaAllocatorT() } } -template -inline void *ArenaAllocatorT::AllocateAndAddNewPool(size_t size, Alignment alignment) +template +inline void *ArenaAllocatorT::AllocateAndAddNewPool(size_t size, Alignment alignment) { void *mem = arenas_->Alloc(size, alignment); if (mem == nullptr) { @@ -86,8 +86,8 @@ inline void *ArenaAllocatorT::AllocateAndAddNewPool(size_t size return mem; } -template -void *ArenaAllocatorT::Alloc(size_t size, Alignment align) +template +void *ArenaAllocatorT::Alloc(size_t size, Alignment align) { trace::ScopedTrace scoped_trace("ArenaAllocator allocate"); LOG(DEBUG, ALLOC) << "ArenaAllocator: try to alloc " << size << " with align " << align; @@ -103,7 +103,7 @@ void *ArenaAllocatorT::Alloc(size_t size, Alignment align) ret = AllocateAndAddNewPool(size, align); } // NOLINTNEXTLINE(readability-braces-around-statements, bugprone-suspicious-semicolon) - if constexpr (use_oom_handler) { + if constexpr (USE_OOM_HANDLER) { if (ret == nullptr) { oom_handler_(); } @@ -113,8 +113,8 @@ void *ArenaAllocatorT::Alloc(size_t size, Alignment align) return ret; } -template -void ArenaAllocatorT::Resize(size_t new_size) +template +void ArenaAllocatorT::Resize(size_t new_size) { LOG(DEBUG, ALLOC) << "ArenaAllocator: resize to new size " << new_size; // TODO(aemelenko): we have O(2n) here in the worst case @@ -149,8 +149,8 @@ void ArenaAllocatorT::Resize(size_t new_size) ASSERT(bytes_to_delete == 0); } -template -bool ArenaAllocatorT::AddArenaFromPool(size_t pool_size) +template +bool ArenaAllocatorT::AddArenaFromPool(size_t pool_size) { ASSERT(pool_size != 0); pool_size = AlignUp(pool_size, PANDA_POOL_ALIGNMENT_IN_BYTES); @@ -163,8 +163,8 @@ bool ArenaAllocatorT::AddArenaFromPool(size_t pool_size) return true; } -template -size_t ArenaAllocatorT::GetAllocatedSize() const +template +size_t ArenaAllocatorT::GetAllocatedSize() const { size_t size = 0; if (ON_STACK_ALLOCATION_ENABLED) { diff --git a/libpandabase/mem/arena_allocator.h b/libpandabase/mem/arena_allocator.h index 7175dc7f54089ef8a2396b8f9e8e1b25046b273d..fc6255570839081b802d4ea0672dfa00111e774f 100644 --- a/libpandabase/mem/arena_allocator.h +++ b/libpandabase/mem/arena_allocator.h @@ -49,15 +49,15 @@ constexpr bool ON_STACK_ALLOCATION_ENABLED = false; constexpr size_t DEFAULT_ON_STACK_ARENA_ALLOCATOR_BUFF_SIZE = 128 * SIZE_1K; -template +template class ArenaAllocatorAdapter; -template +template class ArenaAllocatorT { public: using OOMHandler = std::add_pointer_t; template - using AdapterType = ArenaAllocatorAdapter; + using AdapterType = ArenaAllocatorAdapter; explicit ArenaAllocatorT(SpaceType space_type, BaseMemStats *mem_stats = nullptr, bool limit_alloc_size_by_pool = false); @@ -88,17 +88,17 @@ public: { static constexpr size_t SIZE_BEFORE_DATA_OFFSET = AlignUp(sizeof(size_t), GetAlignmentInBytes(DEFAULT_ARENA_ALIGNMENT)); - using element_type = std::remove_extent_t; - void *p = Alloc(SIZE_BEFORE_DATA_OFFSET + sizeof(element_type) * size); + using ElementType = std::remove_extent_t; + void *p = Alloc(SIZE_BEFORE_DATA_OFFSET + sizeof(ElementType) * size); if (UNLIKELY(p == nullptr)) { return nullptr; } *static_cast(p) = size; - auto *data = ToNativePtr(ToUintPtr(p) + SIZE_BEFORE_DATA_OFFSET); - element_type *current_element = data; + auto *data = ToNativePtr(ToUintPtr(p) + SIZE_BEFORE_DATA_OFFSET); + ElementType *current_element = data; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) for (size_t i = 0; i < size; ++i, ++current_element) { - new (current_element) element_type(); + new (current_element) ElementType(); } return data; } @@ -106,7 +106,7 @@ public: template [[nodiscard]] T *AllocArray(size_t arr_length); - ArenaAllocatorAdapter Adapter(); + ArenaAllocatorAdapter Adapter(); size_t GetAllocatedSize() const; @@ -125,39 +125,39 @@ protected: Arena *arenas_ = nullptr; // NOLINT(misc-non-private-member-variables-in-classes) private: - template + template class OnStackBuffT { public: void *Alloc(size_t size, Alignment align = DEFAULT_ARENA_ALIGNMENT) { size_t free_size = GetFreeSize(); - void *new_pos = curPos_; + void *new_pos = cur_pos_; void *ret = std::align(GetAlignmentInBytes(align), size, new_pos, free_size); if (ret != nullptr) { - curPos_ = static_cast(ToVoidPtr(ToUintPtr(ret) + size)); + cur_pos_ = static_cast(ToVoidPtr(ToUintPtr(ret) + size)); } return ret; } size_t GetFreeSize() const { - return DEFAULT_ON_STACK_ARENA_ALLOCATOR_BUFF_SIZE - (curPos_ - &buff_[0]); + return DEFAULT_ON_STACK_ARENA_ALLOCATOR_BUFF_SIZE - (cur_pos_ - &buff_[0]); } size_t GetOccupiedSize() const { - return curPos_ - &buff_[0]; + return cur_pos_ - &buff_[0]; } void Resize(size_t new_size) { ASSERT(new_size <= GetOccupiedSize()); - curPos_ = static_cast(ToVoidPtr(ToUintPtr(&buff_[0]) + new_size)); + cur_pos_ = static_cast(ToVoidPtr(ToUintPtr(&buff_[0]) + new_size)); } private: std::array buff_ {0}; - char *curPos_ = &buff_[0]; + char *cur_pos_ = &buff_[0]; }; template @@ -196,14 +196,14 @@ private: inline void AllocArenaMemStats(size_t size) { - if (memStats_ != nullptr) { - memStats_->RecordAllocateRaw(size, space_type_); + if (mem_stats_ != nullptr) { + mem_stats_->RecordAllocateRaw(size, space_type_); } } using OnStackBuff = OnStackBuffT; OnStackBuff buff_; - BaseMemStats *memStats_; + BaseMemStats *mem_stats_; SpaceType space_type_; OOMHandler oom_handler_ {nullptr}; bool limit_alloc_size_by_pool_ {false}; @@ -212,10 +212,10 @@ private: using ArenaAllocator = ArenaAllocatorT; using ArenaAllocatorWithOOMHandler = ArenaAllocatorT; -template +template class ArenaResizeWrapper { public: - explicit ArenaResizeWrapper(ArenaAllocatorT *arena_allocator) + explicit ArenaResizeWrapper(ArenaAllocatorT *arena_allocator) : old_size_(arena_allocator->GetAllocatedSize()), allocator_(arena_allocator) { } @@ -227,15 +227,15 @@ public: private: size_t old_size_; - ArenaAllocatorT *allocator_; + ArenaAllocatorT *allocator_; NO_COPY_SEMANTIC(ArenaResizeWrapper); NO_MOVE_SEMANTIC(ArenaResizeWrapper); }; -template +template template -T *ArenaAllocatorT::AllocArray(size_t arr_length) +T *ArenaAllocatorT::AllocArray(size_t arr_length) { // TODO(Dmitrii Trubenkov): change to the proper implementation return static_cast(Alloc(sizeof(T) * arr_length)); diff --git a/libpandabase/mem/arena_allocator_stl_adapter.h b/libpandabase/mem/arena_allocator_stl_adapter.h index d672db2c8e7a1dbcca19d9e42dcb421870c421d4..d5648104c36a5e17aa1724ae06425e772d88fdd4 100644 --- a/libpandabase/mem/arena_allocator_stl_adapter.h +++ b/libpandabase/mem/arena_allocator_stl_adapter.h @@ -21,28 +21,30 @@ namespace panda { // Adapter for use of ArenaAllocator in STL containers. -template +template class ArenaAllocatorAdapter; -template -class ArenaAllocatorAdapter { +template +class ArenaAllocatorAdapter { public: + // NOLINTNEXTLINE(readability-identifier-naming) using value_type = void; - using pointer = void *; - using const_pointer = const void *; + using Pointer = void *; + using ConstPointer = const void *; template struct Rebind { - using other = ArenaAllocatorAdapter; + // NOLINTNEXTLINE(readability-identifier-naming) + using other = ArenaAllocatorAdapter; }; template - using rebind = Rebind; + using rebind = Rebind; // NOLINT(readability-identifier-naming) - explicit ArenaAllocatorAdapter(ArenaAllocatorT *allocator) : allocator_(allocator) {} + explicit ArenaAllocatorAdapter(ArenaAllocatorT *allocator) : allocator_(allocator) {} template // NOLINTNEXTLINE(google-explicit-constructor) - ArenaAllocatorAdapter(const ArenaAllocatorAdapter &other) : allocator_(other.allocator_) + ArenaAllocatorAdapter(const ArenaAllocatorAdapter &other) : allocator_(other.allocator_) { } ArenaAllocatorAdapter(const ArenaAllocatorAdapter &) = default; @@ -52,35 +54,37 @@ public: ~ArenaAllocatorAdapter() = default; private: - ArenaAllocatorT *allocator_; + ArenaAllocatorT *allocator_; - template + template friend class ArenaAllocatorAdapter; }; -template +template class ArenaAllocatorAdapter { public: + // NOLINTNEXTLINE(readability-identifier-naming) using value_type = T; - using pointer = T *; - using reference = T &; - using const_pointer = const T *; - using const_reference = const T &; - using size_type = size_t; - using difference_type = ptrdiff_t; + using Pointer = T *; + using Reference = T &; + using ConstPointer = const T *; + using ConstReference = const T &; + using SizeType = size_t; + using DifferenceType = ptrdiff_t; template struct Rebind { - using other = ArenaAllocatorAdapter; + // NOLINTNEXTLINE(readability-identifier-naming) + using other = ArenaAllocatorAdapter; }; template - using rebind = Rebind; + using rebind = Rebind; // NOLINT(readability-identifier-naming) - explicit ArenaAllocatorAdapter(ArenaAllocatorT *allocator) : allocator_(allocator) {} + explicit ArenaAllocatorAdapter(ArenaAllocatorT *allocator) : allocator_(allocator) {} template // NOLINTNEXTLINE(google-explicit-constructor) - ArenaAllocatorAdapter(const ArenaAllocatorAdapter &other) : allocator_(other.allocator_) + ArenaAllocatorAdapter(const ArenaAllocatorAdapter &other) : allocator_(other.allocator_) { } ArenaAllocatorAdapter(const ArenaAllocatorAdapter &) = default; @@ -99,32 +103,32 @@ public: ~ArenaAllocatorAdapter() = default; // NOLINTNEXTLINE(readability-identifier-naming) - size_type max_size() const + SizeType max_size() const { - return static_cast(-1) / sizeof(T); + return static_cast(-1) / sizeof(T); } // NOLINTNEXTLINE(readability-identifier-naming) - pointer address(reference x) const + Pointer address(Reference x) const { return &x; } // NOLINTNEXTLINE(readability-identifier-naming) - const_pointer address(const_reference x) const + ConstReference address(ConstReference x) const { return &x; } // NOLINTNEXTLINE(readability-identifier-naming) - pointer allocate(size_type n, - [[maybe_unused]] typename ArenaAllocatorAdapter::pointer ptr = nullptr) + Pointer allocate(SizeType n, + [[maybe_unused]] typename ArenaAllocatorAdapter::Pointer ptr = nullptr) { ASSERT(n <= max_size()); return allocator_->template AllocArray(n); } // NOLINTNEXTLINE(readability-identifier-naming) - void deallocate([[maybe_unused]] pointer p, [[maybe_unused]] size_type n) {} + void deallocate([[maybe_unused]] Pointer p, [[maybe_unused]] SizeType n) {} template void construct(U *p, Args &&...args) // NOLINT(readability-identifier-naming) @@ -138,35 +142,35 @@ public: } private: - ArenaAllocatorT *allocator_ {nullptr}; + ArenaAllocatorT *allocator_ {nullptr}; - template + template friend class ArenaAllocatorAdapter; - template + template // NOLINTNEXTLINE(readability-redundant-declaration) - friend inline bool operator==(const ArenaAllocatorAdapter &lhs, - const ArenaAllocatorAdapter &rhs); + friend inline bool operator==(const ArenaAllocatorAdapter &lhs, + const ArenaAllocatorAdapter &rhs); }; -template -inline bool operator==(const ArenaAllocatorAdapter &lhs, - const ArenaAllocatorAdapter &rhs) +template +inline bool operator==(const ArenaAllocatorAdapter &lhs, + const ArenaAllocatorAdapter &rhs) { return lhs.allocator_ == rhs.allocator_; } -template -inline bool operator!=(const ArenaAllocatorAdapter &lhs, - const ArenaAllocatorAdapter &rhs) +template +inline bool operator!=(const ArenaAllocatorAdapter &lhs, + const ArenaAllocatorAdapter &rhs) { return !(lhs == rhs); } -template -inline ArenaAllocatorAdapter ArenaAllocatorT::Adapter() +template +inline ArenaAllocatorAdapter ArenaAllocatorT::Adapter() { - return ArenaAllocatorAdapter(this); + return ArenaAllocatorAdapter(this); } } // namespace panda diff --git a/libpandabase/mem/code_allocator.cpp b/libpandabase/mem/code_allocator.cpp index fbac9f0a26fddf88af7b339b5a457c7a8f95871d..c7ef3d7da96bef8280417ff4496490433dd364d9 100644 --- a/libpandabase/mem/code_allocator.cpp +++ b/libpandabase/mem/code_allocator.cpp @@ -26,31 +26,31 @@ namespace panda { const Alignment CodeAllocator::PAGE_LOG_ALIGN = GetLogAlignment(os::mem::GetPageSize()); CodeAllocator::CodeAllocator(BaseMemStats *mem_stats) - : arenaAllocator_([&]() { + : arena_allocator_([&]() { trace::ScopedTrace scoped_trace(__PRETTY_FUNCTION__); // Do not set up mem_stats in internal arena allocator, because we will manage memstats here. return ArenaAllocator(SpaceType::SPACE_TYPE_CODE, nullptr); }()), - memStats_(mem_stats) + mem_stats_(mem_stats) { ASSERT(LOG_ALIGN_MIN <= PAGE_LOG_ALIGN && PAGE_LOG_ALIGN <= LOG_ALIGN_MAX); } CodeAllocator::~CodeAllocator() { - codeRangeStart_ = nullptr; - codeRangeEnd_ = nullptr; + code_range_start_ = nullptr; + code_range_end_ = nullptr; } void *CodeAllocator::AllocateCode(size_t size, const void *code_buff) { trace::ScopedTrace scoped_trace("Allocate Code"); - void *code_ptr = arenaAllocator_.Alloc(size, PAGE_LOG_ALIGN); + void *code_ptr = arena_allocator_.Alloc(size, PAGE_LOG_ALIGN); if (UNLIKELY(code_ptr == nullptr || memcpy_s(code_ptr, size, code_buff, size) != EOK)) { return nullptr; } ProtectCode(os::mem::MapRange(static_cast(code_ptr), size)); - memStats_->RecordAllocateRaw(size, SpaceType::SPACE_TYPE_CODE); + mem_stats_->RecordAllocateRaw(size, SpaceType::SPACE_TYPE_CODE); CodeRangeUpdate(code_ptr, size); return code_ptr; } @@ -58,11 +58,11 @@ void *CodeAllocator::AllocateCode(size_t size, const void *code_buff) os::mem::MapRange CodeAllocator::AllocateCodeUnprotected(size_t size) { trace::ScopedTrace scoped_trace("Allocate Code"); - void *code_ptr = arenaAllocator_.Alloc(size, PAGE_LOG_ALIGN); + void *code_ptr = arena_allocator_.Alloc(size, PAGE_LOG_ALIGN); if (UNLIKELY(code_ptr == nullptr)) { return os::mem::MapRange(nullptr, 0); } - memStats_->RecordAllocateRaw(size, SpaceType::SPACE_TYPE_CODE); + mem_stats_->RecordAllocateRaw(size, SpaceType::SPACE_TYPE_CODE); CodeRangeUpdate(code_ptr, size); return os::mem::MapRange(static_cast(code_ptr), size); } @@ -76,18 +76,18 @@ void CodeAllocator::ProtectCode(os::mem::MapRange mem_range) bool CodeAllocator::InAllocatedCodeRange(const void *pc) { os::memory::ReadLockHolder rlock(code_range_lock_); - return (pc >= codeRangeStart_) && (pc <= codeRangeEnd_); + return (pc >= code_range_start_) && (pc <= code_range_end_); } void CodeAllocator::CodeRangeUpdate(void *ptr, size_t size) { os::memory::WriteLockHolder rwlock(code_range_lock_); - if (ptr < codeRangeStart_ || codeRangeStart_ == nullptr) { - codeRangeStart_ = ptr; + if (ptr < code_range_start_ || code_range_start_ == nullptr) { + code_range_start_ = ptr; } void *buffer_end = ToVoidPtr(ToUintPtr(ptr) + size); - if (buffer_end > codeRangeEnd_ || codeRangeEnd_ == nullptr) { - codeRangeEnd_ = buffer_end; + if (buffer_end > code_range_end_ || code_range_end_ == nullptr) { + code_range_end_ = buffer_end; } } diff --git a/libpandabase/mem/code_allocator.h b/libpandabase/mem/code_allocator.h index 504f5ae7d196b5f1c37cd87663b2e1ef6a81ca8d..23276e8c5eb20ca63be8c373bc05acc30fcc3dec 100644 --- a/libpandabase/mem/code_allocator.h +++ b/libpandabase/mem/code_allocator.h @@ -64,11 +64,11 @@ private: static const Alignment PAGE_LOG_ALIGN; // TODO(dtrubenkov): Remove when some CodeCache space will be implemented, currently used for avoid memleak noise - ArenaAllocator arenaAllocator_; - BaseMemStats *memStats_; + ArenaAllocator arena_allocator_; + BaseMemStats *mem_stats_; os::memory::RWLock code_range_lock_; - void *codeRangeStart_ {nullptr}; - void *codeRangeEnd_ {nullptr}; + void *code_range_start_ {nullptr}; + void *code_range_end_ {nullptr}; }; } // namespace panda diff --git a/libpandabase/mem/gc_barrier.h b/libpandabase/mem/gc_barrier.h index b067395f75f3005dd479ac6074c59090f4814e92..84ecc9101e1966a1c3cdfb6224e1be937ca3ccae 100644 --- a/libpandabase/mem/gc_barrier.h +++ b/libpandabase/mem/gc_barrier.h @@ -162,8 +162,8 @@ constexpr bool IsEmptyBarrier(BarrierType barrier_type) (barrier_type == BarrierType::PRE_RB_NONE) || (barrier_type == BarrierType::POST_RB_NONE); } -using objRefProcessFunc = void (*)(void *); -using objTwoRefProcessFunc = void (*)(const void *, const void *); +using ObjRefProcessFunc = void (*)(void *); +using ObjTwoRefProcessFunc = void (*)(const void *, const void *); enum class BarrierOperandType { ADDRESS = 0, // just an address (void*) @@ -175,7 +175,7 @@ enum class BarrierOperandType { }; using BarrierOperandValue = - std::variant *, uint8_t *, objRefProcessFunc, uint8_t, objTwoRefProcessFunc>; + std::variant *, uint8_t *, ObjRefProcessFunc, uint8_t, ObjTwoRefProcessFunc>; class BarrierOperand { public: diff --git a/libpandabase/mem/mem.h b/libpandabase/mem/mem.h index 05d15fd82266f3a9e9e5055f229ff4c15f497fee..6b5f26cb2fda75853a62b221e7a49cdcd3026c9a 100644 --- a/libpandabase/mem/mem.h +++ b/libpandabase/mem/mem.h @@ -43,12 +43,12 @@ using MemStatsType = MemStatsDefault; class ObjectHeader; #ifdef PANDA_USE_32_BIT_POINTER -using object_pointer_type = uint32_t; +using ObjectPointerType = uint32_t; #else -using object_pointer_type = uintptr_t; +using ObjectPointerType = uintptr_t; #endif -constexpr size_t OBJECT_POINTER_SIZE = sizeof(object_pointer_type); +constexpr size_t OBJECT_POINTER_SIZE = sizeof(ObjectPointerType); /** * \brief Logarithmic/bit alignment @@ -74,9 +74,9 @@ enum Alignment { * @param logAlignment - logarithmic alignment * @return alingnment in bytes */ -constexpr size_t GetAlignmentInBytes(const Alignment LOG_ALIGNMENT) +constexpr size_t GetAlignmentInBytes(const Alignment log_alignment) { - return 1U << static_cast(LOG_ALIGNMENT); + return 1U << static_cast(log_alignment); } /** @@ -84,14 +84,14 @@ constexpr size_t GetAlignmentInBytes(const Alignment LOG_ALIGNMENT) * @param ALIGNMENT_IN_BYTES - should be power of 2 * @return alignment in bits */ -constexpr Alignment GetLogAlignment(const uint32_t ALIGNMENT_IN_BYTES) +constexpr Alignment GetLogAlignment(const uint32_t alignment_in_bytes) { using helpers::math::GetIntLog2; // check if it is power of 2 - ASSERT((ALIGNMENT_IN_BYTES != 0) && !(ALIGNMENT_IN_BYTES & (ALIGNMENT_IN_BYTES - 1))); - ASSERT(GetIntLog2(ALIGNMENT_IN_BYTES) >= Alignment::LOG_ALIGN_MIN); - ASSERT(GetIntLog2(ALIGNMENT_IN_BYTES) <= Alignment::LOG_ALIGN_MAX); - return static_cast(GetIntLog2(ALIGNMENT_IN_BYTES)); + ASSERT((alignment_in_bytes != 0) && !(alignment_in_bytes & (alignment_in_bytes - 1))); + ASSERT(GetIntLog2(alignment_in_bytes) >= Alignment::LOG_ALIGN_MIN); + ASSERT(GetIntLog2(alignment_in_bytes) <= Alignment::LOG_ALIGN_MAX); + return static_cast(GetIntLog2(alignment_in_bytes)); } template @@ -224,15 +224,15 @@ inline bool IsInObjectsAddressSpace(T *address) } template -inline object_pointer_type ToObjPtrType(T *val) +inline ObjectPointerType ToObjPtrType(T *val) { ASSERT(IsInObjectsAddressSpace(ToUintPtr(val))); - return static_cast(ToUintPtr(val)); + return static_cast(ToUintPtr(val)); } -inline object_pointer_type ToObjPtrType(std::nullptr_t) +inline ObjectPointerType ToObjPtrType(std::nullptr_t) { - return static_cast(ToUintPtr(nullptr)); + return static_cast(ToUintPtr(nullptr)); } enum class ObjectStatus : bool { diff --git a/libpandabase/mem/mem_config.cpp b/libpandabase/mem/mem_config.cpp index a528eae948a8dec895ac5b2c8df9c8a2b74c82af..54dc9840fef241467a7c7d0c3bf26b43b7e2dcce 100644 --- a/libpandabase/mem/mem_config.cpp +++ b/libpandabase/mem/mem_config.cpp @@ -17,10 +17,10 @@ namespace panda::mem { -bool MemConfig::is_initialized = false; -size_t MemConfig::initial_heap_size_limit = 0; -size_t MemConfig::heap_size_limit = 0; -size_t MemConfig::internal_memory_size_limit = 0; -size_t MemConfig::code_cache_size_limit = 0; -size_t MemConfig::compiler_memory_size_limit = 0; +bool MemConfig::is_initialized_ = false; +size_t MemConfig::initial_heap_size_limit_ = 0; +size_t MemConfig::heap_size_limit_ = 0; +size_t MemConfig::internal_memory_size_limit_ = 0; +size_t MemConfig::code_cache_size_limit_ = 0; +size_t MemConfig::compiler_memory_size_limit_ = 0; } // namespace panda::mem diff --git a/libpandabase/mem/mem_config.h b/libpandabase/mem/mem_config.h index a8eb876f64561eba8eb153f68ae68f3eba7b488b..ce56bb9d8a0cdced8eff56767d6b2332c6054dad 100644 --- a/libpandabase/mem/mem_config.h +++ b/libpandabase/mem/mem_config.h @@ -32,13 +32,13 @@ public: static void Initialize(size_t object_pool_size, size_t internal_size, size_t compiler_size, size_t code_size, size_t initial_object_pool_size) { - ASSERT(!is_initialized); - initial_heap_size_limit = initial_object_pool_size; - heap_size_limit = object_pool_size; - internal_memory_size_limit = internal_size; - compiler_memory_size_limit = compiler_size; - code_cache_size_limit = code_size; - is_initialized = true; + ASSERT(!is_initialized_); + initial_heap_size_limit_ = initial_object_pool_size; + heap_size_limit_ = object_pool_size; + internal_memory_size_limit_ = internal_size; + compiler_memory_size_limit_ = compiler_size; + code_cache_size_limit_ = code_size; + is_initialized_ = true; } static void Initialize(size_t object_pool_size, size_t internal_size, size_t compiler_size, size_t code_size) @@ -48,40 +48,40 @@ public: static void Finalize() { - is_initialized = false; - heap_size_limit = 0; - internal_memory_size_limit = 0; - code_cache_size_limit = 0; + is_initialized_ = false; + heap_size_limit_ = 0; + internal_memory_size_limit_ = 0; + code_cache_size_limit_ = 0; } static size_t GetInitialHeapSizeLimit() { - ASSERT(is_initialized); - return initial_heap_size_limit; + ASSERT(is_initialized_); + return initial_heap_size_limit_; } static size_t GetHeapSizeLimit() { - ASSERT(is_initialized); - return heap_size_limit; + ASSERT(is_initialized_); + return heap_size_limit_; } static size_t GetInternalMemorySizeLimit() { - ASSERT(is_initialized); - return internal_memory_size_limit; + ASSERT(is_initialized_); + return internal_memory_size_limit_; } static size_t GetCodeCacheSizeLimit() { - ASSERT(is_initialized); - return code_cache_size_limit; + ASSERT(is_initialized_); + return code_cache_size_limit_; } static size_t GetCompilerMemorySizeLimit() { - ASSERT(is_initialized); - return compiler_memory_size_limit; + ASSERT(is_initialized_); + return compiler_memory_size_limit_; } MemConfig() = delete; @@ -92,12 +92,12 @@ public: NO_MOVE_SEMANTIC(MemConfig); private: - static bool is_initialized; - static size_t initial_heap_size_limit; // Initial heap size - static size_t heap_size_limit; // Max heap size - static size_t internal_memory_size_limit; // Max internal memory used by the VM - static size_t code_cache_size_limit; // The limit for compiled code size. - static size_t compiler_memory_size_limit; // Max memory used by compiler + static bool is_initialized_; + static size_t initial_heap_size_limit_; // Initial heap size + static size_t heap_size_limit_; // Max heap size + static size_t internal_memory_size_limit_; // Max internal memory used by the VM + static size_t code_cache_size_limit_; // The limit for compiled code size. + static size_t compiler_memory_size_limit_; // Max memory used by compiler }; } // namespace panda::mem diff --git a/libpandabase/mem/object_pointer.h b/libpandabase/mem/object_pointer.h index 60ad1ec59125a16c8a4156eec2ad6314b1595ad6..f009b818a0f428be808977519b68a6d9ecb1a1bd 100644 --- a/libpandabase/mem/object_pointer.h +++ b/libpandabase/mem/object_pointer.h @@ -127,16 +127,16 @@ public: ~ObjectPointer() = default; private: - object_pointer_type object_ {}; + ObjectPointerType object_ {}; - ALWAYS_INLINE static Object *ToObjectPtr(const object_pointer_type pointer) noexcept + ALWAYS_INLINE static Object *ToObjectPtr(const ObjectPointerType pointer) noexcept { return ToNativePtr(static_cast(pointer)); } }; -// size of ObjectPointer must be equal size of object_pointer_type -static_assert(sizeof(ObjectPointer) == sizeof(object_pointer_type)); +// size of ObjectPointer must be equal size of ObjectPointerType +static_assert(sizeof(ObjectPointer) == sizeof(ObjectPointerType)); } // namespace panda diff --git a/libpandabase/mem/pool_manager.cpp b/libpandabase/mem/pool_manager.cpp index f5aa04c27a328b8cd5b48ab5cdbe5d5e1263495f..7ba1d23a5e33a356e040437fe79378e2cee7f3cb 100644 --- a/libpandabase/mem/pool_manager.cpp +++ b/libpandabase/mem/pool_manager.cpp @@ -20,66 +20,66 @@ namespace panda { -// default is mmap_mem_pool -PoolType PoolManager::pool_type = PoolType::MMAP; -bool PoolManager::is_initialized = false; -MallocMemPool *PoolManager::malloc_mem_pool = nullptr; -MmapMemPool *PoolManager::mmap_mem_pool = nullptr; +// default is mmap_mem_pool_ +PoolType PoolManager::pool_type_ = PoolType::MMAP; +bool PoolManager::is_initialized_ = false; +MallocMemPool *PoolManager::malloc_mem_pool_ = nullptr; +MmapMemPool *PoolManager::mmap_mem_pool_ = nullptr; Arena *PoolManager::AllocArena(size_t size, SpaceType space_type, AllocatorType allocator_type, const void *allocator_addr) { - if (pool_type == PoolType::MMAP) { - return mmap_mem_pool->AllocArenaImpl(size, space_type, allocator_type, allocator_addr); + if (pool_type_ == PoolType::MMAP) { + return mmap_mem_pool_->AllocArenaImpl(size, space_type, allocator_type, allocator_addr); } - return malloc_mem_pool->AllocArenaImpl(size, space_type, allocator_type, allocator_addr); + return malloc_mem_pool_->AllocArenaImpl(size, space_type, allocator_type, allocator_addr); } void PoolManager::FreeArena(Arena *arena) { - if (pool_type == PoolType::MMAP) { - return mmap_mem_pool->FreeArenaImpl(arena); + if (pool_type_ == PoolType::MMAP) { + return mmap_mem_pool_->FreeArenaImpl(arena); } - return malloc_mem_pool->FreeArenaImpl(arena); + return malloc_mem_pool_->FreeArenaImpl(arena); } void PoolManager::Initialize(PoolType type) { - ASSERT(!is_initialized); - is_initialized = true; - pool_type = type; - if (pool_type == PoolType::MMAP) { - mmap_mem_pool = new MmapMemPool(); + ASSERT(!is_initialized_); + is_initialized_ = true; + pool_type_ = type; + if (pool_type_ == PoolType::MMAP) { + mmap_mem_pool_ = new MmapMemPool(); } else { - malloc_mem_pool = new MallocMemPool(); + malloc_mem_pool_ = new MallocMemPool(); } LOG(DEBUG, ALLOC) << "PoolManager Initialized"; } MmapMemPool *PoolManager::GetMmapMemPool() { - ASSERT(is_initialized); - ASSERT(pool_type == PoolType::MMAP); - return mmap_mem_pool; + ASSERT(is_initialized_); + ASSERT(pool_type_ == PoolType::MMAP); + return mmap_mem_pool_; } MallocMemPool *PoolManager::GetMallocMemPool() { - ASSERT(is_initialized); - ASSERT(pool_type == PoolType::MALLOC); - return malloc_mem_pool; + ASSERT(is_initialized_); + ASSERT(pool_type_ == PoolType::MALLOC); + return malloc_mem_pool_; } void PoolManager::Finalize() { - ASSERT(is_initialized); - is_initialized = false; - if (pool_type == PoolType::MMAP) { - delete mmap_mem_pool; - mmap_mem_pool = nullptr; + ASSERT(is_initialized_); + is_initialized_ = false; + if (pool_type_ == PoolType::MMAP) { + delete mmap_mem_pool_; + mmap_mem_pool_ = nullptr; } else { - delete malloc_mem_pool; - malloc_mem_pool = nullptr; + delete malloc_mem_pool_; + malloc_mem_pool_ = nullptr; } } diff --git a/libpandabase/mem/pool_manager.h b/libpandabase/mem/pool_manager.h index eee735c730b438d5a5cd3710d3a31e59b70c70ea..419ce6ca2258b4e9ce34338f1cdbcc42c9c4e362 100644 --- a/libpandabase/mem/pool_manager.h +++ b/libpandabase/mem/pool_manager.h @@ -38,10 +38,10 @@ public: static void Finalize(); private: - static bool is_initialized; - static PoolType pool_type; - static MallocMemPool *malloc_mem_pool; - static MmapMemPool *mmap_mem_pool; + static bool is_initialized_; + static PoolType pool_type_; + static MallocMemPool *malloc_mem_pool_; + static MmapMemPool *mmap_mem_pool_; }; } // namespace panda diff --git a/libpandabase/mem/ringbuf/lock_free_ring_buffer.h b/libpandabase/mem/ringbuf/lock_free_ring_buffer.h index 251b1cc9f6a6b8fd0831d93790e983fca946401a..0d5b77460c51fb36641e1e6afeb3dfcea9761a6e 100644 --- a/libpandabase/mem/ringbuf/lock_free_ring_buffer.h +++ b/libpandabase/mem/ringbuf/lock_free_ring_buffer.h @@ -85,15 +85,15 @@ public: CheckInvariant(); // Atomic with acquire order reason: get the latest value - auto currentHead = head_index_.load(std::memory_order_acquire); + auto current_head = head_index_.load(std::memory_order_acquire); // Atomic with acquire order reason: get the latest value - if (currentHead == tail_index_.load(std::memory_order_acquire)) { + if (current_head == tail_index_.load(std::memory_order_acquire)) { return false; } - *pval = buffer_[currentHead]; - size_t new_value = Increment(currentHead); + *pval = buffer_[current_head]; + size_t new_value = Increment(current_head); // Atomic with release order reason: let others threads to see the latest value head_index_.store(new_value, std::memory_order_release); return true; diff --git a/runtime/compiler.cpp b/runtime/compiler.cpp index c1256471f745e7a78c0071b5c65619fd7a1b552e..6c8cbc72b080a5ad3f9a66b2e26b7b186ddbf7e3 100644 --- a/runtime/compiler.cpp +++ b/runtime/compiler.cpp @@ -771,7 +771,7 @@ void Compiler::JoinWorker() #endif } -object_pointer_type PandaRuntimeInterface::GetNonMovableString(MethodPtr method, StringId id) const +ObjectPointerType PandaRuntimeInterface::GetNonMovableString(MethodPtr method, StringId id) const { auto vm = Runtime::GetCurrent()->GetPandaVM(); auto pf = MethodCast(method)->GetPandaFile(); diff --git a/runtime/compiler.h b/runtime/compiler.h index bca5424aef3f68bd3b6e7b75d45f30aa9bbbd41c..4c4bec59819109981789b082d5005f73fcaecd65 100644 --- a/runtime/compiler.h +++ b/runtime/compiler.h @@ -376,7 +376,7 @@ public: return panda::coretypes::String::GetCompressedStringsEnabled(); } - object_pointer_type GetNonMovableString(MethodPtr method, StringId id) const override; + ObjectPointerType GetNonMovableString(MethodPtr method, StringId id) const override; ClassPtr GetStringClass(MethodPtr method) const override; diff --git a/runtime/include/cframe.h b/runtime/include/cframe.h index 01d56135331df32b733a7f5c752675221aaea469..b066dc9a35140499ebdd392bd18a4200520b09ca 100644 --- a/runtime/include/cframe.h +++ b/runtime/include/cframe.h @@ -176,7 +176,7 @@ public: { auto val = GetVRegValueInternal(vreg, code_info, callee_stack).GetValue(); if (vreg.IsObject()) { - reg.SetReference(reinterpret_cast(static_cast(val))); + reg.SetReference(reinterpret_cast(static_cast(val))); } else { reg.SetPrimitive(val); } diff --git a/runtime/include/coretypes/array-inl.h b/runtime/include/coretypes/array-inl.h index efe1306fd68e0fd9365e41a89efc3ac67812e6f7..34e3c4689a9219ca8f563bed71ab4aaebf3071e3 100644 --- a/runtime/include/coretypes/array-inl.h +++ b/runtime/include/coretypes/array-inl.h @@ -155,7 +155,7 @@ inline void Array::Set(array_size_t idx, T elem) static_assert(std::is_arithmetic_v || IS_REF, "T should be arithmetic type or pointer to managed object type"); - size_t elem_size = (IS_REF && !is_dyn) ? sizeof(object_pointer_type) : sizeof(T); + size_t elem_size = (IS_REF && !is_dyn) ? sizeof(ObjectPointerType) : sizeof(T); size_t offset = elem_size * idx; // Disable checks due to clang-tidy bug https://bugs.llvm.org/show_bug.cgi?id=32203 @@ -175,7 +175,7 @@ inline T Array::Get(array_size_t idx) const static_assert(std::is_arithmetic_v || IS_REF, "T should be arithmetic type or pointer to managed object type"); - size_t elem_size = (IS_REF && !is_dyn) ? sizeof(object_pointer_type) : sizeof(T); + size_t elem_size = (IS_REF && !is_dyn) ? sizeof(ObjectPointerType) : sizeof(T); size_t offset = elem_size * idx; // NOLINTNEXTLINE(readability-braces-around-statements, bugprone-suspicious-semicolon) @@ -193,7 +193,7 @@ inline void Array::Set([[maybe_unused]] const ManagedThread *thread, array_size_ static_assert(std::is_arithmetic_v || IS_REF, "T should be arithmetic type or pointer to managed object type"); - size_t elem_size = (IS_REF && !is_dyn) ? sizeof(object_pointer_type) : sizeof(T); + size_t elem_size = (IS_REF && !is_dyn) ? sizeof(ObjectPointerType) : sizeof(T); size_t offset = elem_size * idx; // NOLINTNEXTLINE(readability-braces-around-statements, bugprone-suspicious-semicolon) @@ -211,7 +211,7 @@ inline T Array::Get([[maybe_unused]] const ManagedThread *thread, array_size_t i static_assert(std::is_arithmetic_v || IS_REF, "T should be arithmetic type or pointer to managed object type"); - size_t elem_size = (IS_REF && !is_dyn) ? sizeof(object_pointer_type) : sizeof(T); + size_t elem_size = (IS_REF && !is_dyn) ? sizeof(ObjectPointerType) : sizeof(T); size_t offset = elem_size * idx; // NOLINTNEXTLINE(readability-braces-around-statements, bugprone-suspicious-semicolon) diff --git a/runtime/include/object_accessor-inl.h b/runtime/include/object_accessor-inl.h index 6f537bfdf7cf6bc43bb700fa392d844ecd5d9da7..d4963e02b3c1da6eb4587e9b615ad4f90b2bf04b 100644 --- a/runtime/include/object_accessor-inl.h +++ b/runtime/include/object_accessor-inl.h @@ -30,7 +30,7 @@ inline ObjectHeader *ObjectAccessor::GetObject(const void *obj, size_t offset) { // We don't have GC with read barriers now if (!is_dyn) { - return reinterpret_cast(Get(obj, offset)); + return reinterpret_cast(Get(obj, offset)); } return Get(obj, offset); } @@ -48,7 +48,7 @@ inline void ObjectAccessor::SetObject(void *obj, size_t offset, ObjectHeader *va } if (!is_dyn) { - Set(obj, offset, ToObjPtrType(value)); + Set(obj, offset, ToObjPtrType(value)); } else { Set(obj, offset, value); } @@ -58,7 +58,7 @@ inline void ObjectAccessor::SetObject(void *obj, size_t offset, ObjectHeader *va } } else { if (!is_dyn) { - Set(obj, offset, ToObjPtrType(value)); + Set(obj, offset, ToObjPtrType(value)); } else { Set(obj, offset, value); } @@ -72,7 +72,7 @@ inline ObjectHeader *ObjectAccessor::GetObject([[maybe_unused]] const ManagedThr { // We don't have GC with read barriers now if (!is_dyn) { - return reinterpret_cast(Get(obj, offset)); + return reinterpret_cast(Get(obj, offset)); } return Get(obj, offset); } @@ -89,7 +89,7 @@ inline void ObjectAccessor::SetObject(const ManagedThread *thread, void *obj, si } if (!is_dyn) { - Set(obj, offset, ToObjPtrType(value)); + Set(obj, offset, ToObjPtrType(value)); } else { Set(obj, offset, value); } @@ -98,7 +98,7 @@ inline void ObjectAccessor::SetObject(const ManagedThread *thread, void *obj, si } } else { if (!is_dyn) { - Set(obj, offset, ToObjPtrType(value)); + Set(obj, offset, ToObjPtrType(value)); } else { Set(obj, offset, value); } @@ -191,7 +191,7 @@ template inline ObjectHeader *ObjectAccessor::GetFieldObject(const void *obj, int offset, std::memory_order memory_order) { if (!is_dyn) { - return reinterpret_cast(Get(obj, offset, memory_order)); + return reinterpret_cast(Get(obj, offset, memory_order)); } return Get(obj, offset, memory_order); } @@ -223,7 +223,7 @@ inline void ObjectAccessor::SetFieldObject(void *obj, size_t offset, ObjectHeade } if (!is_dyn) { - Set(obj, offset, ToObjPtrType(value), memory_order); + Set(obj, offset, ToObjPtrType(value), memory_order); } else { Set(obj, offset, value, memory_order); } @@ -233,7 +233,7 @@ inline void ObjectAccessor::SetFieldObject(void *obj, size_t offset, ObjectHeade } } else { if (!is_dyn) { - Set(obj, offset, ToObjPtrType(value), memory_order); + Set(obj, offset, ToObjPtrType(value), memory_order); } else { Set(obj, offset, value, memory_order); } @@ -272,8 +272,8 @@ inline std::pair ObjectAccessor::CompareAndSetFieldObject( success = value.first; result = value.second; } else { - auto value = CompareAndSetFieldPrimitive( - obj, offset, ToObjPtrType(old_value), ToObjPtrType(new_value), memory_order, strong); + auto value = CompareAndSetFieldPrimitive(obj, offset, ToObjPtrType(old_value), + ToObjPtrType(new_value), memory_order, strong); success = value.first; result = reinterpret_cast(value.second); } @@ -319,7 +319,7 @@ inline ObjectHeader *ObjectAccessor::GetAndSetFieldObject(void *obj, size_t offs barrier_set->PreBarrier(GetObject(obj, offset)); } ObjectHeader *result = is_dyn ? GetAndSetFieldPrimitive(obj, offset, value, memory_order) - : reinterpret_cast(GetAndSetFieldPrimitive( + : reinterpret_cast(GetAndSetFieldPrimitive( obj, offset, ToObjPtrType(value), memory_order)); if (result != nullptr && !mem::IsEmptyBarrier(barrier_set->GetPostType())) { barrier_set->PostBarrier(ToVoidPtr(ToUintPtr(obj)), value); @@ -330,7 +330,7 @@ inline ObjectHeader *ObjectAccessor::GetAndSetFieldObject(void *obj, size_t offs return is_dyn ? GetAndSetFieldPrimitive(obj, offset, value, memory_order) : reinterpret_cast( - GetAndSetFieldPrimitive(obj, offset, ToObjPtrType(value), memory_order)); + GetAndSetFieldPrimitive(obj, offset, ToObjPtrType(value), memory_order)); } /* static */ diff --git a/runtime/include/object_header.h b/runtime/include/object_header.h index d5b2f7546435dba8baa232625d826038b18074f7..a953e50b473688c152a483c27516afbb1ab083fd 100644 --- a/runtime/include/object_header.h +++ b/runtime/include/object_header.h @@ -77,7 +77,7 @@ public: inline void SetClass(BaseClass *klass) { - static_assert(sizeof(ClassHelper::classWordSize) == sizeof(object_pointer_type)); + static_assert(sizeof(ClassHelper::classWordSize) == sizeof(ObjectPointerType)); // Atomic with release order reason: data race with classWord_ with dependecies on writes before the store which // should become visible acquire reinterpret_cast *>(&classWord_) diff --git a/runtime/interpreter/vregister.h b/runtime/interpreter/vregister.h index 28103d3ed269c9460975dc124b2706c888313cdf..e4d772e7b2700d1714ef7d02afe441fa19220007 100644 --- a/runtime/interpreter/vregister.h +++ b/runtime/interpreter/vregister.h @@ -180,7 +180,7 @@ public: template > * = nullptr> ALWAYS_INLINE inline ObjectHeader *GetAs() const { - return reinterpret_cast(static_cast(GetValue())); + return reinterpret_cast(static_cast(GetValue())); } private: diff --git a/runtime/mem/gc/bitmap.h b/runtime/mem/gc/bitmap.h index 4a8edc039492a3624fbc4a0e67f3f1da579ff0ed..4342b99839da9c87347058cccef780d33a4a5662 100644 --- a/runtime/mem/gc/bitmap.h +++ b/runtime/mem/gc/bitmap.h @@ -395,7 +395,7 @@ private: * Memory bitmap, binding a continuous range of memory to a bitmap. * One bit represents BYTESPERCHUNK bytes of memory. */ -template +template class MemBitmap : public Bitmap { public: explicit MemBitmap(void *mem_addr, size_t heap_size, void *bitmap_addr) diff --git a/runtime/mem/gc/g1/g1-gc.cpp b/runtime/mem/gc/g1/g1-gc.cpp index 75f829c36f544c9f765f3905ae7165f984b9c6c4..82a5d680d03c5f720e58094378bd11268261a9ac 100644 --- a/runtime/mem/gc/g1/g1-gc.cpp +++ b/runtime/mem/gc/g1/g1-gc.cpp @@ -31,9 +31,9 @@ namespace panda::mem { -static inline object_pointer_type ToObjPtr(const void *ptr) +static inline ObjectPointerType ToObjPtr(const void *ptr) { - return static_cast(ToUintPtr(ptr)); + return static_cast(ToUintPtr(ptr)); } #ifndef NDEBUG diff --git a/runtime/mem/gc/gc_barrier_set.cpp b/runtime/mem/gc/gc_barrier_set.cpp index 29cdd6561865feda3b9786c8c310aa5ef8692b75..02d5e7eaa910a016b2dc30241c4b2ebed3acb009 100644 --- a/runtime/mem/gc/gc_barrier_set.cpp +++ b/runtime/mem/gc/gc_barrier_set.cpp @@ -68,7 +68,7 @@ void PostIntergenerationalBarrier(const void *min_addr, uint8_t *card_table_addr } void PostInterregionBarrier(const void *obj_addr, const void *ref, const size_t region_size_bits, - const CardTable *card_table, objTwoRefProcessFunc update_func) + const CardTable *card_table, ObjTwoRefProcessFunc update_func) { if (ref != nullptr) { // If it is cross-region reference diff --git a/runtime/mem/gc/gc_barrier_set.h b/runtime/mem/gc/gc_barrier_set.h index d841b6bcc969def1b799fee08762df6b56f19020..3bbea20de3dea250caf0cf69563742233a19858d 100644 --- a/runtime/mem/gc/gc_barrier_set.h +++ b/runtime/mem/gc/gc_barrier_set.h @@ -201,9 +201,9 @@ public: GCG1BarrierSet(mem::InternalAllocatorPtr allocator, // PRE ARGS: - std::atomic *concurrent_marking_flag, objRefProcessFunc pre_store_func, + std::atomic *concurrent_marking_flag, ObjRefProcessFunc pre_store_func, // POST ARGS: - objTwoRefProcessFunc post_func, uint8_t region_size_bits_count, CardTable *card_table, + ObjTwoRefProcessFunc post_func, uint8_t region_size_bits_count, CardTable *card_table, ThreadLocalCardQueues *updated_refs_queue, os::memory::Mutex *queue_lock) : GCBarrierSet(allocator, BarrierType::PRE_SATB_BARRIER, BarrierType::POST_INTERREGION_BARRIER), concurrent_marking_flag_(concurrent_marking_flag), @@ -273,9 +273,9 @@ private: // Store operands explicitly for interpreter perf // PRE BARRIER std::atomic *concurrent_marking_flag_ {nullptr}; - objRefProcessFunc pre_store_func_ {nullptr}; + ObjRefProcessFunc pre_store_func_ {nullptr}; // POST BARRIER - objTwoRefProcessFunc post_func_; //! function which is called for the post barrier if all conditions + ObjTwoRefProcessFunc post_func_; //! function which is called for the post barrier if all conditions uint8_t region_size_bits_count_ {0}; //! how much bits needed for the region CardTable *card_table_ {nullptr}; //! void *min_addr_ {nullptr}; //! Minimal address used by VM. Used as a base for card index calculation diff --git a/runtime/mem/refstorage/reference_storage.cpp b/runtime/mem/refstorage/reference_storage.cpp index 5e7d50ad6f3306f031b782713f98c134a4b52429..a72f147dee44d3878e30ba592c1d516df396c0b7 100644 --- a/runtime/mem/refstorage/reference_storage.cpp +++ b/runtime/mem/refstorage/reference_storage.cpp @@ -199,7 +199,7 @@ ObjectHeader *ReferenceStorage::GetObject(const Reference *ref) // But compiler may store 32-bit and trash in hi-part // That's why need cut object pointer return reinterpret_cast( - (*reinterpret_cast(Reference::GetRefWithoutType(ref)))); + (*reinterpret_cast(Reference::GetRefWithoutType(ref)))); } case Reference::ObjectType::LOCAL: { ObjectHeader *obj = FindLocalObject(ref); diff --git a/runtime/tests/bitmap_clear_range_test.cpp b/runtime/tests/bitmap_clear_range_test.cpp index 6353ea68e8b62d051da44616ae66a750c6868531..64193cf9f6c38593bdfdb0b48807cf7f1edb52c7 100644 --- a/runtime/tests/bitmap_clear_range_test.cpp +++ b/runtime/tests/bitmap_clear_range_test.cpp @@ -31,7 +31,7 @@ TEST_F(BitmapTest, ClearRange) std::make_unique((HEAP_CAPACITY >> Bitmap::LOG_BITSPERWORD) / DEFAULT_ALIGNMENT_IN_BYTES); MemBitmap bm(ToVoidPtr(heap_begin), HEAP_CAPACITY, bm_ptr.get()); - using mem_range = std::pair; + using mem_range = std::pair; constexpr mem_range FIRST_RANGE {0, 10_KB + DEFAULT_ALIGNMENT_IN_BYTES}; constexpr mem_range SECOND_RANGE {DEFAULT_ALIGNMENT_IN_BYTES, DEFAULT_ALIGNMENT_IN_BYTES}; constexpr mem_range THIRD_RANGE {DEFAULT_ALIGNMENT_IN_BYTES, 2 * DEFAULT_ALIGNMENT_IN_BYTES}; diff --git a/runtime/tests/bitmap_test_base.h b/runtime/tests/bitmap_test_base.h index 9e004895e9130786986d701952a421f15e670b07..1c45b3ed861f5fcfda5763683af743e0fd7a90d1 100644 --- a/runtime/tests/bitmap_test_base.h +++ b/runtime/tests/bitmap_test_base.h @@ -23,7 +23,7 @@ namespace panda::mem { class BitmapTest : public testing::Test { public: - static constexpr object_pointer_type HEAP_STARTING_ADDRESS = static_cast(0x10000000); + static constexpr ObjectPointerType HEAP_STARTING_ADDRESS = static_cast(0x10000000); }; using BitmapWordType = panda::mem::Bitmap::BitmapWordType; @@ -88,7 +88,7 @@ static void RunTest(TestFn &&fn) const size_t end = offset + fn_rounddown(std::rand() % (remain + 1), kAlignment); size_t manual = 0; - for (object_pointer_type k = offset; k < end; k += kAlignment) { + for (ObjectPointerType k = offset; k < end; k += kAlignment) { if (bm.Test(ToVoidPtr(heap_begin + k))) { manual++; } @@ -102,7 +102,7 @@ static void RunTest(TestFn &&fn) template static void RunTestCount() { - auto count_test_fn = [](MemBitmap *bitmap, object_pointer_type begin, object_pointer_type end, + auto count_test_fn = [](MemBitmap *bitmap, ObjectPointerType begin, ObjectPointerType end, size_t manual_count) { size_t count = 0; auto count_fn = [&count]([[maybe_unused]] void *obj) { count++; }; @@ -115,7 +115,7 @@ static void RunTestCount() template void RunTestOrder() { - auto order_test_fn = [](MemBitmap *bitmap, object_pointer_type begin, object_pointer_type end, + auto order_test_fn = [](MemBitmap *bitmap, ObjectPointerType begin, ObjectPointerType end, size_t manual_count) { void *last_ptr = nullptr; auto order_check = [&last_ptr](void *obj) { diff --git a/runtime/tests/class_size_test.cpp b/runtime/tests/class_size_test.cpp index 329b9f0f76ac8395485484bc0fe1a4920d99b35b..a88c189566db6457379c48ae555834df7c43a261 100644 --- a/runtime/tests/class_size_test.cpp +++ b/runtime/tests/class_size_test.cpp @@ -26,7 +26,7 @@ namespace panda::test { using TaggedValue = coretypes::TaggedValue; -static constexpr size_t OBJECT_POINTER_SIZE = sizeof(object_pointer_type); +static constexpr size_t OBJECT_POINTER_SIZE = sizeof(ObjectPointerType); static constexpr size_t POINTER_SIZE = ClassHelper::POINTER_SIZE; TEST(ClassSizeTest, TestSizeOfEmptyClass) diff --git a/runtime/tests/debugger_test.cpp b/runtime/tests/debugger_test.cpp index 1d268f18da2954540621c0091bc31da20ce59c4a..53e283c3fc9a76a548ab35ddb3af08a1cd660822 100644 --- a/runtime/tests/debugger_test.cpp +++ b/runtime/tests/debugger_test.cpp @@ -53,12 +53,12 @@ protected: static ObjectHeader *ToPtr(uint64_t v) { - return reinterpret_cast(static_cast(v)); + return reinterpret_cast(static_cast(v)); } static uint64_t FromPtr(ObjectHeader *ptr) { - return static_cast(reinterpret_cast(ptr)); + return static_cast(reinterpret_cast(ptr)); } template diff --git a/runtime/tests/interpreter_test.cpp b/runtime/tests/interpreter_test.cpp index 38126a3ca5789d06720957066a3f0459fb1599d2..4b1556c9fbf31c0daecee52e7dd8493b78a6e1a9 100644 --- a/runtime/tests/interpreter_test.cpp +++ b/runtime/tests/interpreter_test.cpp @@ -877,14 +877,14 @@ struct ArrayStoredTypeHelperT { template <> struct ArrayStoredTypeHelperT { - using type = object_pointer_type; + using type = ObjectPointerType; }; template typename ArrayStoredTypeHelperT::type CastIfRef(ArrayComponentTypeHelperT value) { if constexpr (type_id == panda_file::Type::TypeId::REFERENCE) { - return static_cast(reinterpret_cast(value)); + return static_cast(reinterpret_cast(value)); } else { return value; }