64bit - Visual Studio 2013 x64 calling convention optimization for returning shared_ptr -
i'm confused because disassembled code different knowledge. know, first argument passed rcx , homecoming value stored @ rax. below code utilize rcx homecoming value container , pass first argument rdx. why happen , name of way?
this cpp code compile:
#include "stdafx.h" #include <memory> #include <map> #include <iostream> using namespace std; class zelon { public: int64_t kkk; int64_t lll; }; typedef shared_ptr<zelon> zelonptr; std::map<std::string, zelonptr> amap; shared_ptr<zelon> find(const std::string& f) { auto = amap.find(f); homecoming == amap.end() ? nullptr : it->second; } int _tmain(int argc, _tchar* argv[]) { std::string k = "zelon"; zelonptr result = find(k); if (result->kkk == 100) { cout << "100" << endl; } homecoming 0; }
and disassembled code:
zelonptr result = find(k); 00007ff6fac014de lea rdx,[k] 00007ff6fac014e3 lea rcx,[result] 00007ff6fac014e8 phone call find (07ff6fac012b0h) 00007ff6fac014ed nop if (result->kkk == 100) { 00007ff6fac014ee mov rax,qword ptr [result] 00007ff6fac014f3 cmp qword ptr [rax],64h
this code compiled in visual studio 2013 x64 release total optimization.
i got reply http://msdn.microsoft.com/en-us/library/ms364057(vs.80).aspx
it's method of 'return value optimization', utilize of hidden argument.
visual-studio-2013 64bit calling-convention disassembly
No comments:
Post a Comment