{"id":1962,"date":"2017-09-08T15:48:42","date_gmt":"2017-09-08T07:48:42","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=1962"},"modified":"2017-09-08T15:48:42","modified_gmt":"2017-09-08T07:48:42","slug":"%e8%af%a6%e8%a7%a3javascript%e7%9a%84just-in-timejit%e7%bc%96%e8%af%91%e5%99%a8%e7%9a%84%e5%b7%a5%e4%bd%9c%e5%8e%9f%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=1962","title":{"rendered":"\u8be6\u89e3JavaScript\u7684Just-in-time(JIT\u7f16\u8bd1\u5668)\u7684\u5de5\u4f5c\u539f\u7406"},"content":{"rendered":"<p>\n\tJavaScript \u7684\u542f\u52a8\u6bd4\u8f83\u7f13\u6162\uff0c\u4f46\u662f\u901a\u8fc7 JIT \u53ef\u4ee5\u4f7f\u5176\u53d8\u5feb\u3002 JIT \u6709\u8fd9\u4e48\u795e\u5947\u7684\u4f5c\u7528\uff0c\u90a3\u4e48\u5b83\u7684\u539f\u7406\u662f\u4ec0\u4e48\u5462\uff1f\u4e14\u770b\u672c\u6587\u7684\u8be6\u7ec6\u4ecb\u7ecd\u3002\n<\/p>\n<p>\n\t\u5927\u90e8\u5206\u5f00\u53d1\u8005\u5728\u4f7f\u7528 JavaScript \u65f6\uff0c\u53ea\u8003\u8651\u5b83\u5b9e\u73b0\u529f\u80fd\uff0c\u800c\u6ca1\u6709\u8003\u8651\u5b83\u662f\u5982\u4f55\u88ab\u673a\u5668\u6267\u884c\u7684\u3002\n<\/p>\n<p>\n\t\u4f60\u8bf4\u7684\u662f\u4eba\u7c7b\u7684\u8bed\u8a00\uff0c\u800c\u8ba1\u7b97\u673a\u7528\u7684\u662f\u673a\u5668\u8bed\u8a00\u3002\u673a\u5668\u8bed\u8a00\u4e5f\u662f\u4e00\u79cd\u8bed\u8a00\uff0c\u53ea\u662f JavaScript \u6216\u8005\u5176\u4ed6\u9ad8\u7ea7\u7f16\u7a0b\u8bed\u8a00\u673a\u5668\u80fd\u770b\u5f97\u61c2\uff0c\u800c\u4eba\u7c7b\u4e0d\u7528\u4ed6\u4eec\u6765\u4ea4\u6d41\u7f62\u4e86\u3002\u5b83\u4eec\u662f\u57fa\u4e8e\u4eba\u7c7b\u8ba4\u77e5\u800c\u8bbe\u8ba1\u51fa\u6765\u7684\u3002\n<\/p>\n<p>\n\t\u6240\u4ee5\u5462\uff0cJavaScript \u5f15\u64ce\u7684\u5de5\u4f5c\u5c31\u662f\u628a\u4eba\u7c7b\u7684\u8bed\u8a00\u8f6c\u6362\u6210\u673a\u5668\u80fd\u770b\u61c2\u7684\u8bed\u8a00\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u673a\u5668\u8bed\u8a00\u5904\u7406\" src=\"http:\/\/img.bbs.csdn.net\/upload\/201709\/08\/1504854337_70451.png\" style=\"width: 500px;height: 286px\" \/>\n<\/p>\n<p>\n\t\u5728\u4ee3\u7801\u7684\u4e16\u754c\u4e2d\uff0c\u901a\u5e38\u6709\u4e24\u79cd\u65b9\u5f0f\u6765\u7ffb\u8bd1\u673a\u5668\u8bed\u8a00\uff1a\u89e3\u91ca\u5668\u548c\u7f16\u8bd1\u5668\u3002\u6bd4\u5982 java \u5c31\u662f\u8fd9\u6837\u3002\n<\/p>\n<p>\n\t\u5982\u679c\u662f\u901a\u8fc7\u89e3\u91ca\u5668\uff0c\u7ffb\u8bd1\u662f\u4e00\u884c\u884c\u5730\u8fb9\u89e3\u91ca\u8fb9\u6267\u884c\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u89e3\u91ca\u5668\u5c06\u4ee3\u7801\u89e3\u91ca\u6210\u673a\u5668\u80fd\u8bc6\u522b\u7684\u4e8c\u8fdb\u5236\" src=\"http:\/\/img.bbs.csdn.net\/upload\/201709\/08\/1504854585_967043.png\" style=\"width: 500px;height: 291px\" \/>\n<\/p>\n<p>\n\t\u7f16\u8bd1\u5668\u662f\u628a\u6e90\u4ee3\u7801\u6574\u4e2a\u7f16\u8bd1\u6210\u76ee\u6807\u4ee3\u7801\uff0c\u6267\u884c\u65f6\u4e0d\u518d\u9700\u8981\u7f16\u8bd1\u5668\uff0c\u76f4\u63a5\u5728\u652f\u6301\u76ee\u6807\u4ee3\u7801\u7684\u5e73\u53f0\u4e0a\u8fd0\u884c\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u7f16\u8bd1\u5668\u662f\u628a\u6e90\u4ee3\u7801\u6574\u4e2a\u7f16\u8bd1\u6210\u76ee\u6807\u4ee3\u7801\" src=\"http:\/\/img.bbs.csdn.net\/upload\/201709\/08\/1504854846_975123.png\" style=\"width: 500px;height: 297px\" \/>\n<\/p>\n<p>\n\t\u8fd9\u4e24\u79cd\u7ffb\u8bd1\u7684\u65b9\u5f0f\u90fd\u5404\u6709\u5229\u5f0a\u3002\n<\/p>\n<h2>\n\t\u89e3\u91ca\u5668\u7684\u5229\u5f0a<br \/>\n<\/h2>\n<p>\n\t\u89e3\u91ca\u5668\u542f\u52a8\u548c\u6267\u884c\u7684\u66f4\u5feb\u3002\u4f60\u4e0d\u9700\u8981\u7b49\u5f85\u6574\u4e2a\u7f16\u8bd1\u8fc7\u7a0b\u5b8c\u6210\u5c31\u53ef\u4ee5\u8fd0\u884c\u4f60\u7684\u4ee3\u7801\u3002\u4ece\u7b2c\u4e00\u884c\u5f00\u59cb\u7ffb\u8bd1\uff0c\u5c31\u53ef\u4ee5\u4f9d\u6b21\u7ee7\u7eed\u6267\u884c\u4e86\u3002\n<\/p>\n<p>\n\t\u6b63\u662f\u56e0\u4e3a\u8fd9\u4e2a\u539f\u56e0\uff0c\u89e3\u91ca\u5668\u770b\u8d77\u6765\u66f4\u52a0\u9002\u5408 JavaScript\u3002\u5bf9\u4e8e\u4e00\u4e2a Web \u5f00\u53d1\u4eba\u5458\u6765\u8bb2\uff0c\u80fd\u591f\u5feb\u901f\u6267\u884c\u4ee3\u7801\u5e76\u770b\u5230\u7ed3\u679c\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\n<\/p>\n<p>\n\t\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u6700\u5f00\u59cb\u7684\u6d4f\u89c8\u5668\u90fd\u662f\u7528 JavaScript \u89e3\u91ca\u5668\u7684\u539f\u56e0\u3002\n<\/p>\n<p>\n\t\u53ef\u662f\u5f53\u4f60\u8fd0\u884c\u540c\u6837\u7684\u4ee3\u7801\u4e00\u6b21\u4ee5\u4e0a\u7684\u65f6\u5019\uff0c\u89e3\u91ca\u5668\u7684\u5f0a\u5904\u5c31\u663e\u73b0\u51fa\u6765\u4e86\u3002\u6bd4\u5982\u4f60\u6267\u884c\u4e00\u4e2a\u5faa\u73af\uff0c\u90a3\u89e3\u91ca\u5668\u5c31\u4e0d\u5f97\u4e0d\u4e00\u6b21\u53c8\u4e00\u6b21\u7684\u8fdb\u884c\u7ffb\u8bd1\uff0c\u8fd9\u662f\u4e00\u79cd\u6548\u7387\u4f4e\u4e0b\u7684\u8868\u73b0\u3002\n<\/p>\n<h2>\n\t\u7f16\u8bd1\u5668\u7684\u5229\u5f0a<br \/>\n<\/h2>\n<p>\n\t\u7f16\u8bd1\u5668\u7684\u95ee\u9898\u5219\u6070\u597d\u76f8\u53cd\u3002\n<\/p>\n<p>\n\t\u5b83\u9700\u8981\u82b1\u4e00\u4e9b\u65f6\u95f4\u5bf9\u6574\u4e2a\u6e90\u4ee3\u7801\u8fdb\u884c\u7f16\u8bd1\uff0c\u7136\u540e\u751f\u6210\u76ee\u6807\u6587\u4ef6\u624d\u80fd\u5728\u673a\u5668\u4e0a\u6267\u884c\u3002\u5bf9\u4e8e\u6709\u5faa\u73af\u7684\u4ee3\u7801\u6267\u884c\u7684\u5f88\u5feb\uff0c\u56e0\u4e3a\u5b83\u4e0d\u9700\u8981\u91cd\u590d\u7684\u53bb\u7ffb\u8bd1\u6bcf\u4e00\u6b21\u5faa\u73af\u3002\n<\/p>\n<p>\n\t\u53e6\u5916\u4e00\u4e2a\u4e0d\u540c\u662f\uff0c\u7f16\u8bd1\u5668\u53ef\u4ee5\u7528\u66f4\u591a\u7684\u65f6\u95f4\u5bf9\u4ee3\u7801\u8fdb\u884c\u4f18\u5316\uff0c\u4ee5\u4f7f\u7684\u4ee3\u7801\u6267\u884c\u7684\u66f4\u5feb\u3002\u800c\u89e3\u91ca\u5668\u662f\u5728 runtime \u65f6\u8fdb\u884c\u8fd9\u4e00\u6b65\u9aa4\u7684\uff0c\u8fd9\u5c31\u51b3\u5b9a\u4e86\u5b83\u4e0d\u53ef\u80fd\u5728\u7ffb\u8bd1\u7684\u65f6\u5019\u7528\u5f88\u591a\u65f6\u95f4\u8fdb\u884c\u4f18\u5316\u3002\n<\/p>\n<h2>\n\tJust-in-time \u7f16\u8bd1\u5668<br \/>\n<\/h2>\n<p>\n\tJust-in-time \u7f16\u8bd1\u5668\u7b80\u79f0 JIT\u3002\u5b83\u7efc\u5408\u4e86\u89e3\u91ca\u5668\u548c\u7f16\u8bd1\u5668\u4e24\u8005\u7684\u4f18\u70b9\u3002\n<\/p>\n<p>\n\t\u4e3a\u4e86\u89e3\u51b3\u89e3\u91ca\u5668\u7684\u4f4e\u6548\u95ee\u9898\uff0c\u540e\u6765\u7684\u6d4f\u89c8\u5668\u628a\u7f16\u8bd1\u5668\u4e5f\u5f15\u5165\u8fdb\u6765\uff0c\u5f62\u6210\u6df7\u5408\u6a21\u5f0f\u3002\n<\/p>\n<p>\n\t\u4e0d\u540c\u7684\u6d4f\u89c8\u5668\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\u7684\u65b9\u5f0f\u4e0d\u540c\uff0c\u4e0d\u8fc7\u5176\u57fa\u672c\u601d\u60f3\u662f\u4e00\u81f4\u7684\u3002\u5728 JavaScript \u5f15\u64ce\u4e2d\u589e\u52a0\u4e00\u4e2a\u76d1\u89c6\u5668\uff08\u4e5f\u53eb\u5206\u6790\u5668\uff09\u3002\u76d1\u89c6\u5668\u76d1\u63a7\u7740\u4ee3\u7801\u7684\u8fd0\u884c\u60c5\u51b5\uff0c\u8bb0\u5f55\u4ee3\u7801\u4e00\u5171\u8fd0\u884c\u4e86\u591a\u5c11\u6b21\u3001\u5982\u4f55\u8fd0\u884c\u7684\u7b49\u4fe1\u606f\u3002\n<\/p>\n<p>\n\t\u8d77\u521d\uff0c\u76d1\u89c6\u5668\u76d1\u89c6\u7740\u6240\u6709\u901a\u8fc7\u89e3\u91ca\u5668\u7684\u4ee3\u7801\u3002\n<\/p>\n<p>\n\t\u5982\u679c\u540c\u4e00\u884c\u4ee3\u7801\u8fd0\u884c\u4e86\u51e0\u6b21\uff0c\u8fd9\u4e2a\u4ee3\u7801\u6bb5\u5c31\u88ab\u6807\u8bb0\u6210\u4e86 &ldquo;warm&rdquo;\uff0c\u5982\u679c\u8fd0\u884c\u4e86\u5f88\u591a\u6b21\uff0c\u5219\u88ab\u6807\u8bb0\u6210 &ldquo;hot&rdquo;\u3002\n<\/p>\n<h2>\n\t\u57fa\u7ebf\u7f16\u8bd1\u5668<br \/>\n<\/h2>\n<p>\n\t\u5982\u679c\u4e00\u6bb5\u4ee3\u7801\u53d8\u6210\u4e86 &ldquo;warm&rdquo;\uff0c\u90a3\u4e48 JIT \u5c31\u628a\u5b83\u9001\u5230\u7f16\u8bd1\u5668\u53bb\u7f16\u8bd1\uff0c\u5e76\u4e14\u628a\u7f16\u8bd1\u7ed3\u679c\u5b58\u50a8\u8d77\u6765\u3002\n<\/p>\n<p>\n\t\u4ee3\u7801\u6bb5\u7684\u6bcf\u4e00\u884c\u90fd\u4f1a\u88ab\u7f16\u8bd1\u6210\u4e00\u4e2a&ldquo;\u6869&rdquo;\uff08stub\uff09\uff0c\u540c\u65f6\u7ed9\u8fd9\u4e2a\u6869\u5206\u914d\u4e00\u4e2a\u4ee5&ldquo;\u884c\u53f7 + \u53d8\u91cf\u7c7b\u578b&rdquo;\u7684\u7d22\u5f15\u3002\u5982\u679c\u76d1\u89c6\u5668\u76d1\u89c6\u5230\u4e86\u6267\u884c\u540c\u6837\u7684\u4ee3\u7801\u548c\u540c\u6837\u7684\u53d8\u91cf\u7c7b\u578b\uff0c\u90a3\u4e48\u5c31\u76f4\u63a5\u628a\u8fd9\u4e2a\u5df2\u7f16\u8bd1\u7684\u7248\u672c push \u51fa\u6765\u7ed9\u6d4f\u89c8\u5668\u3002\n<\/p>\n<p>\n\t\u901a\u8fc7\u8fd9\u6837\u7684\u505a\u6cd5\u53ef\u4ee5\u52a0\u5feb\u6267\u884c\u901f\u5ea6\uff0c\u4f46\u662f\u6b63\u5982\u524d\u9762\u6211\u6240\u8bf4\u7684\uff0c\u7f16\u8bd1\u5668\u8fd8\u53ef\u4ee5\u627e\u5230\u66f4\u6709\u6548\u5730\u6267\u884c\u4ee3\u7801\u7684\u65b9\u6cd5\uff0c\u4e5f\u5c31\u662f\u505a\u4f18\u5316\u3002\n<\/p>\n<p>\n\t\u57fa\u7ebf\u7f16\u8bd1\u5668\u53ef\u4ee5\u505a\u4e00\u90e8\u5206\u8fd9\u6837\u7684\u4f18\u5316\uff08\u4e0b\u9762\u6211\u4f1a\u7ed9\u51fa\u4f8b\u5b50\uff09\uff0c\u4e0d\u8fc7\u57fa\u7ebf\u7f16\u8bd1\u5668\u4f18\u5316\u7684\u65f6\u95f4\u4e0d\u80fd\u592a\u4e45\uff0c\u56e0\u4e3a\u4f1a\u4f7f\u5f97\u7a0b\u5e8f\u7684\u6267\u884c\u5728\u8fd9\u91cc hold \u4f4f\u3002\n<\/p>\n<p>\n\t\u4e0d\u8fc7\u5982\u679c\u4ee3\u7801\u786e\u5b9e\u975e\u5e38 &ldquo;hot&rdquo;\uff08\u4e5f\u5c31\u662f\u8bf4\u51e0\u4e4e\u6240\u6709\u7684\u6267\u884c\u65f6\u95f4\u90fd\u8017\u8d39\u5728\u8fd9\u91cc\uff09\uff0c\u90a3\u4e48\u82b1\u70b9\u65f6\u95f4\u505a\u4f18\u5316\u4e5f\u662f\u503c\u5f97\u7684\u3002\n<\/p>\n<h2>\n\t\u4f18\u5316\u7f16\u8bd1\u5668<br \/>\n<\/h2>\n<p>\n\t\u5982\u679c\u4e00\u4e2a\u4ee3\u7801\u6bb5\u53d8\u5f97 &ldquo;very hot&rdquo;\uff0c\u76d1\u89c6\u5668\u4f1a\u628a\u5b83\u53d1\u9001\u5230\u4f18\u5316\u7f16\u8bd1\u5668\u4e2d\u3002\u751f\u6210\u4e00\u4e2a\u66f4\u5feb\u901f\u548c\u9ad8\u6548\u7684\u4ee3\u7801\u7248\u672c\u51fa\u6765\uff0c\u5e76\u4e14\u5b58\u50a8\u4e4b\u3002\n<\/p>\n<p>\n\t\u4e3a\u4e86\u751f\u6210\u4e00\u4e2a\u66f4\u5feb\u901f\u7684\u4ee3\u7801\u7248\u672c\uff0c\u4f18\u5316\u7f16\u8bd1\u5668\u5fc5\u987b\u505a\u4e00\u4e9b\u5047\u8bbe\u3002\u4f8b\u5982\uff0c\u5b83\u4f1a\u5047\u8bbe\u7531\u540c\u4e00\u4e2a\u6784\u9020\u51fd\u6570\u751f\u6210\u7684\u5b9e\u4f8b\u90fd\u6709\u76f8\u540c\u7684\u5f62\u72b6&mdash;&mdash;\u5c31\u662f\u8bf4\u6240\u6709\u7684\u5b9e\u4f8b\u90fd\u6709\u76f8\u540c\u7684\u5c5e\u6027\u540d\uff0c\u5e76\u4e14\u90fd\u4ee5\u540c\u6837\u7684\u987a\u5e8f\u521d\u59cb\u5316\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u9488\u5bf9\u8fd9\u4e00\u6a21\u5f0f\u8fdb\u884c\u4f18\u5316\u3002\n<\/p>\n<p>\n\t\u6574\u4e2a\u4f18\u5316\u5668\u8d77\u4f5c\u7528\u7684\u94fe\u6761\u662f\u8fd9\u6837\u7684\uff0c\u76d1\u89c6\u5668\u4ece\u4ed6\u6240\u76d1\u89c6\u4ee3\u7801\u7684\u6267\u884c\u60c5\u51b5\u505a\u51fa\u81ea\u5df1\u7684\u5224\u65ad\uff0c\u63a5\u4e0b\u6765\u628a\u5b83\u6240\u6574\u7406\u7684\u4fe1\u606f\u4f20\u9012\u7ed9\u4f18\u5316\u5668\u8fdb\u884c\u4f18\u5316\u3002\u5982\u679c\u67d0\u4e2a\u5faa\u73af\u4e2d\u5148\u524d\u6bcf\u6b21\u8fed\u4ee3\u7684\u5bf9\u8c61\u90fd\u6709\u76f8\u540c\u7684\u5f62\u72b6\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u8ba4\u4e3a\u5b83\u4ee5\u540e\u8fed\u4ee3\u7684\u5bf9\u8c61\u7684\u5f62\u72b6\u90fd\u662f\u76f8\u540c\u7684\u3002\u53ef\u662f\u5bf9\u4e8e JavaScript \u4ece\u6765\u5c31\u6ca1\u6709\u4fdd\u8bc1\u8fd9\u4e48\u4e00\u8bf4\uff0c\u524d 99 \u4e2a\u5bf9\u8c61\u4fdd\u6301\u7740\u5f62\u72b6\uff0c\u53ef\u80fd\u7b2c 100 \u4e2a\u5c31\u5c11\u4e86\u67d0\u4e2a\u5c5e\u6027\u3002\n<\/p>\n<p>\n\t\u6b63\u662f\u7531\u4e8e\u8fd9\u6837\u7684\u60c5\u51b5\uff0c\u6240\u4ee5\u7f16\u8bd1\u4ee3\u7801\u9700\u8981\u5728\u8fd0\u884c\u4e4b\u524d\u68c0\u67e5\u5176\u5047\u8bbe\u662f\u4e0d\u662f\u5408\u7406\u7684\u3002\u5982\u679c\u5408\u7406\uff0c\u90a3\u4e48\u4f18\u5316\u7684\u7f16\u8bd1\u4ee3\u7801\u4f1a\u8fd0\u884c\uff0c\u5982\u679c\u4e0d\u5408\u7406\uff0c\u90a3\u4e48 JIT \u4f1a\u8ba4\u4e3a\u505a\u4e86\u4e00\u4e2a\u9519\u8bef\u7684\u5047\u8bbe\uff0c\u5e76\u4e14\u628a\u4f18\u5316\u4ee3\u7801\u4e22\u6389\u3002\n<\/p>\n<p>\n\t\u8fd9\u65f6\uff08\u53d1\u751f\u4f18\u5316\u4ee3\u7801\u4e22\u5f03\u7684\u60c5\u51b5\uff09\u6267\u884c\u8fc7\u7a0b\u5c06\u4f1a\u56de\u5230\u89e3\u91ca\u5668\u6216\u8005\u57fa\u7ebf\u7f16\u8bd1\u5668\uff0c\u8fd9\u4e00\u8fc7\u7a0b\u53eb\u505a\u53bb\u4f18\u5316\u3002\n<\/p>\n<p>\n\t\u901a\u5e38\u4f18\u5316\u7f16\u8bd1\u5668\u4f1a\u4f7f\u5f97\u4ee3\u7801\u53d8\u5f97\u66f4\u5feb\uff0c\u4f46\u662f\u4e00\u4e9b\u60c5\u51b5\u4e5f\u4f1a\u5f15\u8d77\u4e00\u4e9b\u610f\u60f3\u4e0d\u5230\u7684\u6027\u80fd\u95ee\u9898\u3002\u5982\u679c\u4f60\u7684\u4ee3\u7801\u4e00\u76f4\u9677\u5165\u4f18\u5316&lt;-&gt;\u53bb\u4f18\u5316\u7684\u602a\u5708\uff0c\u90a3\u4e48\u7a0b\u5e8f\u6267\u884c\u5c06\u4f1a\u53d8\u6162\uff0c\u8fd8\u4e0d\u5982\u57fa\u7ebf\u7f16\u8bd1\u5668\u5feb\u3002\n<\/p>\n<p>\n\t\u5927\u591a\u6570\u7684\u6d4f\u89c8\u5668\u90fd\u505a\u4e86\u9650\u5236\uff0c\u5f53\u4f18\u5316\/\u53bb\u4f18\u5316\u5faa\u73af\u53d1\u751f\u7684\u65f6\u5019\u4f1a\u5c1d\u8bd5\u8df3\u51fa\u8fd9\u79cd\u5faa\u73af\u3002\u6bd4\u5982\uff0c\u5982\u679c JIT \u505a\u4e86 10 \u6b21\u4ee5\u4e0a\u7684\u4f18\u5316\u5e76\u4e14\u53c8\u4e22\u5f03\u7684\u64cd\u4f5c\uff0c\u90a3\u4e48\u5c31\u4e0d\u7ee7\u7eed\u5c1d\u8bd5\u53bb\u4f18\u5316\u8fd9\u6bb5\u4ee3\u7801\u4e86\u6869\u3002\n<\/p>\n<h2>\n\t\u7c7b\u578b\u7279\u5316\uff08Type specialization\uff09<br \/>\n<\/h2>\n<p>\n\t\u6709\u5f88\u591a\u4e0d\u540c\u7c7b\u578b\u7684\u4f18\u5316\u65b9\u6cd5\uff0c\u8fd9\u91cc\u6211\u4ecb\u7ecd\u4e00\u79cd\uff0c\u8ba9\u5927\u5bb6\u80fd\u591f\u660e\u767d\u662f\u5982\u4f55\u4f18\u5316\u7684\u3002\u4f18\u5316\u7f16\u8bd1\u5668\u6700\u6210\u529f\u4e00\u4e2a\u7279\u70b9\u53eb\u505a\u7c7b\u578b\u7279\u5316\uff0c\u4e0b\u9762\u8be6\u7ec6\u89e3\u91ca\u3002\n<\/p>\n<p>\n\tJavaScript \u6240\u4f7f\u7528\u7684\u52a8\u6001\u7c7b\u578b\u4f53\u7cfb\u5728\u8fd0\u884c\u65f6\u9700\u8981\u8fdb\u884c\u989d\u5916\u7684\u89e3\u91ca\u5de5\u4f5c\uff0c\u4f8b\u5982\u4e0b\u9762\u4ee3\u7801\uff1a\n<\/p>\n<pre class=\"brush:jscript;\">\r\nfunction arraySum(arr) {\r\n  var sum = 0;\r\n  for (var i = 0; i &lt; arr.length; i++) {\r\n    sum += arr[i];\r\n  }\r\n}<\/pre>\n<p>\n\t+= \u5faa\u73af\u4e2d\u8fd9\u4e00\u6b65\u770b\u8d77\u6765\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u8fdb\u884c\u4e00\u6b65\u8ba1\u7b97\uff0c\u4f46\u662f\u6070\u6070\u56e0\u4e3a\u662f\u7528\u52a8\u6001\u7c7b\u578b\uff0c\u4ed6\u6240\u9700\u8981\u7684\u6b65\u9aa4\u8981\u6bd4\u4f60\u6240\u60f3\u8c61\u7684\u66f4\u590d\u6742\u4e00\u4e9b\u3002\n<\/p>\n<p>\n\t\u6211\u4eec\u5047\u8bbe arr \u662f\u4e00\u4e2a\u6709 100 \u4e2a\u6574\u6570\u7684\u6570\u7ec4\u3002\u5f53\u4ee3\u7801\u88ab\u6807\u8bb0\u4e3a &ldquo;warm&rdquo; \u65f6\uff0c\u57fa\u7ebf\u7f16\u8bd1\u5668\u5c31\u4e3a\u51fd\u6570\u4e2d\u7684\u6bcf\u4e00\u4e2a\u64cd\u4f5c\u751f\u6210\u4e00\u4e2a\u6869\u3002sum += arr[i] \u4f1a\u6709\u4e00\u4e2a\u76f8\u5e94\u7684\u6869\uff0c\u5e76\u4e14\u628a\u91cc\u9762\u7684 += \u64cd\u4f5c\u5f53\u6210\u6574\u6570\u52a0\u6cd5\u3002\n<\/p>\n<p>\n\t\u4f46\u662f\uff0csum \u548c arr[i] \u4e24\u4e2a\u6570\u5e76\u4e0d\u4fdd\u8bc1\u90fd\u662f\u6574\u6570\u3002\u56e0\u4e3a\u5728 JavaScript \u4e2d\u7c7b\u578b\u90fd\u662f\u52a8\u6001\u7c7b\u578b\uff0c\u5728\u63a5\u4e0b\u6765\u7684\u5faa\u73af\u5f53\u4e2d\uff0carr[i] \u5f88\u6709\u53ef\u80fd\u53d8\u6210\u4e86 string \u7c7b\u578b\u3002\u6574\u6570\u52a0\u6cd5\u548c\u5b57\u7b26\u4e32\u8fde\u63a5\u662f\u5b8c\u5168\u4e0d\u540c\u7684\u4e24\u4e2a\u64cd\u4f5c\uff0c\u4f1a\u88ab\u7f16\u8bd1\u6210\u4e0d\u540c\u7684\u673a\u5668\u7801\u3002\n<\/p>\n<p>\n\tJIT \u5904\u7406\u8fd9\u4e2a\u95ee\u9898\u7684\u65b9\u6cd5\u662f\u7f16\u8bd1\u591a\u57fa\u7ebf\u6869\u3002\u5982\u679c\u4e00\u4e2a\u4ee3\u7801\u6bb5\u662f\u5355\u4e00\u5f62\u6001\u7684\uff08\u5373\u603b\u662f\u4ee5\u540c\u4e00\u7c7b\u578b\u88ab\u8c03\u7528\uff09\uff0c\u5219\u53ea\u751f\u6210\u4e00\u4e2a\u6869\u3002\u5982\u679c\u662f\u591a\u5f62\u6001\u7684\uff08\u5373\u8c03\u7528\u7684\u8fc7\u7a0b\u4e2d\uff0c\u7c7b\u578b\u4e0d\u65ad\u53d8\u5316\uff09\uff0c\u5219\u4f1a\u4e3a\u64cd\u4f5c\u6240\u8c03\u7528\u7684\u6bcf\u4e00\u4e2a\u7c7b\u578b\u7ec4\u5408\u751f\u6210\u4e00\u4e2a\u6869\u3002\n<\/p>\n<p>\n\t\u8fd9\u5c31\u662f\u8bf4 JIT \u5728\u9009\u62e9\u4e00\u4e2a\u6869\u4e4b\u524d\uff0c\u4f1a\u8fdb\u884c\u591a\u5206\u679d\u9009\u62e9\uff0c\u7c7b\u4f3c\u4e8e\u51b3\u7b56\u6811\uff0c\u95ee\u81ea\u5df1\u5f88\u591a\u95ee\u9898\u624d\u4f1a\u786e\u5b9a\u6700\u7ec8\u9009\u62e9\u54ea\u4e2a\u3002\n<\/p>\n<p>\n\t\u6b63\u662f\u56e0\u4e3a\u5728\u57fa\u7ebf\u7f16\u8bd1\u5668\u4e2d\u6bcf\u884c\u4ee3\u7801\u90fd\u6709\u81ea\u5df1\u7684\u6869\uff0c\u6240\u4ee5 JIT \u5728\u6bcf\u884c\u4ee3\u7801\u88ab\u6267\u884c\u7684\u65f6\u5019\u90fd\u4f1a\u68c0\u67e5\u6570\u636e\u7c7b\u578b\u3002\u5728\u5faa\u73af\u7684\u6bcf\u6b21\u8fed\u4ee3\uff0cJIT \u4e5f\u90fd\u4f1a\u91cd\u590d\u4e00\u6b21\u5206\u679d\u9009\u62e9\u3002\n<\/p>\n<p>\n\t\u5982\u679c\u4ee3\u7801\u5728\u6267\u884c\u7684\u8fc7\u7a0b\u4e2d\uff0cJIT \u4e0d\u662f\u6bcf\u6b21\u90fd\u91cd\u590d\u68c0\u67e5\u7684\u8bdd\uff0c\u90a3\u4e48\u6267\u884c\u7684\u8fd8\u4f1a\u66f4\u5feb\u4e00\u4e9b\uff0c\u800c\u8fd9\u5c31\u662f\u4f18\u5316\u7f16\u8bd1\u5668\u6240\u9700\u8981\u505a\u7684\u5de5\u4f5c\u4e4b\u4e00\u4e86\u3002\n<\/p>\n<p>\n\t\u4f18\u5316\u7f16\u8bd1\u5668\u4e2d\uff0c\u6574\u4e2a\u51fd\u6570\u88ab\u7edf\u4e00\u7f16\u8bd1\uff0c\u8fd9\u6837\u7684\u8bdd\u5c31\u53ef\u4ee5\u5728\u5faa\u73af\u5f00\u59cb\u6267\u884c\u4e4b\u524d\u8fdb\u884c\u7c7b\u578b\u68c0\u67e5\u3002\n<\/p>\n<p>\n\t\u4e00\u4e9b\u6d4f\u89c8\u5668\u7684 JIT \u4f18\u5316\u66f4\u52a0\u590d\u6742\u3002\u6bd4\u5982\u5728 Firefox \u4e2d\uff0c\u7ed9\u4e00\u4e9b\u6570\u7ec4\u8bbe\u5b9a\u4e86\u7279\u5b9a\u7684\u7c7b\u578b\uff0c\u6bd4\u5982\u91cc\u9762\u53ea\u5305\u542b\u6574\u578b\u3002\u5982\u679c arr \u662f\u8fd9\u79cd\u6570\u7ec4\u7c7b\u578b\uff0c\u90a3\u4e48 JIT \u5c31\u4e0d\u9700\u8981\u68c0\u67e5 arr[i] \u662f\u4e0d\u662f\u6574\u578b\u4e86\uff0c\u8fd9\u4e5f\u610f\u5473\u7740 JIT \u53ef\u4ee5\u5728\u8fdb\u5165\u5faa\u73af\u4e4b\u524d\u8fdb\u884c\u6240\u6709\u7684\u7c7b\u578b\u68c0\u67e5\u3002\n<\/p>\n<h2>\n\t\u603b\u7ed3<br \/>\n<\/h2>\n<p>\n\t\u7b80\u800c\u8a00\u4e4b JIT \u662f\u4ec0\u4e48\u5462\uff1f\u5b83\u662f\u4f7f JavaScript \u8fd0\u884c\u66f4\u5feb\u7684\u4e00\u79cd\u624b\u6bb5\uff0c\u901a\u8fc7\u76d1\u89c6\u4ee3\u7801\u7684\u8fd0\u884c\u72b6\u6001\uff0c\u628a hot \u4ee3\u7801\uff08\u91cd\u590d\u6267\u884c\u591a\u6b21\u7684\u4ee3\u7801\uff09\u8fdb\u884c\u4f18\u5316\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u4f7f JavaScript \u5e94\u7528\u7684\u6027\u80fd\u63d0\u5347\u5f88\u591a\u500d\u3002\n<\/p>\n<p>\n\t\u4e3a\u4e86\u4f7f\u6267\u884c\u901f\u5ea6\u53d8\u5feb\uff0cJIT \u4f1a\u589e\u52a0\u5f88\u591a\u591a\u4f59\u7684\u5f00\u9500\uff0c\u8fd9\u4e9b\u5f00\u9500\u5305\u62ec\uff1a\n<\/p>\n<ul>\n<li>\n\t\t\u4f18\u5316\u548c\u53bb\u4f18\u5316\u5f00\u9500\n\t<\/li>\n<li>\n\t\t\u76d1\u89c6\u5668\u8bb0\u5f55\u4fe1\u606f\u5bf9\u5185\u5b58\u7684\u5f00\u9500\n\t<\/li>\n<li>\n\t\t\u53d1\u751f\u53bb\u4f18\u5316\u60c5\u51b5\u65f6\u6062\u590d\u4fe1\u606f\u7684\u8bb0\u5f55\u5bf9\u5185\u5b58\u7684\u5f00\u9500\n\t<\/li>\n<li>\n\t\t\u5bf9\u57fa\u7ebf\u7248\u672c\u548c\u4f18\u5316\u540e\u7248\u672c\u8bb0\u5f55\u7684\u5185\u5b58\u5f00\u9500\n\t<\/li>\n<\/ul>\n<p>\n\t\u8fd9\u91cc\u8fd8\u6709\u5f88\u5927\u7684\u63d0\u5347\u7a7a\u95f4\uff1a\u5373\u6d88\u9664\u5f00\u9500\u3002\u901a\u8fc7\u6d88\u9664\u5f00\u9500\u4f7f\u5f97\u6027\u80fd\u4e0a\u6709\u8fdb\u4e00\u6b65\u5730\u63d0\u5347\uff0c\u8fd9\u4e5f\u662f WebAssembly \u6240\u8981\u505a\u7684\u4e8b\u4e4b\u4e00\u3002\n<\/p>\n<h2>\n\t\u53c2\u8003\u8d44\u6599<br \/>\n<\/h2>\n<ul>\n<li>\n\t\t<a href=\"https:\/\/hacks.mozilla.org\/2017\/02\/a-crash-course-in-just-in-time-jit-compilers\/\" name=\"A crash course in just-in-time (JIT) compilers\" target=\"_blank\" title=\"A crash course in just-in-time (JIT) compilers\">A crash course in just-in-time (JIT) compilers<\/a>\n\t<\/li>\n<\/ul>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=1962\">\u8be6\u89e3JavaScript\u7684Just-in-time(JIT\u7f16\u8bd1\u5668)\u7684\u5de5\u4f5c\u539f\u7406<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>JavaScript \u7684\u542f\u52a8\u6bd4\u8f83\u7f13\u6162\uff0c\u4f46\u662f\u901a\u8fc7 JIT \u53ef\u4ee5\u4f7f\u5176\u53d8\u5feb\u3002 JIT \u6709\u8fd9\u4e48\u795e\u5947\u7684\u4f5c\u7528\uff0c\u90a3\u4e48\u5b83\u7684\u539f\u7406 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[1106,1496,1497,1493],"class_list":["post-1962","post","type-post","status-publish","format-standard","hentry","category-html5","tag-javascript","tag-jit","tag-just-in-time","tag-webassembly"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1962","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1962"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1962\/revisions"}],"predecessor-version":[{"id":1963,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1962\/revisions\/1963"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}