Remove InfoVars::ctx (bug 5844 part 5, r=fyren).
1.1 --- a/sourcepawn/jit/x86/jit_x86.cpp Sun Aug 11 11:33:29 2013 -0700
1.2 +++ b/sourcepawn/jit/x86/jit_x86.cpp Sun Aug 11 11:33:47 2013 -0700
1.3 @@ -166,9 +166,9 @@
1.4 }
1.5
1.6 static int
1.7 -PopTrackerAndSetHeap(sp_plugin_t *plugin, InfoVars &vars)
1.8 +PopTrackerAndSetHeap(BaseRuntime *rt, InfoVars &vars)
1.9 {
1.10 - tracker_t *trk = (tracker_t *)(vars.ctx->vm[JITVARS_TRACKER]);
1.11 + tracker_t *trk = (tracker_t *)(rt->GetBaseContext()->GetCtx()->vm[JITVARS_TRACKER]);
1.12 assert(trk->pCur > trk->pBase);
1.13
1.14 trk->pCur--;
1.15 @@ -176,7 +176,7 @@
1.16 return SP_ERROR_TRACKER_BOUNDS;
1.17
1.18 ucell_t amt = *trk->pCur;
1.19 - if (amt > (vars.hp - plugin->data_size))
1.20 + if (amt > (vars.hp - rt->plugin()->data_size))
1.21 return SP_ERROR_HEAPMIN;
1.22
1.23 vars.hp -= amt;
1.24 @@ -207,7 +207,7 @@
1.25 }
1.26
1.27 static int
1.28 -GenerateArray(sp_plugin_t *plugin, InfoVars &vars, uint32_t argc, cell_t *argv, int autozero)
1.29 +GenerateArray(BaseRuntime *rt, InfoVars &vars, uint32_t argc, cell_t *argv, int autozero)
1.30 {
1.31 // Calculate how many cells are needed.
1.32 if (argv[0] <= 0)
1.33 @@ -236,16 +236,16 @@
1.34 return SP_ERROR_ARRAY_TOO_BIG;
1.35
1.36 uint32_t new_hp = vars.hp + bytes;
1.37 - cell_t *dat_hp = reinterpret_cast<cell_t *>(plugin->memory + new_hp);
1.38 + cell_t *dat_hp = reinterpret_cast<cell_t *>(rt->plugin()->memory + new_hp);
1.39
1.40 // argv, coincidentally, is STK.
1.41 if (dat_hp >= argv - STACK_MARGIN)
1.42 return SP_ERROR_HEAPLOW;
1.43
1.44 - if (int err = PushTracker(vars.ctx, bytes))
1.45 + if (int err = PushTracker(rt->GetBaseContext()->GetCtx(), bytes))
1.46 return err;
1.47
1.48 - cell_t *base = reinterpret_cast<cell_t *>(plugin->memory + vars.hp);
1.49 + cell_t *base = reinterpret_cast<cell_t *>(rt->plugin()->memory + vars.hp);
1.50 cell_t offs = GenerateArrayIndirectionVectors(base, argv, argc, autozero);
1.51 assert(size_t(offs) == cells);
1.52
1.53 @@ -1264,9 +1264,8 @@
1.54 __ push(pri);
1.55 __ push(alt);
1.56
1.57 - __ movl(eax, Operand(info, AMX_INFO_CONTEXT));
1.58 __ push(amount * 4);
1.59 - __ push(eax);
1.60 + __ push(intptr_t(rt_->GetBaseContext()->GetCtx()));
1.61 __ call(ExternalAddress((void *)PushTracker));
1.62 __ addl(esp, 8);
1.63 __ testl(eax, eax);
1.64 @@ -1285,7 +1284,7 @@
1.65
1.66 // Get the context pointer and call the sanity checker.
1.67 __ push(info);
1.68 - __ push(intptr_t(plugin_));
1.69 + __ push(intptr_t(rt_));
1.70 __ call(ExternalAddress((void *)PopTrackerAndSetHeap));
1.71 __ addl(esp, 8);
1.72 __ testl(eax, eax);
1.73 @@ -1414,7 +1413,7 @@
1.74
1.75 __ shll(tmp, 2);
1.76 __ push(tmp);
1.77 - __ push(Operand(info, AMX_INFO_CONTEXT));
1.78 + __ push(intptr_t(rt_->GetBaseContext()->GetCtx()));
1.79 __ call(ExternalAddress((void *)PushTracker));
1.80 __ addl(esp, 4);
1.81 __ pop(tmp);
1.82 @@ -1442,7 +1441,7 @@
1.83 __ push(stk);
1.84 __ push(val);
1.85 __ push(info);
1.86 - __ push(intptr_t(plugin_));
1.87 + __ push(intptr_t(rt_));
1.88 __ call(ExternalAddress((void *)GenerateArray));
1.89 __ addl(esp, 5 * sizeof(void *));
1.90
1.91 @@ -1472,7 +1471,7 @@
1.92
1.93 // eax = context
1.94 // ecx = rp
1.95 - __ movl(eax, Operand(info, AMX_INFO_CONTEXT));
1.96 + __ movl(eax, intptr_t(rt_->GetBaseContext()->GetCtx()));
1.97 __ movl(ecx, Operand(eax, offsetof(sp_context_t, rp)));
1.98
1.99 // Check if the return stack is used up.
1.100 @@ -1505,7 +1504,7 @@
1.101 __ movl(Operand(info, AMX_INFO_CIP), cip);
1.102
1.103 // Mark us as leaving the last frame.
1.104 - __ movl(tmp, Operand(info, AMX_INFO_CONTEXT));
1.105 + __ movl(tmp, intptr_t(rt_->GetBaseContext()->GetCtx()));
1.106 __ subl(Operand(tmp, offsetof(sp_context_t, rp)), 1);
1.107 return true;
1.108 }
1.109 @@ -1595,7 +1594,7 @@
1.110
1.111 // Relocate all our absolute junk to be dat-relative, and store it all back
1.112 // into the context.
1.113 - __ movl(eax, Operand(info, AMX_INFO_CONTEXT));
1.114 + __ movl(eax, intptr_t(rt_->GetBaseContext()->GetCtx()));
1.115 __ movl(ecx, Operand(info, AMX_INFO_HEAP));
1.116 __ movl(Operand(eax, offsetof(sp_context_t, hp)), ecx);
1.117 __ subl(stk, dat);
1.118 @@ -1608,7 +1607,7 @@
1.119 __ call(ExternalAddress((void *)NativeCallback));
1.120
1.121 // Check for errors.
1.122 - __ movl(ecx, Operand(info, AMX_INFO_CONTEXT));
1.123 + __ movl(ecx, intptr_t(rt_->GetBaseContext()->GetCtx()));
1.124 __ movl(ecx, Operand(ecx, offsetof(sp_context_t, n_err)));
1.125 __ testl(ecx, ecx);
1.126 __ j(not_zero, &extern_error_);
1.127 @@ -1750,7 +1749,7 @@
1.128
1.129 if (extern_error_.used()) {
1.130 __ bind(&extern_error_);
1.131 - __ movl(eax, Operand(info, AMX_INFO_CONTEXT));
1.132 + __ movl(eax, intptr_t(rt_->GetBaseContext()->GetCtx()));
1.133 __ movl(eax, Operand(eax, offsetof(sp_context_t, n_err)));
1.134 __ jmp(g_Jit.GetUniversalReturn());
1.135 }
1.136 @@ -1774,10 +1773,9 @@
1.137 __ movl(esi, Operand(ebp, 8 + 4 * 0));
1.138 __ movl(ecx, Operand(ebp, 8 + 4 * 1));
1.139 __ movl(eax, Operand(ebp, 8 + 4 * 2));
1.140 - __ movl(edx, Operand(esi, AMX_INFO_CONTEXT));
1.141
1.142 // Set up run-time registers.
1.143 - __ movl(edi, Operand(edx, offsetof(sp_context_t, sp)));
1.144 + __ movl(edi, Operand(esi, AMX_INFO_FRAME));
1.145 __ addl(edi, eax);
1.146 __ movl(ebp, eax);
1.147 __ movl(ebx, edi);
1.148 @@ -1797,9 +1795,8 @@
1.149 Label error;
1.150 __ bind(&error);
1.151 __ movl(esp, Operand(info, AMX_INFO_NSTACK));
1.152 - __ movl(ecx, Operand(info, AMX_INFO_CONTEXT));
1.153 __ subl(stk, dat);
1.154 - __ movl(Operand(ecx, offsetof(sp_context_t, sp)), stk);
1.155 + __ movl(Operand(esi, AMX_INFO_FRAME), stk);
1.156
1.157 __ pop(ebx);
1.158 __ pop(edi);
1.159 @@ -1969,13 +1966,13 @@
1.160 vars.frm = ctx->sp;
1.161 vars.hp = ctx->hp;
1.162 vars.rval = result;
1.163 - vars.ctx = ctx;
1.164 vars.cip = fn->GetPCodeAddress();
1.165 /* vars.esp will be set in the entry code */
1.166
1.167 pfn = (JIT_EXECUTE)m_pJitEntry;
1.168 err = pfn(&vars, fn->GetEntryAddress(), runtime->plugin()->memory);
1.169
1.170 + ctx->sp = vars.frm;
1.171 ctx->hp = vars.hp;
1.172 ctx->err_cip = vars.cip;
1.173
2.1 --- a/sourcepawn/jit/x86/jit_x86.h Sun Aug 11 11:33:29 2013 -0700
2.2 +++ b/sourcepawn/jit/x86/jit_x86.h Sun Aug 11 11:33:47 2013 -0700
2.3 @@ -198,7 +198,6 @@
2.4 ucell_t frm;
2.5 ucell_t hp;
2.6 cell_t *rval;
2.7 - sp_context_t *ctx;
2.8 ucell_t cip;
2.9 void *esp;
2.10 };
2.11 @@ -206,7 +205,6 @@
2.12 #define AMX_INFO_FRAME offsetof(InfoVars, frm)
2.13 #define AMX_INFO_HEAP offsetof(InfoVars, hp)
2.14 #define AMX_INFO_RETVAL offsetof(InfoVars, rval)
2.15 -#define AMX_INFO_CONTEXT offsetof(InfoVars, ctx)
2.16 #define AMX_INFO_CIP offsetof(InfoVars, cip)
2.17 #define AMX_INFO_NSTACK offsetof(InfoVars, esp)
2.18