Adding mmap for code cache and exposing cache properties.

This commit is contained in:
Ben Vanik
2015-06-16 20:13:39 -07:00
parent c34db170f5
commit 5f33087a12
8 changed files with 80 additions and 13 deletions

View File

@@ -10,27 +10,31 @@
#ifndef XENIA_BACKEND_X64_X64_CODE_CACHE_H_
#define XENIA_BACKEND_X64_X64_CODE_CACHE_H_
// For RUNTIME_FUNCTION:
#include "xenia/base/platform.h"
#include <atomic>
#include <mutex>
#include <string>
#include <vector>
#include "xenia/base/mutex.h"
#include "xenia/base/platform.h"
#include "xenia/cpu/backend/code_cache.h"
namespace xe {
namespace cpu {
namespace backend {
namespace x64 {
class X64CodeCache {
class X64CodeCache : public CodeCache {
public:
X64CodeCache();
virtual ~X64CodeCache();
~X64CodeCache() override;
bool Initialize();
std::wstring file_name() const override { return file_name_; }
uint32_t base_address() const override { return kGeneratedCodeBase; }
uint32_t total_size() const override { return kGeneratedCodeSize; }
// TODO(benvanik): ELF serialization/etc
// TODO(benvanik): keep track of code blocks
// TODO(benvanik): padding/guards/etc
@@ -55,6 +59,9 @@ class X64CodeCache {
size_t unwind_table_slot, uint8_t* code_address,
size_t code_size, size_t stack_size);
std::wstring file_name_;
HANDLE mapping_;
// Must be held when manipulating the offsets or counts of anything, to keep
// the tables consistent and ordered.
xe::mutex allocation_mutex_;