In-progress work: refactoring PAL not to be instanced.

This removes a lot of useless passing around of the PAL object.
This commit is contained in:
Ben Vanik
2013-03-29 05:07:32 -07:00
parent c46093266e
commit 85bdbd24d1
45 changed files with 444 additions and 189 deletions

View File

@@ -27,7 +27,6 @@ public:
int Launch(const xechar_t* path);
private:
xe_pal_ref pal_;
xe_memory_ref memory_;
shared_ptr<Processor> processor_;
shared_ptr<Runtime> runtime_;
@@ -39,26 +38,24 @@ Run::Run() {
Run::~Run() {
xe_memory_release(memory_);
xe_pal_release(pal_);
}
int Run::Setup() {
xe_pal_options_t pal_options;
xe_zero_struct(&pal_options, sizeof(pal_options));
pal_ = xe_pal_create(pal_options);
XEEXPECTNOTNULL(pal_);
XEEXPECTZERO(xe_pal_init(pal_options));
debugger_ = shared_ptr<Debugger>(new Debugger(pal_));
debugger_ = shared_ptr<Debugger>(new Debugger());
xe_memory_options_t memory_options;
xe_zero_struct(&memory_options, sizeof(memory_options));
memory_ = xe_memory_create(pal_, memory_options);
memory_ = xe_memory_create(memory_options);
XEEXPECTNOTNULL(memory_);
processor_ = shared_ptr<Processor>(new Processor(pal_, memory_));
processor_ = shared_ptr<Processor>(new Processor(memory_));
XEEXPECTZERO(processor_->Setup());
runtime_ = shared_ptr<Runtime>(new Runtime(pal_, processor_, XT("")));
runtime_ = shared_ptr<Runtime>(new Runtime(processor_, XT("")));
return 0;
XECLEANUP:

View File

@@ -26,8 +26,7 @@ DEFINE_string(test_path, "test/codegen/",
typedef vector<pair<string, string> > annotations_list_t;
int read_annotations(xe_pal_ref pal, string& src_file_path,
annotations_list_t& annotations) {
int read_annotations(string& src_file_path, annotations_list_t& annotations) {
// TODO(benvanik): use PAL instead of this
FILE* f = fopen(src_file_path.c_str(), "r");
char line_buffer[BUFSIZ];
@@ -98,7 +97,7 @@ int check_test_results(xe_memory_ref memory, Processor* processor,
return any_failed;
}
int run_test(xe_pal_ref pal, string& src_file_path) {
int run_test(string& src_file_path) {
int result_code = 1;
// test.s -> test.bin
@@ -126,11 +125,10 @@ int run_test(xe_pal_ref pal, string& src_file_path) {
runtime = shared_ptr<Runtime>(new Runtime(pal, processor, XT("")));
// Load the binary module.
XEEXPECTZERO(processor->LoadBinary(bin_file_path.c_str(), 0x82010000,
runtime->export_resolver()));
XEEXPECTZERO(processor->LoadRawBinary(bin_file_path.c_str(), 0x82010000));
// Simulate a thread.
thread_state = processor->AllocThread(256 * 1024 * 1024, 0);
thread_state = processor->AllocThread(256 * 1024, 0);
// Setup test state from annotations.
XEEXPECTZERO(setup_test_state(memory, processor.get(), thread_state,
@@ -186,13 +184,11 @@ int run_tests(const xechar_t* test_name) {
int failed_count = 0;
int passed_count = 0;
xe_pal_ref pal = NULL;
vector<string> test_files;
xe_pal_options_t pal_options;
xe_zero_struct(&pal_options, sizeof(pal_options));
pal = xe_pal_create(pal_options);
XEEXPECTNOTNULL(pal);
XEEXPECTZERO(xe_pal_init(pal_options));
XEEXPECTZERO(discover_tests(FLAGS_test_path, test_files));
if (!test_files.size()) {
@@ -225,7 +221,6 @@ int run_tests(const xechar_t* test_name) {
result_code = failed_count ? 1 : 0;
XECLEANUP:
xe_pal_release(pal);
return result_code;
}