-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Convert some more array FCalls to managed #102739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
566b15e
8a592b9
0dce3d4
d29e5d8
5dd0e3c
527021c
e7d843a
2bb5fe7
f7da172
0924555
dc85381
f99c553
c5e6cc4
470b86f
c7821e6
5225203
07293e3
5da88c3
5222bca
335b2fb
93ec9d8
c3f5097
481e4d4
a266a30
b8e4584
5465a97
4ce4f51
30b7d8f
8a9c5bc
f95fa34
ebfd224
d9205c6
7eef724
8cfb58f
fbb9d71
324df76
089ae12
a5e7441
5552d63
133cd8a
e17bf0e
dd1e2dd
32b8789
582eaf1
1836ae5
cb6aa00
49cf866
7a0c398
db677ad
353715e
8fb1c96
26d4c80
5f7263f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ public static unsafe void InitializeArray(Array array, RuntimeFieldHandle fldHan | |
if (array is null) | ||
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); | ||
|
||
if ((RuntimeFieldHandle.GetAttributes(fldInfo.Value) & FieldAttributes.HasFieldRVA) == 0) | ||
if (!RuntimeFieldHandle.GetRVAFieldInfo(new QCallFieldHandle(ref fldInfo), out IntPtr address, out uint size)) | ||
throw new ArgumentException(SR.Argument_BadFieldForInitializeArray); | ||
|
||
// Note that we do not check that the field is actually in the PE file that is initializing | ||
|
@@ -35,13 +35,11 @@ public static unsafe void InitializeArray(Array array, RuntimeFieldHandle fldHan | |
MethodTable* pMT = GetMethodTable(array); | ||
nuint totalSize = pMT->ComponentSize * array.NativeLength; | ||
|
||
uint size = RuntimeFieldHandle.GetFieldSize(new QCallFieldHandle(ref fldInfo)); | ||
|
||
// make certain you don't go off the end of the rva static | ||
if (totalSize > size) | ||
throw new ArgumentException(SR.Argument_BadFieldForInitializeArray); | ||
|
||
void* src = (void*)RuntimeFieldHandle.GetStaticFieldAddress(fldInfo); | ||
void* src = (void*)address; | ||
huoyaoyuan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
ref byte dst = ref MemoryMarshal.GetArrayDataReference(array); | ||
|
||
Debug.Assert(!pMT->GetArrayElementTypeHandle().AsMethodTable()->ContainsGCPointers); | ||
|
@@ -86,7 +84,7 @@ public static unsafe void InitializeArray(Array array, RuntimeFieldHandle fldHan | |
{ | ||
IRuntimeFieldInfo fldInfo = fldHandle.GetRuntimeFieldInfo(); | ||
|
||
if ((RuntimeFieldHandle.GetAttributes(fldInfo.Value) & FieldAttributes.HasFieldRVA) == 0) | ||
if (!RuntimeFieldHandle.GetRVAFieldInfo(new QCallFieldHandle(ref fldInfo), out IntPtr data, out uint totalSize)) | ||
throw new ArgumentException(SR.Argument_BadFieldForInitializeArray); | ||
|
||
TypeHandle th = new TypeHandle((void*)targetTypeHandle.Value); | ||
|
@@ -95,10 +93,8 @@ public static unsafe void InitializeArray(Array array, RuntimeFieldHandle fldHan | |
if (!th.GetVerifierCorElementType().IsPrimitiveType()) // Enum is included | ||
huoyaoyuan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
throw new ArgumentException(SR.Argument_MustBePrimitiveArray); | ||
|
||
|
||
uint totalSize = RuntimeFieldHandle.GetFieldSize(new QCallFieldHandle(ref fldInfo)); | ||
uint targetTypeSize = th.AsMethodTable()->GetNumInstanceFieldBytes(); | ||
|
||
IntPtr data = RuntimeFieldHandle.GetStaticFieldAddress(fldInfo); | ||
if (data % targetTypeSize != 0) | ||
throw new ArgumentException(SR.Argument_BadFieldForInitializeArray); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.