【文章內(nèi)容簡介】
,把 Java源程序翻譯成一種特定的二進制 字節(jié)碼文件 ( Bytecode) ,再把這個字節(jié)碼文件交給 Java解釋器來 解釋執(zhí)行 ?javac程序將 Java源代碼編譯為字節(jié)碼 ? Java編譯器所生成的可執(zhí)行代碼可以不基于任何具體的硬件平臺,而是 基于 JVM。 ?C/C++要的源程序要在不同的平臺上運行,必須重新進行編譯。 32 實時編譯 ? 實時編譯 JIT中,字節(jié)碼 在運行時 被編譯為本機的 目標代碼 ?第一步是編譯得到字節(jié)碼 ?字節(jié)碼被配置到目標系統(tǒng)中 ?當字節(jié)碼被執(zhí)行時,運行環(huán)境下的編譯器將其翻譯為本地機器碼 33 實時編譯 ? JIT模糊了解釋器、字節(jié)碼解釋器和編譯器之間的邊界與區(qū)分 ?JIT 也用于 .NET和 Java平臺 源代碼 (.java) 編譯器 字節(jié)碼 (.class) 宿主系統(tǒng) (OS、硬件 ) 編譯 解釋執(zhí)行 解釋器 編譯器 目標碼 (.obj) 執(zhí)行 編譯 34 JIT需編譯哪些部分? ? 只有當某個 函數(shù)要被執(zhí)行時 ,才被編譯,因此稱為 JIT ? 而且, JIT并不是編譯全部的代碼,而是只編譯那些 被頻繁執(zhí)行 的代碼段 ?被執(zhí)行多次的方法 ?包含多次循環(huán)的方法 35 問題 ? 針對解釋器的三種策略: ?傳統(tǒng)解釋器 (traditionally interpreted) ?基于字節(jié)碼的解釋器 (piled to bytecode which is then interpreted) ?JustinTime (JIT)編譯器 ? 對比各自的工作原理,并對比分析各自的優(yōu)缺點。 36 2. 案例分析 ( Key Word in Context, KWIC) 37 KWIC( Key Word in Context) ? KWIC索引 是二次文獻的輔助索引 ?這種索引的出現(xiàn)是現(xiàn)代科學技術的發(fā)展和科技文獻急劇增長的產(chǎn)物 ?KWIC索引是最早出現(xiàn)的用電子計算機編制的文獻索引 ? 1972年, David L. Parnas在論文“ On the Criteria To Be Used in Deposing Systems into Modules”將 KWIC索引系統(tǒng)作為一個案例用于模塊化設計的研究 ?KWIC被全世界各個大學的軟件設計課程奉為課堂講義或者作業(yè)的 經(jīng)典案例 38 KWIC:功能需求 ? 功能需求 : ?接受一些 行 ?每行有若干 詞 ?每個詞由若干 字符 組成 ?每行都可以 循環(huán)移位 :重復地把第一個詞刪除,然后接到行末 ?KWIC把所有行的各種移位情況按照字母表順序輸出 39 KWIC:舉例 40 A third way for styles to be bined is to elaborate one level of A third way for styles to third way for styles to A way for styles to A third for styles to A third way styles to A third way for to A third way for styles be bined is to bined is to be is to be bined to be bined is elaborate one level of one level of elaborate level of elaborate one of elaborate one level A third way for styles to be bined is to bined is to be elaborate one level of for styles to A third way is to be bined level of elaborate one of elaborate one level one level of elaborate styles to A third way for third way for styles to A to A third way for styles to be bined is way for styles to A third Input(輸入 ) Circular shifts(循環(huán)移位 ) Output(輸出 ) KWIC:非功能需求 ? 可修改性 ( Modifiability) ?算法的變化 ( Change in Algorithm) ? 讀入一行,便進行移位操作( incremental) ? 讀入所有行,然后再進行移位操作( batch ) ? 按需進行移位操作 ?數(shù)據(jù)表示方式的變化 ( Change in Data Representation) ? 行的存儲方法可以有多種