-emu/emumem.h: Hold onto memory cache handler change subscriptions.

-cpu/mips: Replaced a std::function with a marginally more efficient delegate.
This commit is contained in:
Vas Crabb 2022-02-14 01:40:31 +11:00
parent e4588d1f45
commit bd7f27c6f2
4 changed files with 25 additions and 22 deletions

View File

@ -402,14 +402,14 @@ void mips3_device::device_start()
if (m_data_bits == 32) if (m_data_bits == 32)
{ {
m_program->cache(m_cache32le); m_program->cache(m_cache32le);
m_pr32 = [this](offs_t address) -> u32 { return m_cache32le.read_dword(address); }; m_pr32 = delegate<u32 (offs_t)>(&memory_access<32, 2, 0, ENDIANNESS_LITTLE>::cache::read_dword, &m_cache32le);
m_prptr = [this](offs_t address) -> const void * { return m_cache32le.read_ptr(address); }; m_prptr = [this] (offs_t address) -> const void * { return m_cache32le.read_ptr(address); };
} }
else else
{ {
m_program->cache(m_cache64le); m_program->cache(m_cache64le);
m_pr32 = [this](offs_t address) -> u32 { return m_cache64le.read_dword(address); }; m_pr32 = delegate<u32 (offs_t)>(&memory_access<32, 3, 0, ENDIANNESS_LITTLE>::cache::read_dword, &m_cache64le);
m_prptr = [this](offs_t address) -> const void * { return m_cache64le.read_ptr(address); }; m_prptr = [this] (offs_t address) -> const void * { return m_cache64le.read_ptr(address); };
} }
} }
else else
@ -417,14 +417,14 @@ void mips3_device::device_start()
if (m_data_bits == 32) if (m_data_bits == 32)
{ {
m_program->cache(m_cache32be); m_program->cache(m_cache32be);
m_pr32 = [this](offs_t address) -> u32 { return m_cache32be.read_dword(address); }; m_pr32 = delegate<u32 (offs_t)>(&memory_access<32, 2, 0, ENDIANNESS_BIG>::cache::read_dword, &m_cache32be);
m_prptr = [this](offs_t address) -> const void * { return m_cache32be.read_ptr(address); }; m_prptr = [this] (offs_t address) -> const void * { return m_cache32be.read_ptr(address); };
} }
else else
{ {
m_program->cache(m_cache64be); m_program->cache(m_cache64be);
m_pr32 = [this](offs_t address) -> u32 { return m_cache64be.read_dword(address); }; m_pr32 = delegate<u32 (offs_t)>(&memory_access<32, 3, 0, ENDIANNESS_BIG>::cache::read_dword, &m_cache64be);
m_prptr = [this](offs_t address) -> const void * { return m_cache64be.read_ptr(address); }; m_prptr = [this] (offs_t address) -> const void * { return m_cache64be.read_ptr(address); };
} }
} }

View File

@ -431,7 +431,7 @@ protected:
address_space * m_program; address_space * m_program;
uint32_t m_data_bits; uint32_t m_data_bits;
std::function<u32(offs_t)> m_pr32; delegate<u32 (offs_t)> m_pr32;
std::function<const void * (offs_t)> m_prptr; std::function<const void * (offs_t)> m_prptr;
uint32_t c_system_clock; uint32_t c_system_clock;
uint32_t m_cpu_clock; uint32_t m_cpu_clock;

View File

@ -1573,6 +1573,8 @@ private:
handler_entry_read <Width, AddrShift> *m_root_read; // decode tree roots handler_entry_read <Width, AddrShift> *m_root_read; // decode tree roots
handler_entry_write<Width, AddrShift> *m_root_write; handler_entry_write<Width, AddrShift> *m_root_write;
util::notifier_subscription m_subscription;
NativeType read_native(offs_t address, NativeType mask = ~NativeType(0)); NativeType read_native(offs_t address, NativeType mask = ~NativeType(0));
void write_native(offs_t address, NativeType data, NativeType mask = ~NativeType(0)); void write_native(offs_t address, NativeType data, NativeType mask = ~NativeType(0));
std::pair<NativeType, u16> read_native_flags(offs_t address, NativeType mask = ~NativeType(0)); std::pair<NativeType, u16> read_native_flags(offs_t address, NativeType mask = ~NativeType(0));
@ -2444,18 +2446,19 @@ set(address_space *space, std::pair<void *, void *> rw)
m_space = space; m_space = space;
m_addrmask = space->addrmask(); m_addrmask = space->addrmask();
space->add_change_notifier([this](read_or_write mode) { m_subscription = space->add_change_notifier(
if(u32(mode) & u32(read_or_write::READ)) { [this] (read_or_write mode) {
m_addrend_r = 0; if(u32(mode) & u32(read_or_write::READ)) {
m_addrstart_r = 1; m_addrend_r = 0;
m_cache_r = nullptr; m_addrstart_r = 1;
} m_cache_r = nullptr;
if(u32(mode) & u32(read_or_write::WRITE)) { }
m_addrend_w = 0; if(u32(mode) & u32(read_or_write::WRITE)) {
m_addrstart_w = 1; m_addrend_w = 0;
m_cache_w = nullptr; m_addrstart_w = 1;
} m_cache_w = nullptr;
}); }
});
m_root_read = (handler_entry_read <Width, AddrShift> *)(rw.first); m_root_read = (handler_entry_read <Width, AddrShift> *)(rw.first);
m_root_write = (handler_entry_write<Width, AddrShift> *)(rw.second); m_root_write = (handler_entry_write<Width, AddrShift> *)(rw.second);

View File

@ -91,7 +91,7 @@ public:
/// inactive if it is default constructed, reset, transferred away, /// inactive if it is default constructed, reset, transferred away,
/// or if the underlying notifier is destructed. /// or if the underlying notifier is destructed.
/// \return True if the subscription is active, false otherwise. /// \return True if the subscription is active, false otherwise.
explicit operator bool() const noexcept { return bool(m_token.lock()); } explicit operator bool() const noexcept { return !m_token.expired(); }
/// \brief Transfer ownership of a subscription /// \brief Transfer ownership of a subscription
/// ///