diff -r bc77cfde7c5c -r fca2b54741ca sourcepawn/jit/sp_vm_basecontext.cpp --- a/sourcepawn/jit/sp_vm_basecontext.cpp Thu Aug 08 09:40:23 2013 -0700 +++ b/sourcepawn/jit/sp_vm_basecontext.cpp Thu Aug 08 09:41:24 2013 -0700 @@ -1,5 +1,5 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet: * ============================================================================= * SourcePawn * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. @@ -46,7 +46,6 @@ BaseContext::BaseContext(BaseRuntime *pRuntime) { m_pRuntime = pRuntime; - m_pPlugin = m_pRuntime->m_pPlugin; m_InExec = false; m_CustomMsg = false; @@ -75,8 +74,8 @@ m_pNullString = NULL; } - m_ctx.hp = m_pPlugin->data_size; - m_ctx.sp = m_pPlugin->mem_size - sizeof(cell_t); + m_ctx.hp = m_pRuntime->plugin()->data_size; + m_ctx.sp = m_pRuntime->plugin()->mem_size - sizeof(cell_t); m_ctx.frm = m_ctx.sp; m_ctx.n_err = SP_ERROR_NONE; m_ctx.n_idx = SP_ERROR_NONE; @@ -204,7 +203,7 @@ return SP_ERROR_HEAPLOW; } - addr = (cell_t *)(m_pPlugin->memory + m_ctx.hp); + addr = (cell_t *)(m_pRuntime->plugin()->memory + m_ctx.hp); /* store size of allocation in cells */ *addr = (cell_t)cells; addr++; @@ -229,12 +228,12 @@ /* check the bounds of this address */ local_addr -= sizeof(cell_t); - if (local_addr < (cell_t)m_pPlugin->data_size || local_addr >= m_ctx.sp) + if (local_addr < (cell_t)m_pRuntime->plugin()->data_size || local_addr >= m_ctx.sp) { return SP_ERROR_INVALID_ADDRESS; } - addr = (cell_t *)(m_pPlugin->memory + local_addr); + addr = (cell_t *)(m_pRuntime->plugin()->memory + local_addr); cellcount = (*addr) * sizeof(cell_t); /* check if this memory count looks valid */ if ((signed)(m_ctx.hp - cellcount - sizeof(cell_t)) != local_addr) @@ -250,7 +249,7 @@ int BaseContext::HeapRelease(cell_t local_addr) { - if (local_addr < (cell_t)m_pPlugin->data_size) + if (local_addr < (cell_t)m_pRuntime->plugin()->data_size) { return SP_ERROR_INVALID_ADDRESS; } @@ -334,14 +333,14 @@ int BaseContext::LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr) { if (((local_addr >= m_ctx.hp) && (local_addr < m_ctx.sp)) - || (local_addr < 0) || ((ucell_t)local_addr >= m_pPlugin->mem_size)) + || (local_addr < 0) || ((ucell_t)local_addr >= m_pRuntime->plugin()->mem_size)) { return SP_ERROR_INVALID_ADDRESS; } if (phys_addr) { - *phys_addr = (cell_t *)(m_pPlugin->memory + local_addr); + *phys_addr = (cell_t *)(m_pRuntime->plugin()->memory + local_addr); } return SP_ERROR_NONE; @@ -365,11 +364,11 @@ int BaseContext::LocalToString(cell_t local_addr, char **addr) { if (((local_addr >= m_ctx.hp) && (local_addr < m_ctx.sp)) - || (local_addr < 0) || ((ucell_t)local_addr >= m_pPlugin->mem_size)) + || (local_addr < 0) || ((ucell_t)local_addr >= m_pRuntime->plugin()->mem_size)) { return SP_ERROR_INVALID_ADDRESS; } - *addr = (char *)(m_pPlugin->memory + local_addr); + *addr = (char *)(m_pRuntime->plugin()->memory + local_addr); return SP_ERROR_NONE; } @@ -385,7 +384,7 @@ size_t len; if (((local_addr >= m_ctx.hp) && (local_addr < m_ctx.sp)) - || (local_addr < 0) || ((ucell_t)local_addr >= m_pPlugin->mem_size)) + || (local_addr < 0) || ((ucell_t)local_addr >= m_pRuntime->plugin()->mem_size)) { return SP_ERROR_INVALID_ADDRESS; } @@ -396,7 +395,7 @@ } len = strlen(source); - dest = (char *)(m_pPlugin->memory + local_addr); + dest = (char *)(m_pRuntime->plugin()->memory + local_addr); if (len >= bytes) { @@ -455,7 +454,7 @@ if (((local_addr >= m_ctx.hp) && (local_addr < m_ctx.sp)) || (local_addr < 0) - || ((ucell_t)local_addr >= m_pPlugin->mem_size)) + || ((ucell_t)local_addr >= m_pRuntime->plugin()->mem_size)) { return SP_ERROR_INVALID_ADDRESS; } @@ -466,7 +465,7 @@ } len = strlen(source); - dest = (char *)(m_pPlugin->memory + local_addr); + dest = (char *)(m_pRuntime->plugin()->memory + local_addr); if ((size_t)len >= maxbytes) { @@ -586,21 +585,18 @@ /* We got this far. It's time to start profiling. */ - if ((m_pPlugin->prof_flags & SP_PROF_CALLBACKS) == SP_PROF_CALLBACKS) + if ((m_pRuntime->plugin()->prof_flags & SP_PROF_CALLBACKS) == SP_PROF_CALLBACKS) { - serial = m_pPlugin->profiler->OnCallbackBegin(this, pubfunc); + serial = m_pRuntime->plugin()->profiler->OnCallbackBegin(this, pubfunc); } /* See if we have to compile the callee. */ if ((fn = m_pRuntime->m_PubJitFuncs[public_id]) == NULL) { - uint32_t func_idx; - /* We might not have to - check pcode offset. */ - if ((func_idx = FuncLookup((CompData *)m_pRuntime->m_pCo, pubfunc->code_offs)) != 0) + fn = m_pRuntime->GetJittedFunctionByOffset(pubfunc->code_offs); + if (fn) { - fn = m_pRuntime->GetJittedFunction(func_idx); - assert(fn != NULL); m_pRuntime->m_PubJitFuncs[public_id] = fn; } else @@ -629,7 +625,7 @@ /* Push parameters */ m_ctx.sp -= sizeof(cell_t) * (num_params + 1); - sp = (cell_t *)(m_pPlugin->memory + m_ctx.sp); + sp = (cell_t *)(m_pRuntime->plugin()->memory + m_ctx.sp); sp[0] = num_params; for (unsigned int i = 0; i < num_params; i++) @@ -687,9 +683,9 @@ m_ctx.hp = save_hp; m_ctx.rp = save_rp; - if ((m_pPlugin->prof_flags & SP_PROF_CALLBACKS) == SP_PROF_CALLBACKS) + if ((m_pRuntime->plugin()->prof_flags & SP_PROF_CALLBACKS) == SP_PROF_CALLBACKS) { - m_pPlugin->profiler->OnCallbackEnd(serial); + m_pRuntime->plugin()->profiler->OnCallbackEnd(serial); } m_ctx.err_cip = save_cip; @@ -746,7 +742,6 @@ { uint32_t max, iter; sp_fdbg_symbol_t *sym; - sp_fdbg_arraydim_t *arr; uint8_t *cursor = (uint8_t *)(m_pPlugin->debug.symbols); max = m_pPlugin->debug.syms_num; @@ -765,7 +760,6 @@ if (sym->dimcount > 0) { cursor += sizeof(sp_fdbg_symbol_t); - arr = (sp_fdbg_arraydim_t *)cursor; cursor += sizeof(sp_fdbg_arraydim_t) * sym->dimcount; continue; } @@ -779,7 +773,6 @@ { uint32_t max, iter; sp_u_fdbg_symbol_t *sym; - sp_u_fdbg_arraydim_t *arr; uint8_t *cursor = (uint8_t *)(m_pPlugin->debug.symbols); max = m_pPlugin->debug.syms_num; @@ -798,7 +791,6 @@ if (sym->dimcount > 0) { cursor += sizeof(sp_u_fdbg_symbol_t); - arr = (sp_u_fdbg_arraydim_t *)cursor; cursor += sizeof(sp_u_fdbg_arraydim_t) * sym->dimcount; continue; } @@ -848,7 +840,7 @@ cell_t *BaseContext::GetLocalParams() { - return (cell_t *)(m_pPlugin->memory + m_ctx.frm + (2 * sizeof(cell_t))); + return (cell_t *)(m_pRuntime->plugin()->memory + m_ctx.frm + (2 * sizeof(cell_t))); } void BaseContext::SetKey(int k, void *value)