Bug 314241 (MONO56208) - [PATCH] Marshal.UnsafeAddrOfPinnedArrayElement patches
Summary: [PATCH] Marshal.UnsafeAddrOfPinnedArrayElement patches
Status: RESOLVED FIXED
Alias: MONO56208
Product: Mono: Class Libraries
Classification: Mono
Component: CORLIB (show other bugs)
Version: unspecified
Hardware: Other Red Hat 9.0
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2004-03-30 09:26 UTC by Vladimir Vukicevic
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
mcs_arrayaddr.patch (886 bytes, patch)
2004-03-30 09:26 UTC, Thomas Wiest
Details | Diff
mono_arrayaddr.patch (2.15 KB, patch)
2004-03-30 09:26 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 18:32:03 UTC


---- Reported by vladimir@pobox.com 2004-03-30 02:26:01 MST ----

Attached are two small patches that implement
System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(). 
My simple tests seem to work right, but I could be doing something horribly
wrong.



---- Additional Comments From vladimir@pobox.com 2004-03-30 02:26:21 MST ----

Created an attachment (id=165818)
mcs_arrayaddr.patch




---- Additional Comments From vladimir@pobox.com 2004-03-30 02:26:44 MST ----

Created an attachment (id=165819)
mono_arrayaddr.patch




---- Additional Comments From bmaurer@users.sf.net 2004-04-04 11:20:12 MST ----

It would be pretty easy to make an opcode in this for mini so that it
was fast (look at ldelema, but just do it without the bounds check.
also,you will have to access the vtable->klass to find out the element
size).

MSDN says:
`For maximum performance, this method does no validation on the array
passed to it; this can result in unexpected behavior.', so it sounds
like they think it is a method that needs to be performant.

not really a big issue though.



---- Additional Comments From bmaurer@users.sf.net 2004-04-04 11:43:46 MST ----

also, look at:
#define mono_array_addr_with_size(array,size,index) (
((char*)(array)->vector) + (size) * (index) )

you should probably use that for the icall version, for neatness.



---- Additional Comments From vargaz@freemail.hu 2004-05-05 08:02:50 MST ----

Fixed in CVS. Thanks for the patch.

Imported an attachment (id=165818)
Imported an attachment (id=165819)