So I understand that thiscall doesn't really exist in x64 programming. However, I can't really find any definitive explanation as to where the this pointer is put to be passed to the callee.

Is a x64 thiscall like a true cdecl call, where this is put on to the 'stack' last (on both GCC and MSVC compilers)?

EDIT: Running through GDB, it appears so. rdi held the this pointer and rsi held the one parameter that particular method had. Is this how it always works?

  • 1
    I couldn't find a proper reference for it, but to my knowledge the this parameter is usually treated as the first argument of the function. Jun 22, 2014 at 7:40

2 Answers 2


As far as I am aware there is no explicit convention for passing a this pointer. Since it is passed into the function as a hidden additional argument, it will be passed using the convention for arguments. Which argument is presumably left to the compiler designer.

There are only two calling conventions in use, effectively Windows and Unix. In each case functions with a small number of arguments (4 or 6) pass all arguments in registers. That still doesn't tell you which has the this pointer.

I'm drawing the distinction between the officially sanctioned calling convention (which says that the first 4 or 6 arguments go in specified registers), and whatever unofficial convention is used for choosing which argument should represent the this pointer. In most cases it will probably be the first argument (which matches your experience), but it may not always be so.


According to https://msdn.microsoft.com/en-us/library/windows/hardware/ff561499%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

"the [this pointer] is passed as an implicit first parameter." So in X64 __fastcall convention [this pointer] should always be set in the RCX register.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.