Permalink
Browse files

fixed odd memory leak in macos due to call to vector reserve

  • Loading branch information...
objeck committed Dec 3, 2018
1 parent e03f91d commit 19038a4024596f7c48b78394e1c1e4910988a4a4
@@ -974,7 +974,7 @@ void JitCompilerIA64::ProcessLoadCharElement(StackInstr* instr) {
move_mem16_reg(0, elem_holder->GetRegister(), holder->GetRegister()); move_mem16_reg(0, elem_holder->GetRegister(), holder->GetRegister());
#else #else
move_mem32_reg(0, elem_holder->GetRegister(), holder->GetRegister()); move_mem32_reg(0, elem_holder->GetRegister(), holder->GetRegister());
#endif #endif
ReleaseRegister(elem_holder); ReleaseRegister(elem_holder);
working_stack.push_front(new RegInstr(holder)); working_stack.push_front(new RegInstr(holder));
} }
@@ -4062,4 +4062,4 @@ long JitExecutor::ExecuteMachineCode(long cls_id, long mthd_id, size_t* inst, un
#endif #endif


return status; return status;
} }
@@ -429,11 +429,11 @@ namespace Runtime {
class JitCompilerIA64 { class JitCompilerIA64 {
static StackProgram* program; static StackProgram* program;
static PageManager* page_manager; static PageManager* page_manager;

deque<RegInstr*> working_stack; deque<RegInstr*> working_stack;
vector<RegisterHolder*> aval_regs; vector<RegisterHolder*> aval_regs;
list<RegisterHolder*> used_regs; list<RegisterHolder*> used_regs;
stack<RegisterHolder*> aux_regs; stack<RegisterHolder*> aux_regs;
RegisterHolder* rax_reg;
vector<RegisterHolder*> aval_xregs; vector<RegisterHolder*> aval_xregs;
list<RegisterHolder*> used_xregs; list<RegisterHolder*> used_xregs;
unordered_map<long, StackInstr*> jump_table; // jump addresses unordered_map<long, StackInstr*> jump_table; // jump addresses
@@ -1043,7 +1043,7 @@ namespace Runtime {
#ifdef _DEBUG #ifdef _DEBUG
wcout << L">>> No general registers avaiable! <<<" << endl; wcout << L">>> No general registers avaiable! <<<" << endl;
#endif #endif
aux_regs.push(new RegisterHolder(RAX)); aux_regs.push(rax_reg);
holder = aux_regs.top(); holder = aux_regs.top();
aux_regs.pop(); aux_regs.pop();
} }
@@ -1998,12 +1998,13 @@ namespace Runtime {
#endif #endif
floats_index = instr_index = code_index = epilog_index = instr_count = 0; floats_index = instr_index = code_index = epilog_index = instr_count = 0;


rax_reg = new RegisterHolder(RAX);
#ifdef _WIN64 #ifdef _WIN64
// general use registers // general use registers
aval_regs.push_back(new RegisterHolder(RDX)); aval_regs.push_back(new RegisterHolder(RDX));
aval_regs.push_back(new RegisterHolder(RCX)); aval_regs.push_back(new RegisterHolder(RCX));
aval_regs.push_back(new RegisterHolder(RBX)); aval_regs.push_back(new RegisterHolder(RBX));
aval_regs.push_back(new RegisterHolder(RAX)); aval_regs.push_back(rax_reg);
// aux general use registers // aux general use registers
aux_regs.push(new RegisterHolder(RSI)); aux_regs.push(new RegisterHolder(RSI));
aux_regs.push(new RegisterHolder(RDI)); aux_regs.push(new RegisterHolder(RDI));
@@ -2022,7 +2023,7 @@ namespace Runtime {
// aval_regs.push_back(new RegisterHolder(RDX)); // aval_regs.push_back(new RegisterHolder(RDX));
// aval_regs.push_back(new RegisterHolder(RCX)); // aval_regs.push_back(new RegisterHolder(RCX));
aval_regs.push_back(new RegisterHolder(RBX)); aval_regs.push_back(new RegisterHolder(RBX));
aval_regs.push_back(new RegisterHolder(RAX)); aval_regs.push_back(rax_reg);
// aux general use registers // aux general use registers
// aux_regs.push(new RegisterHolder(RDI)); // aux_regs.push(new RegisterHolder(RDI));
// aux_regs.push(new RegisterHolder(RSI)); // aux_regs.push(new RegisterHolder(RSI));
@@ -2118,6 +2119,8 @@ namespace Runtime {
// store compiled code // store compiled code
method->SetNativeCode(new NativeCode(page_manager->GetPage(code, code_index), code_index, floats)); method->SetNativeCode(new NativeCode(page_manager->GetPage(code, code_index), code_index, floats));




free(code); free(code);
code = NULL; code = NULL;


@@ -686,7 +686,6 @@ void* MemoryManager::CollectMemory(void* arg)


#endif #endif
vector<size_t*> live_memory; vector<size_t*> live_memory;
live_memory.reserve(allocated_memory.size());
for(size_t i = 0; i < allocated_memory.size(); ++i) { for(size_t i = 0; i < allocated_memory.size(); ++i) {
size_t* mem = allocated_memory[i]; size_t* mem = allocated_memory[i];


@@ -656,13 +656,6 @@ namespace Runtime {
if(monitor) { if(monitor) {
MemoryManager::RemovePdaMethodRoot(monitor); MemoryManager::RemovePdaMethodRoot(monitor);


for(size_t i = 0; i < CALL_STACK_SIZE; ++i) {
StackFrame* temp = call_stack[i];
if(temp) {
delete temp;
temp = NULL;
}
}
delete[] call_stack; delete[] call_stack;
call_stack = NULL; call_stack = NULL;


0 comments on commit 19038a4

Please sign in to comment.