[Mono-devel-list] [PATCH] Move of Interlocked.Increment/Decrement/Exchange I4 to op codes

Paolo Molaro lupus at ximian.com
Fri Nov 26 10:11:17 EST 2004


On 11/23/04 Torstensson, Patrik wrote:
> bus lock prefix (2,5 x speed difference). There is one known issue with
> this patch; it should ignore the mp check when doing AOT, havn't had the
> time to fix that in this patch (simple.. Just check for AOT in
> detection)

We need to add the number of cpus in the aot file, so if that changes
we won't load it.
The code in io-layer/system.c needs to be changed to be pessimistic:
if it can't figure out the number of processors it should assume 2, not
1 or we may end up generating incorrect code.

> Index: mini-ops.h
> ===================================================================
> --- mini-ops.h	(revision 36280)
> +++ mini-ops.h	(working copy)
> @@ -400,6 +400,10 @@
>  MINI_OP(OP_RESTORE_LMF, "restore_lmf")
>  
>  
> +/* ATOMIC operands */
> +MINI_OP(OP_ATOMIC_INC_I4, "op_atomic_inc_i4")
> +MINI_OP(OP_ATOMIC_DEC_I4, "op_atomic_dec_i4")

How about adding OP_ATOMIC_ADD_IMM and OP_ATOMIC_ADD, instead?
The latter is needed for the next version, anyway, and the first
can be used to get the small optimization.
Using OP_ATOMIC_ADD_IMM requires a small refactoring of
mono_arch_get_opcode_for_method(): it should be changed to
create and return a MonoInst*, so it can also set the immediate value:
this seems more flexible and may be needed for other ops, too.

> +			br1 = code;
> +			if (!up_machine)
> +				x86_prefix (code, X86_LOCK_PREFIX);
> +			x86_cmpxchg_membase_reg (code, ins->inst_basereg, ins->inst_offset, sreg2);
> +			x86_branch8 (code, X86_CC_NE, br1 - code - 1, FALSE);

Use x86_patch, here, instead of hardcoding br1 - code - 1.

Thanks.
lupus


-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list