Mass renaming. I love clang-format.

This commit is contained in:
Ben Vanik
2015-05-31 16:58:12 -07:00
parent 9c3d2b54fb
commit 08770a4ec0
37 changed files with 892 additions and 717 deletions

View File

@@ -22,15 +22,10 @@ ExportResolver::~ExportResolver() {}
void ExportResolver::RegisterTable(const std::string& library_name,
Export* exports, const size_t count) {
tables_.emplace_back(library_name, exports, count);
for (size_t n = 0; n < count; n++) {
exports[n].variable_ptr = 0;
exports[n].function_data.shim = nullptr;
}
}
Export* ExportResolver::GetExportByOrdinal(const std::string& library_name,
const uint32_t ordinal) {
uint16_t ordinal) {
for (const auto& table : tables_) {
if (table.name == library_name || table.simple_name == library_name) {
// TODO(benvanik): binary search?
@@ -46,8 +41,7 @@ Export* ExportResolver::GetExportByOrdinal(const std::string& library_name,
}
void ExportResolver::SetVariableMapping(const std::string& library_name,
const uint32_t ordinal,
uint32_t value) {
uint16_t ordinal, uint32_t value) {
auto export = GetExportByOrdinal(library_name, ordinal);
assert_not_null(export);
export->tags |= ExportTag::kImplemented;
@@ -55,7 +49,7 @@ void ExportResolver::SetVariableMapping(const std::string& library_name,
}
void ExportResolver::SetFunctionMapping(const std::string& library_name,
const uint32_t ordinal,
uint16_t ordinal,
xe_kernel_export_shim_fn shim) {
auto export = GetExportByOrdinal(library_name, ordinal);
assert_not_null(export);
@@ -63,5 +57,14 @@ void ExportResolver::SetFunctionMapping(const std::string& library_name,
export->function_data.shim = shim;
}
void ExportResolver::SetFunctionMapping(const std::string& library_name,
uint16_t ordinal,
ExportTrampoline trampoline) {
auto export = GetExportByOrdinal(library_name, ordinal);
assert_not_null(export);
export->tags |= ExportTag::kImplemented;
export->function_data.trampoline = trampoline;
}
} // namespace cpu
} // namespace xe

View File

@@ -40,6 +40,8 @@ struct ExportTag {
// DEPRECATED
typedef void (*xe_kernel_export_shim_fn)(void*, void*);
typedef void (*ExportTrampoline)(xe::cpu::frontend::PPCContext* ppc_context);
class Export {
public:
enum class Type {
@@ -47,14 +49,19 @@ class Export {
kVariable = 1,
};
uint32_t ordinal;
Export(uint16_t ordinal, Type type, std::string name)
: ordinal(ordinal),
type(type),
name(name),
tags(0),
variable_ptr(0),
function_data({nullptr, nullptr, 0}) {}
uint16_t ordinal;
Type type;
std::string name;
ExportTag::type tags;
void (*trampoline)(xe::cpu::frontend::PPCContext* ppc_context);
uint64_t call_count;
bool is_implemented() const {
return (tags & ExportTag::kImplemented) == ExportTag::kImplemented;
}
@@ -66,10 +73,13 @@ class Export {
uint32_t variable_ptr;
struct {
// Shimmed implementation.
// This is called directly from generated code.
// It should parse args, do fixups, and call the impl.
// DEPRECATED
xe_kernel_export_shim_fn shim;
// Trampoline that is called from the guest-to-host thunk.
// Expects only PPC context as first arg.
ExportTrampoline trampoline;
uint64_t call_count;
} function_data;
};
};
@@ -82,14 +92,14 @@ class ExportResolver {
void RegisterTable(const std::string& library_name, Export* exports,
const size_t count);
Export* GetExportByOrdinal(const std::string& library_name,
const uint32_t ordinal);
Export* GetExportByOrdinal(const std::string& library_name, uint16_t ordinal);
void SetVariableMapping(const std::string& library_name,
const uint32_t ordinal, uint32_t value);
void SetFunctionMapping(const std::string& library_name,
const uint32_t ordinal,
void SetVariableMapping(const std::string& library_name, uint16_t ordinal,
uint32_t value);
void SetFunctionMapping(const std::string& library_name, uint16_t ordinal,
xe_kernel_export_shim_fn shim);
void SetFunctionMapping(const std::string& library_name, uint16_t ordinal,
ExportTrampoline trampoline);
private:
struct ExportTable {

View File

@@ -57,18 +57,18 @@ PPCFrontend::~PPCFrontend() {
Memory* PPCFrontend::memory() const { return processor_->memory(); }
void CheckGlobalLock(PPCContext* ppc_state, void* arg0, void* arg1) {
ppc_state->scratch = 0x8000;
void CheckGlobalLock(PPCContext* ppc_context, void* arg0, void* arg1) {
ppc_context->scratch = 0x8000;
}
void HandleGlobalLock(PPCContext* ppc_state, void* arg0, void* arg1) {
void HandleGlobalLock(PPCContext* ppc_context, void* arg0, void* arg1) {
auto global_lock = reinterpret_cast<xe::mutex*>(arg0);
volatile bool* global_lock_taken = reinterpret_cast<bool*>(arg1);
uint64_t value = ppc_state->scratch;
uint64_t value = ppc_context->scratch;
if (value == 0x8000) {
global_lock->lock();
*global_lock_taken = false;
global_lock->unlock();
} else if (value == ppc_state->r[13]) {
} else if (value == ppc_context->r[13]) {
global_lock->lock();
*global_lock_taken = true;
global_lock->unlock();

View File

@@ -233,13 +233,13 @@ class TestRunner {
}
bool SetupTestState(TestCase& test_case) {
auto ppc_state = thread_state->context();
auto ppc_context = thread_state->context();
for (auto& it : test_case.annotations) {
if (it.first == "REGISTER_IN") {
size_t space_pos = it.second.find(" ");
auto reg_name = it.second.substr(0, space_pos);
auto reg_value = it.second.substr(space_pos + 1);
ppc_state->SetRegFromString(reg_name.c_str(), reg_value.c_str());
ppc_context->SetRegFromString(reg_name.c_str(), reg_value.c_str());
} else if (it.first == "MEMORY_IN") {
size_t space_pos = it.second.find(" ");
auto address_str = it.second.substr(0, space_pos);
@@ -264,7 +264,7 @@ class TestRunner {
}
bool CheckTestResults(TestCase& test_case) {
auto ppc_state = thread_state->context();
auto ppc_context = thread_state->context();
char actual_value[2048];
@@ -274,9 +274,9 @@ class TestRunner {
size_t space_pos = it.second.find(" ");
auto reg_name = it.second.substr(0, space_pos);
auto reg_value = it.second.substr(space_pos + 1);
if (!ppc_state->CompareRegWithString(reg_name.c_str(),
reg_value.c_str(), actual_value,
xe::countof(actual_value))) {
if (!ppc_context->CompareRegWithString(reg_name.c_str(),
reg_value.c_str(), actual_value,
xe::countof(actual_value))) {
any_failed = true;
printf("Register %s assert failed:\n", reg_name.c_str());
printf(" Expected: %s == %s\n", reg_name.c_str(), reg_value.c_str());

View File

@@ -34,10 +34,10 @@ void UndefinedImport(PPCContext* ppc_context,
XELOGE("call to undefined import");
}
XexModule::XexModule(Processor* processor, KernelState* state)
XexModule::XexModule(Processor* processor, KernelState* kernel_state)
: Module(processor),
processor_(processor),
kernel_state_(state),
kernel_state_(kernel_state),
xex_(nullptr),
base_address_(0),
low_address_(0),

View File

@@ -26,7 +26,7 @@ class Runtime;
class XexModule : public xe::cpu::Module {
public:
XexModule(Processor* processor, kernel::KernelState* state);
XexModule(Processor* processor, kernel::KernelState* kernel_state);
virtual ~XexModule();
xe_xex2_ref xex() const { return xex_; }