1.1 --- a/sourcepawn/vm/jit/x86/opcode_helpers.cpp Thu Sep 21 01:48:19 2006 +0000
1.2 +++ b/sourcepawn/vm/jit/x86/opcode_helpers.cpp Thu Sep 21 02:58:59 2006 +0000
1.3 @@ -159,7 +159,7 @@
1.4 //sub esp, 4 - correct stack for returning to non-inlined JIT
1.5 IA32_Sub_Rm_Imm8(jit, REG_ESP, 4, MOD_REG);
1.6 }
1.7 - Write_Error(jit, SP_ERR_DIVZERO);
1.8 + Write_Error(jit, SP_ERR_DIVIDE_BY_ZERO);
1.9 //continue:
1.10 IA32_Send_Jump8_Here(jit, jmp);
1.11
1.12 @@ -227,13 +227,66 @@
1.13 }
1.14 }
1.15
1.16 +void Write_BoundsCheck(JitWriter *jit)
1.17 +{
1.18 + CompData *data = (CompData *)jit->data;
1.19 + bool always_inline = ((data->inline_level & JIT_INLINE_ERRORCHECKS) == JIT_INLINE_ERRORCHECKS);
1.20 +
1.21 + /* :TODO: break out on high -O level? */
1.22 +
1.23 + if (!always_inline)
1.24 + {
1.25 + if (data->jit_bounds)
1.26 + {
1.27 + /* just generate the call */
1.28 + //mov ecx, <val>
1.29 + //call <offs>
1.30 + IA32_Mov_Reg_Imm32(jit, AMX_REG_TMP, jit->read_cell());
1.31 + jitoffs_t call = IA32_Call_Imm32(jit, 0);
1.32 + IA32_Write_Jump32(jit, call, data->jit_bounds);
1.33 + } else {
1.34 + //cmp eax, 0
1.35 + //jl :err_bounds
1.36 + //cmp eax, ecx
1.37 + //jg :err_bounds
1.38 + //ret
1.39 + IA32_Cmp_Rm_Imm32(jit, MOD_REG, AMX_REG_PRI, 0);
1.40 + jitoffs_t jmp1 = IA32_Jump_Cond_Imm8(jit, CC_L, 0);
1.41 + //:TODO: make sure this is right order
1.42 + IA32_Cmp_Rm_Reg(jit, AMX_REG_PRI, AMX_REG_TMP, MOD_REG);
1.43 + jitoffs_t jmp2 = IA32_Jump_Cond_Imm8(jit, CC_G, 0);
1.44 + IA32_Return(jit);
1.45 + IA32_Send_Jump8_Here(jit, jmp1);
1.46 + IA32_Send_Jump8_Here(jit, jmp2);
1.47 + Write_Error(jit, SP_ERR_ARRAY_BOUNDS);
1.48 + }
1.49 + } else {
1.50 + //cmp eax, 0
1.51 + //jl :err_bounds
1.52 + IA32_Cmp_Rm_Imm32(jit, MOD_REG, AMX_REG_PRI, 0);
1.53 + jitoffs_t jmp1 = IA32_Jump_Cond_Imm8(jit, CC_L, 0);
1.54 + //cmp eax, <val>
1.55 + //jg :err_bounds
1.56 + IA32_Cmp_Rm_Imm32(jit, MOD_REG, AMX_REG_PRI, jit->read_cell());
1.57 + jitoffs_t jmp2 = IA32_Jump_Cond_Imm8(jit, CC_G, 0);
1.58 + //jmp :continue
1.59 + jitoffs_t cont = IA32_Jump_Imm8(jit, 0);
1.60 + //:err_bounds
1.61 + IA32_Send_Jump8_Here(jit, jmp1);
1.62 + IA32_Send_Jump8_Here(jit, jmp2);
1.63 + Write_Error(jit, SP_ERR_ARRAY_BOUNDS);
1.64 + //:continue
1.65 + IA32_Send_Jump8_Here(jit, cont);
1.66 + }
1.67 +}
1.68 +
1.69 void Write_CheckMargin_Heap(JitWriter *jit)
1.70 {
1.71 CompData *data = (CompData *)jit->data;
1.72
1.73 bool always_inline = ((data->inline_level & JIT_INLINE_ERRORCHECKS) == JIT_INLINE_ERRORCHECKS);
1.74
1.75 - if (always_inline && data->jit_chkmargin_heap)
1.76 + if (!always_inline && data->jit_chkmargin_heap)
1.77 {
1.78 /* just generate the call */
1.79 jitoffs_t call = IA32_Call_Imm32(jit, 0);