{"id":10812,"date":"2023-11-28T21:44:16","date_gmt":"2023-11-28T13:44:16","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=10812"},"modified":"2023-11-28T21:44:20","modified_gmt":"2023-11-28T13:44:20","slug":"java-zhongsafepoint-shi-shen-me-ni-shi-ru-he-li-ji","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/java-zhongsafepoint-shi-shen-me-ni-shi-ru-he-li-ji\/","title":{"rendered":"Java\u4e2dsafepoint\u662f\u4ec0\u4e48\uff0c\u4f60\u662f\u5982\u4f55\u7406\u89e3\u7684\uff1f"},"content":{"rendered":"<p>\u4ec0\u4e48\u662fSafePoint<br \/>\nSafePoint\u662fJava\u4ee3\u7801\u4e2d\u7684\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u80fd\u6682\u505c\u6267\u884c\u7684\u4f4d\u7f6e\u3002SafePoint\u4fdd\u5b58\u4e86\u5728\u5176\u4ed6\u4f4d\u7f6e\u6ca1 \u6709\u7684\u4e00\u4e9b\u8fd0\u884c\u65f6\u4fe1\u606f\u3002SafePoint\u4fdd\u5b58\u4e86\u7ebf\u7a0b\u4e0a\u4e0b\u6587\u4e2d\u7684\u4efb\u4f55\u4e1c\u897f\uff0c\u5305\u62ec\u5bf9\u8c61\uff0c\u6307\u5411\u5bf9\u8c61\u6216\u975e \u5bf9\u8c61\u7684\u5185\u90e8\u6307\u9488\u3002<br \/>\n\u5728JVM\u5904\u4e8eSafePoint\u65f6\uff0c\u53ef\u4ee5\u505a\u4ec0\u4e48\u5462\uff1f<br \/>\n1\u3001\tGarbage collection pauses<br \/>\n2\u3001\tCode deoptimization<br \/>\n3\u3001\tFlushing code cache<br \/>\n4\u3001\tClass redefinition \uff08e.g.hot swap or instrumentation\uff09<br \/>\n5\u3001\tBiased lock revocation<br \/>\n6\u3001\tVarious debug operation \uff08e.g.deadlock check or stacktrace dump\uff09<br \/>\n\u5728JVM\u6e90\u7801\u7684\u6ce8\u91ca\u91cc\u63d0\u5230\uff0c\u5f53\u7cfb\u7edf\u8981\u8fdb\u5165SafePoint\u65f6\uff0c\u4e0d\u540c\u72b6\u6001\u7684Java\u7ebf\u7a0b\u7684\u6682\u505c\u673a\u5236\u662f\u4e0d\u4e00\u6837\u7684\uff1a<br \/>\n1\u3001\t\u8fd0\u884c\u72b6\u6001\u7684\u7ebf\u7a0b\u5fc5\u987b\u963b\u585e\u3002<br \/>\n2\u3001\t\u4e0d\u4e0eJVM\u4ea4\u4e92\u7684\u8fd0\u884cNative Code\u7684\u7ebf\u7a0b\u80fd\u7ee7\u7eed\u6267\u884c\uff08\u5982\u679c\u9700\u8981\u901a\u8fc7JNI\u8bbf\u95eeJava\u5bf9 \u8c61\uff0c\u8c03\u7528JAVA\u65b9\u6cd5\uff0c\u4eceNative\u56de\u5230JAVA\u7684\u8bdd\uff0c\u5219\u5fc5\u987b\u7b49\u5230Safepoint\u7ed3\u675f\uff09\u3002<br \/>\n3\u3001\t\u6240\u6709\u963b\u585e\u4e2d\u7684\u7ebf\u7a0b\uff0c\u9700\u8981\u7b49\u5f85SafePoint\u7ed3\u675f\uff0c\u624d\u80fd\u8fd4\u56de\u3002<br \/>\nJava\u7ebf\u7a0b\u662f\u5982\u4f55\u8fdb\u5165SafePoint\u7684\u5462\uff1f<br \/>\n1\u3001\t\u6bcf\u4e2a\u7ebf\u7a0b\u901a\u8fc7\u68c0\u67e5SafePoint\u6570\u636e\u7ed3\u6784\u7684\u72b6\u6001\u6765\u786e\u5b9a\u662f\u5426\u9700\u8981\u6682\u505c\u81ea\u5df1\u6765\u8fdb\u5165\u5b89\u5168\u6001\u3002<br \/>\n2\u3001\t\u5bf9\u4e8e\u7f16\u8bd1\u7684\u4ee3\u7801\uff0cJIT\u901a\u8fc7\u5728\u4ee3\u7801\u4e2d\u9002\u5f53\u7684\u4f4d\u7f6e\u63d2\u5165SafePoint\u68c0\u67e5\u7684\u4ee3\u7801\uff08\u901a\u5e38\u5728\u8c03\u7528\u7684\u8fd4\u56de\u548c\u5faa\u73af\u7684\u9000\u51fa\uff09<br \/>\nJIT\u4f1a\u5728\u6240\u6709\u65b9\u6cd5\u7684\u8fd4\u56de\u4e4b\u524d\uff0c\u4ee5\u53ca\u6240\u6709\u975ecounted loop\u7684\u5faa\u73af\uff08\u65e0\u754c\u5faa\u73af\uff09\u56de\u8df3\u4e4b\u524d\u653e\u7f6e \u4e00\u4e2aSafePoint,\u9632\u6b62\u53d1\u751fGC\u9700\u8981STW\u65f6\uff0c\u8be5\u7ebf\u7a0b\u4e00\u76f4\u4e0d\u80fd\u6682\u505c\u3002<br \/>\n3\u3001\t\u5bf9\u4e8e\u89e3\u91ca\u7684\u4ee3\u7801\uff0cJVM\u4fdd\u5b58\u4e86\u4e24\u5f20\u5b57\u8282\u7801\u7684\u6267\u884c\u8868\uff0c\u5982\u679c\u9700\u8981\u8fdb\u884cSafePoint\u68c0\u67e5\uff0cJVM\u4f1a \u5728\u4e24\u5f20\u8868\u4e4b\u95f4\u5207\u6362\u3002<br \/>\n\u901a\u5e38safepoint\u6709\u4e09\u79cd\u72b6\u6001\uff1a<br \/>\n1\u3001\tnot_synchronized\uff1a\u6b63\u5e38\u8fd0\u884c\u72b6\u6001\u3002<br \/>\n2\u3001\tsynchronizing\uff1a VM Thread \u6b63\u5728\u7b49\u5f85\u6240\u6709\u7ebf\u7a0b\u8fdb\u5165 safepoint\u3002<br \/>\n3\u3001\tsynchronized\uff1a\u6240\u6709\u7ebf\u7a0b\u8fdb\u5165safepoint, VM Thread\u53ef\u4ee5\u5f00\u59cb\u5de5\u4f5c\u4e86\u3002<br \/>\n\u7a0b\u5e8f\u8fd0\u884c\u65f6\uff0c\u53ef\u4ee5\u8bbe\u7f6e JVM \u53c2\u6570 -XX\uff1a+PrintSafepointStatistics &#8211;<br \/>\nXX\uff1aPrintSafepointStatisticsCount=l \u6765\u8f93\u51fa SafePoint \u7684\u7edf\u8ba1\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662fSafePoint SafePoint\u662fJava\u4ee3\u7801\u4e2d\u7684\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u80fd\u6682\u505c\u6267\u884c\u7684\u4f4d\u7f6e\u3002SafePoint\u4fdd [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[118],"tags":[],"class_list":["post-10812","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/10812","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=10812"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/10812\/revisions"}],"predecessor-version":[{"id":10813,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/10812\/revisions\/10813"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=10812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=10812"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=10812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}