mirror of
https://github.com/holub/mame
synced 2025-05-30 17:41:47 +03:00
Netlist: Some hand-crafted optimizations. GCC seems to like ugly pointer C more than using readable arrays :-( The speedup is noticeable.
This commit is contained in:
parent
539241d2e3
commit
bac6bff9e6
@ -294,39 +294,11 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_timed_queue
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_HOT ATTR_ALIGN void netlist_timed_queue::push(const entry_t &e)
|
||||
{
|
||||
const netlist_time &t = e.time();
|
||||
if (is_empty() || (t <= item(m_end - 1).time()))
|
||||
{
|
||||
set_item(m_end, e);
|
||||
m_end++;
|
||||
inc_stat(m_prof_end);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = m_end;
|
||||
m_end++;
|
||||
while ((i>0) && (t > item(i-1).time()) )
|
||||
{
|
||||
set_item(i, item(i-1));
|
||||
inc_stat(m_prof_sortmove);
|
||||
i--;
|
||||
}
|
||||
set_item(i, e);
|
||||
inc_stat(m_prof_sort);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netdev_mainclock
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_HOT inline void netdev_mainclock::mc_update(net_output_t &Q, const netlist_time &curtime)
|
||||
ATTR_HOT inline void netdev_mainclock::mc_update(net_output_t &Q, const netlist_time curtime)
|
||||
{
|
||||
Q.m_new_Q = !Q.m_new_Q;
|
||||
Q.set_time(curtime);
|
||||
@ -336,7 +308,6 @@ ATTR_HOT inline void netdev_mainclock::mc_update(net_output_t &Q, const netlist_
|
||||
ATTR_COLD NETLIB_START(netdev_mainclock)
|
||||
{
|
||||
register_output("Q", m_Q);
|
||||
//register_input("FB", m_feedback);
|
||||
|
||||
register_param("FREQ", m_freq, 7159000.0 * 5);
|
||||
m_inc = netlist_time::from_hz(m_freq.Value()*2);
|
||||
@ -520,7 +491,7 @@ ATTR_HOT ATTR_ALIGN void netlist_base_t::process_list(INT32 &atime)
|
||||
{
|
||||
while ( (atime > 0) && (m_queue.is_not_empty()))
|
||||
{
|
||||
const queue_t::entry_t &e = m_queue.pop();
|
||||
const queue_t::entry_t e = m_queue.pop();
|
||||
update_time(e.time(), atime);
|
||||
|
||||
if (FATAL_ERROR_AFTER_NS)
|
||||
@ -548,21 +519,21 @@ ATTR_HOT ATTR_ALIGN void netlist_base_t::process_list(INT32 &atime)
|
||||
{
|
||||
if (m_queue.is_not_empty())
|
||||
{
|
||||
while (m_queue.peek().time() > m_mainclock->m_Q.time())
|
||||
while (m_queue.peek().time() > mcQ.time())
|
||||
{
|
||||
update_time(m_mainclock->m_Q.time(), atime);
|
||||
update_time(mcQ.time(), atime);
|
||||
|
||||
netdev_mainclock::mc_update(mcQ, time() + inc);
|
||||
|
||||
}
|
||||
const queue_t::entry_t &e = m_queue.pop();
|
||||
const queue_t::entry_t e = m_queue.pop();
|
||||
|
||||
update_time(e.time(), atime);
|
||||
|
||||
e.object().update_devs();
|
||||
|
||||
} else {
|
||||
update_time(m_mainclock->m_Q.time(), atime);
|
||||
update_time(mcQ.time(), atime);
|
||||
|
||||
netdev_mainclock::mc_update(mcQ, time() + inc);
|
||||
}
|
||||
|
@ -365,25 +365,45 @@ public:
|
||||
clear();
|
||||
}
|
||||
|
||||
ATTR_HOT inline bool is_empty() const { return (m_end == 0); }
|
||||
ATTR_HOT inline bool is_not_empty() const { return (m_end != 0); }
|
||||
ATTR_HOT inline bool is_empty() const { return (m_end == &m_list[0]); }
|
||||
ATTR_HOT inline bool is_not_empty() const { return (m_end > &m_list[0]); }
|
||||
|
||||
ATTR_HOT ATTR_ALIGN void push(const entry_t &e);
|
||||
|
||||
ATTR_HOT inline const entry_t &pop()
|
||||
ATTR_HOT ATTR_ALIGN inline void push(const entry_t &e)
|
||||
{
|
||||
m_end--;
|
||||
return item(m_end);
|
||||
if (is_empty() || (e.time() <= (m_end - 1)->time()))
|
||||
{
|
||||
*m_end = e;
|
||||
m_end++;
|
||||
//inc_stat(m_prof_end);
|
||||
}
|
||||
else
|
||||
{
|
||||
entry_t *i = m_end++;
|
||||
while ((i>&m_list[0]) && (e.time() > (i-1)->time()) )
|
||||
{
|
||||
i--;
|
||||
*(i+1) = *i;
|
||||
//inc_stat(m_prof_sortmove);
|
||||
}
|
||||
*i = e;
|
||||
//inc_stat(m_prof_sort);
|
||||
}
|
||||
}
|
||||
|
||||
ATTR_HOT inline const entry_t &peek() const
|
||||
ATTR_HOT inline const entry_t pop()
|
||||
{
|
||||
return item(m_end-1);
|
||||
m_end--;
|
||||
return *m_end;
|
||||
}
|
||||
|
||||
ATTR_HOT inline const entry_t peek() const
|
||||
{
|
||||
return *(m_end-1);
|
||||
}
|
||||
|
||||
ATTR_COLD void clear()
|
||||
{
|
||||
m_end = 0;
|
||||
m_end = &m_list[0];
|
||||
}
|
||||
// profiling
|
||||
|
||||
@ -392,10 +412,8 @@ public:
|
||||
INT32 m_prof_sortmove;
|
||||
INT32 m_prof_sort;
|
||||
private:
|
||||
ATTR_HOT inline const entry_t &item(const UINT32 x) const { return m_list[x]; }
|
||||
ATTR_HOT inline void set_item(const UINT32 x, const entry_t &aitem) { m_list[x] = aitem; }
|
||||
|
||||
UINT32 m_end;
|
||||
entry_t *m_end;
|
||||
entry_t m_list[SIZE + 1];
|
||||
|
||||
};
|
||||
@ -1188,7 +1206,7 @@ NETLIB_DEVICE_WITH_PARAMS(netdev_mainclock,
|
||||
net_param_t m_freq;
|
||||
netlist_time m_inc;
|
||||
|
||||
ATTR_HOT inline static void mc_update(net_output_t &Q, const netlist_time &curtime);
|
||||
ATTR_HOT inline static void mc_update(net_output_t &Q, const netlist_time curtime);
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user