Merging Runtime into Processor.

This commit is contained in:
Ben Vanik
2015-05-03 22:28:25 -07:00
parent 4c8f3501ad
commit 78921c1a7e
56 changed files with 441 additions and 543 deletions

View File

@@ -16,7 +16,7 @@
namespace xe {
namespace cpu {
class Runtime;
class Processor;
class ThreadState;
} // namespace cpu
} // namespace xe
@@ -205,9 +205,9 @@ typedef struct alignas(64) PPCContext_s {
// Used to shuttle data into externs. Contents volatile.
uint64_t scratch;
// Runtime-specific data pointer. Used on callbacks to get access to the
// Processor-specific data pointer. Used on callbacks to get access to the
// current runtime and its data.
Runtime* runtime;
Processor* processor;
uint8_t* physical_membase;

View File

@@ -13,7 +13,7 @@
#include "xenia/cpu/frontend/ppc_disasm.h"
#include "xenia/cpu/frontend/ppc_emit.h"
#include "xenia/cpu/frontend/ppc_translator.h"
#include "xenia/cpu/runtime.h"
#include "xenia/cpu/processor.h"
namespace xe {
namespace cpu {
@@ -42,7 +42,7 @@ void InitializeIfNeeded() {
void CleanupOnShutdown() {}
PPCFrontend::PPCFrontend(Runtime* runtime) : runtime_(runtime) {
PPCFrontend::PPCFrontend(Processor* processor) : processor_(processor) {
InitializeIfNeeded();
std::unique_ptr<ContextInfo> context_info(
@@ -57,7 +57,7 @@ PPCFrontend::~PPCFrontend() {
translator_pool_.Reset();
}
Memory* PPCFrontend::memory() const { return runtime_->memory(); }
Memory* PPCFrontend::memory() const { return processor_->memory(); }
void CheckGlobalLock(PPCContext* ppc_state, void* arg0, void* arg1) {
ppc_state->scratch = 0x8000;
@@ -78,10 +78,10 @@ void HandleGlobalLock(PPCContext* ppc_state, void* arg0, void* arg1) {
int PPCFrontend::Initialize() {
void* arg0 = reinterpret_cast<void*>(&builtins_.global_lock);
void* arg1 = reinterpret_cast<void*>(&builtins_.global_lock_taken);
builtins_.check_global_lock = runtime_->DefineBuiltin(
builtins_.check_global_lock = processor_->DefineBuiltin(
"CheckGlobalLock", (FunctionInfo::ExternHandler)CheckGlobalLock, arg0,
arg1);
builtins_.handle_global_lock = runtime_->DefineBuiltin(
builtins_.handle_global_lock = processor_->DefineBuiltin(
"HandleGlobalLock", (FunctionInfo::ExternHandler)HandleGlobalLock, arg0,
arg1);

View File

@@ -21,7 +21,7 @@
namespace xe {
namespace cpu {
class Runtime;
class Processor;
} // namespace cpu
} // namespace xe
@@ -40,12 +40,12 @@ struct PPCBuiltins {
class PPCFrontend {
public:
explicit PPCFrontend(Runtime* runtime);
explicit PPCFrontend(Processor* processor);
~PPCFrontend();
int Initialize();
Runtime* runtime() const { return runtime_; }
Processor* processor() const { return processor_; }
Memory* memory() const;
ContextInfo* context_info() const { return context_info_.get(); }
PPCBuiltins* builtins() { return &builtins_; }
@@ -55,7 +55,7 @@ class PPCFrontend {
uint32_t trace_flags, Function** out_function);
private:
Runtime* runtime_;
Processor* processor_;
std::unique_ptr<ContextInfo> context_info_;
PPCBuiltins builtins_;
TypePool<PPCTranslator, PPCFrontend*> translator_pool_;

View File

@@ -18,7 +18,7 @@
#include "xenia/cpu/frontend/ppc_frontend.h"
#include "xenia/cpu/frontend/ppc_instr.h"
#include "xenia/cpu/hir/label.h"
#include "xenia/cpu/runtime.h"
#include "xenia/cpu/processor.h"
#include "xenia/profiling.h"
namespace xe {
@@ -152,9 +152,9 @@ void PPCHIRBuilder::AnnotateLabel(uint32_t address, Label* label) {
}
FunctionInfo* PPCHIRBuilder::LookupFunction(uint32_t address) {
Runtime* runtime = frontend_->runtime();
Processor* processor = frontend_->processor();
FunctionInfo* symbol_info;
if (runtime->LookupFunctionInfo(address, &symbol_info)) {
if (processor->LookupFunctionInfo(address, &symbol_info)) {
return NULL;
}
return symbol_info;

View File

@@ -16,7 +16,7 @@
#include "xenia/base/memory.h"
#include "xenia/cpu/frontend/ppc_frontend.h"
#include "xenia/cpu/frontend/ppc_instr.h"
#include "xenia/cpu/runtime.h"
#include "xenia/cpu/processor.h"
#include "xenia/profiling.h"
#if 0
@@ -35,7 +35,7 @@ PPCScanner::~PPCScanner() {}
bool PPCScanner::IsRestGprLr(uint32_t address) {
FunctionInfo* symbol_info;
if (frontend_->runtime()->LookupFunctionInfo(address, &symbol_info)) {
if (frontend_->processor()->LookupFunctionInfo(address, &symbol_info)) {
return false;
}
return symbol_info->behavior() == FunctionInfo::BEHAVIOR_EPILOG_RETURN;

View File

@@ -20,7 +20,7 @@
#include "xenia/cpu/frontend/ppc_hir_builder.h"
#include "xenia/cpu/frontend/ppc_instr.h"
#include "xenia/cpu/frontend/ppc_scanner.h"
#include "xenia/cpu/runtime.h"
#include "xenia/cpu/processor.h"
#include "xenia/profiling.h"
namespace xe {
@@ -35,11 +35,11 @@ using xe::cpu::compiler::Compiler;
namespace passes = xe::cpu::compiler::passes;
PPCTranslator::PPCTranslator(PPCFrontend* frontend) : frontend_(frontend) {
Backend* backend = frontend->runtime()->backend();
Backend* backend = frontend->processor()->backend();
scanner_.reset(new PPCScanner(frontend));
builder_.reset(new PPCHIRBuilder(frontend));
compiler_.reset(new Compiler(frontend->runtime()));
compiler_.reset(new Compiler(frontend->processor()));
assembler_ = std::move(backend->CreateAssembler());
assembler_->Initialize();

View File

@@ -175,30 +175,30 @@ class TestRunner {
memory.reset(new Memory());
memory->Initialize();
runtime.reset(new Runtime(memory.get(), nullptr, 0, 0));
runtime->Initialize(nullptr);
processor.reset(new Processor(memory.get(), nullptr));
processor->Setup();
}
~TestRunner() {
thread_state.reset();
runtime.reset();
processor.reset();
memory.reset();
}
bool Setup(TestSuite& suite) {
// Load the binary module.
auto module = std::make_unique<xe::cpu::RawModule>(runtime.get());
auto module = std::make_unique<xe::cpu::RawModule>(processor.get());
if (module->LoadFile(START_ADDRESS, suite.bin_file_path)) {
XELOGE("Unable to load test binary %ls", suite.bin_file_path.c_str());
return false;
}
runtime->AddModule(std::move(module));
processor->AddModule(std::move(module));
// Simulate a thread.
uint32_t stack_size = 64 * 1024;
uint32_t stack_address = START_ADDRESS - stack_size;
uint32_t thread_state_address = stack_address - 0x1000;
thread_state.reset(new ThreadState(runtime.get(), 0x100, stack_address,
thread_state.reset(new ThreadState(processor.get(), 0x100, stack_address,
stack_size, thread_state_address));
return true;
@@ -213,7 +213,7 @@ class TestRunner {
// Execute test.
xe::cpu::Function* fn;
runtime->ResolveFunction(test_case.address, &fn);
processor->ResolveFunction(test_case.address, &fn);
if (!fn) {
XELOGE("Entry function not found");
return false;
@@ -313,7 +313,7 @@ class TestRunner {
size_t memory_size;
std::unique_ptr<Memory> memory;
std::unique_ptr<Runtime> runtime;
std::unique_ptr<Processor> processor;
std::unique_ptr<ThreadState> thread_state;
};