From 49bd57509b2002324821b636d5ddbe520e6e379b Mon Sep 17 00:00:00 2001 From: Pavel <68122101+red-prig@users.noreply.github.com> Date: Tue, 4 Feb 2025 23:41:19 +0300 Subject: [PATCH] + --- rtl/x86_jit.pas | 30 ++++++++++++++++++++---------- sys/jit/kern_jit_ops_avx.pas | 23 +++++++++++++---------- sys/jit/kern_jit_ops_sse.pas | 24 ++++++++++++++++++++++++ sys/kern/kern_umtx.pas | 3 ++- 4 files changed, 59 insertions(+), 21 deletions(-) diff --git a/rtl/x86_jit.pas b/rtl/x86_jit.pas index b53b9a68..0c90bd19 100644 --- a/rtl/x86_jit.pas +++ b/rtl/x86_jit.pas @@ -2640,11 +2640,11 @@ begin op:=desc.op; case mreg.AMemSize of - os8: - if (not (not_os8 in desc.opt)) then - begin - Dec(op); - end; + os8: + if (not (not_os8 in desc.opt)) then + begin + Dec(op); + end; os16: if (not (not_prefix in desc.opt)) then begin @@ -2868,11 +2868,11 @@ begin op:=desc.op; case size of - os8: - if (not (not_os8 in desc.opt)) then - begin - Dec(op); - end; + os8: + if (not (not_os8 in desc.opt)) then + begin + Dec(op); + end; os16: if (not (not_prefix in desc.opt)) then begin @@ -3368,6 +3368,11 @@ begin op:=desc.op; case reg.ASize of + os8: + if (not (not_os8 in desc.opt)) then + begin + Dec(op); + end; os16: if (not (not_prefix in desc.opt)) then begin @@ -3424,6 +3429,11 @@ begin op:=desc.op; case mreg.AMemSize of + os8: + if (not (not_os8 in desc.opt)) then + begin + Dec(op); + end; os16: if (not (not_prefix in desc.opt)) then begin diff --git a/sys/jit/kern_jit_ops_avx.pas b/sys/jit/kern_jit_ops_avx.pas index 36915734..af5bb6f1 100644 --- a/sys/jit/kern_jit_ops_avx.pas +++ b/sys/jit/kern_jit_ops_avx.pas @@ -437,22 +437,25 @@ begin end; end; -const - maskmov_dqu_desc:t_op_type=(op:$F7;simdop:1;mm:1); - procedure op_maskmov_dqu(var ctx:t_jit_context2); begin - with ctx.builder do + if jit_memory_guard then begin - //save - movq(r_tmp0,rdi); + with ctx.builder do + begin + //save + movq(r_tmp1,rdi); - op_uplift(ctx,rdi,os64,[not_use_r_tmp0]); //in/out:rdi + op_uplift(ctx,rdi,os64,[not_use_r_tmp1]); //in/out:rdi - _VV(maskmov_dqu_desc,ctx.din.Operand[1].RegValue[0],ctx.din.Operand[2].RegValue[0],os128); + add_orig(ctx); - //restore - movq(rdi,r_tmp0); + //restore + movq(rdi,r_tmp1); + end; + end else + begin + add_orig(ctx); end; end; diff --git a/sys/jit/kern_jit_ops_sse.pas b/sys/jit/kern_jit_ops_sse.pas index 05b64a56..f432aaac 100644 --- a/sys/jit/kern_jit_ops_sse.pas +++ b/sys/jit/kern_jit_ops_sse.pas @@ -603,6 +603,27 @@ begin end; end; +procedure op_maskmov(var ctx:t_jit_context2); +begin + if jit_memory_guard then + begin + with ctx.builder do + begin + //save + movq(r_tmp1,rdi); + + op_uplift(ctx,rdi,os64,[not_use_r_tmp1]); //in/out:rdi + + add_orig(ctx); + + //restore + movq(rdi,r_tmp1); + end; + end else + begin + add_orig(ctx); + end; +end; // @@ -704,6 +725,9 @@ begin jit_cbs[OPPnone,OPmovmsk ,OPSx_pd]:=@op_reg_mem_mov_wo; //reg reg jit_cbs[OPPnone,OPpmovmskb,OPSnone]:=@op_reg_mem_mov_wo; //reg reg + jit_cbs[OPPnone,OPmaskmov,OPSx_q ]:=@op_maskmov; + jit_cbs[OPPnone,OPmaskmov,OPSx_dqu]:=@op_maskmov; + jit_cbs[OPPnone,OPcomi ,OPSx_ss]:=@op_reg_mem_ro; jit_cbs[OPPnone,OPcomi ,OPSx_sd]:=@op_reg_mem_ro; diff --git a/sys/kern/kern_umtx.pas b/sys/kern/kern_umtx.pas index 7e5b20bc..5e19d2cb 100644 --- a/sys/kern/kern_umtx.pas +++ b/sys/kern/kern_umtx.pas @@ -2891,7 +2891,7 @@ begin end; end; -function do_unlock_umutex(td:p_kthread;m:p_umutex):Integer; +function do_unlock_umutex(td:p_kthread;m:p_umutex):Integer; inline; var flags:DWORD; begin @@ -4092,6 +4092,7 @@ begin if (obj=nil) then Exit(EINVAL); td:=curkthread; if (td=nil) then Exit(EFAULT); + Case op of UMTX_OP_LOCK :Result:=__umtx_op_lock_umtx (td,obj,val,uaddr1,uaddr2); UMTX_OP_UNLOCK :Result:=__umtx_op_unlock_umtx (td,obj,val,uaddr1,uaddr2);