mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
netlist: Reduce memory allocation calls in non-core code. (nw)
This commit is contained in:
parent
011a8261eb
commit
4af78838ad
@ -629,7 +629,7 @@ netlist::setup_t &netlist_mame_device::setup()
|
||||
|
||||
void netlist_mame_device::register_memregion_source(netlist::nlparse_t &setup, device_t &dev, const char *name)
|
||||
{
|
||||
setup.register_source(plib::make_unique<netlist_source_memregion_t>(dev, pstring(name)));
|
||||
setup.register_source<netlist_source_memregion_t>(dev, pstring(name));
|
||||
}
|
||||
|
||||
void netlist_mame_analog_input_device::write(const double val)
|
||||
@ -1095,7 +1095,7 @@ void netlist_mame_device::common_dev_start(netlist::netlist_state_t *lnetlist) c
|
||||
|
||||
/* add default data provider for roms - if not in validity check*/
|
||||
//if (has_running_machine())
|
||||
lsetup.register_source(plib::make_unique<netlist_data_memregions_t>(*this));
|
||||
lsetup.register_source<netlist_data_memregions_t>(*this);
|
||||
|
||||
m_setup_func(lsetup);
|
||||
|
||||
@ -1324,7 +1324,7 @@ void netlist_mame_cpu_device::device_start()
|
||||
|
||||
void netlist_mame_cpu_device::nl_register_devices(netlist::setup_t &lsetup) const
|
||||
{
|
||||
lsetup.factory().register_device<nld_analog_callback>( "NETDEV_CALLBACK", "nld_analog_callback", "-");
|
||||
lsetup.factory().register_device<nld_analog_callback>( "NETDEV_CALLBACK", "nld_analog_callback", "-", __FILE__);
|
||||
}
|
||||
|
||||
uint64_t netlist_mame_cpu_device::execute_clocks_to_cycles(uint64_t clocks) const noexcept
|
||||
@ -1477,8 +1477,8 @@ void netlist_mame_sound_device::device_start()
|
||||
|
||||
void netlist_mame_sound_device::nl_register_devices(netlist::setup_t &lsetup) const
|
||||
{
|
||||
lsetup.factory().register_device<nld_sound_out>("NETDEV_SOUND_OUT", "nld_sound_out", "+CHAN");
|
||||
lsetup.factory().register_device<nld_sound_in>("NETDEV_SOUND_IN", "nld_sound_in", "-");
|
||||
lsetup.factory().register_device<nld_sound_out>("NETDEV_SOUND_OUT", "nld_sound_out", "+CHAN", __FILE__);
|
||||
lsetup.factory().register_device<nld_sound_in>("NETDEV_SOUND_IN", "nld_sound_in", "-", __FILE__);
|
||||
}
|
||||
|
||||
void netlist_mame_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
|
||||
|
@ -245,7 +245,7 @@ namespace devices
|
||||
: truthtable_base_element_t(name, classname, def_param, sourcefile)
|
||||
{ }
|
||||
|
||||
unique_pool_ptr<device_t> Create(nlmempool &pool, netlist_state_t &anetlist, const pstring &name) override
|
||||
unique_pool_ptr<device_t> make_device(nlmempool &pool, netlist_state_t &anetlist, const pstring &name) override
|
||||
{
|
||||
using tt_type = nld_truthtable_t<m_NI, m_NO>;
|
||||
|
||||
|
@ -227,7 +227,7 @@ namespace netlist
|
||||
"#define IND_U(ind) ((ind) * 1e-6) \n"
|
||||
"#define IND_N(ind) ((ind) * 1e-9) \n"
|
||||
"#define IND_P(ind) ((ind) * 1e-12) \n";
|
||||
setup().add_include(plib::make_unique<a>("netlist/devices/net_lib.h", content));
|
||||
setup().add_include<a>("netlist/devices/net_lib.h", content);
|
||||
NETLIST_NAME(base)(*m_setup);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ namespace factory {
|
||||
// factory_lib_entry_t: factory class to wrap macro based chips/elements
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
unique_pool_ptr<device_t> library_element_t::Create(nlmempool &pool, netlist_state_t &anetlist, const pstring &name)
|
||||
unique_pool_ptr<device_t> library_element_t::make_device(nlmempool &pool, netlist_state_t &anetlist, const pstring &name)
|
||||
{
|
||||
return pool.make_unique<NETLIB_NAME(wrapper)>(anetlist, name);
|
||||
}
|
||||
|
@ -27,7 +27,8 @@
|
||||
static plib::unique_ptr<factory::element_t> NETLIB_NAME(p_alias ## _c) \
|
||||
(const pstring &classname) \
|
||||
{ \
|
||||
return plib::make_unique<factory::device_element_t<ns :: NETLIB_NAME(chip)>>(p_name, classname, p_def_param, __FILE__); \
|
||||
using devtype = factory::device_element_t<ns :: NETLIB_NAME(chip)>; \
|
||||
return devtype::create(p_name, classname, p_def_param, __FILE__); \
|
||||
} \
|
||||
\
|
||||
factory::constructor_ptr_t decl_ ## p_alias = NETLIB_NAME(p_alias ## _c);
|
||||
@ -54,7 +55,7 @@ namespace factory {
|
||||
|
||||
COPYASSIGNMOVE(element_t, default)
|
||||
|
||||
virtual unique_pool_ptr<device_t> Create(nlmempool &pool,
|
||||
virtual unique_pool_ptr<device_t> make_device(nlmempool &pool,
|
||||
netlist_state_t &anetlist,
|
||||
const pstring &name) = 0;
|
||||
|
||||
@ -87,12 +88,19 @@ namespace factory {
|
||||
const pstring &def_param, const pstring &sourcefile)
|
||||
: element_t(name, classname, def_param, sourcefile) { }
|
||||
|
||||
unique_pool_ptr<device_t> Create(nlmempool &pool,
|
||||
unique_pool_ptr<device_t> make_device(nlmempool &pool,
|
||||
netlist_state_t &anetlist,
|
||||
const pstring &name) override
|
||||
{
|
||||
return pool.make_unique<C>(anetlist, name);
|
||||
}
|
||||
|
||||
static plib::unique_ptr<device_element_t<C>> create(const pstring &name,
|
||||
const pstring &classname, const pstring &def_param,
|
||||
const pstring &sourcefile)
|
||||
{
|
||||
return plib::make_unique<device_element_t<C>>(name, classname, def_param, sourcefile);
|
||||
}
|
||||
};
|
||||
|
||||
class list_t : public std::vector<plib::unique_ptr<element_t>>
|
||||
@ -105,9 +113,9 @@ namespace factory {
|
||||
|
||||
template<class device_class>
|
||||
void register_device(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
const pstring &def_param, const pstring &sourcefile)
|
||||
{
|
||||
register_device(plib::make_unique<device_element_t<device_class>>(name, classname, def_param));
|
||||
register_device(device_element_t<device_class>::create(name, classname, def_param, sourcefile));
|
||||
}
|
||||
|
||||
void register_device(plib::unique_ptr<element_t> &&factory) noexcept(false);
|
||||
@ -151,7 +159,7 @@ namespace factory {
|
||||
{
|
||||
}
|
||||
|
||||
unique_pool_ptr<device_t> Create(nlmempool &pool,
|
||||
unique_pool_ptr<device_t> make_device(nlmempool &pool,
|
||||
netlist_state_t &anetlist,
|
||||
const pstring &name) override;
|
||||
|
||||
|
@ -973,7 +973,7 @@ void setup_t::register_dynamic_log_devices(const std::vector<pstring> &loglist)
|
||||
for (const pstring &ll : loglist)
|
||||
{
|
||||
pstring name = "log_" + ll;
|
||||
auto nc = factory().factory_by_name("LOG")->Create(m_nlstate.pool(), m_nlstate, name);
|
||||
auto nc = factory().factory_by_name("LOG")->make_device(m_nlstate.pool(), m_nlstate, name);
|
||||
register_link(name + ".I", ll);
|
||||
log().debug(" dynamic link {1}: <{2}>\n",ll, name);
|
||||
m_nlstate.register_device(nc->name(), std::move(nc));
|
||||
@ -1217,7 +1217,7 @@ void setup_t::prepare_to_run()
|
||||
if ( factory().is_class<devices::NETLIB_NAME(solver)>(e.second)
|
||||
|| factory().is_class<devices::NETLIB_NAME(netlistparams)>(e.second))
|
||||
{
|
||||
m_nlstate.register_device(e.first, e.second->Create(nlstate().pool(), m_nlstate, e.first));
|
||||
m_nlstate.register_device(e.first, e.second->make_device(nlstate().pool(), m_nlstate, e.first));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1239,7 +1239,7 @@ void setup_t::prepare_to_run()
|
||||
if ( !factory().is_class<devices::NETLIB_NAME(solver)>(e.second)
|
||||
&& !factory().is_class<devices::NETLIB_NAME(netlistparams)>(e.second))
|
||||
{
|
||||
auto dev = e.second->Create(m_nlstate.pool(), m_nlstate, e.first);
|
||||
auto dev = e.second->make_device(m_nlstate.pool(), m_nlstate, e.first);
|
||||
m_nlstate.register_device(dev->name(), std::move(dev));
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ void NETLIST_NAME(name)(netlist::nlparse_t &setup) \
|
||||
#define NETLIST_END() }
|
||||
|
||||
#define LOCAL_SOURCE(name) \
|
||||
setup.register_source(plib::make_unique<netlist::source_proc_t>(# name, &NETLIST_NAME(name)));
|
||||
setup.register_source<netlist::source_proc_t>(# name, &NETLIST_NAME(name));
|
||||
|
||||
#define LOCAL_LIB_ENTRY(name) \
|
||||
LOCAL_SOURCE(name) \
|
||||
@ -277,8 +277,12 @@ namespace netlist
|
||||
void register_frontier(const pstring &attach, const pstring &r_IN, const pstring &r_OUT);
|
||||
|
||||
// register a source
|
||||
void register_source(plib::unique_ptr<plib::psource_t> &&src)
|
||||
template <typename S, typename... Args>
|
||||
void register_source(Args&&... args)
|
||||
{
|
||||
static_assert(std::is_base_of<plib::psource_t, S>::value, "S must inherit from plib::psource_t");
|
||||
|
||||
auto src(plib::make_unique<S>(std::forward<Args>(args)...));
|
||||
m_sources.add_source(std::move(src));
|
||||
}
|
||||
|
||||
@ -305,9 +309,13 @@ namespace netlist
|
||||
// FIXME: used by source_t - need a different approach at some time
|
||||
bool parse_stream(plib::psource_t::stream_ptr &&istrm, const pstring &name);
|
||||
|
||||
void add_include(plib::unique_ptr<plib::psource_t> &&inc)
|
||||
template <typename S, typename... Args>
|
||||
void add_include(Args&&... args)
|
||||
{
|
||||
m_includes.add_source(std::move(inc));
|
||||
static_assert(std::is_base_of<plib::psource_t, S>::value, "S must inherit from plib::psource_t");
|
||||
|
||||
auto src(plib::make_unique<S>(std::forward<Args>(args)...));
|
||||
m_includes.add_source(std::move(src));
|
||||
}
|
||||
|
||||
void add_define(const pstring &def, const pstring &val)
|
||||
|
@ -216,7 +216,7 @@ public:
|
||||
setup().add_define(d);
|
||||
|
||||
for (const auto & r : roms)
|
||||
setup().register_source(plib::make_unique<netlist_data_folder_t>(r));
|
||||
setup().register_source<netlist_data_folder_t>(r);
|
||||
|
||||
#if 0
|
||||
using a = plib::psource_str_t<plib::psource_t>;
|
||||
@ -237,9 +237,9 @@ public:
|
||||
#endif
|
||||
#endif
|
||||
for (const auto & i : includes)
|
||||
setup().add_include(plib::make_unique<netlist_data_folder_t>(i));
|
||||
setup().add_include<netlist_data_folder_t>(i);
|
||||
|
||||
setup().register_source(plib::make_unique<netlist::source_file_t>(filename));
|
||||
setup().register_source<netlist::source_file_t>(filename);
|
||||
setup().include(name);
|
||||
setup().register_dynamic_log_devices(logs);
|
||||
|
||||
@ -720,7 +720,7 @@ void tool_app_t::create_header()
|
||||
nt.log().verbose.set_enabled(false);
|
||||
nt.log().info.set_enabled(false);
|
||||
|
||||
nt.setup().register_source(plib::make_unique<netlist::source_proc_t>("dummy", &netlist_dummy));
|
||||
nt.setup().register_source<netlist::source_proc_t>("dummy", &netlist_dummy);
|
||||
nt.setup().include("dummy");
|
||||
|
||||
pout("// license:GPL-2.0+\n");
|
||||
@ -761,7 +761,7 @@ void tool_app_t::create_docheader()
|
||||
nt.log().verbose.set_enabled(false);
|
||||
nt.log().info.set_enabled(false);
|
||||
|
||||
nt.setup().register_source(plib::make_unique<netlist::source_proc_t>("dummy", &netlist_dummy));
|
||||
nt.setup().register_source<netlist::source_proc_t>("dummy", &netlist_dummy);
|
||||
nt.setup().include("dummy");
|
||||
|
||||
std::vector<pstring> devs;
|
||||
@ -885,7 +885,7 @@ void tool_app_t::listdevices()
|
||||
|
||||
netlist::factory::list_t &list = nt.setup().factory();
|
||||
|
||||
nt.setup().register_source(plib::make_unique<netlist::source_proc_t>("dummy", &netlist_dummy));
|
||||
nt.setup().register_source<netlist::source_proc_t>("dummy", &netlist_dummy);
|
||||
nt.setup().include("dummy");
|
||||
nt.setup().prepare_to_run();
|
||||
|
||||
@ -896,7 +896,7 @@ void tool_app_t::listdevices()
|
||||
pstring out = plib::pfmt("{1:-20} {2}(<id>")(f->classname())(f->name());
|
||||
|
||||
f->macro_actions(nt.setup(), f->name() + "_lc");
|
||||
auto d = f->Create(nt.pool(), nt, f->name() + "_lc");
|
||||
auto d = f->make_device(nt.pool(), nt, f->name() + "_lc");
|
||||
// get the list of terminals ...
|
||||
|
||||
std::vector<pstring> terms(nt.setup().get_terminals_for_device_name(d->name()));
|
||||
|
Loading…
Reference in New Issue
Block a user