1.1 --- a/core/vm/sp_vm_basecontext.cpp Fri Feb 16 03:47:10 2007 +0000
1.2 +++ b/core/vm/sp_vm_basecontext.cpp Fri Feb 16 04:16:31 2007 +0000
1.3 @@ -66,14 +66,19 @@
1.4 }
1.5 }
1.6
1.7 -void BaseContext::FlushFunctionCache()
1.8 +void BaseContext::FlushFunctionCache(bool remove)
1.9 {
1.10 if (m_pub_funcs)
1.11 {
1.12 for (uint32_t i=0; i<ctx->plugin->info.publics_num; i++)
1.13 {
1.14 - delete m_pub_funcs[i];
1.15 - m_pub_funcs[i] = NULL;
1.16 + if (remove)
1.17 + {
1.18 + delete m_pub_funcs[i];
1.19 + m_pub_funcs[i] = NULL;
1.20 + } else if (m_pub_funcs[i]) {
1.21 + m_pub_funcs[i]->Invalidate();
1.22 + }
1.23 }
1.24 }
1.25
1.26 @@ -81,15 +86,20 @@
1.27 {
1.28 for (unsigned int i=0; i<m_funcsnum; i++)
1.29 {
1.30 - delete m_priv_funcs[i];
1.31 - m_priv_funcs[i] = NULL;
1.32 + if (remove)
1.33 + {
1.34 + delete m_priv_funcs[i];
1.35 + m_priv_funcs[i] = NULL;
1.36 + } else if (m_priv_funcs[i]) {
1.37 + m_priv_funcs[i]->Invalidate();
1.38 + }
1.39 }
1.40 }
1.41 }
1.42
1.43 BaseContext::~BaseContext()
1.44 {
1.45 - FlushFunctionCache();
1.46 + FlushFunctionCache(true);
1.47 delete [] m_pub_funcs;
1.48 m_pub_funcs = NULL;
1.49 delete [] m_priv_funcs;
1.50 @@ -105,7 +115,7 @@
1.51 ctx = _ctx;
1.52 ctx->context = this;
1.53 ctx->dbreak = GlobalDebugBreak;
1.54 - FlushFunctionCache();
1.55 + FlushFunctionCache(false);
1.56 }
1.57
1.58 IVirtualMachine *BaseContext::GetVirtualMachine()
1.59 @@ -850,6 +860,8 @@
1.60 {
1.61 m_pub_funcs[func_id] = new CFunction(ctx->publics[func_id].code_offs, this);
1.62 pFunc = m_pub_funcs[func_id];
1.63 + } else if (pFunc->IsInvalidated()) {
1.64 + pFunc->Set(ctx->publics[func_id].code_offs, this);
1.65 }
1.66 } else {
1.67 /* :TODO: currently not used */
1.68 @@ -892,6 +904,15 @@
1.69 m_pub_funcs[index] = new CFunction(pub->code_offs, this);
1.70 }
1.71 pFunc = m_pub_funcs[index];
1.72 + } else if (pFunc->IsInvalidated()) {
1.73 + sp_public_t *pub = NULL;
1.74 + GetPublicByIndex(index, &pub);
1.75 + if (pub)
1.76 + {
1.77 + pFunc->Set(pub->code_offs, this);
1.78 + } else {
1.79 + pFunc = NULL;
1.80 + }
1.81 }
1.82
1.83 return pFunc;