Background technology
Propelling along with mobile phone terminal internationalization process, the continuous expansion of market scale and the continuous renewal of technology, make mobile phone have unprecedented breakthrough at aspects such as kind, outward appearance, functions, at aspects such as operating system, chip, wireless transmission standards, also had expansion simultaneously and goed deep into.Meanwhile, mobile phone market has also produced huge demand growth to Java, support the function of Java Virtual Machine to seem particularly important, the Java Virtual Machine based on embedded platform has become most mainstream carriers to mobile phone, particularly the Compulsory Feature of custom-made mobile phone.It is more powerful that vast consumer, operator, service/content provider and mobile-phone manufacturers thirst for the Java performance of mobile phone strongly, support more more complicated application, for industrial chain each side brings more business opportunities and income, simultaneously also for user brings more colourful valued added applications.As everyone knows, the professional platform independence of Java Virtual Machine, makes the ability of mobile phone obtain continuous lifting, but how Java Virtual Machine is being constantly operator's expansion new business, when bringing abundanter value-added service for user, promoting the performance of self, is also to need the deeply problem of consideration.
There are in the market the patent and the method that much for virtual machine, are optimized, the patent that in prior art, application number is 201010265244.4 discloses the terminal that a kind of Java Virtual Machine picture resource loads, it considers that mobile intelligent terminal has a lot of picture resources to need to load, for traditional picture, load resource method, proposed new picture resource loading velocity and improved one's methods.
The patent that in prior art, application number is 201010588216.6 discloses a kind of kind loading method in advance and device based on embedded real-time Java virtual machine, by revising the java class file of Classloader, be provided for carrying out according to the list of class the loading method of class loading; The jni class of revising virtual machine kernel, is provided for calling described loading method with the kind loading method in advance of the required whole classes of pre-loaded application program; Obtain the class list that comprises the required whole classes of application program.
The first system call method: first system calls corresponding application program (app), and dalvik virtual machine loads corresponding application program and enters virtual machine, system is first loaded storehouse in the required core of application program, then loads loading bin in corresponding this locality.The second system call method: the application program in system, in loading corresponding system resource, employing utilizes the RAM on register and sheet to realize the function of Java stack, partial function is realized with hardware simulation, speed has obtained corresponding lifting like this, but cost, also along with rising, is not suitable for fast-developing hand-held intelligent terminal industry.
To sum up, in above-mentioned prior art, the advantage of the general loading method of intelligent terminal is, more common, virtual machine is first Service Principle first, and response loads the most de novo application program.But shortcoming is also clearly, do not take into full account in the operation of smart mobile phone, the distribution of resource is uneven, and some application programs have not also been used in occupation of the resource of system, and the garbage reclamation phase (GC, Garbage Collection) does not reclaim in time.And the application of often using for user, such as phone, contact person, note, multimedia message, the application such as the network information have little time response, although the processing speed of chip processor rises again and again, along with the use of smart mobile phone, or the more and more slower sensation of sensory system.
Summary of the invention
The object of the invention is to, a kind of disposal route of Java Virtual Machine load module is provided, solve above technical matters.
Technical matters solved by the invention can realize by the following technical solutions:
A disposal route for Java Virtual Machine load module, wherein, described method comprises:
Step s11: start after class loaders, will treat that load classes adds queue to be loaded;
Step s12: described in judgement, whether queue to be loaded is empty, if be not empty, obtains the current class name that runs application and need from queue described to be loaded, and enters step s13; Empty if, load and finish, start the step of resolving bytecode;
Step s13: described class loaders comprises one first load units and one second load units, according to the described class name obtaining, carries out load classes step by described the first load units and/or described the second load units; Described the first load units loads for the first of queue described to be loaded being treated to load classes; Described the second load units loads for the second of queue described to be loaded being treated to load classes.
Preferably, also comprise step s14, generate the constant pool that has load classes in step s13 process, described constant pool comprises the class that load classes will be quoted, and the described class that will quote is added into queue to be loaded, and jumps to step s12.
Preferably, described the first load units and described the second load units are respectively equipped with independent operation interval, independent object heap and Java work stack, access mutually between described the first load units and described the second load units.
Preferably, described the first treats that load classes is the class that conventional application program will be quoted, described the second treats that load classes is the class that common applications will be quoted, and described the first treats that the operated frequency of load classes treats the operated frequency of load classes higher than described the second.
Preferably, described the first treats that load classes is application class, and described the second treats that load classes is java application DLL (dynamic link library) class.
Preferably, in step s13, described the first load units is treated in process that load classes loads the first in queue described to be loaded; In the same time, described the second load units treats that to the second in queue described to be loaded load classes loads.
Preferably, after loading finishes, through the bytecode of resolving, enter Java execution engine and process.
Preferably, described the first load units is as follows to described method of loading until load classes wait the first in loading queue: carry out pre-service described the first is processed separately after the bytecode of load classes is resolved in virtual machine, described in independent loads, the first is treated load classes built-in function used, until described the first is treated the closure of load classes, no longer increases.
Preferably, be applied to intelligent mobile phone system and load field.
Preferably, comprise two described class loaders, described in two described class loaders parallel processings, treat load classes.
Beneficial effect: owing to adopting above technical scheme, the present invention goes to consider to load corresponding application program from the parallel angle of class loaders, the class that the conventional application program for the treatment of in load classes will be quoted is separated loading with the class that common applications will be quoted, and optimized treatment method is introduced to dummy machine system system architecture and is loaded field.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Embodiment based in the present invention, the every other embodiment that those of ordinary skills obtain under the prerequisite of not making creative work, belongs to the scope of protection of the invention.
It should be noted that, in the situation that not conflicting, embodiment and the feature in embodiment in the present invention can combine mutually.
Below in conjunction with the drawings and specific embodiments, the invention will be further described, but not as limiting to the invention.
With reference to Fig. 1, whole Java Virtual Machine architecture, can be divided into two subsystems: class loaders 1 and Java carry out engine 2, and it is processor cores of Java that Java carries out engine 2, be the core of Java Virtual Machine, be responsible for carrying out all Java bytecodes of having resolved; Class loaders 1 creates suitable data structure for Java carries out engine 2, and based on this data structure, Java carries out engine 2 provides effective algorithm to carry out every Java byte code instruction.The class of Java Virtual Machine is loaded and exactly the bytecode being included in class file is loaded in Java Virtual Machine, the class bytecode specifically using by the content in class file being converted to Java Virtual Machine, by class loaders 1, be loaded into the bytecode data in Java Virtual Machine, thereby become executable code.Class file comprises application class 3, also comprises java application DLL (dynamic link library) class (Application Programming Interface, API class) 4.
Under conventional situation, mobile phone is slowly slack-off is to have little time to collect without object because mobile phone EMS memory is progressively occupied, the increasing of memory fragmentation.In the use of application program, use frequently a certain application simultaneously, carried out phone when suddenly, in the time of note, main process is employed program and has occupied, and conventional one time of application can not get system resource.The present invention loads application program entry from Java Virtual Machine and loads, and changes the traditional stowage of virtual machine, in class loaders 1, the bytecode data of binary mode in application program is read in Java Virtual Machine.
Because the resource limitation in the application of embedded intelligence machine is strict, and it is higher to requirement of real-time, if as traditional Java Virtual Machine, when operation, realize that certain class needing just starts class loaders while not being loaded and loads, may cause program operation duration time stopped.Therefore the class loaders of this paper loads into the disposable class java application.
With reference to Fig. 2, Fig. 3, the disposal route of a kind of Java Virtual Machine load module provided by the invention,
Wherein, method comprises:
Step s11: start after class loaders 1, will treat that load classes adds queue to be loaded;
Step s12: judge whether queue to be loaded is empty, if be not empty, obtains the current class name that runs application and need from queue to be loaded, and enters step s13; Empty if, load end, start the step of resolving bytecode, through the bytecode of resolving, enter Java execution engine 2 and process;
Step s13: class loaders 1 comprises one first load units 11 and one second load units 12, according to the class name obtaining, carries out load classes step by the first load units 11 and/or the second load units 12; The first load units 11 loads queue the first for treating treats that load classes loads; The second load units 12 loads queue the second for treating treats that load classes loads.
Preferably, also comprise step s14, generate the constant pool that has load classes in step s13 process, constant pool comprises the class that load classes will be quoted, and analyzes the constant pool of load classes, and the class that will quote is added into queue to be loaded, and jumps to step s12.
Preferably, in step s13, the first load units 11 is treated in the process that the first of loading in queue treats that load classes loads; In the same time, the second load units 12 is treated the second loading in queue and is treated that load classes loads.
The present invention can be mainly used in intelligent mobile phone system and load, and solves the software loading problem of smart mobile phone, treats that load classes comprises application class 3, treats that load classes also comprises java application DLL (dynamic link library) class 4.When people use mobile phone, from function, say and can be divided into conventional contact application and common application.Such as a smart mobile phone, use the most frequently used phone that has, contact person, note, function of multimedia message.And for game, stopwatch, calendar, the different end user's frequency of utilization of different application is also different.Such as for liking to play games, except basic application, the maximum of use are game application.For liking to see e-book, except basic application, what frequency of utilization was many is exactly e-book application program.By daily user's behavioural analysis, the operation of conventional module is many substantially, and frequency is also higher, is that in system, operation is the most frequent, background process scheduling maximum.
A preferred embodiment, the first treats that load classes is application class 3, the second treats that load classes is java application DLL (dynamic link library) class (Application Programming Interface, API class) 4.
Another kind of preferred embodiment, the first treats that load classes is the class that conventional application program will be quoted, and the second treats that load classes is the class that common applications will be quoted, and the first treats that the operated frequency of load classes treats the operated frequency of load classes higher than the second.
Class loaders 1 packs a class in Java Virtual Machine into, complete through three steps, and loading, link and initialization, wherein, link can be divided into again verification, preparation and parsing three steps, and except resolving, other steps complete in strict accordance with order.The present invention is when class loaders 1 loads, consider the feature of smart mobile phone, fully revised smart mobile phone virtual machine load-on module method, the application program of the conventional module of intelligent machine is carried out to special loading and process, to commonly use module separates with general module, load respectively, through loading, connect, after initialization, system is just had any different to treat and has been guaranteed coherent processing like this, also can realize Concurrency Access between conventional module and general module simultaneously, gives prominence to the key points.
As a further improvement on the present invention, the first load units 11 treats that to load the method that the first in queue loads until load classes as follows: carry out pre-service the first is processed separately after the bytecode of load classes is resolved in virtual machine, independent loads the first is treated load classes built-in function used, until the first is treated the closure of load classes, no longer increases.The closure for the treatment of load classes no longer increases, and means the class that will quote loaded.
The second load units 12 is treated the second loading in queue and is treated that load classes loads according to traditional method.Because traditional method belongs to prior art, do not repeat them here.
Smart machine, because copyright has been carried out modification to a certain degree by traditional Java, can be divided into three parts in logic in java runtime memory headroom: method district, Java work stack and object heap; Method district, also referred to as operation interval, store all information relevant to java class, comprise method, class static fields and for the data structure of the relation between representation class inside or class, in the Java method Dou method district that wherein the most important thing is to be likely performed.Java carries out engine from reading run time version here.Therefore, Java Virtual Machine must effectively be organized these methods, when keeping compact as far as possible, makes run time version to be positioned rapidly and to read, and this is the function of class loaders subsystem just.
As a further improvement on the present invention, the first load units 11 and the second load units 12 are respectively equipped with independent operation interval, independent object heap and Java work stack, access mutually between the first load units 11 and the second load units 12.The first load units 11 and the second load units 12 can parallel processing, and can access the other side's data structure, the configuration aspects loading from virtual machine is modified class loaders structure, the class that conventional application program will be quoted loads the class that will quote with common applications and loads, each loading classes can be realized oneself bytecode is independently analyzed, the data field of correspondence oneself, local variable, rreturn value.
A preferred embodiment, comprises two class loaders 1, by two class loaders 1 parallel processings, treats load classes.The present invention goes to consider to load corresponding application program from the parallel angle of class loaders, the class that the conventional application program for the treatment of in load classes will be quoted is separated loading with the class that common applications will be quoted, and optimized treatment method is introduced to dummy machine system system architecture and is loaded field.
The foregoing is only preferred embodiment of the present invention; not thereby limit embodiments of the present invention and protection domain; to those skilled in the art; should recognize that being equal to that all utilizations instructions of the present invention and diagramatic content done replace and the resulting scheme of apparent variation, all should be included in protection scope of the present invention.