diff --git a/src/core/sal/perf/BreakpointBuffer.cc b/src/core/sal/perf/BreakpointBuffer.cc index be222233..3b60244e 100644 --- a/src/core/sal/perf/BreakpointBuffer.cc +++ b/src/core/sal/perf/BreakpointBuffer.cc @@ -1,13 +1,14 @@ #include "BreakpointBuffer.hpp" #include "../SALInst.hpp" +#include "../Listener.hpp" namespace fail { -// FIXME: can not be inlined this way +// FIXME: Can not be inlined this way! ResultSet& PerfVectorBreakpoints::gather(BPEvent* pData) { static ResultSet res; - res.clear(); + res.clear(); // FIXME: This should not free the memory of the underlying std::vector. // Search for all indices of matching listener objects: for(std::vector::iterator it = m_BufList.begin(); it != m_BufList.end(); ++it) { BPListener* pLi = static_cast(simulator.dereference(*it)); diff --git a/src/core/sal/perf/BreakpointBuffer.hpp b/src/core/sal/perf/BreakpointBuffer.hpp index 7585cf68..9b4537da 100644 --- a/src/core/sal/perf/BreakpointBuffer.hpp +++ b/src/core/sal/perf/BreakpointBuffer.hpp @@ -2,58 +2,19 @@ #define __BREAKPOINT_BUFFER_HPP__ #include "BufferInterface.hpp" -#include "../Listener.hpp" -#include -#include // TODOs: // - Make these implementations even faster (see below: continue PerfVecSortedSingleBP). -// - The implementation of gather() (see below) in BreakpointBuffer.cc (not inlined in -// .hpp) avoids an include cycle. Unfortunately, this may cause a bad performance -// because gather() won't be inlined anymore! (The method is called quite often.) namespace fail { class BPEvent; /** - * \class ResultSet - * - * Results (= indices of matching listeners) returned by the "gather"-method, - * see below. (This class can be seen as a "temporary fire-list".) + * Concrete implementation for the \c BPSingleListener class. */ -class ResultSet { - std::vector m_Res; +class PerfVectorBreakpoints : public DefPerfVector { public: - ResultSet() { } - bool hasMore() const { return !m_Res.empty(); } - index_t getNext() { index_t idx = m_Res.back(); m_Res.pop_back(); return idx; } - void add(index_t idx) { m_Res.push_back(idx); } - size_t size() const { return m_Res.size(); } - void clear() { m_Res.clear(); } -}; - -/** - * Concrete implementation of the PerfBufferBase class for \c std::vector - * and \c BPSingleListener. - */ -class PerfVectorBreakpoints : public PerfBufferBase { -protected: - std::vector m_BufList; -public: - void add(index_t idx) { m_BufList.push_back(idx); } - void remove(index_t idx) - { - for (std::vector::iterator it = m_BufList.begin(); - it != m_BufList.end(); ++it) { - if (*it == idx) { - m_BufList.erase(it); - break; - } - } - } - void clear() { m_BufList.clear(); } - size_t size() const { return m_BufList.size(); } ResultSet& gather(BPEvent* pData); }; diff --git a/src/core/sal/perf/BreakpointManagerSlice.ah b/src/core/sal/perf/BreakpointManagerSlice.ah index 4d7266b9..65753990 100644 --- a/src/core/sal/perf/BreakpointManagerSlice.ah +++ b/src/core/sal/perf/BreakpointManagerSlice.ah @@ -5,7 +5,9 @@ #ifdef CONFIG_FAST_BREAKPOINTS +#include #include "BreakpointBuffer.hpp" +#include "../Listener.hpp" /** * \class BreakpointManagerSlice diff --git a/src/core/sal/perf/BufferInterface.hpp b/src/core/sal/perf/BufferInterface.hpp index 30b73ae5..b1fe622c 100644 --- a/src/core/sal/perf/BufferInterface.hpp +++ b/src/core/sal/perf/BufferInterface.hpp @@ -2,6 +2,7 @@ #define __BUFFER_INTERFACE_HPP__ #include +#include namespace fail { @@ -37,6 +38,50 @@ public: virtual std::size_t size() const = 0; }; +/** + * \class ResultSet + * + * Results (= indices of matching listeners) returned by the "gather"-method, + * see below. (This class can be seen as a "temporary fire-list".) + */ +class ResultSet { +private: + std::vector m_Res; //!< vector of matching listener indices +public: + ResultSet() { } + bool hasMore() const { return !m_Res.empty(); } + index_t getNext() { index_t idx = m_Res.back(); m_Res.pop_back(); return idx; } + void add(index_t idx) { m_Res.push_back(idx); } + size_t size() const { return m_Res.size(); } + void clear() { m_Res.clear(); } +}; + +/** + * \class DefPerfVector + * + * Default \c std::vector based performance implementation (abstract) + */ +template +class DefPerfVector : public PerfBufferBase { +protected: + std::vector m_BufList; //!< the performance buffer-list +public: + void add(index_t idx) { m_BufList.push_back(idx); } + void remove(index_t idx) + { + for (std::vector::iterator it = m_BufList.begin(); + it != m_BufList.end(); ++it) { + if (*it == idx) { + m_BufList.erase(it); + break; + } + } + } + void clear() { m_BufList.clear(); } + size_t size() const { return m_BufList.size(); } + virtual ResultSet& gather(T* pData) = 0; +}; + } // end-of-namespace: fail #endif // __BUFFER_INTERFACE_HPP__