欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Java關(guān)于JIT的原理和相關(guān)知識
Java關(guān)于JIT的原理和相關(guān)知識
博客分類(lèi): Java2D
JavaJVMSecuritySUNAccess
今天在讀java.awt.Toolkit類(lèi)時(shí),遇到了JIT,代碼如下:
Java代碼 
 
/**
* Gets the default toolkit.
* <p>
* If a system property named <code>"java.awt.headless"</code> is set
* to <code>true</code> then the headless implementation
* of <code>Toolkit</code> is used.
* <p>
* If there is no <code>"java.awt.headless"</code> or it is set to
* <code>false</code> and there is a system property named
* <code>"awt.toolkit"</code>,
* that property is treated as the name of a class that is a subclass
* of <code>Toolkit</code>;
* otherwise the default platform-specific implementation of
* <code>Toolkit</code> is used.
* <p>
* Also loads additional classes into the VM, using the property
* 'assistive_technologies' specified in the Sun reference
* implementation by a line in the 'accessibility.properties'
* file.  The form is "assistive_technologies=..." where
* the "..." is a comma-separated list of assistive technology
* classes to load.  Each class is loaded in the order given
* and a single instance of each is created using
* Class.forName(class).newInstance().  This is done just after
* the AWT toolkit is created.  All errors are handled via an
* AWTError exception.
* @return    the default toolkit.
* @exception  AWTError  if a toolkit could not be found, or
*                 if one could not be accessed or instantiated.
*/
public static synchronized Toolkit getDefaultToolkit() {
if (toolkit == null) {
try {
// We disable the JIT during toolkit initialization.  This
// tends to touch lots of classes that aren't needed again
// later and therefore JITing is counter-productiive.
java.lang.Compiler.disable();
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
String nm = null;
Class cls = null;
try {
nm = System.getProperty("awt.toolkit", "sun.awt.X11.XToolkit");
try {
cls = Class.forName(nm);
} catch (ClassNotFoundException e) {
ClassLoader cl = ClassLoader.getSystemClassLoader();
if (cl != null) {
try {
cls = cl.loadClass(nm);
} catch (ClassNotFoundException ee) {
throw new AWTError("Toolkit not found: " + nm);
}
}
}
if (cls != null) {
toolkit = (Toolkit)cls.newInstance();
if (GraphicsEnvironment.isHeadless()) {
toolkit = new HeadlessToolkit(toolkit);
}
}
} catch (InstantiationException e) {
throw new AWTError("Could not instantiate Toolkit: " + nm);
} catch (IllegalAccessException e) {
throw new AWTError("Could not access Toolkit: " + nm);
}
return null;
}
});
loadAssistiveTechnologies();
} finally {
// Make sure to always re-enable the JIT.
java.lang.Compiler.enable();
}
}
return toolkit;
}
1.JIT的工作原理圖
工作原理
當JIT編譯啟用時(shí)(默認是啟用的),JVM讀入.class文件解釋后,將其發(fā)給JIT編譯器。JIT編譯器將字節碼編譯成本機機器代碼。
通常javac將程序源代碼編譯,轉換成java字節碼,JVM通過(guò)解釋字節碼將其翻譯成對應的機器指令,逐條讀入,逐條解釋翻譯。很顯然,經(jīng)過(guò)解釋執行,其執行速度必然會(huì )比可執行的二進(jìn)制字節碼程序慢。為了提高執行速度,引入了JIT技術(shù)。
在運行時(shí)JIT會(huì )把翻譯過(guò)的機器碼保存起來(lái),已備下次使用,因此從理論上來(lái)說(shuō),采用該JIT技術(shù)可以,可以接近以前純編譯技術(shù)。
2.相關(guān)知識
JIT是just in time,即時(shí)編譯技術(shù)。使用該技術(shù),能夠加速java程序的執行速度。
JIT并不總是奏效,不能期望JIT一定能夠加速你代碼執行的速度,更糟糕的是她有可能降低代碼的執行速度。這取決于你的代碼結構,當然很多情況下我們還是能夠如愿以?xún)數摹?div style="height:15px;">
從上面我們知道了之所以要關(guān)閉JITjava.lang.Compiler.disable(); 是因為加快執行的速度。由于JIT對每條字節碼都進(jìn)行編譯,造成了編譯過(guò)程負擔過(guò)重。為了避免這種情況,當前的JIT只對經(jīng)常執行的字節碼進(jìn)行編譯,如循環(huán)等。
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
JVM遠程調試為什么要禁用JIT
計算機世界網(wǎng)-Java性能的優(yōu)化(上)
Java性能的優(yōu)化(二)
HotSpot(熱點(diǎn)最新的一種的java虛擬機)詳解
java虛擬機的十年
Java三種編譯方式: 前端編譯 JIT編譯 AOT編譯
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久