fast-breakpoints: created template class DefPerfVector, realizing the buffer interface. Modified PerfVectorBreakpoints appropriately.

This is useful to reuse the DefPerfVector class for fast-watchpoints, too.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1898 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
adrian
2012-11-08 13:18:40 +00:00
parent 148b0bb483
commit 4a6b576b18
4 changed files with 52 additions and 43 deletions

View File

@ -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<index_t>::iterator it = m_BufList.begin(); it != m_BufList.end(); ++it) {
BPListener* pLi = static_cast<BPListener*>(simulator.dereference(*it));

View File

@ -2,58 +2,19 @@
#define __BREAKPOINT_BUFFER_HPP__
#include "BufferInterface.hpp"
#include "../Listener.hpp"
#include <cassert>
#include <vector>
// 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<index_t> m_Res;
class PerfVectorBreakpoints : public DefPerfVector<BPEvent> {
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<index_t> m_BufList;
public:
void add(index_t idx) { m_BufList.push_back(idx); }
void remove(index_t idx)
{
for (std::vector<index_t>::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);
};

View File

@ -5,7 +5,9 @@
#ifdef CONFIG_FAST_BREAKPOINTS
#include <cassert>
#include "BreakpointBuffer.hpp"
#include "../Listener.hpp"
/**
* \class BreakpointManagerSlice

View File

@ -2,6 +2,7 @@
#define __BUFFER_INTERFACE_HPP__
#include <cstddef>
#include <vector>
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<index_t> 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 T>
class DefPerfVector : public PerfBufferBase {
protected:
std::vector<index_t> 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<index_t>::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__