{"id":5802,"date":"2024-04-15T23:57:38","date_gmt":"2024-04-15T15:57:38","guid":{"rendered":"http:\/\/zyg.luchers.cn\/?p=5802"},"modified":"2024-04-15T23:57:38","modified_gmt":"2024-04-15T15:57:38","slug":"%e7%ac%ac%e5%8d%81%e4%b8%80%e7%ab%a0%e3%80%81%e6%8f%90%e5%89%8d%e7%bc%96%e8%af%91%ef%bc%9aaot","status":"publish","type":"post","link":"http:\/\/zyg.luchers.cn\/index.php\/2024\/04\/15\/%e7%ac%ac%e5%8d%81%e4%b8%80%e7%ab%a0%e3%80%81%e6%8f%90%e5%89%8d%e7%bc%96%e8%af%91%ef%bc%9aaot\/","title":{"rendered":"\u7b2c\u5341\u4e00\u7ae0\u3001\u63d0\u524d\u7f16\u8bd1\uff1aAOT"},"content":{"rendered":"<h1>\u7b2c\u5341\u4e00\u7ae0\u3001\u63d0\u524d\u7f16\u8bd1\uff1aAOT<\/h1>\n<h2>1\u3001AOT\u6982\u5ff5<\/h2>\n<h3>1\u3001JIT\u548cAOT\u7684\u533a\u522b<\/h3>\n<h4>1\u3001JIT\uff0c Just-in-time\uff1a\u52a8\u6001(\u5373\u65f6)\u7f16\u8bd1\uff0c\u8fb9\u8fd0\u884c\u8fb9\u7f16\u8bd1<\/h4>\n<p>1\u3001\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\uff0c\u6839\u636e\u7b97\u6cd5\u8ba1\u7b97\u51fa\u70ed\u70b9\u4ee3\u7801\uff0c\u7136\u540e\u8fdb\u884c JIT \u5b9e\u65f6\u7f16\u8bd1\uff0c\u8fd9\u79cd\u65b9\u5f0f\u541e\u5410\u91cf\u9ad8\uff0c\u6709\u8fd0\u884c\u65f6\u6027\u80fd\u52a0\u6210\uff0c\u53ef\u4ee5\u8dd1\u5f97\u66f4\u5feb\uff0c\u5e76\u53ef\u4ee5\u505a\u5230\u52a8\u6001\u751f\u6210\u4ee3\u7801<\/p>\n<p>2\u3001\u76f8\u5bf9\u542f\u52a8\u901f\u5ea6\u8f83\u6162\uff0c\u5e76\u9700\u8981\u4e00\u5b9a\u65f6\u95f4\u548c\u8c03\u7528\u9891\u7387\u624d\u80fd\u89e6\u53d1 JIT \u7684\u5206\u5c42\u673a\u5236<\/p>\n<p>3\u3001\u7f16\u8bd1\u9700\u8981\u5360\u7528\u8fd0\u884c\u65f6\u8d44\u6e90\uff0c\u4f1a\u5bfc\u81f4\u8fdb\u7a0b\u5361\u987f\u3002<\/p>\n<h4>2\u3001AOT\uff0cAhead Of Time\uff0c\u6307\u8fd0\u884c\u524d\u7f16\u8bd1\uff0c\u9884\u5148\u7f16\u8bd1<\/h4>\n<p>1\u3001AOT \u7f16\u8bd1\u80fd\u76f4\u63a5\u5c06\u6e90\u4ee3\u7801\u8f6c\u5316\u4e3a\u673a\u5668\u7801\uff0c\u5185\u5b58\u5360\u7528\u4f4e\uff0c\u542f\u52a8\u901f\u5ea6\u5feb<\/p>\n<p>2\u3001\u53ef\u4ee5\u65e0\u9700 runtime \u8fd0\u884c\uff0c\u76f4\u63a5\u5c06 runtime \u9759\u6001\u94fe\u63a5\u81f3\u6700\u7ec8\u7684\u7a0b\u5e8f\u4e2d<\/p>\n<p>3\u3001\u4f46\u662f\u65e0\u8fd0\u884c\u65f6\u6027\u80fd\u52a0\u6210\uff0c\u4e0d\u80fd\u6839\u636e\u7a0b\u5e8f\u8fd0\u884c\u60c5\u51b5\u505a\u8fdb\u4e00\u6b65\u7684\u4f18\u5316<\/p>\n<p>4\u3001AOT \u7f3a\u70b9\u5c31\u662f\u5728\u7a0b\u5e8f\u8fd0\u884c\u524d\u7f16\u8bd1\u4f1a\u4f7f\u7a0b\u5e8f\u5b89\u88c5\u7684\u65f6\u95f4\u589e\u52a0<\/p>\n<h4>3\u3001\u603b\u7ed3<\/h4>\n<p>1\u3001JIT\u5373\u65f6\u7f16\u8bd1\u6307\u7684\u662f\u5728\u7a0b\u5e8f\u7684\u8fd0\u884c\u8fc7\u7a0b\u4e2d\uff0c\u5c06\u5b57\u8282\u7801\u8f6c\u6362\u4e3a\u53ef\u5728\u786c\u4ef6\u4e0a\u76f4\u63a5\u8fd0\u884c\u7684\u673a\u5668\u7801\uff0c\u5e76\u90e8\u7f72\u81f3\u6258\u7ba1\u73af\u5883\u4e2d\u7684\u8fc7\u7a0b\u3002<\/p>\n<p>2\u3001\u800c AOT \u7f16\u8bd1\u6307\u7684\u5219\u662f\uff0c\u5728\u7a0b\u5e8f\u8fd0\u884c\u4e4b\u524d\uff0c\u4fbf\u5c06\u5b57\u8282\u7801\u8f6c\u6362\u4e3a\u673a\u5668\u7801\u7684\u8fc7\u7a0b\u3002<\/p>\n<pre><code>.java -&gt; .class -&gt; (\u4f7f\u7528jaotc\u7f16\u8bd1\u5de5\u5177) -&gt; .so\uff08\u7a0b\u5e8f\u51fd\u6570\u5e93,\u5373\u7f16\u8bd1\u597d\u7684\u53ef\u4ee5\u4f9b\u5176\u4ed6\u7a0b\u5e8f\u4f7f\u7528\u7684\u4ee3\u7801\u548c\u6570\u636e\uff09<\/code><\/pre>\n<p>3\u3001\u4f8b\u5b50<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/zyg.luchers.cn\/wp-content\/uploads\/2024\/04\/image-20231106142541391.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"http:\/\/zyg.luchers.cn\/wp-content\/uploads\/2024\/04\/image-20231106142541391.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"image-20231106142541391\" \/><\/div><\/p>\n<h3>2\u3001AOT\u7684\u4f18\u70b9<\/h3>\n<p>1\u3001ava \u865a\u62df\u673a\u52a0\u8f7d\u5df2\u7ecf\u9884\u7f16\u8bd1\u6210\u4e8c\u8fdb\u5236\u5e93\uff0c\u53ef\u4ee5\u76f4\u63a5\u6267\u884c<\/p>\n<p>2\u3001\u4e0d\u5fc5\u7b49\u5f85\u53ca\u65f6\u7f16\u8bd1\u5668\u7684\u9884\u70ed\uff0c\u51cf\u5c11 Java \u5e94\u7528\u7ed9\u4eba\u5e26\u6765\u201c\u7b2c\u4e00\u6b21\u8fd0\u884c\u6162\u201d \u7684\u4e0d\u826f\u4f53\u9a8c<\/p>\n<p>3\u3001\u5728\u7a0b\u5e8f\u8fd0\u884c\u524d\u7f16\u8bd1\uff0c\u53ef\u4ee5\u907f\u514d\u5728\u8fd0\u884c\u65f6\u7684\u7f16\u8bd1\u6027\u80fd\u6d88\u8017\u548c\u5185\u5b58\u6d88\u8017<\/p>\n<p>4\u3001\u53ef\u4ee5\u5728\u7a0b\u5e8f\u8fd0\u884c\u521d\u671f\u5c31\u8fbe\u5230\u6700\u9ad8\u6027\u80fd\uff0c\u7a0b\u5e8f\u542f\u52a8\u901f\u5ea6\u5feb<\/p>\n<p>5\u3001\u8fd0\u884c\u4ea7\u7269\u53ea\u6709\u673a\u5668\u7801\uff0c\u6253\u5305\u4f53\u79ef\u5c0f<\/p>\n<h3>3\u3001AOT\u7684\u7f3a\u70b9<\/h3>\n<p>1\u3001\u7531\u4e8e\u662f\u9759\u6001\u63d0\u524d\u7f16\u8bd1\uff0c\u4e0d\u80fd\u6839\u636e\u786c\u4ef6\u60c5\u51b5\u6216\u7a0b\u5e8f\u8fd0\u884c\u60c5\u51b5\u62e9\u4f18\u9009\u62e9\u673a\u5668\u6307\u4ee4\u5e8f\u5217\uff0c\u7406\u8bba\u5cf0\u503c\u6027\u80fd\u4e0d\u5982JIT<\/p>\n<p>2\u3001\u6ca1\u6709\u52a8\u6001\u80fd\u529b\uff0c\u540c\u4e00\u4efd\u4ea7\u7269\u4e0d\u80fd\u8de8\u5e73\u53f0\u8fd0\u884c<\/p>\n<h2>2\u3001Graalvm<\/h2>\n<h3>1\u3001\u6982\u5ff5<\/h3>\n<p>1\u3001Spring6 \u652f\u6301\u7684 AOT \u6280\u672f\uff0c\u8fd9\u4e2a GraalVM  \u5c31\u662f\u5e95\u5c42\u7684\u652f\u6301\uff0cSpring \u4e5f\u5bf9 GraalVM \u672c\u673a\u6620\u50cf\u63d0\u4f9b\u4e86\u4e00\u6d41\u7684\u652f\u6301<\/p>\n<p>2\u3001GraalVM \u662f\u4e00\u79cd\u9ad8\u6027\u80fd JDK\uff0c\u65e8\u5728\u52a0\u901f\u7528 Java \u548c\u5176\u4ed6 JVM \u8bed\u8a00\u7f16\u5199\u7684\u5e94\u7528\u7a0b\u5e8f\u7684\u6267\u884c<\/p>\n<p>3\u3001\u540c\u65f6\u8fd8\u4e3a JavaScript\u3001Python \u548c\u8bb8\u591a\u5176\u4ed6\u6d41\u884c\u8bed\u8a00\u63d0\u4f9b\u8fd0\u884c\u65f6<\/p>\n<p>4\u3001GraalVM \u63d0\u4f9b\u4e24\u79cd\u8fd0\u884c Java \u5e94\u7528\u7a0b\u5e8f\u7684\u65b9\u6cd5\uff1a\u5728 HotSpot JVM \u4e0a\u4f7f\u7528 Graal \u5373\u65f6 (JIT) \u7f16\u8bd1\u5668\u6216\u4f5c\u4e3a\u63d0\u524d (AOT) \u7f16\u8bd1\u7684\u672c\u673a\u53ef\u6267\u884c\u6587\u4ef6<\/p>\n<p>5\u3001GraalVM \u7684\u591a\u8bed\u8a00\u80fd\u529b\u4f7f\u5f97\u5728\u5355\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u6df7\u5408\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u6210\u4e3a\u53ef\u80fd\uff0c\u540c\u65f6\u6d88\u9664\u4e86\u5916\u8bed\u8c03\u7528\u6210\u672c<\/p>\n<p>6\u3001GraalVM \u5411 HotSpot Java \u865a\u62df\u673a\u6dfb\u52a0\u4e86\u4e00\u4e2a\u7528 Java \u7f16\u5199\u7684\u9ad8\u7ea7\u5373\u65f6 (JIT) \u4f18\u5316\u7f16\u8bd1\u5668<\/p>\n<h3>2\u3001\u7279\u70b9<\/h3>\n<p>1\u3001\u4e00\u79cd\u9ad8\u7ea7\u4f18\u5316\u7f16\u8bd1\u5668\uff0c\u5b83\u751f\u6210\u66f4\u5feb\u3001\u66f4\u7cbe\u7b80\u7684\u4ee3\u7801\uff0c\u9700\u8981\u66f4\u5c11\u7684\u8ba1\u7b97\u8d44\u6e90<\/p>\n<p>2\u3001AOT \u672c\u673a\u56fe\u50cf\u7f16\u8bd1\u63d0\u524d\u5c06 Java \u5e94\u7528\u7a0b\u5e8f\u7f16\u8bd1\u4e3a\u672c\u673a\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u7acb\u5373\u542f\u52a8\uff0c\u65e0\u9700\u9884\u70ed\u5373\u53ef\u5b9e\u73b0\u6700\u9ad8\u6027\u80fd<\/p>\n<p>3\u3001Polyglot \u7f16\u7a0b\u5728\u5355\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u5229\u7528\u6d41\u884c\u8bed\u8a00\u7684\u6700\u4f73\u529f\u80fd\u548c\u5e93\uff0c\u65e0\u9700\u989d\u5916\u5f00\u9500<\/p>\n<p>4\u3001\u9ad8\u7ea7\u5de5\u5177\u5728 Java \u548c\u591a\u79cd\u8bed\u8a00\u4e2d\u8c03\u8bd5\u3001\u76d1\u89c6\u3001\u5206\u6790\u548c\u4f18\u5316\u8d44\u6e90\u6d88\u8017<\/p>\n<p>5\u3001\u603b\u7684\u6765\u8bf4\u5bf9\u4e91\u539f\u751f\u7684\u8981\u6c42\u4e0d\u7b97\u9ad8\u77ed\u671f\u5185\u53ef\u4ee5\u7ee7\u7eed\u4f7f\u7528 2.7.X \u7684\u7248\u672c\u548c JDK8\uff0c\u4e0d\u8fc7 Spring \u5b98\u65b9\u5df2\u7ecf\u5bf9 Spring6 \u8fdb\u884c\u4e86\u6b63\u5f0f\u7248\u53d1\u5e03<\/p>\n<h2>3\u3001Native Image<\/h2>\n<h3>1\u3001\u6982\u5ff5<\/h3>\n<p>1\u3001\u53e6\u5916\u4e00\u79cd\u5b9e\u73b0Java AOT\u7684\u601d\u8def\uff0c\u90a3\u5c31\u662f\u76f4\u63a5\u6452\u5f03JVM\uff0c\u548cC\/C++\u4e00\u6837\u901a\u8fc7\u7f16\u8bd1\u5668\u76f4\u63a5\u5c06\u4ee3\u7801\u7f16\u8bd1\u6210\u673a\u5668\u4ee3\u7801\uff0c\u7136\u540e\u8fd0\u884c<\/p>\n<p>2\u3001\u5b83\u901a\u8fc7C\u8bed\u8a00\u5b9e\u73b0\u4e86\u4e00\u4e2a\u8d85\u5fae\u7f29\u7684\u8fd0\u884c\u65f6\u7ec4\u4ef6 \u2014\u2014 Substrate VM\uff0c\u57fa\u672c\u5b9e\u73b0\u4e86JVM\u7684\u5404\u79cd\u7279\u6027\uff0c\u4f46\u8db3\u591f\u8f7b\u91cf\u3001\u53ef\u4ee5\u88ab\u8f7b\u677e\u5185\u5d4c\uff0c\u8fd9\u5c31\u8ba9Java\u8bed\u8a00\u548c\u5de5\u7a0b\u6446\u8131JVM\u7684\u9650\u5236\uff0c\u80fd\u591f\u771f\u6b63\u610f\u4e49\u4e0a\u5b9e\u73b0\u548cC\/C++\u4e00\u6837\u7684AOT\u7f16\u8bd1<\/p>\n<p>3\u3001Native Image \u662f\u4e00\u9879\u521b\u65b0\u6280\u672f\uff0c\u53ef\u5c06 Java \u4ee3\u7801\u7f16\u8bd1\u6210\u72ec\u7acb\u7684\u672c\u673a\u53ef\u6267\u884c\u6587\u4ef6\u6216\u672c\u673a\u5171\u4eab\u5e93\u3002\u5728\u6784\u5efa\u672c\u673a\u53ef\u6267\u884c\u6587\u4ef6\u671f\u95f4\u5904\u7406\u7684 Java \u5b57\u8282\u7801\u5305\u62ec\u6240\u6709\u5e94\u7528\u7a0b\u5e8f\u7c7b\u3001\u4f9d\u8d56\u9879\u3001\u7b2c\u4e09\u65b9\u4f9d\u8d56\u5e93\u548c\u4efb\u4f55\u6240\u9700\u7684 JDK \u7c7b<\/p>\n<p>4\u3001\u751f\u6210\u7684\u81ea\u5305\u542b\u672c\u673a\u53ef\u6267\u884c\u6587\u4ef6\u7279\u5b9a\u4e8e\u4e0d\u9700\u8981 JVM \u7684\u6bcf\u4e2a\u5355\u72ec\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u673a\u5668\u4f53\u7cfb\u7ed3\u6784\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c\u5341\u4e00\u7ae0\u3001\u63d0\u524d\u7f16\u8bd1\uff1aAOT 1\u3001AOT\u6982\u5ff5 1\u3001JIT\u548cAOT\u7684\u533a\u522b 1\u3001JIT\uff0c Just-in-time\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-5802","post","type-post","status-publish","format-standard","hentry","category-spring-spring"],"_links":{"self":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/comments?post=5802"}],"version-history":[{"count":1,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5802\/revisions"}],"predecessor-version":[{"id":5803,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5802\/revisions\/5803"}],"wp:attachment":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/media?parent=5802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/categories?post=5802"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/tags?post=5802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}