summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar couriersud <couriersud@gmx.org>2020-01-18 16:39:49 +0100
committerGravatarGravatar couriersud <couriersud@gmx.org>2020-01-18 16:39:49 +0100
commitf6a7a6fe8822e0c86c521f8a8ea7b3923f923ab6 (patch) (github)
tree02482db2560bb4b5de87ac906a3c60d08ce750f0
parent142f8b0030f34613e159dd7c93188e0160667877 (diff)
downloadmame-f6a7a6fe8822e0c86c521f8a8ea7b3923f923ab6.tar.bz2
mame-f6a7a6fe8822e0c86c521f8a8ea7b3923f923ab6.zip
netlist: Code maintenance. (nw)
Checked and fixed conditional compile paths. Simplified memory allocation. Generalized signal handling.
-rw-r--r--src/lib/netlist/nl_base.h28
-rw-r--r--src/lib/netlist/nl_config.h6
-rw-r--r--src/lib/netlist/plib/palloc.h46
-rw-r--r--src/lib/netlist/plib/pconfig.h2
-rw-r--r--src/lib/netlist/plib/pmempool.h8
-rw-r--r--src/lib/netlist/plib/ppmf.h4
6 files changed, 53 insertions, 41 deletions
diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h
index 625696ddf93..d2ec68800bf 100644
--- a/src/lib/netlist/nl_base.h
+++ b/src/lib/netlist/nl_base.h
@@ -569,17 +569,24 @@ namespace netlist
public plib::linkedlist_t<core_terminal_t>::element_t
{
public:
+ /// \brief Number of signal bits
+ ///
+ /// Going forward setting this to 8 will allow 8-bit signal
+ /// busses to be used in netlist, e.g. for more complex memory
+ /// arrangements.
+ static constexpr const unsigned int INP_BITS = 1;
+ static constexpr const unsigned int INP_MASK = (1 << INP_BITS) - 1;
static constexpr const unsigned int INP_HL_SHIFT = 0;
- static constexpr const unsigned int INP_LH_SHIFT = 1;
+ static constexpr const unsigned int INP_LH_SHIFT = INP_BITS;
enum state_e {
STATE_INP_PASSIVE = 0,
- STATE_INP_HL = (1 << INP_HL_SHIFT),
- STATE_INP_LH = (1 << INP_LH_SHIFT),
+ STATE_INP_HL = (INP_MASK << INP_HL_SHIFT),
+ STATE_INP_LH = (INP_MASK << INP_LH_SHIFT),
STATE_INP_ACTIVE = STATE_INP_HL | STATE_INP_LH,
- STATE_OUT = 128,
- STATE_BIDIR = 256
+ STATE_OUT = (1 << (2*INP_BITS)),
+ STATE_BIDIR = (1 << (2*INP_BITS + 1))
};
core_terminal_t(core_device_t &dev, const pstring &aname,
@@ -590,12 +597,11 @@ namespace netlist
/// \brief The object type.
/// \returns type of the object
-
terminal_type type() const noexcept(false);
+
/// \brief Checks if object is of specified type.
/// \param atype type to check object against.
/// \returns true if object is of specified type else false.
-
bool is_type(const terminal_type atype) const noexcept(false) { return (type() == atype); }
void set_net(net_t *anet) noexcept { m_net = anet; }
@@ -632,7 +638,7 @@ namespace netlist
void set_delegate(const nldelegate &delegate) noexcept { m_delegate = delegate; }
nldelegate &delegate() noexcept { return m_delegate; }
const nldelegate &delegate() const noexcept { return m_delegate; }
- void run_delegate() noexcept { m_delegate(); }
+ inline void run_delegate() noexcept { m_delegate(); }
private:
nldelegate m_delegate;
net_t * m_net;
@@ -762,7 +768,7 @@ namespace netlist
private:
state_var<netlist_sig_t> m_new_Q;
state_var<netlist_sig_t> m_cur_Q;
- state_var<queue_status> m_in_queue; // 0: not in queue, 1: in queue, 2: last was taken
+ state_var<queue_status> m_in_queue;
state_var<netlist_time_ext> m_next_scheduled_time;
core_terminal_t * m_railterminal;
@@ -1858,7 +1864,7 @@ namespace netlist
{
m_next_scheduled_time = exec().time() + delay;
- if (is_queued())
+ if (!!is_queued())
exec().qremove(this);
if (!m_list_active.empty())
@@ -2028,7 +2034,7 @@ namespace netlist
// -----------------------------------------------------------------------------
template <bool KEEP_STATS, typename T>
- inline void detail::net_t::process(const T mask, netlist_sig_t sig) noexcept
+ inline void detail::net_t::process(T mask, netlist_sig_t sig) noexcept
{
m_cur_Q = sig;
diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h
index a918db4d590..0fc82ae4f79 100644
--- a/src/lib/netlist/nl_config.h
+++ b/src/lib/netlist/nl_config.h
@@ -17,11 +17,11 @@
///
/// \brief Version - Minor.
///
-#define NL_VERSION_MINOR 6
+#define NL_VERSION_MINOR 7
///
/// \brief Version - Patch level.
///
-#define NL_VERSION_PATCHLEVEL 0
+#define NL_VERSION_PATCHLEVEL 1
///
/// \addtogroup compiledefine
@@ -61,7 +61,7 @@
/// This approach is stricter and should identify bugs in
/// the netlist core faster.
/// By default it is disabled since it is not as fast as
-/// the default approach. It is up to 10% slower.
+/// the default approach. It is up to 20% slower.
///
#ifndef NL_USE_COPY_INSTEAD_OF_REFERENCE
diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h
index a21fe1b6932..1aa23682ca6 100644
--- a/src/lib/netlist/plib/palloc.h
+++ b/src/lib/netlist/plib/palloc.h
@@ -282,6 +282,9 @@ namespace plib {
static inline void *allocate( size_t alignment, size_t size )
{
+ m_stat_cur_alloc() += size;
+ m_stat_max_alloc() = std::max(m_stat_max_alloc(), m_stat_cur_alloc());
+
#if (PUSE_ALIGNED_ALLOCATION)
#if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER)
return _aligned_malloc(size, alignment);
@@ -302,7 +305,8 @@ namespace plib {
static inline void deallocate( void *ptr, size_t size ) noexcept
{
- unused_var(size);
+ //unused_var(size);
+ m_stat_cur_alloc() -= size;
#if (PUSE_ALIGNED_ALLOCATION)
// NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
free(ptr);
@@ -343,12 +347,32 @@ namespace plib {
}
}
+ template<typename T, typename... Args>
+ static T *alloc(Args&&... args)
+ {
+ auto *p = allocate(alignof(T), sizeof(T));
+ return new(p) T(std::forward<Args>(args)...);
+ }
+
+ template<typename T>
+ static void free(T *ptr) noexcept
+ {
+ ptr->~T();
+ aligned_arena::deallocate(ptr, sizeof(T));
+ }
+
bool operator ==(const aligned_arena &rhs) const noexcept
{
plib::unused_var(rhs);
return true;
}
+ size_type cur_alloc() const noexcept { return m_stat_cur_alloc(); }
+ size_type max_alloc() const noexcept { return m_stat_max_alloc(); }
+ private:
+ static size_t &m_stat_cur_alloc() noexcept { static size_t val = 0; return val; }
+ static size_t &m_stat_max_alloc() noexcept { static size_t val = 0; return val; }
+
};
template <typename T, std::size_t ALIGN>
@@ -378,29 +402,13 @@ namespace plib {
#endif
}
- // FIXME: remove
- template<typename T, typename... Args>
- inline T *pnew(Args&&... args)
- {
- auto *p = aligned_arena::allocate(alignof(T), sizeof(T));
- return new(p) T(std::forward<Args>(args)...);
- }
-
- template<typename T>
- inline void pdelete(T *ptr) noexcept
- {
- ptr->~T();
- aligned_arena::deallocate(ptr, sizeof(T));
- }
-
-
template <typename T>
- using unique_ptr = std::unique_ptr<T, arena_deleter<aligned_arena, T>>;
+ using unique_ptr = aligned_arena::unique_pool_ptr<T>;
template<typename T, typename... Args>
plib::unique_ptr<T> make_unique(Args&&... args)
{
- return plib::unique_ptr<T>(pnew<T>(std::forward<Args>(args)...));
+ return aligned_arena::instance().make_unique<T>(std::forward<Args>(args)...);
}
template <class T, std::size_t ALIGN = alignof(T)>
diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h
index 0870d8c59d5..115eafd2196 100644
--- a/src/lib/netlist/plib/pconfig.h
+++ b/src/lib/netlist/plib/pconfig.h
@@ -25,7 +25,7 @@
/// \brief System supports INT128
///
/// Set this to one if you want to use 128 bit int for ptime.
-/// This is about 15% slower on a kaby lake processor for pongf.
+/// This is about 10% slower on a skylake processor for pongf.
///
#ifndef PHAS_INT128
#define PHAS_INT128 (0)
diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h
index 1e197fdfc82..a06c67acd8e 100644
--- a/src/lib/netlist/plib/pmempool.h
+++ b/src/lib/netlist/plib/pmempool.h
@@ -59,7 +59,7 @@ namespace plib {
plib::perrlogger("Found {} info blocks\n", sinfo().size());
plib::perrlogger("Found block with {} dangling allocations\n", b->m_num_alloc);
}
- plib::pdelete(b);
+ aligned_arena::free(b);
//::operator delete(b->m_data);
}
}
@@ -126,7 +126,7 @@ namespace plib {
plib::terminate("mempool::free - block not found");
mp.m_blocks.erase(itb);
- plib::pdelete(b);
+ aligned_arena::free(b);
}
sinfo().erase(it);
}
@@ -222,15 +222,13 @@ namespace plib {
size_type m_pos;
};
-
block * new_block(size_type min_bytes)
{
- auto *b = plib::pnew<block>(*this, min_bytes);
+ auto *b = aligned_arena::alloc<block>(*this, min_bytes);
m_blocks.push_back(b);
return b;
}
-
static std::unordered_map<void *, info> &sinfo()
{
static std::unordered_map<void *, info> spinfo;
diff --git a/src/lib/netlist/plib/ppmf.h b/src/lib/netlist/plib/ppmf.h
index bbbe95ded05..a9df2f6b4aa 100644
--- a/src/lib/netlist/plib/ppmf.h
+++ b/src/lib/netlist/plib/ppmf.h
@@ -273,7 +273,7 @@ namespace plib {
#endif
}
template<typename O>
- R call(O *obj, Targs... args) const noexcept(true)
+ R call(O *obj, Targs&&... args) const noexcept(true)
{
using function_ptr = MEMBER_ABI R (*)(O *obj, Targs... args);
return (reinterpret_cast<function_ptr>(m_func))(obj, std::forward<Targs>(args)...);
@@ -311,7 +311,7 @@ namespace plib {
m_obj = reinterpret_cast<generic_class *>(object);
}
- inline R operator()(Targs ... args) const noexcept(true)
+ inline R operator()(Targs... args) const noexcept(true)
{
return this->call(m_obj, std::forward<Targs>(args)...);
}