Bug 1028613 - Modify the x86 MSVC implementation of NS_InvokeByIndex to make it compatible with clang-cl; r=bsmedberg
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 23 Jun 2014 10:29:21 -0700
changeset 190253 240408f52150574775a9cfb7f4f2a4dc1ef3c45d
parent 190166 984cd22ec8c3dc680ba969d2668ca7fd95522956
child 190254 6279aec8541c9c05ef914961a16d7b454fc93f40
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbsmedberg
bugs1028613
milestone33.0a1
Bug 1028613 - Modify the x86 MSVC implementation of NS_InvokeByIndex to make it compatible with clang-cl; r=bsmedberg
xpcom/reflect/xptcall/src/md/win32/xptcinvoke.cpp
--- a/xpcom/reflect/xptcall/src/md/win32/xptcinvoke.cpp
+++ b/xpcom/reflect/xptcall/src/md/win32/xptcinvoke.cpp
@@ -62,13 +62,19 @@ NS_InvokeByIndex(nsISupports* that, uint
         mov     ecx,esp
         push    params
         call    invoke_copy_to_stack // fastcall, ecx = d, edx = paramCount, params is on the stack
 noparams:
         mov     ecx,that            // instance in ecx
         push    ecx                 // push this
         mov     edx,[ecx]           // vtable in edx
         mov     eax,methodIndex
-        call    [edx][eax*4]        // stdcall, i.e. callee cleans up stack.
+        call    dword ptr[edx+eax*4] // stdcall, i.e. callee cleans up stack.
         mov     esp,ebp
+        // clang-cl doesn't emit the pop and ret instructions because it doesn't realize
+        // that the call instruction sets a return value in eax.  See
+        // https://bugzilla.mozilla.org/show_bug.cgi?id=1028613 and
+        // http://llvm.org/bugs/show_bug.cgi?id=17201.
+        pop     ebp
+        ret
     }
 }
 #pragma warning(default : 4035) // restore default