Implement Array.UnsafeLoad and Array.UnsafeStore. Both functions ignores bounds check...
commit5ee66e1983ab15ef04136623d8b5c05ed9598e88
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 1 Oct 2012 17:02:34 +0000 (1 13:02 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 1 Oct 2012 19:15:24 +0000 (1 15:15 -0400)
treef5d5233692d5ad60d14c4759163f4fcaa5d531c1
parentc8200121e50ded14a191713731e16cec5045858f
Implement Array.UnsafeLoad and Array.UnsafeStore. Both functions ignores bounds check when possible.

* Array.cs: Add UnsafeLoad and UnsafeStore functions that don't perform bounds check.
The JIT will generate, when possible, direct a load/store. Right now the only case we can't
handle are stores to reference arrays.

Reference arrays are covariant on their element type which means that we must perform a runtime
type check on stores to preserve type safety. Since the type check is usually must more expensive
than the bounds check we simply ignore this for now.

The reasoning behind this decision was that given our initial target are corlib's collections and
they are too covariant to their element types they do need too a runtime type check on stores to ensure
correctness.
mcs/class/corlib/System/Array.cs
mono/mini/method-to-ir.c