[x86/Linux] 16-byte aligned BackPatchWorkerAsmStub (dotnet/coreclr#10759)
authorJonghyun Park <parjong@gmail.com>
Wed, 12 Apr 2017 22:07:56 +0000 (07:07 +0900)
committerJan Vorlicek <janvorli@microsoft.com>
Wed, 12 Apr 2017 22:07:56 +0000 (00:07 +0200)
* [x86/Linux] 16-byte aligned BackPatchWorkerAsmStub

* Use fixed alignment padding

* Do NOT push ebx (no longer required)

Commit migrated from https://github.com/dotnet/coreclr/commit/cebfa42d658e9ab39f189aeb01baeb266ed1190a

src/coreclr/src/vm/i386/asmhelpers.S

index 2242c80..98525ac 100644 (file)
@@ -1177,12 +1177,28 @@ NESTED_ENTRY BackPatchWorkerAsmStub, _TEXT, NoHandler
     PROLOG_PUSH edx
     PROLOG_END
 
-    sub     esp, 4     //  for 16 bytes align
-    push    eax        //  push any indirect call address as the second arg to BackPatchWorker
-    push    [ebp+8]    //  and push return address as the first arg to BackPatchWorker
+    // Call BackPatchWorkerStaticStub
+    //
+    // Here is expected stack layout at this point:
+    //  | saved edx |
+    //  | saved ecx |
+    //  | saved eax |
+    //  +-----------+ <- ebp
+    //  | saved ebp |
+    //  | saved eip |
+    //  +-----------+ <- CFA of BackPatchWorkerAsmStub
+    //  | saved eip |
+    //  +-----------+ <- CFA of ResolveStub (16-byte aligned)
+    // (Please refer to ResolveStub in vm/i386/virtualcallstubcpu.hpp for details)
+    //
+    push    eax                       //  any indirect call address as the 2nd arg
+    push    DWORD PTR [ebp + 8]       //  return address (of ResolveStub) as the 1st arg
 
+    CHECK_STACK_ALIGNMENT
     call    C_FUNC(BackPatchWorkerStaticStub)
-    add     esp, 12
+
+    // Clean up arguments and alignment padding
+    add     esp, 2*4
 
     EPILOG_BEG
     EPILOG_POP edx