{"id":2795,"date":"2019-01-31T18:26:03","date_gmt":"2019-01-31T10:26:03","guid":{"rendered":"https:\/\/damogame.cn:15443\/wordpress\/?p=2795"},"modified":"2019-01-31T18:34:08","modified_gmt":"2019-01-31T10:34:08","slug":"%e7%90%86%e8%a7%a3-golang-%e4%b8%ad%e5%87%bd%e6%95%b0%e8%b0%83%e7%94%a8%e7%9a%84%e5%8e%9f%e7%90%86-2","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/2795","title":{"rendered":"\u7406\u89e3 Golang \u4e2d\u51fd\u6570\u8c03\u7528\u7684\u539f\u7406"},"content":{"rendered":"<header class=\"post-template post-header\">\n<section class=\"post-meta\"><time class=\"post-date\" datetime=\"2019-01-20\">20 JAN 2019<\/time>\u00a0<a href=\"https:\/\/draveness.me\/tag\/Golang\">Golang<\/a>\u00a0<a href=\"https:\/\/draveness.me\/tag\/Go%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86\">Go\u5b9e\u73b0\u539f\u7406<\/a>\u00a0<a href=\"https:\/\/draveness.me\/tag\/%E5%87%BD%E6%95%B0%E8%B0%83%E7%94%A8\">\u51fd\u6570\u8c03\u7528<\/a>\u00a0<a href=\"https:\/\/draveness.me\/tag\/%E8%B0%83%E7%94%A8%E6%83%AF%E4%BE%8B\">\u8c03\u7528\u60ef\u4f8b<\/a>\u00a0<a href=\"https:\/\/draveness.me\/tag\/%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92\">\u53c2\u6570\u4f20\u9012<\/a><\/section>\n<\/header>\n<section class=\"post-content\">\n<ul class=\"section-nav markdown-toc-relative\">\n<li class=\"toc-entry toc-h2\"><a href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E8%B0%83%E7%94%A8%E6%83%AF%E4%BE%8B\">\u8c03\u7528\u60ef\u4f8b<\/a>\n<ul>\n<li class=\"toc-entry toc-h3\"><a href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#c-%E8%AF%AD%E8%A8%80\">C \u8bed\u8a00<\/a><\/li>\n<li class=\"toc-entry toc-h3\"><a href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#golang\">Golang<\/a><\/li>\n<\/ul>\n<\/li>\n<li class=\"toc-entry toc-h2\"><a href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92\">\u53c2\u6570\u4f20\u9012<\/a>\n<ul>\n<li class=\"toc-entry toc-h3\"><a href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E6%95%B4%E5%9E%8B%E5%92%8C%E6%95%B0%E7%BB%84\">\u6574\u578b\u548c\u6570\u7ec4<\/a><\/li>\n<li class=\"toc-entry toc-h3\"><a href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E7%BB%93%E6%9E%84%E4%BD%93%E5%92%8C%E6%8C%87%E9%92%88\">\u7ed3\u6784\u4f53\u548c\u6307\u9488<\/a><\/li>\n<li class=\"toc-entry toc-h3\"><a href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E5%B0%8F%E7%BB%93\">\u5c0f\u7ed3<\/a><\/li>\n<\/ul>\n<\/li>\n<li class=\"toc-entry toc-h2\"><a href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E6%80%BB%E7%BB%93\">\u603b\u7ed3<\/a><\/li>\n<li class=\"toc-entry toc-h2\"><a href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#reference\">Reference<\/a><\/li>\n<\/ul>\n<p>\u51fd\u6570\u662f Go \u8bed\u8a00\u4e2d\u7684\u4e00\u7b49\u516c\u6c11\uff0c\u7406\u89e3\u548c\u638c\u63e1\u51fd\u6570\u7684\u8c03\u7528\u8fc7\u7a0b\u662f\u6df1\u5165\u5b66\u4e60 Golang \u65f6\u65e0\u6cd5\u8df3\u8fc7\u7684\u6b65\u9aa4\uff0c\u8fd9\u91cc\u4f1a\u4ecb\u7ecd Go \u8bed\u8a00\u4e2d\u51fd\u6570\u8c03\u7528\u7684\u8fc7\u7a0b\u548c\u5b9e\u73b0\u539f\u7406\u5e76\u4e0e C \u8bed\u8a00\u4e2d\u51fd\u6570\u6267\u884c\u7684\u8fc7\u7a0b\u8fdb\u884c\u5bf9\u6bd4\uff0c\u540c\u65f6\u5bf9\u53c2\u6570\u4f20\u9012\u7684\u539f\u7406\u8fdb\u884c\u5256\u6790\uff0c\u8ba9\u8bfb\u8005\u80fd\u591f\u6e05\u695a\u5730\u77e5\u9053 Go \u5728\u51fd\u6570\u7684\u6267\u884c\u8fc7\u7a0b\u4e2d\u7a76\u7adf\u90fd\u505a\u4e86\u54ea\u4e9b\u5de5\u4f5c\u3002<\/p>\n<p>\u672c\u6587\u5c06\u4ece\u51fd\u6570\u7684\u8c03\u7528\u60ef\u4f8b\u548c\u53c2\u6570\u7684\u4f20\u9012\u65b9\u6cd5\u4e24\u4e2a\u65b9\u9762\u5206\u522b\u4ecb\u7ecd\u51fd\u6570\u7684\u6267\u884c\u8fc7\u7a0b\uff0c\u540c\u65f6\u5728\u8fd9\u91cc\u4f1a\u9ed8\u8ba4\u9605\u8bfb\u8fd9\u7bc7\u6587\u7ae0\u7684\u8bfb\u8005\u5df2\u7ecf\u638c\u63e1\u4e86\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Stack_(abstract_data_type)\">\u6808<\/a>\u3001<a href=\"https:\/\/en.wikipedia.org\/wiki\/Processor_register\">\u5bc4\u5b58\u5668<\/a>\u00a0\u7b49\u6982\u5ff5\uff0c\u6587\u7ae0\u5e76\u4e0d\u4f1a\u5c31\u8fd9\u4e24\u90e8\u5206\u5185\u5bb9\u5c55\u5f00\u8fdb\u884c\u4ecb\u7ecd\u3002<\/p>\n<h2 id=\"\u8c03\u7528\u60ef\u4f8b\"><a id=\"\u8c03\u7528\u60ef\u4f8b\" class=\"anchor\" href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E8%B0%83%E7%94%A8%E6%83%AF%E4%BE%8B\" aria-hidden=\"true\"><\/a>\u8c03\u7528\u60ef\u4f8b<\/h2>\n<p>\u5728\u8ba1\u7b97\u673a\u79d1\u5b66\u4e2d\uff0c\u8c03\u7528\u60ef\u4f8b\u5176\u5b9e\u5c31\u662f\u6307\u5728\u5b9e\u73b0\u5c42\u9762\u4e0a\uff0c\u4e00\u4e2a\u51fd\u6570\uff08\u5b50\u7a0b\u5e8f\uff09\u5982\u4f55\u63a5\u53d7\u4e3b\u7a0b\u5e8f\u4f20\u9012\u7684\u53c2\u6570\u5e76\u5982\u4f55\u5c06\u8fd4\u56de\u503c\u4f20\u9012\u56de\u4e3b\u7a0b\u5e8f\u3002\u4e0d\u540c\u8bed\u8a00\u5bf9\u4e8e\u4f20\u9012\u53c2\u6570\u548c\u8fd4\u56de\u503c\u7684\u5b9e\u73b0\u4e0a\u4f1a\u6709\u4e00\u4e9b\u5dee\u5f02\uff0c\u4e0d\u8fc7\u65e0\u8bba\u662f\u5728 C\u3001Go \u8bed\u8a00\u8fd9\u79cd\u6bd4\u8f83\u63a5\u8fd1\u7cfb\u7edf\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u8fd8\u662f Ruby\u3001Python \u8fd9\u7c7b\u8bed\u8a00\uff0c\u5b83\u4eec\u5728<em>\u51fd\u6570\u8c03\u7528<\/em>\u4e0a\u5f80\u5f80\u90fd\u5177\u6709\u76f8\u540c\u7684\u5f62\u5f0f\uff0c\u4e5f\u5c31\u662f\u4e00\u822c\u5305\u542b\u51fd\u6570\u540d\u3001\u53c2\u6570\u5217\u8868\u4e24\u4e2a\u90e8\u5206\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">somefunction(arg0, arg1)<\/pre>\n<p>\u867d\u7136\u5b83\u4eec\u7684\u8c03\u7528\u5f62\u5f0f\u770b\u8d77\u6765\u5dee\u4e0d\u591a\uff0c\u4f46\u662f\u5728\u8fd9\u91cc\u6211\u4eec\u9700\u8981\u8003\u8651 C \u548c Go \u8fd9\u4e24\u95e8\u8bed\u8a00\u7a76\u7adf\u662f\u5982\u4f55\u5b9e\u73b0\u8c03\u7528\u60ef\u4f8b\u7684\uff0c\u8fd9\u5bf9\u4e8e\u6211\u4eec\u7406\u89e3\u7684 Go \u8bed\u8a00\u7684\u51fd\u6570\u8c03\u7528\u539f\u7406\u4f1a\u6709\u975e\u5e38\u5927\u7684\u5e2e\u52a9\u3002<\/p>\n<h3 id=\"c-\u8bed\u8a00\"><a id=\"c-\u8bed\u8a00\" class=\"anchor\" href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#c-%E8%AF%AD%E8%A8%80\" aria-hidden=\"true\"><\/a>C \u8bed\u8a00<\/h3>\n<p>\u5982\u679c\u60f3\u8981\u4e86\u89e3 C \u8bed\u8a00\u4e2d\u7684\u51fd\u6570\u8c03\u7528\u7684\u539f\u7406\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 gcc \u6216\u8005 clang \u5c06 C \u8bed\u8a00\u7684\u4ee3\u7801\u7f16\u8bd1\u6210\u6c47\u7f16\u8bed\u8a00\uff0c\u4ece\u6c47\u7f16\u8bed\u8a00\u4e2d\u53ef\u4ee5\u4e00\u7aa5\u51fd\u6570\u8c03\u7528\u7684\u5177\u4f53\u8fc7\u7a0b\uff0c\u4f5c\u8005\u4f7f\u7528\u7684\u662f\u7f16\u8bd1\u5668\u548c\u5185\u6838\u7684\u7248\u672c\u5982\u4e0b\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$ gcc --version\r\ngcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2\r\nCopyright (C) 2013 Free Software Foundation, Inc.\r\nThis is free software; see the source for copying conditions.  There is NO\r\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\n$ uname -a\r\nLinux iZ255w13cy6Z 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU\/Linux<\/pre>\n<p>gcc \u548c clang \u867d\u7136\u5728\u7f16\u8bd1 C \u8bed\u8a00\u4ee3\u7801\u65f6\u751f\u6210\u7684\u6c47\u7f16\u8bed\u8a00\u53ef\u80fd\u6709\u6bd4\u8f83\u5927\u7684\u5dee\u522b\uff0c\u4f46\u662f\u751f\u6210\u4ee3\u7801\u7684\u7ed3\u6784\u4e0d\u4f1a\u6709\u592a\u5927\u7684\u533a\u522b\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\u4e0d\u540c\u5185\u6838\u7248\u672c\u7684\u64cd\u4f5c\u7cfb\u7edf\u751f\u6210\u7684\u6c47\u7f16\u6307\u4ee4\u53ef\u80fd\u6709\u6bd4\u8f83\u5927\u7684\u4e0d\u540c\uff0c\u4e0d\u8fc7\u5bf9\u4e8e\u6211\u4eec\u8fd9\u4e9b\u53ea\u662f\u60f3\u8981\u4e86\u89e3\u5b9e\u73b0\u539f\u7406\u7684\u5f00\u53d1\u8005\u6765\u8bf4\u6ca1\u6709\u592a\u591a\u7684\u5f71\u54cd\u3002<\/p>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4ee5\u4e0b\u7684 C \u8bed\u8a00\u4ee3\u7801\uff0c\u4ee3\u7801\u4e2d\u53ea\u5305\u542b\u4e24\u4e2a\u51fd\u6570\uff0c\u5176\u4e2d\u4e00\u4e2a\u662f\u4e3b\u51fd\u6570\u00a0<code>main<\/code>\uff0c\u53e6\u4e00\u4e2a\u5c31\u662f\u6211\u4eec\u5b9a\u4e49\u7684\u51fd\u6570\u00a0<code>my_function<\/code>\uff0c\u4ee3\u7801\u975e\u5e38\u7b80\u5355\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">int my_function(int arg1, int arg2) {\r\n    return arg1 + arg2;\r\n}\r\n\r\nint main() {\r\n    int i = my_function(1, 2);\r\n}<\/pre>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u00a0<code>gcc -S main.c<\/code>\u00a0\u5c06\u5f53\u524d\u7684\u6587\u4ef6\u7f16\u8bd1\u6210\u5305\u542b\u6c47\u7f16\u8bed\u8a00\u7684\u00a0<code>main.s<\/code>\u00a0\u6587\u4ef6\uff0c\u4e3a\u4e86\u51cf\u5c11\u4e00\u4e9b\u4e0e\u51fd\u6570\u8c03\u7528\u65e0\u5173\u7684\u566a\u97f3\uff0c\u6211\u4eec\u5c06\u751f\u6210\u7684\u6c47\u7f16\u4ee3\u7801\u7ecf\u8fc7\u4e00\u4e9b\u7b80\u5355\u5730\u5220\u51cf\u5c55\u793a\u51fa\u6765\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">my_function:\r\n.LFB0:\r\n    .cfi_startproc\r\n    pushq\t%rbp\r\n    .cfi_def_cfa_offset 16\r\n    .cfi_offset 6, -16\r\n    movq\t%rsp, %rbp\r\n    .cfi_def_cfa_register 6\r\n    movl\t%edi, -4(%rbp)\r\n    movl\t%esi, -8(%rbp)\r\n    movl\t-8(%rbp), %eax\r\n    movl\t-4(%rbp), %edx\r\n    addl\t%edx, %eax \/\/ arg1 + arg2\r\n    popq\t%rbp\r\n    .cfi_def_cfa 7, 8\r\n    ret\r\n    .cfi_endproc\r\nmain:\r\n.LFB1:\r\n    .cfi_startproc\r\n    pushq\t%rbp\r\n    .cfi_def_cfa_offset 16\r\n    .cfi_offset 6, -16\r\n    movq\t%rsp, %rbp\r\n    .cfi_def_cfa_register 6\r\n    subq\t$16, %rsp\r\n    movl\t$2, %esi \/\/ \u5904\u7406\u7b2c\u4e8c\u4e2a\u53c2\u6570\r\n    movl\t$1, %edi \/\/ \u5904\u7406\u7b2c\u4e00\u4e2a\u53c2\u6570\r\n    call\tmy_function\r\n    movl\t%eax, -4(%rbp)\r\n    leave\r\n    .cfi_def_cfa 7, 8\r\n    ret\r\n    .cfi_endproc<\/pre>\n<p>\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5728\u8c03\u7528\u00a0<code>my_function<\/code>\u00a0\u51fd\u6570\u4e4b\u524d\uff0c\u4e0a\u8ff0\u4ee3\u7801\u5c06\u8be5\u51fd\u6570\u9700\u8981\u7684\u4e24\u4e2a\u53c2\u6570\u5206\u522b\u5b58\u5230\u4e86 edi \u548c esi \u5bc4\u5b58\u5668\u4e2d\uff1b\u5728\u00a0<code>my_function<\/code>\u00a0\u6267\u884c\u65f6\uff0c\u5b83\u4f1a\u5148\u4ece\u5bc4\u5b58\u5668\u4e2d\u53d6\u51fa\u6570\u636e\u5e76\u653e\u7f6e\u5230\u5806\u6808\u4e0a\uff0c\u968f\u540e\u901a\u8fc7\u6c47\u7f16\u6307\u4ee4\u5728 eax \u5bc4\u5b58\u5668\u4e0a\u8fdb\u884c\u8ba1\u7b97\uff0c\u6700\u540e\u7684\u7ed3\u679c\u5176\u5b9e\u662f\u901a\u8fc7\u53e6\u4e00\u4e2a\u5bc4\u5b58\u5668 eax \u8fd4\u56de\u7684\uff0c<code>main<\/code>\u00a0\u51fd\u6570\u5728\u00a0<code>my_function<\/code>\u00a0\u8fd4\u56de\u4e4b\u540e\u5c06\u8fd4\u56de\u503c\u5b58\u50a8\u5230\u5806\u6808\u4e0a\u7684\u00a0<code>i<\/code>\u00a0\u53d8\u91cf\u4e2d\u3002<\/p>\n<p>\u5f53\u6211\u4eec\u5c06\u00a0<code>my_function<\/code>\u00a0\u51fd\u6570\u7684\u53c2\u6570\u589e\u52a0\u81f3 8 \u4e2a\u4e4b\u540e\uff0c\u6211\u4eec\u518d\u91cd\u65b0\u7f16\u8bd1\u5f53\u524d\u7684 C \u8bed\u8a00\u4ee3\u7801\uff0c\u8fd9\u65f6\u53ef\u4ee5\u5f97\u5230\u66f4\u957f\u7684\u6c47\u7f16\u8bed\u8a00\u4ee3\u7801\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/\/ main.c\r\nint my_function(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8) {\r\n    return arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8;\r\n}\r\n\r\nint main() {\r\n    my_function(1, 2, 3, 4, 5, 6, 7, 8);\r\n}\r\n\r\n\/\/ main.s\r\nmain:\r\n.LFB1:\r\n    .cfi_startproc\r\n    pushq\t%rbp\r\n    .cfi_def_cfa_offset 16\r\n    .cfi_offset 6, -16\r\n    movq\t%rsp, %rbp\r\n    .cfi_def_cfa_register 6\r\n    subq\t$16, %rsp\r\n    movl\t$8, 8(%rsp)\r\n    movl\t$7, (%rsp)\r\n    movl\t$6, %r9d\r\n    movl\t$5, %r8d\r\n    movl\t$4, %ecx\r\n    movl\t$3, %edx\r\n    movl\t$2, %esi\r\n    movl\t$1, %edi\r\n    call\tmy_function\r\n    leave\r\n    .cfi_def_cfa 7, 8\r\n    ret\r\n    .cfi_endproc<\/pre>\n<p>\u4ece\u8fd9\u6bb5\u4ee3\u7801\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\u5982\u4e0b\u7684\u51e0\u4e2a\u95ee\u9898\uff0c\u9996\u5148\uff0c\u524d\u516d\u4e2a\u53c2\u6570\u7684\u4f20\u9012\u4f9d\u7136\u662f\u901a\u8fc7\u5bc4\u5b58\u5668\u8fdb\u884c\u7684\uff0c\u5206\u522b\u5b58\u50a8\u5728 edi\u3001esi\u3001edx\u3001ecx\u3001r8d \u548c r9d \u516d\u4e2a\u5bc4\u5b58\u5668\u4e2d\uff0c\u8fd9\u91cc\u7684\u5bc4\u5b58\u5668\u7684\u4f7f\u7528\u987a\u5e8f\u4e5f\u662f\u6709\u8bb2\u7a76\u7684\uff0c\u4f5c\u4e3a\u8c03\u7528\u60ef\u4f8b\uff0c\u4f20\u9012\u53c2\u6570\u65f6\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e00\u5b9a\u4f1a\u653e\u5728 edi \u5bc4\u5b58\u5668\u4e2d\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u653e\u5728 esi \u5bc4\u5b58\u5668\uff0c\u4ee5\u6b64\u7c7b\u63a8\uff1b\u6700\u540e\u7684\u7b2c\u4e03\u548c\u7b2c\u516b\u4e24\u4e2a\u53c2\u6570\u90fd\u901a\u8fc7\u6808\u8fdb\u884c\u4f20\u9012\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8fd9\u5f20\u56fe\u7247\u6765\u7b80\u5355\u7406\u89e3\u00a0<code>main<\/code>\u00a0\u51fd\u6570\u5728\u8c03\u7528\u00a0<code>my_function<\/code>\u00a0\u65f6\u7684\u5806\u6808\uff1a<\/p>\n<p>\u9700\u8981\u8bf4\u7684\u662f\uff0crbp \u662f\u4e00\u4e2a\u5b58\u50a8\u51fd\u6570\u8c03\u7528\u5806\u6808\u57fa\u5740\u6307\u9488\u7684\u5bc4\u5b58\u5668\uff0c\u4e5f\u5c31\u662f\u8bf4\u5f53\u524d\u51fd\u6570\u6808\u662f\u4ece\u54ea\u91cc\u5f00\u59cb\u7684\uff1b\u53e6\u4e00\u4e2a\u5bc4\u5b58\u5668 rsp \u5b58\u50a8\u7684\u5c31\u662f\u5f53\u524d\u51fd\u6570\u8c03\u7528\u6808\u6808\u9876\u7684\u4f4d\u7f6e\uff0c\u4e5f\u5c31\u662f\u5f53\u524d\u6808\u7684\u5185\u5b58\u5206\u914d\u5230\u4e86\u54ea\u91cc\uff0c\u8fd9\u4e24\u4e2a\u5bc4\u5b58\u5668\u8868\u793a\u4e00\u4e2a\u51fd\u6570\u6808\u7684\u5f00\u59cb\u548c\u7ed3\u675f\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.draveness.me\/2019-01-20-c-function-call-stack.png\" alt=\"c-function-call-stack\" \/><\/p>\n<p>\u5728\u8c03\u7528\u51fd\u6570\u4e4b\u524d\u901a\u8fc7\u00a0<code>subq $16, %rsp<\/code>\u00a0\u6307\u4ee4\u5206\u914d\u4e86 16 \u4e2a\u5b57\u8282\u7684\u6808\u5730\u5740\uff0c\u968f\u540e\u6309\u7167\u4ece\u53f3\u5411\u5de6\u7684\u987a\u5e8f\u5bf9\u53c2\u6570\u8fdb\u884c\u538b\u6808\uff0c\u5c06\u7b2c\u516b\u548c\u7b2c\u4e03\u8fd9\u4e24\u4e2a\u53c2\u6570\u653e\u7f6e\u5230\u6808\u4e2d\uff0c\u5728\u8fd9\u4e4b\u540e\u5c06\u4f59\u4e0b\u7684 6 \u4e2a\u53c2\u6570\u5b58\u50a8\u5230\u5bc4\u5b58\u5668\u540e\u624d\u8fd0\u884c\u00a0<code>call my_function<\/code>\u6307\u4ee4\u8c03\u7528\u00a0<code>my_function<\/code>\u00a0\u51fd\u6570\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">my_function:\r\n.LFB0:\r\n    .cfi_startproc\r\n    pushq\t%rbp\r\n    .cfi_def_cfa_offset 16\r\n    .cfi_offset 6, -16\r\n    movq\t%rsp, %rbp\r\n    .cfi_def_cfa_register 6\r\n    movl\t%edi, -4(%rbp)\r\n    movl\t%esi, -8(%rbp)\r\n    movl\t%edx, -12(%rbp)\r\n    movl\t%ecx, -16(%rbp)\r\n    movl\t%r8d, -20(%rbp)\r\n    movl\t%r9d, -24(%rbp)\r\n    movl\t-8(%rbp), %eax \/\/ eax = 2\r\n    movl\t-4(%rbp), %edx \/\/ edx = 1\r\n    addl\t%eax, %edx     \/\/ edx = eax + edx = 3\r\n    movl\t-12(%rbp), %eax\r\n    addl\t%eax, %edx \r\n    movl\t-16(%rbp), %eax\r\n    addl\t%eax, %edx \r\n    movl\t-20(%rbp), %eax \r\n    addl\t%eax, %edx\r\n    movl\t-24(%rbp), %eax\r\n    addl\t%eax, %edx\r\n    movl\t16(%rbp), %eax  \/\/ eax = 7\r\n    addl\t%eax, %edx      \/\/ edx = eax + edx = 28\r\n    movl\t24(%rbp), %eax  \/\/ eax = 8\r\n    addl\t%edx, %eax      \/\/ edx = eax + edx = 36\r\n    popq\t%rbp\r\n    .cfi_def_cfa 7, 8\r\n    ret\r\n    .cfi_endproc<\/pre>\n<p>\u56e0\u4e3a\u00a0<code>my_function<\/code>\u00a0\u51fd\u6570\u6ca1\u6709\u8c03\u7528\u5176\u4ed6\u7684\u51fd\u6570\uff0c\u6240\u4ee5\u5e76\u6ca1\u6709\u901a\u8fc7\u00a0<code>subq<\/code>\u00a0\u4fee\u6539\u6808\u6307\u9488\u5bc4\u5b58\u5668 rsp \u4e2d\u7684\u5185\u5bb9\uff0c\u5b83\u7684\u6267\u884c\u8fc7\u7a0b\u5c31\u662f\u5148\u5c06\u5bc4\u5b58\u5668\u4e2d\u7684\u5168\u90e8\u6570\u636e\u90fd\u8f6c\u79fb\u5230\u6808\u4e0a\uff0c\u7136\u540e\u5229\u7528 eax \u5bc4\u5b58\u5668\u8ba1\u7b97\u5e76\u8fd4\u56de\u7ed3\u679c\u3002<\/p>\n<p>\u7b80\u5355\u603b\u7ed3\u4e00\u4e0b\uff0c\u5982\u679c\u6211\u4eec\u5728 C \u8bed\u8a00\u4e2d\u8c03\u7528\u4e00\u4e2a\u51fd\u6570\uff0c<strong>\u51fd\u6570\u7684\u53c2\u6570\u662f\u901a\u8fc7\u5bc4\u5b58\u5668\u548c\u6808\u4f20\u9012\u7684<\/strong>\uff0c\u5728 x86_64 \u7684\u673a\u5668\u4e0a\uff0c6 \u4e2a\u4ee5\u4e0b\uff08\u542b 6 \u4e2a\uff09\u7684\u53c2\u6570\u4f1a\u6309\u7167\u987a\u5e8f\u5206\u522b\u4f7f\u7528 edi\u3001esi\u3001edx\u3001ecx\u3001r8d \u548c r9d \u516d\u4e2a\u5bc4\u5b58\u5668\u4f20\u9012\uff0c\u8d85\u8fc7 6 \u4e2a\u7684\u5269\u4f59\u53c2\u6570\u4f1a\u901a\u8fc7\u6808\u8fdb\u884c\u4f20\u9012\uff1b<strong>\u51fd\u6570\u7684\u8fd4\u56de\u503c\u662f\u901a\u8fc7 eax \u5bc4\u5b58\u5668\u8fdb\u884c\u4f20\u9012\u7684<\/strong>\uff0c\u8fd9\u4e5f\u5c31\u662f\u4e3a\u4ec0\u4e48 C \u8bed\u8a00\u4e2d\u4e0d\u652f\u6301\u591a\u4e2a\u8fd4\u56de\u503c\u3002<\/p>\n<h3 id=\"golang\"><a id=\"golang\" class=\"anchor\" href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#golang\" aria-hidden=\"true\"><\/a>Golang<\/h3>\n<p>\u4ecb\u7ecd\u4e86 C \u8bed\u8a00\u4e2d\u51fd\u6570\u8c03\u7528\u7684\u6d41\u7a0b\u4e4b\u540e\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u518d\u6765\u5256\u6790\u4e00\u4e0b Golang \u4e2d\u51fd\u6570\u8c03\u7528\u65f6\u53c2\u6570\u548c\u8fd4\u56de\u503c\u5982\u4f55\u4f20\u9012\u7684\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u4ee5\u4e0b\u9762\u8fd9\u4e2a\u975e\u5e38\u7b80\u5355\u7684\u4ee3\u7801\u7247\u6bb5\u4e3a\u4f8b\u7b80\u5355\u5206\u6790\u4e00\u4e0b\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package main\r\n\r\nfunc myFunction(a, b int) (int, int) {\r\n    return a + b, a - b\r\n}\r\n\r\nfunc main() {\r\n    myFunction(66, 77)\r\n}<\/pre>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u7247\u6bb5\u4e2d\u7684\u00a0<code>myFunction<\/code>\u00a0\u51fd\u6570\u63a5\u53d7\u4e24\u4e2a\u7c7b\u578b\u4e3a\u00a0<code>int<\/code>\u00a0\u7684\u51fd\u6570\u5e76\u8fd4\u56de\u4e24\u4e2a\u7c7b\u578b\u4e3a\u00a0<code>int<\/code>\u00a0\u7684\u53c2\u6570\uff0c<code>main<\/code>\u00a0\u51fd\u6570\u5728\u8c03\u7528\u8be5\u51fd\u6570\u65f6\u4f1a\u5c06 66 \u548c 77 \u4e24\u4e2a\u53c2\u6570\u4f20\u9012\u5230\u5f53\u524d\u51fd\u6570\u4e2d\uff0c\u7ecf\u8fc7\u7f16\u8bd1\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u5982\u4e0b\u6240\u793a\u7684\u4f2a\u6c47\u7f16\u4ee3\u7801\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\"\".main STEXT size=68 args=0x0 locals=0x28\r\n    0x0000 00000 (main.go:7)\tTEXT\t\"\".main(SB), $40-0\r\n    0x0000 00000 (main.go:7)\tMOVQ\t(TLS), CX\r\n    0x0009 00009 (main.go:7)\tCMPQ\tSP, 16(CX)\r\n    0x000d 00013 (main.go:7)\tJLS\t61\r\n    0x000f 00015 (main.go:7)\tSUBQ\t$40, SP \/\/ \u5206\u914d 40 \u5b57\u8282\u6808\u7a7a\u95f4\r\n    0x0013 00019 (main.go:7)\tMOVQ\tBP, 32(SP) \/\/ \u5c06\u57fa\u5740\u6307\u9488\u5b58\u50a8\u5230\u6808\u4e0a\r\n    0x0018 00024 (main.go:7)\tLEAQ\t32(SP), BP\r\n    0x001d 00029 (main.go:8)\tMOVQ\t$66, (SP)  \/\/ \u7b2c\u4e00\u4e2a\u53c2\u6570\r\n    0x0025 00037 (main.go:8)\tMOVQ\t$77, 8(SP) \/\/ \u7b2c\u4e8c\u4e2a\u53c2\u6570\r\n    0x002e 00046 (main.go:8)\tPCDATA\t$0, $0\r\n    0x002e 00046 (main.go:8)\tCALL\t\"\".myFunction(SB)\r\n    0x0033 00051 (main.go:9)\tMOVQ\t32(SP), BP\r\n    0x0038 00056 (main.go:9)\tADDQ\t$40, SP\r\n    0x003c 00060 (main.go:9)\tRET<\/pre>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\u7f16\u8bd1\u8fd9\u6bb5 Golang \u4ee3\u7801\u65f6\uff0c\u9700\u8981\u4f7f\u7528\u5982\u4e0b\u7684\u547d\u4ee4\u8fdb\u884c\u7f16\u8bd1\u00a0<code>GOOS=linux GOARCH=amd64 go tool compile -S -N -l main.go<\/code>\uff0c\u5982\u679c\u4e0d\u52a0\u4e0a -N -l \u7684\u53c2\u6570\uff0c\u7f16\u8bd1\u5668\u4f1a\u5bf9\u6c47\u7f16\u4ee3\u7801\u8fdb\u884c\u4f18\u5316\uff0c\u7f16\u8bd1\u7ed3\u679c\u4f1a\u8ddf\u8fd9\u91cc\u7684\u5dee\u522b\u975e\u5e38\u5927\u3002<\/p>\n<p>\u6839\u636e\u00a0<code>main<\/code>\u00a0\u51fd\u6570\u751f\u6210\u7684\u6c47\u7f16\u6307\u4ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u5206\u6790\u51fa\u5728\u00a0<code>main<\/code>\u00a0\u51fd\u6570\u4e2d\u8c03\u7528\u00a0<code>myFunction<\/code>\u00a0\u4e4b\u524d\u7684\u5806\u6808\u60c5\u51b5\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.draveness.me\/2019-01-20-golang-function-call-stack-before-calling.png\" alt=\"golang-function-call-stack-before-calling\" \/><\/p>\n<p>\u5728\u00a0<code>main<\/code>\u00a0\u51fd\u6570\u4e2d\uff0c\u901a\u8fc7\u00a0<code>SUBQ $40, SP<\/code>\u00a0\u6307\u4ee4\u4e00\u5171\u5728\u6808\u4e0a\u5206\u914d\u4e86 40 \u5b57\u8282\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u6700\u5f00\u59cb\u7684 8 \u4e2a\u5b57\u8282\u5b58\u50a8\u4e86\u00a0<code>main<\/code>\u51fd\u6570\u7684\u6808\u57fa\u5740\u6307\u9488\uff0c\u4e4b\u540e\u7684 16 \u4e2a\u5b57\u8282\u662f\u4e3a\u51fd\u6570\u00a0<code>myFunction<\/code>\u00a0\u7684\u4e24\u4e2a\u8fd4\u56de\u503c\u9884\u7559\u7684\u7a7a\u95f4\uff0c\u6700\u540e\u7684 16 \u5b57\u8282\u5b58\u50a8\u4e86\u8be5\u51fd\u6570\u8c03\u7528\u65f6\u9700\u8981\u7684\u4e24\u4e2a\u53c2\u6570\uff0c\u538b\u6808\u7684\u987a\u5e8f\u548c C \u8bed\u8a00\u4e2d\u4e00\u6837\uff0c\u4e5f\u662f\u4ece\u53f3\u5230\u5de6\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u5c31\u8c03\u7528\u4e86\u6c47\u7f16\u6307\u4ee4\u00a0<code>CALL \"\".myFunction(SB)<\/code>\uff0c\u8fd9\u4e2a\u6307\u4ee4\u9996\u5148\u4f1a\u5c06\u5f53\u524d\u51fd\u6570\u00a0<code>main<\/code>\u00a0\u7684\u8fd4\u56de\u503c\u538b\u6808\uff0c\u7136\u540e\u6539\u53d8\u5f53\u524d\u7684\u6808\u6307\u9488 SP \u5e76\u5f00\u59cb\u6267\u884c\u00a0<code>myFunction<\/code>\u00a0\u7684\u6c47\u7f16\u6307\u4ee4\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\"\".myFunction STEXT nosplit size=49 args=0x20 locals=0x0\r\n    0x0000 00000 (main.go:3)\tTEXT\t\"\".myFunction(SB), NOSPLIT, $0-32\r\n    0x0000 00000 (main.go:3)\tMOVQ\t$0, \"\".~r2+24(SP) \/\/ \u521d\u59cb\u5316\u7b2c\u4e00\u4e2a\u8fd4\u56de\u503c\r\n    0x0009 00009 (main.go:3)\tMOVQ\t$0, \"\".~r3+32(SP) \/\/ \u521d\u59cb\u5316\u7b2c\u4e8c\u4e2a\u8fd4\u56de\u503c\r\n    0x0012 00018 (main.go:4)\tMOVQ\t\"\".a+8(SP), AX    \/\/ AX = 66\r\n    0x0017 00023 (main.go:4)\tADDQ\t\"\".b+16(SP), AX   \/\/ AX = AX + 77 = 143\r\n    0x001c 00028 (main.go:4)\tMOVQ\tAX, \"\".~r2+24(SP) \/\/ (24)SP = AX = 143\r\n    0x0021 00033 (main.go:4)\tMOVQ\t\"\".a+8(SP), AX    \/\/ AX = 66\r\n    0x0026 00038 (main.go:4)\tSUBQ\t\"\".b+16(SP), AX   \/\/ AX = AX - 77 = -11\r\n    0x002b 00043 (main.go:4)\tMOVQ\tAX, \"\".~r3+32(SP) \/\/ (32)SP = AX = -11\r\n    0x0030 00048 (main.go:4)\tRET<\/pre>\n<p>\u4ece\u4e0a\u8ff0\u7684\u6c47\u7f16\u4ee3\u7801\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\uff0c\u5f53\u524d\u51fd\u6570\u5728\u6267\u884c\u65f6\u9996\u5148\u4f1a\u5c06\u00a0<code>main<\/code>\u00a0\u51fd\u6570\u4e2d\u7684\u9884\u7559\u7684\u4e24\u4e2a\u8fd4\u56de\u503c\u5730\u5740\u7f6e\u6210\u00a0<code>int<\/code>\u7c7b\u578b\u7684\u9ed8\u8ba4\u503c 0\uff0c\u7136\u540e\u6839\u636e\u6808\u7684\u76f8\u5bf9\u4f4d\u7f6e\u83b7\u53d6\u53c2\u6570\u5e76\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\uff0c\u6700\u7ec8\u5c06\u503c\u5b58\u50a8\u56de\u6808\u4e2d\uff0c\u6240\u4ee5\u7ecf\u8fc7\u5206\u6790\u00a0<code>myFunction<\/code>\u00a0\u6267\u884c\u4e4b\u540e\u7684\u5806\u6808\u4fe1\u606f\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.draveness.me\/2019-01-20-golang-function-call-stack-before-return.png\" alt=\"golang-function-call-stack-before-return\" \/><\/p>\n<p><code>myFunction<\/code>\u00a0\u51fd\u6570\u8fd4\u56de\u4e4b\u540e\uff0c<code>main<\/code>\u00a0\u51fd\u6570\u5c31\u4f1a\u901a\u8fc7\u4ee5\u4e0b\u7684\u6307\u4ee4\u6765\u6062\u590d\u6808\u57fa\u5740\u6307\u9488\u5e76\u9500\u6bc1\u5df2\u7ecf\u5931\u53bb\u4f5c\u7528\u7684 40 \u5b57\u8282\u7684\u6808\u7a7a\u95f4\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">0x0033 00051 (main.go:9)    MOVQ    32(SP), BP\r\n0x0038 00056 (main.go:9)    ADDQ    $40, SP\r\n0x003c 00060 (main.go:9)    RET<\/pre>\n<p>\u901a\u8fc7\u5bf9 Golang \u4f2a\u6c47\u7f16\u8bed\u8a00\u8bed\u8a00\u7684\u5206\u6790\uff0c\u6211\u4eec\u53d1\u73b0\u00a0<strong>Go \u8bed\u8a00\u4f20\u9012\u548c\u63a5\u53d7\u53c2\u6570\u4f7f\u7528\u7684\u90fd\u662f\u6808<\/strong>\uff0c\u5b83\u6ca1\u6709\u50cf C \u8bed\u8a00\u4e00\u6837\u5728\u51fd\u6570\u53c2\u6570\u8f83\u5c11\u65f6\u4f7f\u7528\u5bc4\u5b58\u5668\u4f20\u9012\u53c2\u6570\uff0c\u540c\u65f6\u4f7f\u7528\u6808\u4ee3\u66ff eax \u5bc4\u5b58\u5668\u4f20\u9012\u8fd4\u56de\u503c\u4e5f\u80fd\u591f\u540c\u65f6\u8fd4\u56de\u591a\u4e2a\u7ed3\u679c\uff0c\u4f46\u662f\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u51fd\u6570\u5165\u53c2\u548c\u51fa\u53c2\u7684\u5185\u5b58\u7a7a\u95f4\u90fd\u9700\u8981\u8c03\u7528\u65b9\u5728\u6808\u4e0a\u8fdb\u884c\u5206\u914d\uff0c\u8fd9\u79cd\u4f7f\u7528\u6808\u8fdb\u884c\u53c2\u6570\u4f20\u9012\u7684\u65b9\u5f0f\u867d\u7136\u8ddf\u4f7f\u7528\u5bc4\u5b58\u5668\u76f8\u6bd4\u5728\u6027\u80fd\u4e0a\u4f1a\u6709\u4e00\u4e9b\u635f\u5931\uff0c\u4f46\u662f\u4e5f\u80fd\u591f\u5e26\u6765\u5176\u4ed6\u7684\u597d\u5904\uff1a<\/p>\n<ol>\n<li>\u80fd\u591f\u964d\u4f4e\u5b9e\u73b0\u7684\u590d\u6742\u5ea6\uff1b\n<ul>\n<li>\u4e0d\u9700\u8981\u8003\u8651\u8d85\u8fc7\u5bc4\u5b58\u5668\u4e2a\u6570\u7684\u53c2\u6570\u5e94\u8be5\u5982\u4f55\u4f20\u9012\uff1b<\/li>\n<\/ul>\n<\/li>\n<li>\u66f4\u65b9\u4fbf\u7684\u517c\u5bb9\u4e0d\u540c\u7684\u786c\u4ef6\uff1b\n<ul>\n<li>\u4e0d\u540c CPU \u7684\u5bc4\u5b58\u5668\u5dee\u522b\u6bd4\u8f83\u5927\uff1b<\/li>\n<\/ul>\n<\/li>\n<li>\u51fd\u6570\u53ef\u4ee5\u5177\u6709\u591a\u4e2a\u8fd4\u56de\u503c\uff1b\n<ul>\n<li>\u6808\u4e0a\u7684\u5185\u5b58\u5730\u5740\u4e0e\u76f8\u6bd4\u5bc4\u5b58\u5668\u7684\u4e2a\u6570\u662f\u65e0\u9650\u7684\uff1b<\/li>\n<li>\u4f7f\u7528\u5bc4\u5b58\u5668\u652f\u6301\u591a\u4e2a\u8fd4\u56de\u503c\u4e5f\u4f1a\u975e\u5e38\u56f0\u96be\uff0c\u8d85\u51fa\u5bc4\u5b58\u5668\u4e2a\u6570\u7684\u8fd4\u56de\u503c\u4e5f\u9700\u8981\u4f7f\u7528\u6808\u6765\u4f20\u9012\uff1b<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h2 id=\"\u53c2\u6570\u4f20\u9012\"><a id=\"\u53c2\u6570\u4f20\u9012\" class=\"anchor\" href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92\" aria-hidden=\"true\"><\/a>\u53c2\u6570\u4f20\u9012<\/h2>\n<p>\u9664\u4e86\u51fd\u6570\u7684\u8c03\u7528\u60ef\u4f8b\u4e4b\u5916\uff0c\u51fd\u6570\u7684\u53c2\u6570\u5728\u8c03\u7528\u65f6\u7a76\u7adf\u662f\u4f20\u503c\u8fd8\u662f\u4f20\u5f15\u7528\u4e5f\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u8da3\u7684\u95ee\u9898\uff0c\u5f88\u591a\u4eba\u90fd\u4f1a\u8bf4\u65e0\u8bba\u662f\u4f20\u503c\u8fd8\u662f\u4f20\u5f15\u7528\u672c\u8d28\u4e0a\u90fd\u662f\u5bf9\u503c\u7684\u4f20\u9012\uff0c\u8fd9\u79cd\u8bba\u8c03\u5176\u5b9e\u5e76\u6ca1\u6709\u4ec0\u4e48\u610f\u4e49\uff0c\u6211\u4eec\u5176\u5b9e\u9700\u8981\u77e5\u9053\u5bf9\u51fd\u6570\u4e2d\u53c2\u6570\u7684\u4fee\u6539\u4f1a\u4e0d\u4f1a\u5f71\u54cd\u8c03\u7528\u65b9\u6808\u4e0a\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u4e0d\u540c\u8bed\u8a00\u5bf9\u4e8e\u53c2\u6570\u4f20\u9012\u7684\u65b9\u5f0f\u53ef\u80fd\u8bbe\u8ba1\u6709\u6240\u4e0d\u540c\uff0cJava \u5728\u4f20\u9012\u57fa\u672c\u7c7b\u578b\u65f6\u4f1a\u5bf9\u5b57\u9762\u91cf\u8fdb\u884c\u62f7\u8d1d\uff0c\u4e0d\u8fc7\u4f20\u9012\u5bf9\u8c61\u53c2\u6570\u65f6\u5c31\u662f\u5bf9\u8c61\u5728\u5806\u4e2d\u7684\u5730\u5740\uff0c\u76f8\u6bd4\u4e8e Java \u8fd9\u79cd\u7a0d\u663e\u590d\u6742\u7684\u8bbe\u8ba1\uff0cGolang \u7684\u8bbe\u8ba1\u5c31\u7b80\u5355\u4e86\u5f88\u591a\uff0c<strong>\u65e0\u8bba\u662f\u4f20\u9012\u57fa\u672c\u7c7b\u578b\u3001\u7ed3\u6784\u4f53\u8fd8\u662f\u6307\u9488\uff0c\u90fd\u4f1a\u5bf9\u4f20\u9012\u7684\u53c2\u6570\u8fdb\u884c\u62f7\u8d1d<\/strong>\uff0c\u8fd9\u4e00\u8282\u5269\u4e0b\u7684\u5185\u5bb9\u5c31\u4f1a\u5e2e\u52a9\u9a8c\u8bc1\u8fd9\u4e2a\u7ed3\u8bba\u7684\u6b63\u786e\u6027\u3002<\/p>\n<h3 id=\"\u6574\u578b\u548c\u6570\u7ec4\"><a id=\"\u6574\u578b\u548c\u6570\u7ec4\" class=\"anchor\" href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E6%95%B4%E5%9E%8B%E5%92%8C%E6%95%B0%E7%BB%84\" aria-hidden=\"true\"><\/a>\u6574\u578b\u548c\u6570\u7ec4<\/h3>\n<p>\u6211\u4eec\u6784\u5efa\u4e00\u4e2a\u5982\u4e0b\u7684\u51fd\u6570\u00a0<code>myFunction<\/code>\uff0c\u5b83\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\uff0c\u4e00\u4e2a\u6574\u578b\u53d8\u91cf\u00a0<code>i<\/code>\u00a0\u548c\u53e6\u4e00\u4e2a\u662f\u6570\u7ec4\u00a0<code>arr<\/code>\uff0c\u8fd9\u4e2a\u51fd\u6570\u4f1a\u5c06\u4f20\u5165\u7684\u4e24\u4e2a\u53c2\u6570\u7684\u5730\u5740\u6253\u5370\u51fa\u6765\uff0c\u5728\u6700\u5916\u5c42\u7684\u4e3b\u51fd\u6570\u4e5f\u4f1a\u5728\u65b9\u6cd5\u8c03\u7528\u524d\u540e\u5206\u522b\u6253\u5370\u4e24\u4e2a\u53c2\u6570\u7684\u5730\u5740\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">func myFunction(i int, arr [2]int) {\r\n    fmt.Printf(\"in my_funciton - i=%p arr=%p\\n\", &amp;i, &amp;arr)\r\n}\r\n\r\nfunc main() {\r\n    i := 30\r\n    arr := [2]int{66, 77}\r\n    fmt.Printf(\"before calling - i=%p arr=%p\\n\", &amp;i, &amp;arr)\r\n    myFunction(i, arr)\r\n    fmt.Printf(\"after  calling - i=%p arr=%p\\n\", &amp;i, &amp;arr)\r\n}\r\n\r\n$ go run main.go\r\nbefore calling - i=0xc00009a000 arr=0xc00009a010\r\nin my_funciton - i=0xc00009a008 arr=0xc00009a020\r\nafter  calling - i=0xc00009a000 arr=0xc00009a010<\/pre>\n<p>\u901a\u8fc7\u547d\u4ee4\u8fd0\u884c\u8fd9\u6bb5\u4ee3\u7801\u6211\u4eec\u4f1a\u53d1\u73b0\uff0c<code>main<\/code>\u00a0\u51fd\u6570\u548c\u88ab\u8c03\u7528\u8005\u00a0<code>myFunction<\/code>\u00a0\u4e2d\u53c2\u6570\u7684\u5730\u5740\u662f\u5b8c\u5168\u4e0d\u540c\u7684\u3002<\/p>\n<p>\u4f46\u662f\u65e0\u8bba\u662f\u8c03\u7528\u00a0<code>myFunction<\/code>\u00a0\u524d\u8fd8\u662f\u8c03\u7528\u00a0<code>myFunction<\/code>\u00a0\u540e\uff0c\u4e24\u4e2a\u53c2\u6570\u7684\u5730\u5740\u90fd\u6ca1\u6709\u53d8\u5316\uff0c\u5982\u679c\u6211\u4eec\u5c1d\u8bd5\u5728\u51fd\u6570\u5185\u90e8\u5bf9\u53c2\u6570\u8fdb\u884c\u4fee\u6539\u53c8\u4f1a\u600e\u4e48\u6837\u5462\uff1f<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">func myFunction(i int, arr [2]int) {\r\n    i = 29\r\n    arr[1] = 88\r\n    fmt.Printf(\"in my_funciton - i=(%d, %p) arr=(%v, %p)\\n\", i, &amp;i, arr, &amp;arr)\r\n}\r\n\r\nfunc main() {\r\n    i := 30\r\n    arr := [2]int{66, 77}\r\n    fmt.Printf(\"before calling - i=(%d, %p) arr=(%v, %p)\\n\", i, &amp;i, arr, &amp;arr)\r\n    myFunction(i, arr)\r\n    fmt.Printf(\"after  calling - i=(%d, %p) arr=(%v, %p)\\n\", i, &amp;i, arr, &amp;arr)\r\n}\r\n\r\n$ go run main.go\r\nbefore calling - i=(30, 0xc000072008) arr=([66 77], 0xc000072010)\r\nin my_funciton - i=(29, 0xc000072028) arr=([66 88], 0xc000072040)\r\nafter  calling - i=(30, 0xc000072008) arr=([66 77], 0xc000072010)<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\u5728\u00a0<code>myFunction<\/code>\u00a0\u4e2d\u5bf9\u53c2\u6570\u7684\u4fee\u6539\u4e5f\u4ec5\u4ec5\u5f71\u54cd\u4e86\u5f53\u524d\u7684\u51fd\u6570\u6808\uff0c\u540c\u65f6\u5e76\u6ca1\u6709\u5bf9\u8c03\u7528\u65b9\u7684\u51fd\u6570\u6808\u6709\u4efb\u4f55\u7684\u5f71\u54cd\uff0c\u6211\u4eec\u4e5f\u80fd\u7ed9\u51fa\u5982\u4e0b\u7684\u7ed3\u8bba &#8211;\u00a0<strong>Go \u8bed\u8a00\u4e2d\u5bf9\u4e8e\u6574\u578b\u548c\u6570\u7ec4\u7c7b\u578b\u7684\u53c2\u6570\u90fd\u662f\u503c\u4f20\u9012\u7684<\/strong>\uff0c\u4e5f\u5c31\u662f\u5728\u8c03\u7528\u51fd\u6570\u65f6\u4f1a\u5bf9\u5185\u5bb9\u8fdb\u884c\u62f7\u8d1d\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\u5982\u679c\u5f53\u524d\u6570\u7ec4\u7684\u5927\u5c0f\u975e\u5e38\u7684\u5927\uff0c\u8fd9\u79cd\u76f4\u63a5\u590d\u5236\u4f20\u503c\u7684\u65b9\u5f0f\u5c31\u4f1a\u5bf9\u6027\u80fd\u9020\u6210\u6bd4\u8f83\u5927\u7684\u5f71\u54cd\u3002<\/p>\n<h3 id=\"\u7ed3\u6784\u4f53\u548c\u6307\u9488\"><a id=\"\u7ed3\u6784\u4f53\u548c\u6307\u9488\" class=\"anchor\" href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E7%BB%93%E6%9E%84%E4%BD%93%E5%92%8C%E6%8C%87%E9%92%88\" aria-hidden=\"true\"><\/a>\u7ed3\u6784\u4f53\u548c\u6307\u9488<\/h3>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u9700\u8981\u518d\u6765\u770b\u4e00\u4e0b\u5728 Golang \u4e2d\u7684\u53e6\u5916\u4e24\u79cd\u5e38\u89c1\u7684\u7c7b\u578b &#8211; \u7ed3\u6784\u4f53\u548c\u6307\u9488\u5728\u53c2\u6570\u7684\u4f20\u9012\u8fc7\u7a0b\u4e2d\u662f\u4f20\u503c\u8fd8\u662f\u4f20\u5f15\u7528\u7684\u3002\u5728\u8fd9\u91cc\u5b9a\u4e49\u4e00\u4e2a\u53ea\u5305\u542b\u4e00\u4e2a\u6210\u5458\u53d8\u91cf\u7684\u7b80\u5355\u7ed3\u6784\u4f53\u00a0<code>MyStruct<\/code>\u00a0\u4ee5\u53ca\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\u7684\u00a0<code>myFunction<\/code>\u00a0\u65b9\u6cd5\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">type MyStruct struct {\r\n    i int\r\n}\r\n\r\nfunc myFunction(a MyStruct, b *MyStruct) {\r\n    a.i = 31\r\n    b.i = 41\r\n    fmt.Printf(\"in my_function - a=(%d, %p) b=(%v, %p)\\n\", a, &amp;a, b, &amp;b)\r\n}\r\n\r\nfunc main() {\r\n    a := MyStruct{i: 30}\r\n    b := &amp;MyStruct{i: 40}\r\n    fmt.Printf(\"before calling - a=(%d, %p) b=(%v, %p)\\n\", a, &amp;a, b, &amp;b)\r\n    myFunction(a, b)\r\n    fmt.Printf(\"after calling  - a=(%d, %p) b=(%v, %p)\\n\", a, &amp;a, b, &amp;b)\r\n}\r\n\r\n$ go run main.go\r\nbefore calling - a=({30}, 0xc000018178) b=(&amp;{40}, 0xc00000c028)\r\nin my_function - a=({31}, 0xc000018198) b=(&amp;{41}, 0xc00000c038)\r\nafter calling  - a=({30}, 0xc000018178) b=(&amp;{41}, 0xc00000c028)<\/pre>\n<p>\u4ece\u8fd9\u6bb5\u4ee3\u7801\u4e2d\u6211\u4eec\u5176\u5b9e\u53ef\u4ee5\u770b\u51fa\uff0c\u5982\u679c\u4f20\u9012\u7684\u662f\u7ed3\u6784\u4f53\uff0c\u90a3\u4e48\u5728\u4f20\u9012\u53c2\u6570\u65f6\u4f9d\u7136\u4f1a\u5bf9\u7ed3\u6784\u4f53\u4e2d\u7684\u5168\u90e8\u5185\u5bb9\u8fdb\u884c\u62f7\u8d1d\uff0c\u800c\u4f20\u9012\u6307\u9488\u65f6\u590d\u5236\u7684\u5176\u5b9e\u4e5f\u662f\u6307\u9488\u7684\u5185\u5bb9 &#8211; \u5730\u5740\uff0c\u6240\u4ee5\u5bf9\u6307\u9488\u7684\u4fee\u6539\u5176\u5b9e\u5c31\u662f\u4fee\u6539\u6307\u9488\u80cc\u540e\u7684\u503c\uff0c<code>b.i<\/code>\u00a0\u53ef\u4ee5\u88ab\u7406\u89e3\u6210\u00a0<code>(*b).i<\/code>\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u5148\u83b7\u53d6\u6307\u9488\u00a0<code>b<\/code>\u00a0\u80cc\u540e\u7684\u7ed3\u6784\u4f53\uff0c\u518d\u4fee\u6539\u7ed3\u6784\u4f53\u4e2d\u7684\u6210\u5458\u53d8\u91cf\uff0c\u4f20\u9012\u7684\u6307\u9488\u5176\u5b9e\u4e5f\u5c31\u662f\u5730\u5740\u3002\u6211\u4eec\u7b80\u5355\u5bf9\u4e0a\u8ff0\u4ee3\u7801\u8fdb\u884c\u4fee\u6539\uff0c\u770b\u770b\u5f53\u524d\u7ed3\u6784\u4f53\u5728\u5185\u5b58\u4e2d\u662f\u5982\u4f55\u5e03\u5c40\u7684\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package main\r\n\r\nimport \"unsafe\"\r\nimport \"fmt\"\r\n\r\ntype MyStruct struct {\r\n    i int\r\n    j int\r\n}\r\n\r\nfunc myFunction(ms *MyStruct) {\r\n    ptr := unsafe.Pointer(ms)\r\n    for i := 0; i &lt; 2; i++ {\r\n        c := (*int)(unsafe.Pointer((uintptr(ptr) + uintptr(8*i))))\r\n        *c += i + 1\r\n        fmt.Printf(\"[%p] %d\\n\", c, *c)\r\n    }\r\n}\r\n\r\nfunc main() {\r\n    a := &amp;MyStruct{i: 40, j: 50}\r\n    myFunction(a)\r\n    fmt.Printf(\"[%p] %v\\n\", a, a)\r\n}\r\n\r\n$ go run main.go\r\n[0xc000018180] 41\r\n[0xc000018188] 52\r\n[0xc000018180] &amp;{41 52}<\/pre>\n<p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u76f4\u63a5\u901a\u8fc7\u6307\u9488\u7684\u65b9\u5f0f\u4fee\u6539\u7ed3\u6784\u4f53\u4e2d\u7684\u6210\u5458\u53d8\u91cf\uff0c\u7ed3\u6784\u4f53\u5728\u5185\u5b58\u4e2d\u5176\u5b9e\u5c31\u662f\u4e00\u7bc7\u8fde\u7eed\u7684\u7a7a\u95f4\uff0c\u5176\u4e2d\u7684\u591a\u4e2a\u6210\u5458\u53d8\u91cf\u8fde\u7eed\u5e03\u5c40\uff0c\u6307\u5411\u7ed3\u6784\u4f53\u7684\u6307\u9488\u5176\u5b9e\u4e5f\u662f\u6307\u5411\u8fd9\u4e2a\u7ed3\u6784\u4f53\u7684\u9996\u5730\u5740\uff0c\u5982\u679c\u6211\u4eec\u5c06\u00a0<code>MyStruct<\/code>\u00a0\u6307\u9488\u4fee\u6539\u6210\u00a0<code>int<\/code>\u00a0\u7c7b\u578b\u7684\uff0c\u90a3\u4e48\u5bf9\u65b0\u6307\u9488\u7684\u53bb\u5f15\u7528\uff08dereference\uff09\u5c31\u4f1a\u8fd4\u56de\u4e00\u4e2a\u6574\u578b\u53d8\u91cf\u00a0<code>i<\/code>\uff0c\u7531\u4e8e\u4e00\u4e2a\u00a0<code>int<\/code>\u00a0\u7c7b\u578b\u7684\u53d8\u91cf\u5360 8 \u4e2a\u5b57\u8282\uff0c\u6240\u4ee5\u5c06\u6307\u9488\u79fb\u52a8 8 \u4f4d\u4e4b\u540e\u5c31\u80fd\u83b7\u53d6\u4e0b\u4e00\u4e2a\u7ed3\u6784\u7684\u6210\u5458\u53d8\u91cf\u00a0<code>j<\/code>\u3002<\/p>\n<p>\u5982\u679c\u6211\u4eec\u5c06\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u5927\u90e8\u5206\u65e0\u5173\u7684\u4fe1\u606f\u7701\u7565\u5e76\u53ea\u5bf9\u5176\u4e2d\u7684\u00a0<code>myFuncion<\/code>\u00a0\u548c\u00a0<code>MyStruct<\/code>\u00a0\u8fd9\u4e24\u6bb5\u4ee3\u7801\u8fdb\u884c\u7f16\u8bd1\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">type MyStruct struct {\r\n    i int\r\n    j int\r\n}\r\n\r\nfunc myFunction(ms *MyStruct) *MyStruct {\r\n    return ms\r\n}\r\n\r\n\/\/ assembly\r\n\"\".myFunction STEXT nosplit size=20 args=0x10 locals=0x0\r\n    0x0000 00000 (main.go:8)\tTEXT\t\"\".myFunction(SB), NOSPLIT, $0-16\r\n    0x0000 00000 (main.go:8)\tFUNCDATA\t$0, gclocals\u00b7aef1f7ba6e2630c93a51843d99f5a28a(SB)\r\n    0x0000 00000 (main.go:8)\tFUNCDATA\t$1, gclocals\u00b733cdeccccebe80329f1fdbee7f5874cb(SB)\r\n    0x0000 00000 (main.go:8)\tMOVQ\t$0, \"\".~r1+16(SP) \/\/ \u521d\u59cb\u5316\u8fd4\u56de\u503c\r\n    0x0009 00009 (main.go:9)\tMOVQ\t\"\".ms+8(SP), AX   \/\/ \u590d\u5236\u5f15\u7528\r\n    0x000e 00014 (main.go:9)\tMOVQ\tAX, \"\".~r1+16(SP) \/\/ \u8fd4\u56de\u5f15\u7528\r\n    0x0013 00019 (main.go:9)\tRET<\/pre>\n<p>\u5728\u8fd9\u6bb5\u6c47\u7f16\u8bed\u8a00\u4e2d\u6211\u4eec\u53d1\u73b0\u5f53\u53c2\u6570\u662f\u6307\u9488\u65f6\uff0c\u5176\u5b9e\u4e5f\u4f1a\u4f7f\u7528\u00a0<code>MOVQ \"\".ms+8(SP), AX<\/code>\u00a0\u6307\u4ee4\u5148\u5bf9\u5f15\u7528\u8fdb\u884c\u590d\u5236\uff0c\u7136\u540e\u518d\u5c06\u590d\u5236\u540e\u7684\u6307\u9488\u4f5c\u4e3a\u8fd4\u56de\u503c\u4f20\u9012\u56de\u8c03\u7528\u65b9\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.draveness.me\/2019-01-21-golang-pointer-as-argument.png\" alt=\"golang-pointer-as-argument\" \/><\/p>\n<p>\u6240\u4ee5\u5176\u5b9e\u5c06\u6307\u9488\u4f5c\u4e3a\u53c2\u6570\u4f20\u5165\u67d0\u4e00\u4e2a\u51fd\u6570\u65f6\uff0c\u5176\u5b9e\u5728\u51fd\u6570\u5185\u90e8\u4f1a\u5bf9\u6307\u9488\u8fdb\u884c\u590d\u5236\uff0c\u4e5f\u5c31\u662f\u4f1a\u540c\u65f6\u51fa\u73b0\u4e24\u4e2a\u6307\u9488\u6307\u5411\u539f\u6709\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u6240\u4ee5 Go \u8bed\u8a00\u4e2d\u300e\u4f20\u6307\u9488\u300f\u5176\u5b9e\u4e5f\u662f\u4f20\u503c\u3002<\/p>\n<h3 id=\"\u5c0f\u7ed3\"><a id=\"\u5c0f\u7ed3\" class=\"anchor\" href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E5%B0%8F%E7%BB%93\" aria-hidden=\"true\"><\/a>\u5c0f\u7ed3<\/h3>\n<p>\u5f53\u6211\u4eec\u5bf9 Go \u8bed\u8a00\u4e2d\u5927\u591a\u6570\u5e38\u89c1\u7684\u6570\u636e\u7ed3\u6784\u8fdb\u884c\u9a8c\u8bc1\u4e4b\u540e\uff0c\u5176\u5b9e\u5c31\u80fd\u591f\u63a8\u6d4b\u51fa Go \u8bed\u8a00\u5728\u4f20\u9012\u53c2\u6570\u65f6\u5176\u5b9e\u4f7f\u7528\u7684\u5c31\u662f\u4f20\u503c\u7684\u65b9\u5f0f\uff0c\u63a5\u6536\u65b9\u6536\u5230\u53c2\u6570\u65f6\u4f1a\u5bf9\u8fd9\u4e9b\u53c2\u6570\u8fdb\u884c\u590d\u5236\uff1b\u4e86\u89e3\u5230\u8fd9\u4e00\u70b9\u4e4b\u540e\uff0c\u5728\u4f20\u9012\u6570\u7ec4\u6216\u8005\u5185\u5b58\u5360\u7528\u975e\u5e38\u5927\u7684\u7ed3\u6784\u4f53\u65f6\uff0c\u6211\u4eec\u5728\u4e00\u4e9b\u51fd\u6570\u4e2d\u5e94\u8be5\u5c3d\u91cf\u4f7f\u7528\u6307\u9488\u4f5c\u4e3a\u53c2\u6570\u7c7b\u578b\u6765\u907f\u514d\u53d1\u751f\u5927\u91cf\u6570\u636e\u7684\u62f7\u8d1d\u800c\u5f71\u54cd\u6027\u80fd\u3002<\/p>\n<h2 id=\"\u603b\u7ed3\"><a id=\"\u603b\u7ed3\" class=\"anchor\" href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#%E6%80%BB%E7%BB%93\" aria-hidden=\"true\"><\/a>\u603b\u7ed3<\/h2>\n<p>\u8fd9\u4e00\u8282\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u4e86 Go \u8bed\u8a00\u4e2d\u65b9\u6cd5\u8c03\u7528\u65f6\u7684\u8c03\u7528\u60ef\u4f8b\uff0c\u5305\u62ec\u53c2\u6570\u4f20\u9012\u7684\u8fc7\u7a0b\u548c\u539f\u7406\uff0c\u7b80\u5355\u68b3\u7406\u4e00\u4e0b\u65b9\u6cd5\u8c03\u7528\u7684\u8fc7\u7a0b\uff1aGo \u901a\u8fc7\u5806\u6808\u7684\u65b9\u5f0f\u5bf9\u51fd\u6570\u7684\u53c2\u6570\u548c\u8fd4\u56de\u503c\u8fdb\u884c\u4f20\u9012\u548c\u63a5\u53d7\uff0c\u5728\u8c03\u7528\u51fd\u6570\u4e4b\u524d\u4f1a\u5728\u6808\u4e0a\u4e3a\u8fd4\u56de\u503c\u5206\u914d\u5408\u9002\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u968f\u540e\u6309\u7167\u5165\u53c2\u4ece\u53f3\u5230\u5de6\u6309\u987a\u5e8f\u538b\u6808\uff0c\u88ab\u8c03\u7528\u65b9\u63a5\u53d7\u53c2\u6570\u65f6\u4f1a\u5bf9\u53c2\u6570\u8fdb\u884c\u62f7\u8d1d\u540e\u518d\u8fdb\u884c\u8ba1\u7b97\uff0c\u8fd4\u56de\u503c\u6700\u7ec8\u4f1a\u88ab\u653e\u7f6e\u5230\u8c03\u7528\u8005\u9884\u7559\u597d\u7684\u6808\u7a7a\u95f4\u4e0a\uff0cGo \u8bed\u8a00\u51fd\u6570\u8c03\u7528\u7684\u539f\u7406\u53ef\u4ee5\u603b\u7ed3\u6210\u4ee5\u4e0b\u7684\u51e0\u6761\u89c4\u5219\uff1a<\/p>\n<ol>\n<li>\u901a\u8fc7\u5806\u6808\u4f20\u9012\u53c2\u6570\uff0c\u5165\u6808\u7684\u987a\u5e8f\u662f\u4ece\u53f3\u5230\u5de6\uff1b<\/li>\n<li>\u51fd\u6570\u8fd4\u56de\u503c\u901a\u8fc7\u5806\u6808\u4f20\u9012\u5e76\u7531\u8c03\u7528\u8005\u9884\u5148\u5206\u914d\u5185\u5b58\u7a7a\u95f4\uff1b<\/li>\n<li>\u8c03\u7528\u51fd\u6570\u65f6\u90fd\u662f\u4f20\u503c\uff0c\u63a5\u6536\u65b9\u4f1a\u5bf9\u5165\u53c2\u8fdb\u884c\u590d\u5236\u518d\u8ba1\u7b97\uff1b<\/li>\n<\/ol>\n<h2 id=\"reference\"><a id=\"reference\" class=\"anchor\" href=\"https:\/\/draveness.me\/golang-funciton-call?from=groupmessage&amp;isappinstalled=0#reference\" aria-hidden=\"true\"><\/a>Reference<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.tenouk.com\/Bufferoverflowc\/Bufferoverflow2a.html\">The Function Stack<\/a><\/li>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/16453314\/why-do-byte-spills-occur-and-what-do-they-achieve\">Why do byte spills occur and what do they achieve?<\/a><\/li>\n<li><a href=\"https:\/\/mikeash.com\/pyblog\/friday-qa-2011-12-16-disassembling-the-assembly-part-1.html\">Friday Q&amp;A 2011-12-16: Disassembling the Assembly, Part 1<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/X86_calling_conventions\">x86 calling conventions<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Call_stack\">Call Stack<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/teh-cmc\/go-internals\/blob\/master\/chapter1_assembly_primer\/README.md\">Chapter I: A Primer on Go Assembly<\/a><\/li>\n<\/ul>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>20 JAN 2019\u00a0Golang\u00a0G<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[122],"class_list":["post-2795","post","type-post","status-publish","format-standard","hentry","tag-06-godocker"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/2795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=2795"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/2795\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=2795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=2795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=2795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}