sourcepawn/jit/x86/opcode_helpers.cpp
changeset 237 b2210331d415
parent 157 a6a907b73374
child 238 43c7cb6914a8
     1.1 --- a/sourcepawn/jit/x86/opcode_helpers.cpp	Sun Dec 31 03:02:40 2006 +0000
     1.2 +++ b/sourcepawn/jit/x86/opcode_helpers.cpp	Sun Dec 31 22:33:47 2006 +0000
     1.3 @@ -146,7 +146,7 @@
     1.4  	//add esp, 8
     1.5  	//popad
     1.6  	IA32_Push_Rm_Disp8(jit, AMX_REG_INFO, AMX_INFO_FRAME); //:TODO: move to regs and push? and dont disp for 0
     1.7 -	IA32_Push_Rm_Disp8(jit, AMX_REG_TMP, offsetof(sp_context_t, context));
     1.8 +	IA32_Push_Reg(jit, AMX_REG_TMP);
     1.9  	IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_TMP, offsetof(sp_context_t, dbreak));
    1.10  	IA32_Call_Reg(jit, AMX_REG_TMP);
    1.11  	IA32_Add_Rm_Imm8(jit, REG_ESP, 4*2, MOD_REG);
    1.12 @@ -166,7 +166,7 @@
    1.13  	//mov eax, [eax+ctx.error]
    1.14  	//jmp [jit_return]
    1.15  	IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, AMX_REG_INFO, AMX_INFO_CONTEXT);
    1.16 -	IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, REG_EAX, offsetof(sp_context_t, err));
    1.17 +	IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, REG_EAX, offsetof(sp_context_t, n_err));
    1.18  	IA32_Jump_Imm32_Abs(jit, data->jit_return);
    1.19  }
    1.20  
    1.21 @@ -435,7 +435,7 @@
    1.22  	//cmp [ecx+err], 0
    1.23  	//jnz :error
    1.24  	IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_INFO, AMX_INFO_CONTEXT);
    1.25 -	IA32_Cmp_Rm_Disp8_Imm8(jit, AMX_REG_TMP, offsetof(sp_context_t, err), 0);
    1.26 +	IA32_Cmp_Rm_Disp8_Imm8(jit, AMX_REG_TMP, offsetof(sp_context_t, n_err), 0);
    1.27  	IA32_Jump_Cond_Imm32_Abs(jit, CC_NZ, data->jit_extern_error);
    1.28  
    1.29  	/* restore what we damaged */
    1.30 @@ -662,7 +662,7 @@
    1.31  	//cmp [ecx+err], 0
    1.32  	//jnz :error
    1.33  	IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_INFO, AMX_INFO_CONTEXT);
    1.34 -	IA32_Cmp_Rm_Disp8_Imm8(jit, AMX_REG_TMP, offsetof(sp_context_t, err), 0);
    1.35 +	IA32_Cmp_Rm_Disp8_Imm8(jit, AMX_REG_TMP, offsetof(sp_context_t, n_err), 0);
    1.36  	IA32_Jump_Cond_Imm32_Abs(jit, CC_NZ, data->jit_extern_error);
    1.37  
    1.38  	/* restore what we damaged */
    1.39 @@ -713,13 +713,15 @@
    1.40  	IA32_Write_Jump32_Abs(jit, call, JIT_VerifyOrAllocateTracker);
    1.41  
    1.42  	/* Check for errors */
    1.43 -	//pop eax
    1.44 -	//cmp [eax+err], 0
    1.45 +	//cmp eax, 0
    1.46  	//jnz :error
    1.47 -	IA32_Pop_Reg(jit, REG_EAX);
    1.48 -	IA32_Cmp_Rm_Disp8_Imm8(jit, REG_EAX, offsetof(sp_context_t, err), 0);
    1.49 +	IA32_Cmp_Rm_Imm32(jit, MOD_REG, REG_EAX, 0);
    1.50  	IA32_Jump_Cond_Imm32_Abs(jit, CC_NZ, data->jit_error_tracker_bounds);
    1.51  
    1.52 +	/* Restore */
    1.53 +	//pop eax
    1.54 +	IA32_Pop_Reg(jit, REG_EAX);
    1.55 +	
    1.56  	/* Push the register into the stack and increment pCur */
    1.57  	//mov edx, [eax+vm[]]
    1.58  	//mov eax, [edx+pcur]
    1.59 @@ -742,14 +744,13 @@
    1.60  	IA32_Pop_Reg(jit, AMX_REG_PRI);
    1.61  }
    1.62  
    1.63 -void JIT_VerifyOrAllocateTracker(sp_context_t *ctx)
    1.64 +int JIT_VerifyOrAllocateTracker(sp_context_t *ctx)
    1.65  {
    1.66  	tracker_t *trk = (tracker_t *)(ctx->vm[JITVARS_TRACKER]);
    1.67  
    1.68  	if ((size_t)(trk->pCur - trk->pBase) >= trk->size)
    1.69  	{
    1.70 -		ctx->err = SP_ERROR_TRACKER_BOUNDS;
    1.71 -		return;
    1.72 +		return SP_ERROR_TRACKER_BOUNDS;
    1.73  	}
    1.74  
    1.75  	if (trk->pCur+1 - (trk->pBase + trk->size) == 0)
    1.76 @@ -760,20 +761,23 @@
    1.77  
    1.78  		if (!trk->pBase)
    1.79  		{
    1.80 -			ctx->err = SP_ERROR_TRACKER_BOUNDS;
    1.81 -			return;
    1.82 +			return SP_ERROR_TRACKER_BOUNDS;
    1.83  		}
    1.84  
    1.85  		trk->pCur = trk->pBase + disp;
    1.86  	}
    1.87 +
    1.88 +	return SP_ERROR_NONE;
    1.89  }
    1.90  
    1.91 -void JIT_VerifyLowBoundTracker(sp_context_t *ctx)
    1.92 +int JIT_VerifyLowBoundTracker(sp_context_t *ctx)
    1.93  {
    1.94  	tracker_t *trk = (tracker_t *)(ctx->vm[JITVARS_TRACKER]);
    1.95  
    1.96  	if (trk->pCur <= trk->pBase)
    1.97  	{
    1.98 -		ctx->err = SP_ERROR_TRACKER_BOUNDS;
    1.99 +		return SP_ERROR_TRACKER_BOUNDS;
   1.100  	}
   1.101 -}
   1.102 \ No newline at end of file
   1.103 +
   1.104 +	return SP_ERROR_NONE;
   1.105 +}