Lua虛擬機(jī)的機(jī)制分析
本文關(guān)鍵詞:Lua虛擬機(jī)的機(jī)制分析 出處:《廣東工業(yè)大學(xué)》2015年碩士論文 論文類型:學(xué)位論文
更多相關(guān)文章: Lua虛擬機(jī) 執(zhí)行框架 效率 GC算法
【摘要】:自Lua從巴西天主教大學(xué)被開(kāi)發(fā)出來(lái)已經(jīng)有20多年。隨著計(jì)算機(jī)應(yīng)用技術(shù)的飛速發(fā)展和高級(jí)腳本語(yǔ)言的不斷完善,Lua能很方便地嵌入到應(yīng)用程序并為它們提供靈活的擴(kuò)展和定制功能。與其它同類的高級(jí)解釋型腳本語(yǔ)言相比,Lua有著兩點(diǎn)非常重要的特性:簡(jiǎn)潔、高效。多數(shù)實(shí)驗(yàn)表明,Lua在程序執(zhí)行效率上要比大部分的腳本語(yǔ)言(如Python、Perl等)高。另外Lua還提供非常豐富和實(shí)用的功能,比如函數(shù)式編程(所有的函數(shù)都是第一類值)、協(xié)同程序、自動(dòng)內(nèi)存管理等。由于Lua是用C編寫(xiě)而成,它與C/C++能非常方便的交互,而所有這些特性都?xì)w功于它有一個(gè)精簡(jiǎn)的、巧妙的、高效的Lua虛擬機(jī)的設(shè)計(jì)。Lua在相當(dāng)長(zhǎng)一段時(shí)間內(nèi)都使用堆棧式的虛擬機(jī),而從5.0版本后才改用寄存器式的虛擬機(jī);诩拇嫫鞯奶摂M機(jī)減少了指令總數(shù)和指令執(zhí)行時(shí)堆棧調(diào)整的開(kāi)銷因此執(zhí)行效率得到提高。虛擬機(jī)的效率除了與指令操作數(shù)存儲(chǔ)結(jié)構(gòu)有關(guān)外還與編譯和解釋過(guò)程相關(guān)。解釋性源程序一般要經(jīng)過(guò)編譯成字節(jié)碼階段,然后由解釋器逐條解釋和執(zhí)行字節(jié)碼。解釋器中執(zhí)行框架的設(shè)計(jì)直接影響了解釋效率,Lua采用了一種最簡(jiǎn)單的執(zhí)行框架設(shè)計(jì)方式(switch-case),由于它指令數(shù)較少,因此也獲得了較好的執(zhí)行效率。較新版本的Python虛擬機(jī)在采用了較好的指令分派方式后也獲得了效率提升,而其它的采用效率更高方案的虛擬機(jī)必然也在設(shè)計(jì)上更復(fù)雜或占用更多內(nèi)存。除此之外,垃圾回收(GC)算法也在一定程度上影響了虛擬機(jī)的效率,雖然Lua GC經(jīng)過(guò)了若干技術(shù)的優(yōu)化—比如分代的、增量式的垃圾回收—有著與其他GC機(jī)制相差不大的效率。但與其它虛擬機(jī)GC機(jī)制相比,Lua GC主體仍使用較為古老的標(biāo)記-清除算法,該算法在標(biāo)記和回收過(guò)程上都比較耗時(shí)而且在內(nèi)存利用率(內(nèi)存碎片的產(chǎn)生)方面有劣勢(shì),因而在性能上也略低于許多其它的虛擬機(jī),Lua GC機(jī)制仍需要改善。本文首先簡(jiǎn)單的介紹了Lua的語(yǔ)言特性;然后深入分析了Lua虛擬機(jī)的實(shí)現(xiàn),特別對(duì)Lua的編譯過(guò)程、線程執(zhí)行、函數(shù)調(diào)用和GC過(guò)程進(jìn)行了深度探究;其次將Lua虛擬機(jī)中的關(guān)鍵技術(shù)與Python虛擬機(jī)的實(shí)現(xiàn)進(jìn)行了比對(duì),解釋了其效率差異的原因;之后再對(duì)Lua虛擬機(jī)執(zhí)行框架和GC機(jī)制進(jìn)行改進(jìn),在執(zhí)行框架中加入了查表分派和超級(jí)指令方式,在GC方面提出了滑動(dòng)式分步拷貝算法,并將其應(yīng)用于LuaGC;最后通過(guò)若干組測(cè)試用例對(duì)所作的改進(jìn)進(jìn)行試驗(yàn),通過(guò)對(duì)實(shí)驗(yàn)結(jié)果的比較、分析和總結(jié)驗(yàn)證了改進(jìn)的優(yōu)勢(shì)和不足。
[Abstract]:It has been more than 20 years since Lua was developed from the Catholic University of Brazil. With the rapid development of computer application technology and the continuous improvement of advanced scripting language. Lua is easy to embed into applications and provides flexible extension and customization capabilities. Compared with other advanced interpreted scripting languages of its kind, Lua has two very important features: simplicity. Most experiments have shown that Lua is more efficient in program execution than most scripting languages (such as Python Perl, etc.). In addition, Lua provides very rich and practical functionality. For example, functional programming (all functions are class I values, collaborative programs, automatic memory management, etc.) since Lua is written in C, it can easily interact with C / C. All of this is due to the fact that it has a concise, clever, and efficient design for Lua virtual machines. Lua has been using stack virtual machines for quite some time. The register-based virtual machine reduces the total number of instructions and the overhead of stack adjustment when the instructions are executed. The efficiency of the virtual machine is improved. The Operand storage structure is also related to the compilation and interpretation process. The interpretive source program is usually compiled into bytecode. Then, bytecode is interpreted and executed by interpreter. The design of execution framework in interpreter directly affects the efficiency of interpretation. Lua uses one of the simplest execution framework design methods, switch-casein, because it has a small number of instructions. As a result, better execution efficiency has been achieved. The newer version of Python virtual machine has also achieved higher efficiency after adopting better instruction dispatch mode. However, other virtual machines with more efficient schemes are bound to be more complex in design or occupy more memory. In addition, garbage collection GC-based algorithms also affect the efficiency of virtual machines to a certain extent. Although Lua GC has been optimized by several technologies, such as generational, incremental garbage collection, it is less efficient than other GC mechanisms, but compared with other virtual machine GC mechanisms. The Lua GC body still uses the older marker-clear algorithm, which is both time-consuming and inefficient in terms of memory utilization (the generation of memory fragmentation). Therefore, the performance of Lua is also slightly lower than that of many other virtual machines, the mechanism of Lua GC still needs to be improved. Firstly, this paper briefly introduces the language features of Lua; Then the implementation of Lua virtual machine is deeply analyzed, especially the compilation process, thread execution, function call and GC procedure of Lua. Secondly, the key technologies in the Lua virtual machine are compared with the implementation of the Python virtual machine, and the reasons for the difference in efficiency are explained. After that, the Lua virtual machine execution framework and GC mechanism are improved, the look-up table dispatch and super instruction mode are added to the execution framework, and the sliding step copy algorithm is proposed in GC. It was applied to LuaGC; Finally, the improvement is tested by several test cases, and the advantages and disadvantages of the improvement are analyzed and summarized by comparing the experimental results.
【學(xué)位授予單位】:廣東工業(yè)大學(xué)
【學(xué)位級(jí)別】:碩士
【學(xué)位授予年份】:2015
【分類號(hào)】:TP302
【相似文獻(xiàn)】
相關(guān)期刊論文 前10條
1 陳雪梅;可視虛擬機(jī)關(guān)鍵技術(shù)研究[J];廣東科技;2005年08期
2 李超,方潛生;Java虛擬機(jī)中類裝載機(jī)制的原理分析與應(yīng)用研究[J];安徽建筑工業(yè)學(xué)院學(xué)報(bào)(自然科學(xué)版);2005年05期
3 張幼真;;用虛擬機(jī)實(shí)現(xiàn)多系統(tǒng)操作[J];微電腦世界;2005年09期
4 劉暉;;系統(tǒng)問(wèn)答[J];電腦迷;2005年05期
5 朱海華;陳自剛;;Java虛擬機(jī)性能及調(diào)優(yōu)[J];電腦知識(shí)與技術(shù);2005年36期
6 楊麗潔;;虛擬機(jī)控制流的途徑[J];河北工業(yè)大學(xué)成人教育學(xué)院學(xué)報(bào);2005年04期
7 方向陽(yáng);;“虛擬機(jī)”在實(shí)驗(yàn)教學(xué)中的應(yīng)用探索[J];中國(guó)現(xiàn)代教育裝備;2006年11期
8 張廣敏;盤(pán)細(xì)平;涂杰;;Java虛擬機(jī)的面向?qū)ο笮訹J];計(jì)算機(jī)應(yīng)用與軟件;2006年03期
9 北鄉(xiāng)達(dá)郎;南庭;;嵌入式Java虛擬機(jī)滲透到手機(jī)以外的領(lǐng)域[J];電子設(shè)計(jì)應(yīng)用;2007年10期
10 歐陽(yáng)星明;朱金銀;;虛擬機(jī)的可定制生成及其動(dòng)態(tài)優(yōu)化[J];計(jì)算機(jī)工程與科學(xué);2008年01期
相關(guān)會(huì)議論文 前10條
1 孟廣平;;虛擬機(jī)漂移網(wǎng)絡(luò)連接方法探討[A];中國(guó)計(jì)量協(xié)會(huì)冶金分會(huì)2011年會(huì)論文集[C];2011年
2 段翼真;王曉程;;可信安全虛擬機(jī)平臺(tái)的研究[A];第26次全國(guó)計(jì)算機(jī)安全學(xué)術(shù)交流會(huì)論文集[C];2011年
3 李明宇;張倩;呂品;;網(wǎng)絡(luò)流量感知的虛擬機(jī)高可用動(dòng)態(tài)部署研究[A];2014第二屆中國(guó)指揮控制大會(huì)論文集(上)[C];2014年
4 林紅;;Java虛擬機(jī)面向數(shù)字媒體的應(yīng)用研究[A];計(jì)算機(jī)技術(shù)與應(yīng)用進(jìn)展——全國(guó)第17屆計(jì)算機(jī)科學(xué)與技術(shù)應(yīng)用(CACIS)學(xué)術(shù)會(huì)議論文集(上冊(cè))[C];2006年
5 楊旭;彭一明;刑承杰;李若淼;;基于VMware vSphere 5虛擬機(jī)的備份系統(tǒng)實(shí)現(xiàn)[A];中國(guó)高等教育學(xué)會(huì)教育信息化分會(huì)第十二次學(xué)術(shù)年會(huì)論文集[C];2014年
6 沈敏虎;查德平;劉百祥;趙澤宇;;虛擬機(jī)網(wǎng)絡(luò)部署與管理研究[A];中國(guó)高等教育學(xué)會(huì)教育信息化分會(huì)第十次學(xué)術(shù)年會(huì)論文集[C];2010年
7 李英壯;廖培騰;孫夢(mèng);李先毅;;基于云計(jì)算的數(shù)據(jù)中心虛擬機(jī)管理平臺(tái)的設(shè)計(jì)[A];中國(guó)高等教育學(xué)會(huì)教育信息化分會(huì)第十次學(xué)術(shù)年會(huì)論文集[C];2010年
8 朱欣焰;蘇科華;毛繼國(guó);龔健雅;;GIS符號(hào)虛擬機(jī)及實(shí)現(xiàn)方法研究[A];《測(cè)繪通報(bào)》測(cè)繪科學(xué)前沿技術(shù)論壇摘要集[C];2008年
9 于洋;陳曉東;俞承芳;李旦;;基于FPGA平臺(tái)的虛擬機(jī)建模與仿真[A];2007'儀表,,自動(dòng)化及先進(jìn)集成技術(shù)大會(huì)論文集(一)[C];2007年
10 丁濤;郝沁汾;張冰;;內(nèi)核虛擬機(jī)調(diào)度策略的研究與分析[A];'2010系統(tǒng)仿真技術(shù)及其應(yīng)用學(xué)術(shù)會(huì)議論文集[C];2010年
相關(guān)重要報(bào)紙文章 前10條
1 寧家雨;虛擬機(jī)數(shù)據(jù)在哪個(gè)磁盤(pán)上?[N];網(wǎng)絡(luò)世界;2009年
2 本報(bào)記者 郭濤;誰(shuí)來(lái)填補(bǔ)虛擬機(jī)的安全漏洞[N];中國(guó)計(jì)算機(jī)報(bào);2010年
3 本報(bào)記者 郭濤;VMware改變軟件銷售模式[N];中國(guó)計(jì)算機(jī)報(bào);2010年
4 盆盆;真實(shí)的虛擬機(jī)[N];中國(guó)電腦教育報(bào);2004年
5 ;利用工具解決虛擬機(jī)監(jiān)測(cè)難題[N];網(wǎng)絡(luò)世界;2007年
6 宋家雨;別拿虛擬機(jī)不當(dāng)固定資產(chǎn)[N];網(wǎng)絡(luò)世界;2008年
7 《網(wǎng)絡(luò)世界》記者 柴莎莎;虛擬機(jī)通信可視性很關(guān)鍵[N];網(wǎng)絡(luò)世界;2011年
8 Antone Gonsalves;Linux的虛擬化未來(lái)[N];中國(guó)計(jì)算機(jī)報(bào);2007年
9 張承東;安全爭(zhēng)議讓虛擬化用戶“心虛”[N];網(wǎng)絡(luò)世界;2007年
10 本報(bào)記者 郭濤;消除虛擬機(jī)備份的尷尬[N];中國(guó)計(jì)算機(jī)報(bào);2012年
相關(guān)博士學(xué)位論文 前10條
1 陳彬;分布環(huán)境下虛擬機(jī)按需部署關(guān)鍵技術(shù)研究[D];國(guó)防科學(xué)技術(shù)大學(xué);2010年
2 劉海坤;虛擬機(jī)在線遷移性能優(yōu)化關(guān)鍵技術(shù)研究[D];華中科技大學(xué);2012年
3 劉謙;面向云計(jì)算的虛擬機(jī)系統(tǒng)安全研究[D];上海交通大學(xué);2012年
4 趙佳;虛擬機(jī)動(dòng)態(tài)遷移的關(guān)鍵問(wèn)題研究[D];吉林大學(xué);2013年
5 鄧?yán)?基于虛擬機(jī)遷移的動(dòng)態(tài)資源配置研究[D];華中科技大學(xué);2013年
6 李丁丁;虛擬機(jī)本地存儲(chǔ)寫(xiě)性能優(yōu)化研究[D];華中科技大學(xué);2013年
7 董玉雙;云平臺(tái)中虛擬機(jī)部署的關(guān)鍵問(wèn)題研究[D];吉林大學(xué);2014年
8 曹文治;虛擬機(jī)網(wǎng)絡(luò)性能優(yōu)化研究[D];華中科技大學(xué);2013年
9 杜雨陽(yáng);虛擬機(jī)狀態(tài)遷移和相變存儲(chǔ)磨損均衡方法研究[D];清華大學(xué);2011年
10 鄒瓊;Java虛擬機(jī)的自適應(yīng)動(dòng)態(tài)優(yōu)化[D];中國(guó)科學(xué)技術(shù)大學(xué);2008年
相關(guān)碩士學(xué)位論文 前10條
1 鄧洋春;Java虛擬機(jī)關(guān)鍵機(jī)制研究與實(shí)踐[D];中南大學(xué);2009年
2 陸曉雯;虛擬機(jī)資源監(jiān)測(cè)調(diào)整機(jī)制研究[D];華中科技大學(xué);2008年
3 楊衛(wèi)平;面向虛擬機(jī)的網(wǎng)絡(luò)入侵檢測(cè)系統(tǒng)[D];華中科技大學(xué);2008年
4 張德;硬件虛擬機(jī)的域間通訊和性能模型研究[D];華中科技大學(xué);2008年
5 吳曉丹;反病毒虛擬機(jī)關(guān)鍵技術(shù)研究[D];中國(guó)科學(xué)技術(shù)大學(xué);2009年
6 趙彥琨;虛擬機(jī)管理平臺(tái)中的虛擬機(jī)代理服務(wù)機(jī)制研究[D];華中科技大學(xué);2009年
7 袁e
本文編號(hào):1393926
本文鏈接:http://sikaile.net/kejilunwen/jisuanjikexuelunwen/1393926.html