Initial libjit skeleton.
Not currently generating instructions, but most of the flow is right up to that point. A lot of work required to refactor the emitter, but wanted to get this checked in.
This commit is contained in:
@@ -22,8 +22,9 @@ using namespace xe::kernel;
|
||||
|
||||
RawSymbolDatabase::RawSymbolDatabase(
|
||||
xe_memory_ref memory, ExportResolver* export_resolver,
|
||||
SymbolTable* sym_table,
|
||||
uint32_t start_address, uint32_t end_address) :
|
||||
SymbolDatabase(memory, export_resolver) {
|
||||
SymbolDatabase(memory, export_resolver, sym_table) {
|
||||
start_address_ = start_address;
|
||||
end_address_ = end_address;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ class RawSymbolDatabase : public SymbolDatabase {
|
||||
public:
|
||||
RawSymbolDatabase(xe_memory_ref memory,
|
||||
kernel::ExportResolver* export_resolver,
|
||||
SymbolTable* sym_table,
|
||||
uint32_t start_address, uint32_t end_address);
|
||||
virtual ~RawSymbolDatabase();
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
'symbol.h',
|
||||
'symbol_database.cc',
|
||||
'symbol_database.h',
|
||||
'symbol_table.cc',
|
||||
'symbol_table.h',
|
||||
'xex_symbol_database.cc',
|
||||
'xex_symbol_database.h',
|
||||
]
|
||||
|
||||
@@ -57,7 +57,8 @@ FunctionSymbol::FunctionSymbol() :
|
||||
Symbol(Function),
|
||||
start_address(0), end_address(0),
|
||||
type(Unknown), flags(0),
|
||||
kernel_export(0), ee(0) {
|
||||
kernel_export(0), ee(0),
|
||||
impl_value(NULL) {
|
||||
}
|
||||
|
||||
FunctionSymbol::~FunctionSymbol() {
|
||||
|
||||
@@ -124,6 +124,10 @@ public:
|
||||
kernel::KernelExport* kernel_export;
|
||||
ExceptionEntrySymbol* ee;
|
||||
|
||||
// Implementation-specific value. This could be a JIT'ed function ref
|
||||
// or some other structure. Never freed.
|
||||
void* impl_value;
|
||||
|
||||
std::vector<FunctionCall> incoming_calls;
|
||||
std::vector<FunctionCall> outgoing_calls;
|
||||
std::vector<VariableAccess> variable_accesses;
|
||||
|
||||
@@ -24,9 +24,11 @@ using namespace xe::kernel;
|
||||
|
||||
|
||||
SymbolDatabase::SymbolDatabase(xe_memory_ref memory,
|
||||
ExportResolver* export_resolver) {
|
||||
ExportResolver* export_resolver,
|
||||
SymbolTable* sym_table) {
|
||||
memory_ = xe_memory_retain(memory);
|
||||
export_resolver_ = export_resolver;
|
||||
sym_table_ = sym_table;
|
||||
}
|
||||
|
||||
SymbolDatabase::~SymbolDatabase() {
|
||||
@@ -150,7 +152,18 @@ FunctionSymbol* SymbolDatabase::GetFunction(uint32_t address) {
|
||||
if (i != symbols_.end() && i->second->symbol_type == Symbol::Function) {
|
||||
return static_cast<FunctionSymbol*>(i->second);
|
||||
}
|
||||
return NULL;
|
||||
|
||||
// Missing function - analyze on demand.
|
||||
// TODO(benvanik): track this for statistics.
|
||||
FunctionSymbol* fn = new FunctionSymbol();
|
||||
fn->start_address = address;
|
||||
function_count_++;
|
||||
symbols_.insert(SymbolMap::value_type(address, fn));
|
||||
scan_queue_.push_back(fn);
|
||||
|
||||
FlushQueue();
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
VariableSymbol* SymbolDatabase::GetVariable(uint32_t address) {
|
||||
@@ -432,6 +445,9 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
// - if present, flag function as needing a stack
|
||||
// - record prolog/epilog lengths/stack size/etc
|
||||
|
||||
// TODO(benvanik): queue for add without expensive locks?
|
||||
sym_table_->AddFunction(fn->start_address, fn);
|
||||
|
||||
XELOGSDB("Finished analyzing %.8X", fn->start_address);
|
||||
return 0;
|
||||
}
|
||||
@@ -649,7 +665,7 @@ void SymbolDatabase::ReadMap(const char* file_name) {
|
||||
sstream >> std::ws;
|
||||
sstream >> type_str;
|
||||
|
||||
uint32_t addr = (uint32_t)strtol(addr_str.c_str(), NULL, 16);
|
||||
uint32_t addr = (uint32_t)strtoul(addr_str.c_str(), NULL, 16);
|
||||
if (!addr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/cpu/sdb/symbol.h>
|
||||
#include <xenia/cpu/sdb/symbol_table.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -27,7 +28,8 @@ namespace sdb {
|
||||
|
||||
class SymbolDatabase {
|
||||
public:
|
||||
SymbolDatabase(xe_memory_ref memory, kernel::ExportResolver* export_resolver);
|
||||
SymbolDatabase(xe_memory_ref memory, kernel::ExportResolver* export_resolver,
|
||||
SymbolTable* sym_table);
|
||||
virtual ~SymbolDatabase();
|
||||
|
||||
virtual int Analyze();
|
||||
@@ -63,6 +65,7 @@ protected:
|
||||
|
||||
xe_memory_ref memory_;
|
||||
kernel::ExportResolver* export_resolver_;
|
||||
SymbolTable* sym_table_;
|
||||
size_t function_count_;
|
||||
size_t variable_count_;
|
||||
SymbolMap symbols_;
|
||||
|
||||
32
src/xenia/cpu/sdb/symbol_table.cc
Normal file
32
src/xenia/cpu/sdb/symbol_table.cc
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/cpu/sdb/symbol_table.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::cpu;
|
||||
using namespace xe::cpu::sdb;
|
||||
|
||||
|
||||
SymbolTable::SymbolTable() {
|
||||
}
|
||||
|
||||
SymbolTable::~SymbolTable() {
|
||||
}
|
||||
|
||||
int SymbolTable::AddFunction(uint32_t address, FunctionSymbol* symbol) {
|
||||
map_[address] = symbol;
|
||||
return 0;
|
||||
}
|
||||
|
||||
FunctionSymbol* SymbolTable::GetFunction(uint32_t address) {
|
||||
FunctionMap::const_iterator it = map_.find(address);
|
||||
return it != map_.end() ? it->second : NULL;
|
||||
}
|
||||
42
src/xenia/cpu/sdb/symbol_table.h
Normal file
42
src/xenia/cpu/sdb/symbol_table.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_CPU_SDB_SYMBOL_TABLE_H_
|
||||
#define XENIA_CPU_SDB_SYMBOL_TABLE_H_
|
||||
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/cpu/sdb/symbol.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
namespace sdb {
|
||||
|
||||
|
||||
class SymbolTable {
|
||||
public:
|
||||
SymbolTable();
|
||||
~SymbolTable();
|
||||
|
||||
int AddFunction(uint32_t address, sdb::FunctionSymbol* symbol);
|
||||
sdb::FunctionSymbol* GetFunction(uint32_t address);
|
||||
|
||||
private:
|
||||
typedef std::tr1::unordered_map<uint32_t, sdb::FunctionSymbol*> FunctionMap;
|
||||
FunctionMap map_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace sdb
|
||||
} // namespace cpu
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_CPU_SDB_SYMBOL_TABLE_H_
|
||||
@@ -51,8 +51,9 @@ public:
|
||||
|
||||
|
||||
XexSymbolDatabase::XexSymbolDatabase(
|
||||
xe_memory_ref memory, ExportResolver* export_resolver, xe_xex2_ref xex) :
|
||||
SymbolDatabase(memory, export_resolver) {
|
||||
xe_memory_ref memory, ExportResolver* export_resolver,
|
||||
SymbolTable* sym_table, xe_xex2_ref xex) :
|
||||
SymbolDatabase(memory, export_resolver, sym_table) {
|
||||
xex_ = xe_xex2_retain(xex);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class XexSymbolDatabase : public SymbolDatabase {
|
||||
public:
|
||||
XexSymbolDatabase(xe_memory_ref memory,
|
||||
kernel::ExportResolver* export_resolver,
|
||||
xe_xex2_ref xex);
|
||||
SymbolTable* sym_table, xe_xex2_ref xex);
|
||||
virtual ~XexSymbolDatabase();
|
||||
|
||||
virtual int Analyze();
|
||||
|
||||
Reference in New Issue
Block a user