1.1 --- a/sourcepawn/jit/x86/jit_x86.cpp Thu Jan 25 04:25:40 2007 +0000
1.2 +++ b/sourcepawn/jit/x86/jit_x86.cpp Thu Jan 25 04:36:48 2007 +0000
1.3 @@ -2161,10 +2161,12 @@
1.4
1.5 functracker_t *fnc = new functracker_t;
1.6 ctx->vm[JITVARS_FUNCINFO] = fnc;
1.7 + ctx->vm[JITVARS_REBASE] = data->rebase;
1.8 fnc->code_size = codemem;
1.9 fnc->num_functions = data->func_idx;
1.10
1.11 /* clean up relocation+compilation memory */
1.12 + data->rebase = NULL;
1.13 AbortCompilation(co);
1.14
1.15 *err = SP_ERROR_NONE;
1.16 @@ -2194,6 +2196,7 @@
1.17 delete [] ctx->publics;
1.18 delete [] ctx->pubvars;
1.19 delete [] ctx->symbols;
1.20 + engine->BaseFree(ctx->vm[JITVARS_REBASE]);
1.21 free(((tracker_t *)(ctx->vm[JITVARS_TRACKER]))->pBase);
1.22 delete ctx->vm[JITVARS_TRACKER];
1.23 delete ctx;
1.24 @@ -2247,15 +2250,51 @@
1.25 return SOURCEPAWN_VM_API_VERSION;
1.26 }
1.27
1.28 -bool JITX86::FunctionLookup(const sp_context_t *ctx, uint32_t code_addr, unsigned int *result)
1.29 +bool JITX86::FunctionPLookup(const sp_context_t *ctx, uint32_t code_addr, unsigned int *result)
1.30 {
1.31 + uint8_t *rebase = (uint8_t *)ctx->vm[JITVARS_REBASE];
1.32 +
1.33 + /* Is this within the pcode bounds? */
1.34 + if (code_addr >= ctx->plugin->pcode_size - sizeof(uint32_t))
1.35 + {
1.36 + return false;
1.37 + }
1.38 +
1.39 + /* Relocate this */
1.40 + code_addr = *(jitoffs_t *)(rebase + code_addr);
1.41 +
1.42 + /* Check if this is in the relocation bounds */
1.43 functracker_t *fnc = (functracker_t *)ctx->vm[JITVARS_FUNCINFO];
1.44 -
1.45 if (code_addr >= fnc->code_size)
1.46 {
1.47 return false;
1.48 }
1.49
1.50 + /* Get the function info and sanity check */
1.51 + funcinfo_t *f = (funcinfo_t *)((char *)ctx->codebase + code_addr - sizeof(funcinfo_t));
1.52 + if (f->magic != JIT_FUNCMAGIC || f->index >= fnc->num_functions)
1.53 + {
1.54 + return false;
1.55 + }
1.56 +
1.57 + if (result)
1.58 + {
1.59 + *result = f->index;
1.60 + }
1.61 +
1.62 + return true;
1.63 +}
1.64 +
1.65 +bool JITX86::FunctionLookup(const sp_context_t *ctx, uint32_t code_addr, unsigned int *result)
1.66 +{
1.67 + /* Check if this is in the relocation bounds */
1.68 + functracker_t *fnc = (functracker_t *)ctx->vm[JITVARS_FUNCINFO];
1.69 + if (code_addr >= fnc->code_size)
1.70 + {
1.71 + return false;
1.72 + }
1.73 +
1.74 + /* Get the function info and sanity check */
1.75 funcinfo_t *f = (funcinfo_t *)((char *)ctx->codebase + code_addr - sizeof(funcinfo_t));
1.76 if (f->magic != JIT_FUNCMAGIC || f->index >= fnc->num_functions)
1.77 {