Starting to properly attribute virtual vs. physical memory accesses.

This commit is contained in:
Ben Vanik
2015-03-29 11:11:35 -07:00
parent ab90e0932b
commit ec84a688e9
42 changed files with 346 additions and 372 deletions

View File

@@ -29,7 +29,6 @@ ThreadState::ThreadState(Runtime* runtime, uint32_t thread_id,
thread_id_(thread_id),
name_(""),
backend_data_(0),
raw_context_(0),
stack_size_(stack_size),
thread_state_address_(thread_state_address) {
if (thread_id_ == UINT_MAX) {
@@ -50,13 +49,16 @@ ThreadState::ThreadState(Runtime* runtime, uint32_t thread_id,
assert_not_zero(stack_address_);
// Allocate with 64b alignment.
context_ = (PPCContext*)calloc(1, sizeof(PPCContext));
assert_true(((uint64_t)context_ & 0xF) == 0);
context_ =
reinterpret_cast<PPCContext*>(_aligned_malloc(sizeof(PPCContext), 64));
assert_true(((uint64_t)context_ & 0x3F) == 0);
std::memset(context_, 0, sizeof(PPCContext));
// Stash pointers to common structures that callbacks may need.
context_->reserve_address = memory_->reserve_address();
context_->reserve_value = memory_->reserve_value();
context_->membase = memory_->membase();
context_->virtual_membase = memory_->virtual_membase();
context_->physical_membase = memory_->physical_membase();
context_->runtime = runtime;
context_->thread_state = this;
context_->thread_id = thread_id_;
@@ -69,8 +71,6 @@ ThreadState::ThreadState(Runtime* runtime, uint32_t thread_id,
// 16 to 32b.
context_->r[1] -= 64;
raw_context_ = context_;
runtime_->debugger()->OnThreadCreated(this);
}
@@ -84,7 +84,7 @@ ThreadState::~ThreadState() {
thread_state_ = nullptr;
}
free(context_);
_aligned_free(context_);
if (stack_allocated_) {
memory()->SystemHeapFree(stack_address_);
}