Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Fix handling of multi-dim arrays in System.Array - #1263

Merged
jkotas merged 6 commits into
dotnet:masterfrom
MichalStrehovsky:mdArrayFixes
May 11, 2016
Merged

jkotas merged 6 commits into
dotnet:masterfrom
MichalStrehovsky:mdArrayFixes

Conversation

@MichalStrehovsky

@MichalStrehovsky MichalStrehovsky commented May 9, 2016 •

Copy link
Copy Markdown
Member

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:

  • Various Copy details
  • Enumerator
  • SetValue(params)/GetValue(params)

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.


public int GetUpperBound(int dimension)
{
#if CORERT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jkotas

jkotas commented May 10, 2016

Copy link
Copy Markdown
Member

LGTM otherwise.

cc @smosier Could you please glance over this as well?

}

[RuntimeExport("RhGetBaseSize")]
public static unsafe uint RhGetBaseSize(EETypePtr ptrEEType)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@smosier

smosier commented May 10, 2016

Copy link
Copy Markdown
Contributor

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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jkotas

jkotas commented May 11, 2016

Copy link
Copy Markdown
Member

LGTM modulo comments

@jkotas
jkotas merged commit 388ce56 into dotnet:master May 11, 2016
@MichalStrehovsky
MichalStrehovsky deleted the mdArrayFixes branch May 11, 2016 23:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants