mirror of
https://github.com/holub/mame
synced 2025-04-20 23:42:22 +03:00
-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:
parent
e4588d1f45
commit
bd7f27c6f2
@ -402,14 +402,14 @@ void mips3_device::device_start()
|
||||
if (m_data_bits == 32)
|
||||
{
|
||||
m_program->cache(m_cache32le);
|
||||
m_pr32 = [this](offs_t address) -> u32 { return m_cache32le.read_dword(address); };
|
||||
m_prptr = [this](offs_t address) -> const void * { return m_cache32le.read_ptr(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); };
|
||||
}
|
||||
else
|
||||
{
|
||||
m_program->cache(m_cache64le);
|
||||
m_pr32 = [this](offs_t address) -> u32 { return m_cache64le.read_dword(address); };
|
||||
m_prptr = [this](offs_t address) -> const void * { return m_cache64le.read_ptr(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); };
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -417,14 +417,14 @@ void mips3_device::device_start()
|
||||
if (m_data_bits == 32)
|
||||
{
|
||||
m_program->cache(m_cache32be);
|
||||
m_pr32 = [this](offs_t address) -> u32 { return m_cache32be.read_dword(address); };
|
||||
m_prptr = [this](offs_t address) -> const void * { return m_cache32be.read_ptr(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); };
|
||||
}
|
||||
else
|
||||
{
|
||||
m_program->cache(m_cache64be);
|
||||
m_pr32 = [this](offs_t address) -> u32 { return m_cache64be.read_dword(address); };
|
||||
m_prptr = [this](offs_t address) -> const void * { return m_cache64be.read_ptr(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); };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ protected:
|
||||
|
||||
address_space * m_program;
|
||||
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;
|
||||
uint32_t c_system_clock;
|
||||
uint32_t m_cpu_clock;
|
||||
|
@ -1573,6 +1573,8 @@ private:
|
||||
handler_entry_read <Width, AddrShift> *m_root_read; // decode tree roots
|
||||
handler_entry_write<Width, AddrShift> *m_root_write;
|
||||
|
||||
util::notifier_subscription m_subscription;
|
||||
|
||||
NativeType read_native(offs_t address, 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));
|
||||
@ -2444,18 +2446,19 @@ set(address_space *space, std::pair<void *, void *> rw)
|
||||
m_space = space;
|
||||
m_addrmask = space->addrmask();
|
||||
|
||||
space->add_change_notifier([this](read_or_write mode) {
|
||||
if(u32(mode) & u32(read_or_write::READ)) {
|
||||
m_addrend_r = 0;
|
||||
m_addrstart_r = 1;
|
||||
m_cache_r = nullptr;
|
||||
}
|
||||
if(u32(mode) & u32(read_or_write::WRITE)) {
|
||||
m_addrend_w = 0;
|
||||
m_addrstart_w = 1;
|
||||
m_cache_w = nullptr;
|
||||
}
|
||||
});
|
||||
m_subscription = space->add_change_notifier(
|
||||
[this] (read_or_write mode) {
|
||||
if(u32(mode) & u32(read_or_write::READ)) {
|
||||
m_addrend_r = 0;
|
||||
m_addrstart_r = 1;
|
||||
m_cache_r = nullptr;
|
||||
}
|
||||
if(u32(mode) & u32(read_or_write::WRITE)) {
|
||||
m_addrend_w = 0;
|
||||
m_addrstart_w = 1;
|
||||
m_cache_w = nullptr;
|
||||
}
|
||||
});
|
||||
m_root_read = (handler_entry_read <Width, AddrShift> *)(rw.first);
|
||||
m_root_write = (handler_entry_write<Width, AddrShift> *)(rw.second);
|
||||
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
/// inactive if it is default constructed, reset, transferred away,
|
||||
/// or if the underlying notifier is destructed.
|
||||
/// \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
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user