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

Ben Maurer bmaurer at ximian.com
Tue Nov 23 15:07:54 EST 2004


> Hi,
>
> This patch moves the implementation of Interlocked functions for x86 to
> op codes. The patch detects uniprocessor machines to allow skipping the
> bus lock prefix (2,5 x speed difference).
This is looking very nice.

> 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)

No, I don't think so. AOT code should be considered to be specific to the
box it is generated on. For example, if we are on a p4, we can use cmov
and sse.

For `OP_ATOMIC_EXCHANGE_I4', I never understood why we can't use xchg
here. Is there any specific reason.

Also, if you want something in eax or another register, you should just
specify that in the regalloc spec, and not us push/pop.

I think that the inc/dec should use a common path OP_ATOMIC_ADD. In 2.0
there is Interlocked.Add, which adds any number. ALso, we should add
optimizations so that:

Interlocked.Increment (ref foo)

gets turned into

[lock; ] inc [foo]

rather than an xadd type thing.

-- Ben





More information about the Mono-devel-list mailing list