Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor vm additions #5002

Merged
merged 4 commits into from
Aug 18, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions rpcs3/Emu/Memory/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ namespace vm
}

reader_lock::reader_lock()
: locked(true)
{
auto cpu = get_current_cpu_thread();

Expand All @@ -175,12 +174,27 @@ namespace vm

reader_lock::~reader_lock()
{
if (locked)
if (m_upgraded)
{
g_mutex.unlock();
}
else
{
g_mutex.unlock_shared();
}
}

void reader_lock::upgrade()
{
if (m_upgraded)
{
return;
}

g_mutex.lock_upgrade();
m_upgraded = true;
}

writer_lock::writer_lock(int full)
: locked(true)
{
Expand Down Expand Up @@ -801,7 +815,7 @@ namespace vm
{
vm::writer_lock lock(0);

for (auto it = g_locations.begin(); it != g_locations.end(); it++)
for (auto it = g_locations.begin() + memory_location_max; it != g_locations.end(); it++)
{
if (*it && (*it)->addr == addr)
{
Expand Down Expand Up @@ -844,15 +858,13 @@ namespace vm
{
if (location == vm::user64k || location == vm::user1m)
{
g_mutex.lock_upgrade();
lock.upgrade();

if (!loc)
{
// Deferred allocation
loc = _find_map(0x10000000, 0x10000000, location == vm::user64k ? 0x201 : 0x401);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to remove this ternary op

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and change base on _find_map back to 0x30.. (github doesnt let me comment on that line).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing them won't change anything...

Copy link
Member Author

@Nekotekina Nekotekina Aug 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both vm::user locs are "weak" - their exact address is either dynamic or undocumented, but that's enough to classify them differently. Other areas are hardcoded really hard. And _find_map only needs to start at the end of vm::main. Inbetween lies "uncertain" area which can be adjusted from the outside. That's how I see it.

}

g_mutex.lock_degrade();
}
}

Expand Down Expand Up @@ -881,7 +893,7 @@ namespace vm
g_locations =
{
std::make_shared<block_t>(0x00010000, 0x1FFF0000), // main
nullptr, // user 64k pages
std::make_shared<block_t>(0x20000000, 0x10000000, 0x201), // user 64k pages
nullptr, // user 1m pages
std::make_shared<block_t>(0xC0000000, 0x10000000), // video
std::make_shared<block_t>(0xD0000000, 0x10000000), // stack
Expand Down
7 changes: 4 additions & 3 deletions rpcs3/Emu/Memory/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,16 @@ namespace vm
void temporary_unlock(cpu_thread& cpu) noexcept;
void temporary_unlock() noexcept;

struct reader_lock final
class reader_lock final
{
const bool locked;
bool m_upgraded = false;

public:
reader_lock(const reader_lock&) = delete;
reader_lock();
~reader_lock();

explicit operator bool() const { return locked; }
void upgrade();
};

struct writer_lock final
Expand Down