Heap allocating large register files.

This commit is contained in:
Ben Vanik 2013-12-25 23:16:16 -08:00
parent 1b533d8c2b
commit 8e3ca029c2
1 changed files with 8 additions and 1 deletions

View File

@ -103,8 +103,11 @@ void IVMFunction::OnBreakpointHit(ThreadState* thread_state, IntCode* i) {
int IVMFunction::CallImpl(ThreadState* thread_state, uint64_t return_address) {
// Setup register file on stack.
const size_t max_stack_alloc = 16 * 1024;
size_t register_file_size = register_count_ * sizeof(Register);
Register* register_file = (Register*)alloca(register_file_size);
Register* register_file = (Register*)(
register_file_size >= max_stack_alloc ?
xe_malloc(register_file_size) : alloca(register_file_size));
Memory* memory = thread_state->memory();
@ -148,5 +151,9 @@ int IVMFunction::CallImpl(ThreadState* thread_state, uint64_t return_address) {
}
}
if (register_file_size >= max_stack_alloc) {
xe_free(register_file);
}
return 0;
}