[x86/Linux] add three functions for _X86_TARGET_#10378
Conversation
|
@ragmani, It will cover your contributions to all .NET Foundation-managed open source projects. |
|
@parjong This PR is from #10139 |
| dwSize = AlignUp(dwSize, sizeof(ULONG)); | ||
|
|
||
| dwSize += sizeof(ULONG); | ||
| #endif //REDHAWK |
There was a problem hiding this comment.
There was a problem hiding this comment.
Yes, this should do the same thing as reservePersonalityRoutineSpace in VM
|
@dotnet-bot test Windows_NT x86 Checked Build and Test please |
|
@ragmani, It will cover your contributions to all .NET Foundation-managed open source projects. |
There is no functions for _X86_TARGET_. - ZapUnwindData::GetAlignment() - DWORD ZapUnwindData::GetSize() - void ZapUnwindData::Save(ZapWriter * pZapWriter)
remove creating personaly routine when assemblies is generated to ni. add a function for getting size of UnwindDataBlob on x86/linux. Signed-off-by: ragmani <ragmani0216@gmail.com>
|
I modified it as removing personality routine and succeeded in generating to ni with readytorun option. |
|
I confirmed that simple ni assembly runs normally. |
| PVOID pData = GetData(); | ||
| DWORD dwSize = GetBlobSize(); | ||
|
|
||
| UNWIND_INFO * pUnwindInfo = (UNWIND_INFO *)pData; |
There was a problem hiding this comment.
This is unnecessary - pUnwindInfo is not used.
| #elif defined(_TARGET_X86_) && defined(FEATURE_PAL) | ||
| PTR_UNWIND_INFO pUnwindInfo(dac_cast<PTR_UNWIND_INFO>(moduleBase + RUNTIME_FUNCTION__GetUnwindInfoAddress(pRuntimeFunction))); | ||
|
|
||
| *pSize = ALIGN_UP(sizeof(ULONG), sizeof(DWORD)); |
There was a problem hiding this comment.
This is not correct - it will be always 4. It needs to be the actual size like in other cases
There was a problem hiding this comment.
I modified to "*pSize = ALIGN_UP(sizeof(UNWIND_INFO), sizeof(BYTE));"
There was a problem hiding this comment.
Aligning to sizeof(BYTE) doesn't make sense, it would always return the first parameter of the macro unchanged (align ensures that the value returned by the macro is a multiple of the second parameter and sizeof(BYTE) is 1 and all numbers are multiple of 1)
|
|
||
| UINT ZapUnwindData::GetAlignment() | ||
| { | ||
| return sizeof(ULONG); |
There was a problem hiding this comment.
Can this be just sizeof(BYTE) ? The JIT case does not seem to have any extra alignment. It can be same here.
There was a problem hiding this comment.
I modified to BYTE in here and GetUnwindDataBlob function.
|
@ragmani, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
change Unwindinfo's size from sizeof(ULONG) to sizeof(UNWIND_INFO). change Unwindinfo's alignment from sizeof(DWORD) to sizeof(BYTE). remove unnecessary code.
| #elif defined(_TARGET_X86_) && defined(FEATURE_PAL) | ||
| PTR_UNWIND_INFO pUnwindInfo(dac_cast<PTR_UNWIND_INFO>(moduleBase + RUNTIME_FUNCTION__GetUnwindInfoAddress(pRuntimeFunction))); | ||
|
|
||
| *pSize = ALIGN_UP(sizeof(UNWIND_INFO), sizeof(BYTE)); |
There was a problem hiding this comment.
The first argument to ALIGN_UP is correct now, but the second should be sizeof(DWORD)
|
@dotnet-bot test Ubuntu x64 Checked Build and Test please |
|
@dotnet-bot test OSX10.12 x64 Checked Build and Test please |
|
|
||
| UINT ZapUnwindData::GetAlignment() | ||
| { | ||
| return sizeof(BYTE); |
There was a problem hiding this comment.
This should be sizeof(ULONG) like on the other platforms.
There was a problem hiding this comment.
This change was introduced according to the following comment by @jkotas:
Can this be just sizeof(BYTE) ? The JIT case does not seem to have any extra alignment. It can be same here.
Could you let us know the semantics of GetAlignment? x86/Linux currently emits no unwind data, and thus sizeof(BYTE) also looks fine.
There was a problem hiding this comment.
Ok, I was comparing it just to the other platforms. I've missed that comment from @jkotas and he knows better than me the semantics here. So let's ignore all of my comments.
|
|
||
| DWORD ZapUnwindData::GetSize() | ||
| { | ||
| DWORD dwSize = ZapBlob::GetSize(); |
There was a problem hiding this comment.
Please add dwSize = AlignUp(dwSize, sizeof(ULONG)); here, like we use on other platforms.
| PVOID pData = GetData(); | ||
| DWORD dwSize = GetBlobSize(); | ||
|
|
||
| pZapWriter->Write(pData, dwSize); |
There was a problem hiding this comment.
And finally here, I believe we should add the following after the write (again, like we do on other platforms)
DWORD dwPad = AlignmentPad(dwSize, sizeof(DWORD));
if (dwPad != 0)
pZapWriter->WritePad(dwPad);| #elif defined(_TARGET_X86_) && defined(FEATURE_PAL) | ||
| PTR_UNWIND_INFO pUnwindInfo(dac_cast<PTR_UNWIND_INFO>(moduleBase + RUNTIME_FUNCTION__GetUnwindInfoAddress(pRuntimeFunction))); | ||
|
|
||
| *pSize = ALIGN_UP(sizeof(UNWIND_INFO), sizeof(DWORD)); |
There was a problem hiding this comment.
This does not look right. There is no alignment when the unwind blob is getting produced, and so there should be no alignment here where it is getting consumed either.
You should see crashes during GC or exception handling with R2R images because of this bug.
There was a problem hiding this comment.
Maybe this should be identical to the !WIN64EXCEPTIONS path:
PTR_VOID GetUnwindDataBlob(TADDR moduleBase, PTR_RUNTIME_FUNCTION pRuntimeFunction, /* out */ SIZE_T * pSize)
{
*pSize = 0;
return dac_cast<PTR_VOID>(pRuntimeFunction->UnwindData + moduleBase);
}
There was a problem hiding this comment.
Hmm, I am confused here. The added alignment was my request, since we do align in a similar way on AMD64 too (see few lines above).
There was a problem hiding this comment.
The structure of the unwind info is different on x86. There is no actual isolated unwind info blob like on x64. The unwind info is part of GCInfo on x86. So mirroring x64 is not the right strategy.
There was a problem hiding this comment.
Hmm, I see, the size is used to get location of the GCInfo from the address of the unwind data blob, so returning zero size like the Windows x86 is the right thing to do here. I can see now that that's what all the callers of GetUnwindDataBlob expect for x86.
There was a problem hiding this comment.
Btw, it looks like we will need to modify the following functions to take into account the fact that there is no personality routine for x86 Linux:
NativeImageJitManager::IsFilterFunclet
ReadyToRunJitManager::IsFilterFunclet
There was a problem hiding this comment.
@jkotas Should *pSize be set as 0? x86/Linux produces a unwind info that consists of FunctionLength unlike x86/Windows. (from inc/win64unwind.h).
There was a problem hiding this comment.
I see - this may be just sizeof(UNWIND_INFO) for clarity then.
* [x86/Linux] add three functions for _X86_TARGET_ There is no functions for _X86_TARGET_. - ZapUnwindData::GetAlignment() - DWORD ZapUnwindData::GetSize() - void ZapUnwindData::Save(ZapWriter * pZapWriter) * [x86/Linux] remove personality routine on x86/linux. remove creating personaly routine when assemblies is generated to ni. add a function for getting size of UnwindDataBlob on x86/linux. Signed-off-by: ragmani <ragmani0216@gmail.com> * [x86/Linux] correct the unclearly fixed parts. change Unwindinfo's size from sizeof(ULONG) to sizeof(UNWIND_INFO). change Unwindinfo's alignment from sizeof(DWORD) to sizeof(BYTE). remove unnecessary code. * [x86/Linux] change alignment from sizeof(BYTE) to sizeof(DWORD).
There is no functions for X86_TARGET.