[Mono-list] mcs compiles on linux. Now what?

Martin Baulig martin@gnome.org
08 Mar 2002 18:34:18 +0100


Paolo Molaro <lupus@ximian.com> writes:

> On 03/08/02 Martin Baulig wrote:
> > > 21 % is spent in Array.Copy. One third of this time is spent in the
> > > IsValueType checks. Here we can use the fast copy method even for
> > > objects, not only for valuetypes, so that check should not be there, I
> > > think: we could have a new icall the do the check or we could integrate
> > > the chek in FastCopy (but making it return an error code that is checked
> > > and throws an exception or falls back to the slow implementation in C#
> > > code).
> > 
> > So, maybe it was a bad idea to do all the Array.Copy checks in C# -
> > especially if IsValueType shows up in the profile at all ?
> 
> My point is that the IsValueType check should not be there.
> First, if you really want to keep it, one is enough:
> 
> 	typea.IsValueType && typeb.IsValueType && typea == typeb
> 
> is true in all the cases that:
> 
> 	typea.IsValueType && typea == typeb

Good point. I'll fix this.

> is true. This just cut the IsValueType overhead in half.
> Second, the current implementation uses the slow setvalue(getvalue)
> stuff like the old code did for objects. Arrays of objects can always
> use FastCopy if the element type of one array is assign compatible
> with the destination array element type. Do you have test where this
> would not work?

I had no test case at all for this situation, that's why I did not
implement this - I prefered being conservative rather than breaking this
function by committing untested code. I'll write some test cases for it
tomorrow and then implement it.

> Third, in the current implementation calling Copy(source, dest, length),
> the "(source == null || dest == null)" check is done _three_ times
> when one is enough.

The two checks in Copy (Array, int, Array, int, int) are a bug, but the
two checks in Copy (Array, Array, int) are a feature - if this is a
problem, then we need to provide a null-safe GetLowerBounds ....

-- 
Martin Baulig
martin@gnome.org