[Mono-dev] [PATCH] Managed Marshal.Copy implemantations

Paolo Molaro lupus at ximian.com
Mon Dec 17 05:26:47 EST 2007


On 12/17/07 Kornél Pál wrote:
> Can I commit this patch or should Marshal.Copy remain unmanaged or do you 
> have any other objections?

I'm not opposed to have this stuff implemented in managed code, but I
don't like the specific way it has been done as it involves lots of
duplicate code (for example the original C implementation has a bug and
in your code it's duplicated several times) and you also managed to hide
the assignment of a local var inside of a conditional expression.
Your code also omits a check that the current code does of the rank of
the array.

I would support a change that reimplemented in managed code
copy_to_unmanaged()/copy_from_unmanaged(), maybe passing the array
element size as an additional argument.
To do this you just need an additional internal call that returns
a IntPtr to the start of the elements given an Array (the JIT can
recognize this icall and turn it into an addition of a constant).

lupus

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



More information about the Mono-devel-list mailing list