1.1 --- a/sourcepawn/vm/jit/x86/opcode_helpers.cpp Tue Oct 17 03:44:37 2006 +0000
1.2 +++ b/sourcepawn/vm/jit/x86/opcode_helpers.cpp Tue Oct 17 05:50:59 2006 +0000
1.3 @@ -451,11 +451,12 @@
1.4 IA32_Return(jit);
1.5 }
1.6
1.7 -void GenerateArrayIndirectionVectors(cell_t *arraybase, cell_t dims[], ucell_t dimcount)
1.8 +void GenerateArrayIndirectionVectors(cell_t *arraybase, cell_t dims[], ucell_t _dimcount, bool autozero)
1.9 {
1.10 cell_t vectors = 1; /* we need one vector to start off with */
1.11 cell_t cur_offs = 0;
1.12 cell_t cur_write = 0;
1.13 + cell_t dimcount = _dimcount;
1.14
1.15 /* Initialize rotation */
1.16 cur_write = dims[dimcount-1];
1.17 @@ -476,6 +477,17 @@
1.18 vectors = cur_dim;
1.19 }
1.20
1.21 + /* everything after cur_offs can be zeroed */
1.22 + if (autozero)
1.23 + {
1.24 + size_t size = 1;
1.25 + for (ucell_t i=0; i<_dimcount; i++)
1.26 + {
1.27 + size *= dims[i];
1.28 + }
1.29 + memset(&arraybase[cur_offs], 0, size*sizeof(cell_t));
1.30 + }
1.31 +
1.32 return;
1.33 }
1.34
1.35 @@ -492,9 +504,11 @@
1.36 */
1.37 //push ebx
1.38 //push eax
1.39 + //push edx
1.40 //push ecx ;value is referenced on stack
1.41 IA32_Push_Reg(jit, REG_EBX);
1.42 IA32_Push_Reg(jit, REG_EAX);
1.43 + IA32_Push_Reg(jit, REG_EDX);
1.44 IA32_Push_Reg(jit, REG_ECX);
1.45
1.46 /**
1.47 @@ -557,17 +571,19 @@
1.48 * I'm letting the compiler handle it and thus it's in C.
1.49 */
1.50 //lea ebx, [ebp+eax] ;get base pointer
1.51 - //push dword [esp-4] ;push dimension count
1.52 + //push dword [esp-8] ;push autozero
1.53 + //push dword [esp-8] ;push dimension count
1.54 //push edi ;push dim array
1.55 //push ebx
1.56 //call GenerateArrayIndirectionVectors
1.57 //add esp, 4*3
1.58 IA32_Lea_Reg_DispRegMult(jit, REG_EBX, REG_EAX, REG_EBP, NOSCALE);
1.59 - IA32_Push_Rm_Disp8_ESP(jit, 4);
1.60 + IA32_Push_Rm_Disp8_ESP(jit, 8);
1.61 + IA32_Push_Rm_Disp8_ESP(jit, 8);
1.62 IA32_Push_Reg(jit, REG_EDI);
1.63 IA32_Push_Reg(jit, REG_EBX);
1.64 IA32_Write_Jump32_Abs(jit, IA32_Call_Imm32(jit, 0), (void *)&GenerateArrayIndirectionVectors);
1.65 - IA32_Add_Rm_Imm8(jit, REG_ESP, 4*3, MOD_REG);
1.66 + IA32_Add_Rm_Imm8(jit, REG_ESP, 4*4, MOD_REG);
1.67
1.68 /* Store the heap pointer back into the stack */
1.69 //pop eax ;restore heap pointer
1.70 @@ -580,9 +596,11 @@
1.71 IA32_Mov_Rm_Reg(jit, AMX_REG_STK, REG_EAX, MOD_MEM_REG);
1.72
1.73 /* Return to caller */
1.74 + //pop edx
1.75 //pop eax
1.76 //pop ebx
1.77 //ret
1.78 + IA32_Pop_Reg(jit, REG_ECX);
1.79 IA32_Pop_Reg(jit, REG_EAX);
1.80 IA32_Pop_Reg(jit, REG_EBX);
1.81 IA32_Return(jit);