diff options
author | Michal Strehovský <MichalStrehovsky@users.noreply.github.com> | 2017-04-15 00:25:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-15 00:25:24 +0300 |
commit | 46498b14176e85c25f7cb7926c377246fcb47fb2 (patch) | |
tree | a0263cd6dc8c28b21d42e643daa4eaf7869793ac /src/Runtime.Base | |
parent | 1896a8cab2f6f83a86ba3879a02018230c549fcf (diff) |
Add asserts to RhNewObject/RhNewArray (#3334)
The one in `RhNewArray` would have saved me around 45 minutes of
investigation so I think this is worth it.
Diffstat (limited to 'src/Runtime.Base')
-rw-r--r-- | src/Runtime.Base/src/System/Runtime/RuntimeExports.cs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Runtime.Base/src/System/Runtime/RuntimeExports.cs b/src/Runtime.Base/src/System/Runtime/RuntimeExports.cs index 7f6b0efc3..eb5c5e432 100644 --- a/src/Runtime.Base/src/System/Runtime/RuntimeExports.cs +++ b/src/Runtime.Base/src/System/Runtime/RuntimeExports.cs @@ -23,6 +23,21 @@ namespace System.Runtime public static unsafe object RhNewObject(EETypePtr pEEType) { EEType* ptrEEType = (EEType*)pEEType.ToPointer(); + + // This is structured in a funny way because at the present state of things in CoreRT, the Debug.Assert + // below will call into the assert defined in the class library (and not the MRT version of it). The one + // in the class library is not low level enough to be callable when GC statics are not initialized yet. + // Feel free to restructure once that's not a problem. +#if DEBUG + bool isValid = !ptrEEType->IsGenericTypeDefinition && + !ptrEEType->IsInterface && + !ptrEEType->IsArray && + !ptrEEType->IsString && + !ptrEEType->IsByRefLike; + if (!isValid) + Debug.Assert(false); +#endif + #if FEATURE_64BIT_ALIGNMENT if (ptrEEType->RequiresAlign8) { @@ -45,6 +60,9 @@ namespace System.Runtime public static unsafe object RhNewArray(EETypePtr pEEType, int length) { EEType* ptrEEType = (EEType*)pEEType.ToPointer(); + + Debug.Assert(ptrEEType->IsArray || ptrEEType->IsString); + #if FEATURE_64BIT_ALIGNMENT if (ptrEEType->RequiresAlign8) { |