Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@AndyAyersMS
Copy link
Member

With the advent of #25251 we can now see the epilog exit sequence on x86 vary
by as much as 6 bytes. Update the assert accordingly.

With the advent of dotnet#25251 we can now see the epilog exit sequence on x86 vary
by as much as 6 bytes. Update the assert accordingly.
@AndyAyersMS
Copy link
Member Author

cc @dotnet/jit-contrib

Example from bug is:

; Assembly listing for method TestCase.Test:Fact1(byref,byref):int

;; 7 byte mov + jmp
       B80C639907   mov      eax, 0x799630C
       FF20         jmp      dword ptr [eax]TestCase.Test:Fact1(byref,byref):int

;; 1 byte ret
       C3           ret

Copy link

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

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

Seems weird we generate a 'ret' there instead of an 'int 3'

@AndyAyersMS
Copy link
Member Author

It is a different epilog -- I just edited out the rest of the code. Here's the full disassembly:

G_M33028_IG01:
       55           push     ebp
       8BEC         mov      ebp, esp
       83EC0C       sub      esp, 12
       33C0         xor      eax, eax
       8945F4       mov      dword ptr [ebp-0CH], eax
       894DFC       mov      bword ptr [ebp-04H], ecx
       8955F8       mov      bword ptr [ebp-08H], edx

G_M33028_IG02:
       833D6C52990700 cmp      dword ptr [0799526CH], 0
       7405         je       SHORT G_M33028_IG03
       E8C99F7F4E   call     CORINFO_HELP_DBG_IS_JUST_MY_CODE

G_M33028_IG03:
       8B45FC       mov      eax, bword ptr [ebp-04H]
       833801       cmp      dword ptr [eax], 1
       7F09         jg       SHORT G_M33028_IG04
       C745F445230100 mov      dword ptr [ebp-0CH], 0x12345
       EB25         jmp      SHORT G_M33028_IG06

G_M33028_IG04:
       8B45F8       mov      eax, bword ptr [ebp-08H]
       8B00         mov      eax, dword ptr [eax]
       8B55FC       mov      edx, bword ptr [ebp-04H]
       0FAF02       imul     eax, dword ptr [edx]
       8B55F8       mov      edx, bword ptr [ebp-08H]
       8902         mov      dword ptr [edx], eax
       8B45FC       mov      eax, bword ptr [ebp-04H]
       FF08         dec      dword ptr [eax]
       8B4DFC       mov      ecx, bword ptr [ebp-04H]
       8B55F8       mov      edx, bword ptr [ebp-08H]

G_M33028_IG05:
       8BE5         mov      esp, ebp
       5D           pop      ebp
       B80C639907   mov      eax, 0x799630C
       FF20         jmp      dword ptr [eax]TestCase.Test:Fact1(byref,byref):int

G_M33028_IG06:
       8B45F4       mov      eax, dword ptr [ebp-0CH]

G_M33028_IG07:
       8BE5         mov      esp, ebp
       5D           pop      ebp
       C3           ret

; Total bytes of code 92, prolog size 17 for method TestCase.Test:Fact1(byref,byref):int

Note on x86 we always can fit the indir cell address into a 32 bit displacement, so following up on #25286 would compact this back down.

@AndyAyersMS AndyAyersMS merged commit e31c78b into dotnet:master Jun 21, 2019
@AndyAyersMS AndyAyersMS deleted the Fix25301 branch June 21, 2019 15:32
AndyAyersMS added a commit to AndyAyersMS/coreclr that referenced this pull request Jun 24, 2019
On x86 we can always reach any IAT_PVALUE entry via a 32 bit indirect
jump, and proper handling of jmp epilogs depends on this. So check if the
target address is reachable in 32 bits, and if so, use the jmp [addr] form
on x86, and the jmp [rip + disp] form for x64.

Fixes #25345
Fixes #25346
Undoes the assertion change from dotnet#25302
Fixes #25286
jkotas pushed a commit that referenced this pull request Jun 24, 2019
On x86 we can always reach any IAT_PVALUE entry via a 32 bit indirect
jump, and proper handling of jmp epilogs depends on this. So check if the
target address is reachable in 32 bits, and if so, use the jmp [addr] form
on x86, and the jmp [rip + disp] form for x64.

Fixes #25345
Fixes #25346
Undoes the assertion change from #25302
Fixes #25286
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
With the advent of dotnet/coreclr#25251 we can now see the epilog exit sequence on x86 vary
by as much as 6 bytes. Update the assert accordingly.

Fixes dotnet/coreclr#25301.

Commit migrated from dotnet/coreclr@e31c78b
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…r#25348)

On x86 we can always reach any IAT_PVALUE entry via a 32 bit indirect
jump, and proper handling of jmp epilogs depends on this. So check if the
target address is reachable in 32 bits, and if so, use the jmp [addr] form
on x86, and the jmp [rip + disp] form for x64.

Fixes dotnet/coreclr#25345
Fixes dotnet/coreclr#25346
Undoes the assertion change from dotnet/coreclr#25302
Fixes dotnet/coreclr#25286

Commit migrated from dotnet/coreclr@bad8d91
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants