From 99bdc27be323d4bd14e5d13efaffd8fdcba65c5e Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 15 May 2022 14:26:55 -0400 Subject: [PATCH] Internals: Cleanup some statics, trivial part towards (#3419) --- include/verilated_cov.cpp | 4 ---- include/verilated_profiler.h | 2 +- include/verilated_types.h | 4 ++-- include/verilated_vpi.cpp | 7 ++++--- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index bb1893fd8..fb0609be5 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -123,10 +123,6 @@ public: protected: friend class VerilatedCovContext; virtual ~VerilatedCovImp() override { clearGuts(); } - static VerilatedCovImp& imp() VL_MT_SAFE { - static VerilatedCovImp s_singleton; - return s_singleton; - } private: // PRIVATE METHODS diff --git a/include/verilated_profiler.h b/include/verilated_profiler.h index b85bd0eb5..d47be4da4 100644 --- a/include/verilated_profiler.h +++ b/include/verilated_profiler.h @@ -228,7 +228,7 @@ void VlPgoProfiler::write(const char* modelp, const std::string& file // So when we have multiple models in an executable, possibly even // running on different threads, each will have a different symtab so // each will collect is own data correctly. However when each is - // destroid we need to get all the data, not keep overwriting and only + // destroyed we need to get all the data, not keep overwriting and only // get the last model's data. static bool s_firstCall = true; diff --git a/include/verilated_types.h b/include/verilated_types.h index 8e8da1941..d45477d00 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -289,7 +289,7 @@ public: // Can't just overload operator[] or provide a "at" reference to set, // because we need to be able to insert only when the value is set T_Value& at(int32_t index) { - static T_Value s_throwAway; + static VL_THREAD_LOCAL T_Value s_throwAway; // Needs to work for dynamic arrays, so does not use T_MaxSize if (VL_UNLIKELY(index < 0 || index >= m_deque.size())) { s_throwAway = atDefault(); @@ -300,7 +300,7 @@ public: } // Accessing. Verilog: v = assoc[index] const T_Value& at(int32_t index) const { - static T_Value s_throwAway; + static VL_THREAD_LOCAL T_Value s_throwAway; // Needs to work for dynamic arrays, so does not use T_MaxSize if (VL_UNLIKELY(index < 0 || index >= m_deque.size())) { return atDefault(); diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 479a9cb59..277230720 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -81,8 +81,9 @@ public: // To simplify our free list, we use a size large enough for all derived types // We reserve word zero for the next pointer, as that's safer in case a // dangling reference to the original remains around. - static const size_t chunk = 96; - if (VL_UNCOVERABLE(size > chunk)) VL_FATAL_MT(__FILE__, __LINE__, "", "increase chunk"); + static constexpr size_t CHUNK_SIZE = 96; + if (VL_UNCOVERABLE(size > CHUNK_SIZE)) + VL_FATAL_MT(__FILE__, __LINE__, "", "increase CHUNK_SIZE"); if (VL_LIKELY(t_freeHead)) { uint8_t* const newp = t_freeHead; t_freeHead = *(reinterpret_cast(newp)); @@ -90,7 +91,7 @@ public: return newp + 8; } // +8: 8 bytes for next - uint8_t* newp = reinterpret_cast(::operator new(chunk + 8)); + uint8_t* newp = reinterpret_cast(::operator new(CHUNK_SIZE + 8)); *(reinterpret_cast(newp)) = activeMagic(); return newp + 8; }