《毕业设计论文外文翻译基于WEB的新农村村政务系统设计.doc》由会员分享,可在线阅读,更多相关《毕业设计论文外文翻译基于WEB的新农村村政务系统设计.doc(12页珍藏版)》请在三一办公上搜索。
1、Java虚拟机的10年摘要:JVM的设计目标是提供一个基于抽象规格描述的计算机模型,为解释程序开发人员提供很好的灵活性,同时也确保Java代码可在符合该规范的任何系统上运行。关键字:虚拟机 接口 语言Java虚拟机的起源与构造当我们说到“Java”这个词的时候,指的是四个相互关联的概念:Java语言、 Java API、Java Class文件格式、Java虚拟机。整个Java体系是基于Java 虚拟机构造的,正因为如此,才能实现Java的安全性和网络移动性。Java并非是第一个采用“虚拟机”概念的体系,但却是第一个得到广泛运用的虚拟机平台。 “虚拟”,是一种隔离物理资源与逻辑资源的手段。Ja
2、va虚拟机的“虚拟”,则是用来隔离物理机器、底层操作系统与Java语言规范实现的手段。虽然Java是一种面向对象的语言,我们平时大量使用的,是对象间的多态、组合(Composition)、委派(Delegation),但当我们讨论虚拟机的时候,我们看见的基本概念却是“栈(Stack)”和“堆(Heap)”。根据冯诺依曼的“存储计算”模型,所有的代码都保存在代码空间中,随着程序计数器指针的变化进行程序的执行、跳转。Java虚拟机中没有寄存器的概念,方法调用是采用“栈”进行的,这是一种安全、简洁的方法。Java虚拟机通过类装载器支持对类的隔离,这也是Java实现安全性的基础。每个类都具有自己的命名
3、空间,在具有不同安全级别的沙箱中运行,因此不会产生低安全级别的代码来越权访问高级别代码的机会。类装载器的出现是Java虚拟机与大部分用C实现的虚拟机的显著不同之处。Java虚拟机的另外一个显著特点就是实现了自动的垃圾收集。在往常,写程序的时候要牢记对象之间的关联,在每个程序块中假若申请了对象空间,就必须在出口释放掉,方法调用往往同时也就是对象的边界。而自动垃圾收集带给开发者的最大好处,就是可以非常方便地从整体上把系统的对象组织成一张对象图,只需往这张图中添加对象,维护对象之间的关联,却不需要自己做复杂的清扫工作。正是有了这种思维单纯的对象图的支持,OR Mapping(关系数据库与对象映射)技
4、术在最近得以大行其道,设计模式也更容易被Java群体所接受。虚拟机的优化1995年第一代的Java出台之时,其虚拟机执行是依靠“字节码解释器(Byte Code Interceptor)”的,也就是说每条指令都由虚拟机来当场解释执行,这造成速度令人抓狂地缓慢。更有甚者有人开始总结许多的“速度优化经验”,比如说:“尽量把所有的代码都放在较大的方法中执行”与“少用接口”等等,这完全与Java语言的设计目的背道而驰,现在看起来是多么可笑的奇谈怪论,当时却是很多程序员津津乐道的经验之谈。无他,Java本身执行太慢了。Java生命的前十分之三就是如此缓慢地渡过的。于是,Sun的工程师开始拼命想着提高执行
5、速度。JIT静态编译器的出现是在1996年十月,Sun放出了第一个编译器。JIT编译器在每段代码执行前进行编译,编译的结果为本地静态机器码,执行速度有了质的提高。Symantec公司当时凭借其傲人的JIT编译器,在整个Java界受到热烈的追捧。在其后的1998年,Java 1.2发布的时候,附带了JIT编译器,从此Java的使用者终于可以抛开上面说的那些奇怪的“速度优化经验”了。JIT静态编译器虽然可以解决一些问题,但是性能仍然和C/C+有很大的差距。对一段程序而言,一名优秀的程序员是如何来改进运行速度的呢?首先,他不会傻到把所有的代码都来优化,他会观察、思考到底哪段代码对整体性能影响最大?然
6、后集中精力来优化这一段代码。按照经验,整个程序 10%-20%的代码,会占据 80%-90%的运行时间。用这种方法,在同样的时间、付出同样程度的努力后,这名优秀的程序员使整个程序的性能得到了很大程度的优化。HotSpot引擎,就是模仿人工的这种方法进行优化的。在程序运行的开始,Java代码仍然解释执行,但HotSpot引擎开始进行采样(Profiling)。根据采样的结果,决定某段程序是占用较多运行时间的,就认为它是“HotSpot”,它也就是目前程序的瓶颈, 引擎开始启动一个单独的线程进行优化。因为不象原始的 JIT编译器那样无差别的编译所有代码,HotSpot引擎可以集中精力来对HotSp
7、ot代码进行深度优化,这样这部分代码执行起来更加迅捷。之前的静态编译器只能按照预定的策略进行编译优化,而HotSpot引擎的优化是基于采样的结果的,因此这种方法对所有的应用程序都有效。1999年3月27日,Sun放出了第一个HotSpot引擎。在随后的2000年5月的JDK 1.3中,包含了HotSopt引擎,这也使1.3成了一个具有里程碑意义的发行版本。到这里,Java的十年生命,已经过去了一半。HotSpot代表的是一种动态编译的技术。对Java这种大量使用委派、组合等面向对象特性的程序来说,动态编译比起静态编译来有显著的优势。比如Method Inlining。方法的调用是一个很耗时的操
8、作,假若可以把方法调用直接内嵌到调用者的代码中,就可以节省大量的时间, 这被称为“Method Inlining”。因为涉及到类的重载,静态优化很难确切知道哪些属性、方法被重载,因此很难对method进行合并,只好在方法内部进行静态编译,假若每个方法都很小,静态优化能起到的作用也就比较小。而动态编译因为可以完全随时掌握类的重载情况,就可以把相关的方法合并进行深度优化。现代的Java程序,特别是在设计模式教育得到普及之后,大量使用类的继承、委派,形成了很多短小的方法,动态编译的优势就更加明显。自从出现了HotSpot之后,整个Java界为之一振。最近的五年,就是继续优化的五年。继续进行优化的方法
9、有几条路,一是研究新的采样算法。因为采样关系到不同的优化策略,会对整体性能有比较大的影响。二是研究深度优化的方法。三是研究垃圾收集的算法。垃圾收集会带来程序短暂的停顿,这会带来负面的用户体验。于是,如何提高垃圾收集的效率,减少延迟,出现了五花八门的算法,比如渐进式收集、火车算法等。在多处理器的时候,如何利用多处理器进行并行收集也是研究的一个热点。这方面,BEA的JRocket走在了前面。现实生活中的虚拟机最后,让我们来盘点一下目前市面上可见的各个虚拟机。首先要提到的,毫无疑问是Sun的虚拟机。作为大众心目中的“官方实现”,Sun拥有最大的用户群,并且拥有“兼容基准”的地位,其他虚拟机都必须要考
10、虑和Sun虚拟机的兼容性问题。比如 JRocket就会在某些特殊情况下表现出和Sun不同的特性,可能对程序运行有影响。不过Sun也的确没有让广大用户失望,虽然在早期性能比不上Symantec,后来在1.2 的时候性能又被IBM超越,但Sun一直在努力革新,特别是 1.4.2之后,性能有了长足的进步。虽然JDK 1.5的虚拟机在性能上没有什么提高,但是增强了稳定性,据说修改了8000处bug,真是让人汗流不止。原来我们在1.4.2下面一直在享受这么多bug啊。其次是老牌劲旅IBM。IBM的JDK在1.3的时代创下了最好的性能记录,从此树立了高端形象。特别是在其WebSphere产品中得到了很好的
11、评价。其JDK也是最早支持64bit的JDK之一。到了现在,IBM JDK在高端仍然是和BEA可以一拼的。然后是后起之秀,BEA的JRocket。说到BEA突然在JVM领域一夜之间异军突起,多少让人有些瞠目,不过它采取的战略特别简单:自己没有,索性花钱买了在此领域深有研究的JRocket,在前面加上BEA的标志就可以了。JRocket瞄准高端服务器市场,在多处理器环境下有不俗的表现。除此之外,还有几个开放源代码的JVM值得一提。首先就是大名鼎鼎的JikesRVM。说起其大名,大多数人都知道Jikes编译器是 IBM开发的,效率比同等的javac编译器高得多,很多开发者都使用Jikes编译器来取
12、代javac。而JikesRVM则是IBM开源出来的一整套虚拟机技术,包含了JIT,GC的完整实现,在其网站上也有众多的论文,实在是想要深入研究JVM者的绝佳资源()。Kaffe是一个老牌的JVM,不过现在已经很少听到了。结束语时光流转,轰轰烈烈的Java虚拟机性能争论仿佛还在耳边回响,现在新的争论却已经是“Java的性能是否已经超越C/C+”。Joakim Dahlstedt 是 JRockit 的主要架构设计师之一,他坚持认为,Java绝不是一种速度慢,效率低的语言,JVM 是一个关键的组件,确保了系统的部署与运行和开发一样快速、轻松。特别是在目前开发趋势是采用大量预制的框架时,动态编译有
13、可能比C/C+这样的静态优化获得更好的性能。Virtual Machine of Java of 10 YearAbstract:The design goal of JVM is to provide computer module based on the abstract specification description, provide the very good flexibility for the interpreter developers, simultaneously also guarantee the Java code to be possible to run o
14、n any system which conforms to this standard.Key words: Virtual Machine,Interface,LanguageThe origins and the structure of the Virtual Machine of JavaWhen we make reference to the phraseJava, what to point is four mutually the concept of the connection: Language of Java, Java API, Java Class documen
15、t format, Virtual Machine of Java. The whole Java system is according to the Java Virtual Machine structure of, positive as it does, then can carry out the Java safety and networkses to move sex. The Java is the first system that adopt Virtual Machine concept not, but is the first to get the extensi
16、ve usage of Virtual Machine terrace. Conjecture, is a kind of means that insulates the physics resources and the logic resources.The conjecture of the Virtual Machine of Java, then use to the means of insulate the physics machine, the first floor operate system and the Java language norm realization
17、.Although the Java is a kind of language that faces to the object, the most using for us is Many Tais between objects and Composition, Delegation, when we discuss the Virtual Machine, the basic concepts that we can see are Stack and Heap. Basis Ping2 Nuo4 depend onsaving calculation model of Man , a
18、ll codes keep in the code space, counting the variety that the machine points the needle to carry on the performance of the procedure and jump to turn along with the procedure.Did not deposit the concept of the machine in the Virtual Machine of Java, the method adjusts to use is to adopt Stack to ca
19、rry on of, this is a kind of safe, simple and direct method.The Virtual Machine of Java passes a lading machine support to the insulation of the type, this is also the foundation that the Java carries out the safety.Each ones have to assign name to the space ownly, movement in the sand box have diff
20、erent and safe Class, so will not produce the code of the low and safe Class to come more the power interview high class do not the opportunity of the code. An emergence that loads the machine is a Virtual Machine of Java to use the C with the big part the Virtual Machine of the realization shows th
21、e place of dissimilarity of the zhao.Virtual Machine of Java of another a the show the characteristics of the zhao is to carry out the auto of garbage collections.Want to keep firmly in mind the connection between object at the time of usually, writing the procedure, in each procedure piece if appli
22、ed for the object space, must release in the exit, the method adjusts to use usually also is the boundary of the object.But automatic garbage the collections brings the biggest advantage of the developer, is to become an object diagram from whole last object organization of a system very expediently
23、, need to be go toward only to increase the object in this ZHANG TU2, support the connection between object, but do not need the do-it-yourself to clean up the work complicatedly.Had this kind of thinking support of the pure object diagram exactly, the OR Mapping( the relation database and objects r
24、eflect to shoot) technique can go the its teachings greatly recently, designing the mode to also was more easily accept by the community of Java.Virtual Machine of excellent turnIn 1995 hour of Java pedestal of generation, its Virtual Machine performance is to depend on the byte code explained the m
25、achine( the Byte Code Interceptor) of, also is to say that each instructions was come by the Virtual Machine to explain the performance there and then, this resulted in the speed make the person to grasp wildly slow-moving.Even have very a someone starts tally up many the speed is excellent to turn
26、the experience, saying for example: Put all codes as far as possible in bigger method performance with little use to connect etc., this is run in opposite directions with the design purpose of the Java language completely, looking now is how and laughably strange to talk the strange theory, at that
27、time but is a lot of procedure members to take delight in talking about remark based on personal experience.Have no him, Java the performance is too slow.The front of the life of Java very it three is to pass through slow-movingly thus of.Hence, the Sun engineer starts try very hard to want to raise
28、 to carry out the speed.The static state of JIT edits and translate the emergence of the machine is in October of 1996, the Sun let out the first edit and translate the machine.The JIT edits and translate the machine to go forward to go to edit and translate in each code performance, the compiled re
29、sult is the native static state machine code, the performance speed contain the exaltation of the quality.Company of Symantec at that time with borrowed its proud JIT to edit and translate the machine, was warmly make track for to hold in the whole Java field.At the time of afterward of 1998, Java 1
30、.2 release, supplementary the JIT edits and translate the machine, from now on the Java user can lay aside those strange the speed is excellent to turn the experiences that the top say finally.The static state of JIT edit and translate although the machine can resolve some problems, function still a
31、nd C/ C+ have the very big margin.To a procedure, how an excellent procedure member is come improve the movement speed of ? First, he know better than to come all codes excellent turn, he would observe, thinking exactly which code affect to the whole function biggest?Then concentrate the energy to c
32、ome excellent turn this code.According to the experience, the whole 10% of procedure-20% code, will occupy 80%-90% movement time. Using this kind of method, after same of time, pay an effort of same degree, this excellent procedure member makes the whole function of procedure get the very big degree
33、 excellent to turn.Engine of HotSpot, is this kind of method of the artificial of mimicry to carry on excellent turn of. At the beginning that the procedure circulate, the code of Java still explains the performance, but the engine of HotSpot start carry on the sample( Profiling).According to the re
34、sult of the sample, decide what a certain procedure is to take up more movement time, think that it is HotSpot, it is also the bottleneck of the procedure currently, the engine starts start a lone line distance to carry on excellent turn.Because not the JIT of the elephant originality edits and tran
35、slate the machine to edit and translate all codes so indiscriminately, the engine of HotSpot can concentrate the energy to come to carry on the depth to the code of HotSpot excellent turn, thus this part of codes carry out more fast.The previous static state edits and translate the machine only the
36、ability carries on edit and translate according to the reserved strategy excellent turn, but engine of HotSpot of excellent turn is according to result of sample of, therefore this kind of method to all pplied procedures are valid.On March 27 in 1999, the Sun let out the first engine of HotSpot.In t
37、he JDK of subsequent May of 20001.3, included the engine of HotSopt, this also makes 1.30% an issue edition that has the milestone meaning.Arrive the here, Java 10-year life, have already passed by the half.What HotSpot represent is the technique that a kind of dynamic state edit and translate.Appoi
38、nt to this kind of a great deal of usage of Java, combination etc. faces to the procedure of the object characteristic to say, the dynamic state edits and translate to compare with the static state to edit and translate to have the advantage of show.For example Method Inlining.It is a that method ad
39、just to use the operation that consume very much, if can adjust the method to use direct inside the goes to adjust to use in code, can save a great deal of time, this is calledthe Method Inlining.Because involve the type heavy to carry, the static state is excellent to turn very difficult accurate k
40、now which belong to sex, method drive heavy carry, so very difficult carry on the merger to the method, have to carry on static states edit and translate in the method inner part, if each method is all very small, the static state is excellent to turn the function that can rise also smaller.But the
41、dynamic state edit and translate because can completely and at any time control the type heavy to carry the circumstance, can carry on the depth to the related method merger excellent turn.The procedure of Java of the modern, especially after designing the mode education to get universality, a great
42、 deal of usage inherit, appoints, becoming a lot of short and small of method, the advantage that dynamic state edit and translate more obvious.After appeared the HotSpot, the whole Java field is on flap for it.Recent five years, be continue excellent turn of five years.Continue to carry on excellen
43、t turn of method have several roads, one is to study the new sample calculate way.Because the sample relate to different and excellent turn the strategy, will have the ratio the bigger influence to the whole function.Two is study the depth excellent turn of method.Three is a calculate way that studi
44、es the garbage collections.The garbage collections will bring the procedure the brief deadlock, this will bring the negative customer experience.Hence, how raise the efficiency of the garbage collections, reduce to delay, appear the rich in variety calculate way, for example and gradually enter type
45、 collections, train calculate way etc.At the time of have another processor, how the exploitation have another the processor carries on proceeding together the collections is also a research of a hot point.This aspect, the BEA JRocket walk at front.Virtual Machine within realistic lifeEnd, let us co
46、me to stocktaking once currently on the market it is thus clear that of each Virtual Machine.Want to speak of first of, beyond all doubt is a Sun Virtual Machine.Be authorities realization in the publics heart, the Sun owns biggest customers, and own the position of and permit the basis, other Virtu
47、al Machines must consider and Virtual Machine of Sun of and permit the sex problem.For example the JRocket will express the different from Sun characteristic of under the condition of some and special, may circulate to have the influence to the procedure.However Sun also really didnt let large custo
48、mer disappointment, although at the time of the function of the earlier period canning not compare with the Symantec, afterwards at 1.2 function again drive the IBM surmount, Sun always at work hard to reform, especially 1.4.2 after, the function contain substantial progress.Although JDK 1.5 of Virt
49、ual Machine has no exaltation on the function, strengthenned the stability, it is said modify 8000 bugs, is really let person the sweat flow not only.Originally we are under 1.4.2 always at enjoy so many bugs.It is an old-brand crack troop IBM the next in order.IBM JDK at 1.3 of ages set the best function record, set up the high level image from now on.Got the good evaluation in its product of WebSphere especially.Its JDK also