Skip to content
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

[LoongArch64] coreclr/debug and part of inc directory. #62886

Merged
merged 32 commits into from
Apr 25, 2022
Merged

[LoongArch64] coreclr/debug and part of inc directory. #62886

merged 32 commits into from
Apr 25, 2022

Conversation

shushanhf
Copy link
Contributor

[LoongArch64] coreclr-inc,gc, ToolBox directory.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Dec 16, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

src/coreclr/inc/corinfo.h Outdated Show resolved Hide resolved
src/coreclr/inc/corinfo.h Outdated Show resolved Hide resolved
Copy link
Contributor Author

@shushanhf shushanhf left a comment

Choose a reason for hiding this comment

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

What ohter files are dependent on the windows for this PR ?

src/coreclr/binder/assemblybindercommon.cpp Outdated Show resolved Hide resolved
src/coreclr/binder/inc/bindertypes.hpp Outdated Show resolved Hide resolved
@@ -346,6 +346,12 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext* MethodToCompile, i
matchesTargetArch = (targetArch == SPMI_TARGET_ARCHITECTURE_ARM64);
break;

#ifdef TARGET_UNIX
Copy link
Member

Choose a reason for hiding this comment

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

Instead of adding this ifdef, it would be better to define IMAGE_FILE_MACHINE_LOONGARCH64 on Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry, where is the defination on windows?

Copy link
Member

@jkotas jkotas Dec 22, 2021

Choose a reason for hiding this comment

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

I meant that you can define IMAGE_FILE_MACHINE_LOONGARCH64 in a place that shared between Windows and non-Windows so that these ifdefs are not necessary.

src/coreclr/inc/clrnt.h may be a good place to add IMAGE_FILE_MACHINE_LOONGARCH64 definition that is shared between Windows and non-Windows.

Try adding this:

#ifndef IMAGE_FILE_MACHINE_LOONGARCH64
#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264
#endif

at https://github.com/dotnet/runtime/blob/main/src/coreclr/inc/clrnt.h#L1032

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#ifndef IMAGE_FILE_MACHINE_LOONGARCH64
#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264
#endif

Thanks~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#62886 (comment)

But the compiling error is still exist.

Copy link
Contributor Author

@shushanhf shushanhf Dec 22, 2021

Choose a reason for hiding this comment

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

I meant that you can define IMAGE_FILE_MACHINE_LOONGARCH64 in a place that shared between Windows and non-Windows so that these ifdefs are not necessary.

src/coreclr/inc/clrnt.h may be a good place to add IMAGE_FILE_MACHINE_LOONGARCH64 definition that is shared between Windows and non-Windows.

Try adding this:

#ifndef IMAGE_FILE_MACHINE_LOONGARCH64
#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264
#endif

at https://github.com/dotnet/runtime/blob/main/src/coreclr/inc/clrnt.h#L1032

It seems that it doesn't work.

@@ -2233,7 +2233,11 @@ inline ULONG CorSigCompressPointer( // return number of bytes of that compressed
void * pvPointer, // [IN] given uncompressed data
void * pData) // [OUT] buffer where iLen will be compressed and stored.
{
#ifdef TARGET_LOONGARCH64
Copy link
Member

Choose a reason for hiding this comment

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

Changes like this should not be under. This change should be done for all architectures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right.
Especially for CPU processors supporting unaligned memory accessing.
I will update it later with breaking up this PR into serval PRs.

// jirl $r0,$r21,0 ; Jump to the target
DWORD m_rgCode[3];

DWORD m_padding; //aligning stack to 16 bytes
Copy link
Member

Choose a reason for hiding this comment

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

This structure has nothing to do with stack. Is the comment wrong?

Copy link
Contributor Author

@shushanhf shushanhf Dec 22, 2021

Choose a reason for hiding this comment

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

This structure has nothing to do with stack. Is the comment wrong?

Yes.
I should add a macro at here, prestup.cpp-Line:2363 #elif defined(TARGET_ARM) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)

But I also have a question.
Previous within the .NET6-runtime, the initialing code is in the file src/coreclr/zap/zapimport.cpp:489.
But now the zapimport.cpp had been deleted.
Not only the LoongArch64, the others architecturs also do nothing for initialing the m_rgCode.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, CORCOMPILE_EXTERNAL_METHOD_THUNK is no longer used. It would be best to delete it instead of trying to fix it up for LoongArch64.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I will delete it for LoongArch64.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, CORCOMPILE_EXTERNAL_METHOD_THUNK is no longer used. It would be best to delete it instead of trying to fix it up for LoongArch64.

Maybe I have to keep a define for LoongArch64 as the same with other architecture rather than compiling error for undefined value.

Copy link
Member

Choose a reason for hiding this comment

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

I am deleting it in #65869

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am deleting it in #65869

OK, I will update it after you merge that.
Thanks

@shushanhf
Copy link
Contributor Author

Liking the compiling error #62843 (comment)

D:\a\_work\1\s\src\coreclr\debug\shim\debugshim.cpp(678): error C2065: 'IMAGE_FILE_MACHINE_LOONGARCH64': undeclared identifier

This PR's error on windows is also for undefined IMAGE_FILE_MACHINE_LOONGARCH64 which is defined within the file src/coreclr/pal/inc/rt/ntimage.h .

@jkotas
Copy link
Member

jkotas commented Feb 24, 2022

I think you may need to add #define IMAGE_FILE_MACHINE_LOONGARCH64 ... to src/coreclr/inc/clrnt.h to fix the build on Windows.

@shushanhf
Copy link
Contributor Author

I think you may need to add #define IMAGE_FILE_MACHINE_LOONGARCH64 ... to src/coreclr/inc/clrnt.h to fix the build on Windows.

OK, Thanks.
I will submit it later.

@shushanhf
Copy link
Contributor Author

I think you may need to add #define IMAGE_FILE_MACHINE_LOONGARCH64 ... to src/coreclr/inc/clrnt.h to fix the build on Windows.

OK, Thanks. I will submit it later.

I had added #define IMAGE_FILE_MACHINE_LOONGARCH64 ... to src/coreclr/inc/clrnt.h,
but there is still error on windows.

I guess windows and linux included different files for different macro-define, for example, the file src/coreclr/pal/inc/rt/palrt.h with defined RC_INVOKED will not include ntimage.h.
While windows has some default files including the defination IMAGE_FILE_MACHINE_ARM64 which not supporting IMAGE_FILE_MACHINE_LOONGARCH64 .

I will submit a temp patch for testing.

@jkotas
Copy link
Member

jkotas commented Feb 24, 2022

I had added #define IMAGE_FILE_MACHINE_LOONGARCH64 ... to src/coreclr/inc/clrnt.h,

Adding this to palclr.h instead is fine - assuming that it is going to fix all build breaks on Windows.

@shushanhf
Copy link
Contributor Author

shushanhf commented Feb 25, 2022

Hi, @jkotas

Now the CI's errors are about the libunwind which is only on cross-arm64-windows, liking

D:\a\_work\1\s\src\coreclr\pal\src\libunwind\include\libunwind-aarch64.h(198): error C2061: syntax error: identifier 'alignas'
D:\a\_work\1\s\src\coreclr\pal\src\libunwind\include\libunwind-aarch64.h(199): error C2059: syntax error: '}'
D:\a\_work\1\s\src\coreclr\pal\src\libunwind\include\libunwind-aarch64.h(215): error C2079: 'uc_mcontext' uses undefined struct 'unw_sigcontext'
[6/441] Building C object pal\src\libunwind\src\CMakeFiles\libunwind_xdac.dir\aarch64\Gget_save_loc.c.ob

How should I resolv this error ?

@jkotas
Copy link
Member

jkotas commented Feb 25, 2022

Now the CI's errors are about the libunwind which is only on cross-arm64-windows

This is CI infrastructure issue affecting all PRs: #65818. Do not worry about it.

@shushanhf shushanhf requested a review from jkotas April 12, 2022 04:41
mangod9 pushed a commit that referenced this pull request Apr 21, 2022
* Part6-2: -add the coreclr-vm directory for LoongArch64. (#59561)

Co-authored-by: Loongson's .NET-teams

* [LoongArch64] revert the syncblk.cpp.

* [LoongArch64] delete some unused codes.

* [LoongArch64] add vm/CMakeLists.txt from #62889.

* [LoongArch64] add related files from #62886 and #62893.

* [LoongArch64] moved vm/jitinterface.cpp from #62893.
moved inc/corinfo.h from #6288.

* [LoongArch64] run the file `src/coreclr/tools/Common/JitInterface/ThunkGenerator/gen.sh`
and merge the patch from #62893.

* [LoongArch64] revert vm/ceeload.h.
amend the `ToolBox/superpmi/superpmi-shared/agnostic.h`

* [LoongArch64] add empty interfaces within `CorInfoImpl.cs`.

* [LoongArch64] Fix the compiling error on Windows.

* [LoongArch64] Fix the compiling error for memory unaligned m_currentByteStackIndex.

* [LoongArch64] Delete the !TARGET_LOONGARCH64 for m_currentByteStackIndex.

* [LoongArch64] move ToolBox from #62886.

* [LoongArch64] amend the args when needs unsigned extending within CallTargetWorker.

* [LoongArch64] add bool type for args' unsigned extention.

* [LoongArch64] adding char type for args' unsigned extention.
Also rename `TARGET_LOONGARCH64` to `UNIX_LOONGARCH64_ABI` within ABI.

* [LoongArch64] amend renaming `TARGET_LOONGARCH64` to `UNIX_LOONGARCH64_ABI` within ABI.

* [LoongArch64] remove the JIT/EE interface to #62893.

* [LoongArch64] revert the rename `TARGET_LOONGARCH64` to `UNIX_LOONGARCH64_ABI`.
Also add unsigned extend for CHAR type.

* [LoongArch64] refactor the `ArgDestination and ArgLocDesc`.

* [LoongArch64] rename the `m_flag` and `getFieldTypeByHnd`.

* [LoongArch64] add `NATIVE_SYMBOL_READER_DLL` for compiling error.

* [LoongArch64] update the version of the `LICENSE description`.

* [LoongArch64] keep same with the comment in `jit/targetloongarch64.h`

* [LoongArch64] amend the code for reviewing.

* [LoongArch64] refactor LoongArch64-ABI within `vm`,
and also amend some code for review.

* [LoongArch64] delete unused codes.

* [LoongArch64] merge main for #65869.

* [LoongArch64] amend the format for reviewing.

* [LoongArch64] delete some unused code for reviewing.

* [LoongArch64] amend code for CR feedback @jkotas @janvorli

* [LoongArch64] add class type for LoongArch64-ABI.

* [LoongArch64] Amend the LoongArch64's ABI
after merged `MethodTable::GetLoongArch64PassStructInRegisterFlags()`
and `CEEInfo::getLoongArch64PassStructInRegisterFlags()`

* [LoongArch64] Fix the assert error
when running hello-world within debug-mode after refacting.

Co-authored-by: qiaopengcheng <qiaopengcheng-hf@loongson.cn>
@shushanhf
Copy link
Contributor Author

@mikem8361 @hoyosjs
Could you please review this PR ?

@shushanhf
Copy link
Contributor Author

Hi, @tommcdon
Could you please review this PR ?

Copy link
Member

@mikem8361 mikem8361 left a comment

Choose a reason for hiding this comment

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

It looks like you have a lot to implement. Am I looking at this too soon?

src/coreclr/debug/createdump/threadinfounix.cpp Outdated Show resolved Hide resolved
@ghost ghost added the needs-author-action An issue or pull request that requires more info or actions from the author. label Apr 22, 2022
@tonyqus
Copy link

tonyqus commented Apr 22, 2022

@shushanhf I'm a bit curious. Are you working on LoognArch .NET runtime project alone? I've been tracking the PR for a few months. Looks you are the only person committing code. I do suggest you involve a team instead of yourself because this is a huge task.

@ghost ghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Apr 24, 2022
@shushanhf shushanhf requested a review from mikem8361 April 24, 2022 14:07
@BruceForstall
Copy link
Member

It looks like you have a lot to implement. Am I looking at this too soon?

@mikem8361 Does you think more needs to be implemented before this change can be merged? I.e., is this wrong as-is, or just incomplete from a "full implementation" perspective? I presume that there will be additional work to make LoongArch64 a complete implementation.

Copy link
Member

@mikem8361 mikem8361 left a comment

Choose a reason for hiding this comment

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

It looks like everything is implemented now. Thanks.

@BruceForstall BruceForstall merged commit fc2f06e into dotnet:main Apr 25, 2022
@shushanhf shushanhf deleted the main_loongarch64_3 branch May 11, 2022 01:12
@ghost ghost locked as resolved and limited conversation to collaborators Jun 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-loongarch64 area-Diagnostics-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants