Repository navigation
Fix handling of multi-dim arrays in System.Array - #1263
Conversation
352b66e to
2357213
Compare
|
|
||
| public int GetUpperBound(int dimension) | ||
| { | ||
| #if CORERT |
There was a problem hiding this comment.
I think it would be worth it to have unique #define for it, so that we have easier time cleaning it up later once we unify.
|
LGTM otherwise. cc @smosier Could you please glance over this as well? |
| } | ||
|
|
||
| [RuntimeExport("RhGetBaseSize")] | ||
| public static unsafe uint RhGetBaseSize(EETypePtr ptrEEType) |
There was a problem hiding this comment.
Not directly related to this PR, but I would like to phase out these 'trivial EEType accessor APIs'. The EEType structure is, essentially, a binary contract and the upper layer runtime code (i.e. type loader layer) can know everything there is to know about EETypes, so there's not really any need, long term, to have these trivial accessors -- they provide no value.
There was a problem hiding this comment.
I agree ... the nice side effect of this would be elimination of the call overhead for these trivial assessors. It makes me sad every time I step through one of those.
There was a problem hiding this comment.
I'm all up for that. Moving the managed definition of src/Runtime.Base/src/System/Runtime/EEType.cs out to src/Common/... also unblocks unit testability of EEType emission (now we're free to include that file from a unit test and use it to interrogate a byte buffer prepared by the EEType emitter).
Filed #1268 to track that work.
|
LGTM modulo the existing comments. |
|
|
||
| #if REAL_MULTIDIM_ARRAYS | ||
| // The above checks should have covered all the reasons why Clear would fail. | ||
| Debug.Assert(false); |
There was a problem hiding this comment.
The comment seems out of place here. And why would this routine fail (i.e. Assert(false)) all the time in case of REAL_MULTIDIM_ARRAYS?
There was a problem hiding this comment.
This method is a weird performance optimization (it takes out throws from the Clear method).
- When REAL_MULTIDIM_ARRAYS is not defined, it handles the multidim array case, and all the failures.
- When REAL_MULTIDIM_ARRAYS is defined, it only handles the failure cases, because the runtime call in Clear should have handled multidim. It will only be called when Clear failed, and Clear can only fail if one of the inputs is wrong. That's why I have a TODO in the diff above to rename this method (ClearImpl right now) to something else.
Medium to long term, we're getting rid of the fake mdarrays and this method will probably just assert that one of the args is out of range and throw an IndexOutOfRangeException.
|
LGTM modulo comments |
On CoreRT we diverged from Project N by treating multi-dim arrays same as CLR. BCL needs to be fixed to reflect that.
05533d7 to
1525e0e
Compare
On CoreRT we diverged from Project N by treating multi-dim arrays same
as CLR. BCL needs to be fixed to reflect that.
Things that still need fixing:
I'll do those in a later pull request - the more code this has, the harder it is to review it. I'll keep #1103 open.