CN102736943B - Dynamic compiling and executing method of embedded browser engine - Google Patents

Dynamic compiling and executing method of embedded browser engine Download PDF

Info

Publication number
CN102736943B
CN102736943B CN201210191993.6A CN201210191993A CN102736943B CN 102736943 B CN102736943 B CN 102736943B CN 201210191993 A CN201210191993 A CN 201210191993A CN 102736943 B CN102736943 B CN 102736943B
Authority
CN
China
Prior art keywords
bytecode
compiling
redirect
object code
abstract syntax
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201210191993.6A
Other languages
Chinese (zh)
Other versions
CN102736943A (en
Inventor
郭文生
桑楠
郭小福
余启洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
University of Electronic Science and Technology of China
Original Assignee
University of Electronic Science and Technology of China
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by University of Electronic Science and Technology of China filed Critical University of Electronic Science and Technology of China
Priority to CN201210191993.6A priority Critical patent/CN102736943B/en
Publication of CN102736943A publication Critical patent/CN102736943A/en
Application granted granted Critical
Publication of CN102736943B publication Critical patent/CN102736943B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention belongs a dynamic compiling and executing method of a JavaScript engine of an embedded browser, and the method comprises: creating and expanding a combined cache region, compiling a script hot point and an abstract syntax tree, scanning the abstract syntax tree, compiling byte codes and target codes, executing a script and determining and compiling a hot point region. According to the invention, the hot point scanning process is performed in front of the process of converting the abstract syntax tree into byte codes in a dynamic compiling mode in the JavaScript engine of the embedded browser and the advantages of fast explanation and execution response speed and high JIT execution efficiency are fully combined to further detect the hot point beyond the circulating structure in the explanation and execution process. Therefore, the method has the advantages of effectively improving the synchronism and efficiency of dynamic compiling of the JavaScript engine of the embedded browser and the JavaScript script operation, shortening the delay time between the dynamic compiling and executing, quickly executing the JavaScript script, updating the information displayed on a webpage in time and effectively improving the utilization effect of the user.

Description

A kind of built-in browser engine on-the-flier compiler manner of execution
Technical field
The invention belongs to built-in browser technical field, the JavaScript engine on-the-flier compiler of special just a kind of built-in browser and perform the disposal route of JavaScript script, adopt the method effectively to improve synchronism that the on-the-flier compiler of JavaScript engine and JavaScript script perform and efficiency.
Background technology
Browser is a kind of client software based on HTML (Hypertext Markup Language), its major function is from web page elements such as webserver downloading web pages document, picture, CSS (cascading style sheet), affect a lot of because have of browser performance, the performance of script engine is one of key factor determining browser performance.The performance competitive of browser in the sense, is exactly the performance battle of script engine.Script engine mainly needs the client web application that affairs to be processed are exactly parsing dynamic web page, process is relevant.The script that these application are commonly used is JavaScript language; JavaScript language, because it is distinctive based on objectivity, event-driven, security, is widely used.Because JavaScript language itself is interpreted language, thus JavaScript engine perform the mode of script mainly contain explain executive mode, JIT(instant compiler) Just-In-Time mode, on-the-flier compiler mode.Explain that the advantage of executive mode is that to carry out the delay of script execution short, shortcoming be when performing the circulation script repeatedly performed efficiency low (after explaining one, perform one, because of occur in source program circulation, interpretive routine also repeatedly explain afterwards and run this group statement, travelling speed is very slow), just seem unable to do what one wishes when tackling complicated script operation, the script compile of entirety becomes object code to perform by JIT Just-In-Time mode again, relative its efficiency of explanation executive mode has great raising, but JIT Just-In-Time mode performs after compiling overall script again, the interval time of compiling is thus grown thus causes longer delay, in order to reduce this delay, improve operational efficiency, sufficient compile optimization process can not be carried out when compiling and producing object code, on-the-flier compiler mode is on the basis of JIT Just-In-Time mode, research affects the critical area of script execution efficiency, and only carry out JIT Just-In-Time (selectivity Just-In-Time) for these critical areas, this mode more reasonably employs JIT(instant compiler), and relatively traditional JIT Just-In-Time, its compiling is more flexible, postpone also shorter, but this on-the-flier compiler mode needs JavaScript script all to translate into intermediate code before execution, then before intermediate code performs and in implementation, critical area detection is carried out, its critical area is caused to detect opportunity improper, longer to the compiling hysteresis quality of critical area, meanwhile, scanning and record loop code need the at substantial time, and then affect the instantaneity of execution of JavaScript script, efficiency and user's result of use.
Summary of the invention
The object of the invention is the defect existed for background technology, propose a kind of built-in browser engine on-the-flier compiler manner of execution; To shorten on-the-flier compiler further and time delay between performing, effectively to improve synchronism that built-in browser JavaScript engine on-the-flier compiler and JavaScript script run and efficiency, reach and perform Javascript script fast, information more shown by new web page Javascript script is timely, and effectively improves the object such as result of use of user.Thus overcome instantaneity that current web page page JavaScript script that the on-the-flier compiler of background technology built-in browser JavaScript engine exists performs and efficiency poor, the defects such as retardance is still longer, and user's result of use is poor.
Solution of the present invention adopts on the basis of on-the-flier compiler in the JavaScript engine of background technology built-in browser, the opportunity scanning (detection) focus is advanceed to engine to be converted in the process of bytecode by abstract syntax tree, allow like this engine to the process of focus more early, more abundant, it also avoid the generation of the intermediate code of focus, and focus direct compilation is become object code, saved the engine processing time; And fully combine the advantage explaining that execution and JIT perform, namely by ordinary node being compiled into bytecode, focus (loop structure) is compiled into object code, engine then uses the former and explains execution, to improve the response speed that script performs, engine finds corresponding object code, effectively to improve the efficiency that focus performs to the latter by redirect mark; In the explanation implementation of engine, detect the hot spot region beyond loop structure simultaneously further, and be compiled into object code, to improve the execution efficiency of hot spot region; In addition, the large buffer zone of Coutinuous store (entirety) formula background technology adopted, changes into and adopts multiple minibuffer district to be combined into the large buffer area of logic, to realize the storage of redirect connection fast and object code, to avoid mass data to copy the expense brought; Namely the present invention realizes its goal of the invention with this.Therefore, the inventive method comprises:
A. the foundation of combined type buffer zone and expansion thereof: adopt the mode in minibuffer district to store object code and bytecode, each minibuffer district is combined to form the large buffer zone that has logical relation by the mode using the administrative mechanism of combined type buffer zone to be connected by redirect; Only one or more corresponding minibuffer district need be increased on basis, existing minibuffer district when expanding buffer zone;
B. script focus and compiling abstract syntax tree, scanning abstract syntax tree and bytecode, object code compiling:
B 1. the determination of compiling abstract syntax tree and focus: after JavaScript script compile is become abstract syntax tree by background technology (background technology conventional method) by engine, using the loop structure abstract syntax subtree in abstract syntax tree as focus, go to step B 2;
B 2. scanning abstract syntax tree: be compiled in the process of bytecode, namely at abstract syntax tree and the node of abstract syntax tree is scanned successively, to determine that it is ordinary node or focus, namely go to step A after having scanned a node 3, until scanned;
B 3. the compiling of bytecode, object code: to step B 2during scanning abstract syntax tree the ordinary node determined be compiled into the focus determined when bytecode or byte code stream scan then direct compilation become object code, meanwhile between bytecode or byte code stream and the object code that is compiled into, insert redirect to mark, then its result is stored in buffer zone;
C. script perform and the determination of hot spot region, compiling:
C 1. script performs and the determination of hot spot region: be compiled into step B and carry out initialization tag and the execution of execution area stored in the bytecode in steps A, judge in implementation whether bytecode is redirect mark, directly execution is explained if not redirect mark, mark after corresponding object code with this redirect if redirect marks then acquisition, perform, zone marker is carried out to each bytecode section performed explaining in implementation, using be repeatedly executed at predetermined intervals in implementation the region of more than 2 times as hot spot region, go to step C 2, other region is as non-hot spot region; Until script is finished;
C 2. the compiling of hot spot region: first judge that whether the bytecode forming hot spot region is containing redirect mark, if step C 1the hot spot region be made up of the bytecode do not marked containing redirect detected, then directly bytecode is compiled into object code, if step C 1detect be formed by the bytecode marked containing redirect hybrid hot spot region, then combined and be compiled into object code; Be revised as new redirect mark by bytecode corresponding for each hot spot region detected or containing the bytecode of redirect mark simultaneously, go to step C 1.
Described minibuffer district comprises object code buffer zone and bytecode buffer zone in step.And in step C 2described in containing redirect mark bytecode formed Mixed Zone, be compiled into object code through combining, its method of combining compiling is compiled in the process of object code at engine by bytecode, once after finding that redirect mark is connected to current goal code by the object code that this redirect mark is corresponding, then continue the process of associating compiling.
The present invention owing to have employed on-the-flier compiler mode in the JavaScript engine of built-in browser, the opportunity scanning (detection) focus is advanceed to engine abstract syntax tree is converted in the process of bytecode, allow engine to the process of focus more early, more abundant, also omit the generation of the intermediate code of focus, focus direct compilation is become object code, save the engine processing time; Fully combine simultaneously and explain and perform fast response time and the high advantage of JIT execution efficiency, and the focus in the explanation implementation of engine further beyond detection loop structure, not only improve response speed that script performs, but also effectively improve the execution efficiency of focus and hot spot region; The large buffer zone of Coutinuous store (entirety) formula that the present invention adopts minibuffer district to be combined to form a large buffer zone with logical relation, to replace background technology to adopt simultaneously, the mass data that the large buffer zone that both facilitated the capacity extension of buffer zone, turn avoid employing Coutinuous store mode must be carried out copies the expense brought.Thus, the present invention has effectively can improve the synchronism and efficiency that built-in browser JavaScript engine on-the-flier compiler and JavaScript script run, shorten on-the-flier compiler and time delay between performing, to perform Javascript script quick, the information more shown by new web page Javascript script is timely and effectively improve the features such as the result of use of user.
Accompanying drawing explanation
Fig. 1 is specific embodiment of the invention schematic flow sheet.
Embodiment
Present embodiment is for digital TV set-top box processing scripts code: this case script code packages contains in loop structure, script and also comprises event response process, and user constantly can trigger this event response.By according to built-in browser Javascript engine, disposal route of the present invention is specifically set forth to the process of this example now.
Accompanying drawing 1 is present embodiment schematic flow sheet, and the on-the-flier compiler manner of execution of engine is as follows:
Steps A: first set up the minibuffer district, i.e. bytecode buffer zone and the object code buffer zone that are used for bytecode and object code access, for preserving and call bytecode, object code respectively, and realize the management to each minibuffer district object code redirect connection by the administrative mechanism of logical buffers;
Step B1:JavaScript script enters JavaScript engine through grammatical and semantic and lexical analysis, is compiled into abstract syntax tree, and is focus by the loop structure abstract syntax subtree flag in abstract syntax tree, then goes to step B 2-1;
Step B 2-1: scanning abstract syntax tree, judges whether the node of Current Scan is focus, if so, then goes to step B 3-2, otherwise go to step B 3-1;
Step B 3-1: by the compiling bytecode of present node or byte code stream and after store byte code or byte code stream, go to step B 2-2;
Step B 2-2: judge that whether abstract syntax tree is scanned, if scanned, go to step C 1-1, otherwise go to step B 2-1;
Step B 3-2: focus be compiled into object code and store this object code, going to step B simultaneously 3-3;
Step B 3-3: after adding the redirect mark pointing to hot spot target code after the byte code sequence preserved in step, go to step B 2-2;
Step B 2-2: judge that whether abstract syntax tree is scanned, if scanned, go to step C 1-1, otherwise go to step B 2-1;
Step C 1-1: a bytecode in the byte code sequence preserved in extraction step A, if region corresponding to this bytecode is not labeled, its zone marker is initialized as 0 time, goes to step C 1-2;
Step C 1-2: judge that whether current byte code is redirect mark, if, go to step C 1-3, otherwise go to step C 1-4;
Step C 1-3: perform according to the object code preserved in redirect marker extraction steps A, perform after terminating and go to step C 1-6:
Step C 1-4: bytecode is made an explanation execution, adds 1 by former for zone marker corresponding for this bytecode basis simultaneously, after executing, go to step C 1-5;
Step C 1-5: judge whether current byte code region is performed more than 2 times (namely zone marker is more than or equal to 2), if, go to step C 2-1, otherwise go to step C 1-6;
Step C 1-6: judge that bytecode performs and whether complete, if to complete, go to step C 1-7terminate, otherwise go to step C 1-1;
Step C 2-1: judge that whether bytecode in hot spot region is containing redirect mark, if containing, go to step C 2-3, otherwise go to step C 2-2;
Step C 2-2: current hotspot zone bit code is compiled into object code, and stores this object code, go to step C simultaneously 2-4;
Step C 2-3: the bytecode partial compilation in the current hot spot region containing redirect mark is become object code, and marks corresponding object code with redirect in hot spot region and connect, and go to step C 2-4;
Step C 2-4: change new redirect mark into by the bytecode in current hotspot region or containing the bytecode of redirect mark, go to step C 1-6judge that bytecode performs whether to complete, if completed, go to step C 1-7, otherwise go to step C 1-1;
Step C 1-7: script is finished.

Claims (2)

1. a built-in browser engine on-the-flier compiler manner of execution, comprising:
A. the foundation of combined type buffer zone and expansion thereof: set up the minibuffer district be used for bytecode and object code access, preserve and call bytecode, object code respectively, each minibuffer district is combined to form the large buffer zone that has logical relation by the mode using the administrative mechanism of combined type buffer zone to be connected by redirect; Only one or more corresponding minibuffer district need be increased on basis, existing minibuffer district when expanding buffer zone;
B. script focus and compiling abstract syntax tree, scanning abstract syntax tree and bytecode, object code compiling:
B 1. the determination of compiling abstract syntax tree and focus: after JavaScript script compile is become abstract syntax tree, using the loop structure abstract syntax subtree in abstract syntax tree as focus, go to step B 2;
B 2. scanning abstract syntax tree: be compiled in the process of bytecode, namely at abstract syntax tree and the node of abstract syntax tree is scanned successively, to determine that it is ordinary node or focus, namely go to step B after having scanned a node 3, until scanned;
B 3. the compiling of bytecode, object code: to step B 2during scanning abstract syntax tree the ordinary node determined be compiled into the focus determined when bytecode or byte code stream scan then direct compilation become object code, meanwhile between bytecode or byte code stream and the object code that is compiled into, insert redirect to mark, then its result is stored in buffer zone;
C. script perform and the determination of hot spot region, compiling:
C 1. script performs and the determination of hot spot region: be compiled into step B and carry out initialization tag and the execution of execution area stored in the bytecode in steps A, judge in implementation whether bytecode is redirect mark, directly execution is explained if not redirect mark, mark after corresponding object code with this redirect if redirect marks then acquisition, perform, zone marker is carried out to each bytecode section performed explaining in implementation, using be repeatedly executed at predetermined intervals in implementation the region of more than 2 times as hot spot region, go to step C 2, other region is as non-hot spot region; Until script is finished;
C 2. the compiling of hot spot region: first judge that whether the bytecode forming hot spot region is containing redirect mark, if step C 1the hot spot region be made up of the bytecode do not marked containing redirect detected, then directly bytecode is compiled into object code, if step C 1detect be formed by the bytecode marked containing redirect hybrid hot spot region, then combined and be compiled into object code; Be revised as new redirect mark by bytecode corresponding for each hot spot region detected or containing the bytecode of redirect mark simultaneously, go to step C 1.
2., by built-in browser engine on-the-flier compiler manner of execution described in claim 1, it is characterized in that in step C 2described in formed by the bytecode marked containing redirect hybrid hot spot region, then combined and be compiled into object code, its method of combining compiling is compiled in the process of object code at engine by bytecode, once after finding that redirect mark is connected to current goal code by the object code that this redirect mark is corresponding, then continue the process of associating compiling.
CN201210191993.6A 2012-06-12 2012-06-12 Dynamic compiling and executing method of embedded browser engine Expired - Fee Related CN102736943B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210191993.6A CN102736943B (en) 2012-06-12 2012-06-12 Dynamic compiling and executing method of embedded browser engine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210191993.6A CN102736943B (en) 2012-06-12 2012-06-12 Dynamic compiling and executing method of embedded browser engine

Publications (2)

Publication Number Publication Date
CN102736943A CN102736943A (en) 2012-10-17
CN102736943B true CN102736943B (en) 2015-06-17

Family

ID=46992495

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210191993.6A Expired - Fee Related CN102736943B (en) 2012-06-12 2012-06-12 Dynamic compiling and executing method of embedded browser engine

Country Status (1)

Country Link
CN (1) CN102736943B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105589729A (en) * 2015-12-28 2016-05-18 北京锐安科技有限公司 Dynamic compiling method and device based on embedded virtual machine

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103279373B (en) * 2013-05-31 2017-09-22 广州市动景计算机科技有限公司 The update method and device of browser case function
CN103823694A (en) * 2014-02-10 2014-05-28 深圳市同洲电子股份有限公司 Method and device for updating script file
CN105608346A (en) * 2015-12-25 2016-05-25 北京奇虎科技有限公司 ELF file protection method and system based on ARM instruction virtualization
CN110347399B (en) * 2019-05-31 2023-06-06 深圳绿米联创科技有限公司 Data processing method, real-time computing system and information system
CN111176625B (en) * 2019-12-31 2023-07-28 杭州趣链科技有限公司 Method for efficiently compiling intelligent contract of solubility at browser end
CN116302221B (en) * 2023-03-27 2023-10-10 河南牧业经济学院 Function graph drawing method and system based on browser
CN117251553B (en) * 2023-11-15 2024-02-27 知学云(北京)科技股份有限公司 Intelligent learning interaction method based on custom plug-in and large language model

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101231597A (en) * 2008-02-01 2008-07-30 东信和平智能卡股份有限公司 Method for execution of JAVA program instruction in smart card
US7421687B1 (en) * 2003-10-08 2008-09-02 Sun Microsystems, Inc. Optimizing branch condition expressions in a JIT compiler
CN102202242A (en) * 2011-05-19 2011-09-28 广东星海数字家庭产业技术研究院有限公司 Realization method of JavaScript interpreter based on set-top box browser

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7421687B1 (en) * 2003-10-08 2008-09-02 Sun Microsystems, Inc. Optimizing branch condition expressions in a JIT compiler
CN101231597A (en) * 2008-02-01 2008-07-30 东信和平智能卡股份有限公司 Method for execution of JAVA program instruction in smart card
CN102202242A (en) * 2011-05-19 2011-09-28 广东星海数字家庭产业技术研究院有限公司 Realization method of JavaScript interpreter based on set-top box browser

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
C/C++程序的运行时优化研究;朱晓珺 等;《软件导刊》;20090430;第8卷(第4期);60,61 *
Christian Haubl et al..Trace-based Compilation for the Java HotSpot Virtual Machine.《ACM Proceedings of the 9th International Conference on Principles and Practice of Programming in Java 》.2011 ACM ISBN 978-1-4503-0935-6,2011,第129-138页. *
曾亮.嵌入式浏览器Javascript引擎的分析与优化.《中国优秀硕士学位论文全文数据库(电子期刊)信息科技辑》.2011,(第12期),I139-234. *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105589729A (en) * 2015-12-28 2016-05-18 北京锐安科技有限公司 Dynamic compiling method and device based on embedded virtual machine

Also Published As

Publication number Publication date
CN102736943A (en) 2012-10-17

Similar Documents

Publication Publication Date Title
CN102736943B (en) Dynamic compiling and executing method of embedded browser engine
US8819649B2 (en) Profile guided just-in-time (JIT) compiler and byte code generation
US7536682B2 (en) Method and apparatus for performing interpreter optimizations during program code conversion
US7543284B2 (en) Partial dead code elimination optimizations for program code conversion
US9569342B2 (en) Test strategy for profile-guided code execution optimizers
US8296747B2 (en) Method for optimizing character string output processing
CN103282890B (en) Program executing apparatus and compiler system
TWI525543B (en) Hybrid dynamic code compiling device, method, and service system thereof
CN103793432A (en) Method and device for splitting database reading and writing
US20060070049A1 (en) Java bytecode translation method and Java interpreter performing the same
CN103853760A (en) Method and device for extracting contents of bodies of web pages
US20010049818A1 (en) Partitioned code cache organization to exploit program locallity
RU2011149589A (en) METHOD AND DEVICE FOR CONFIGURING SUBMISSION OF SERVICES DIRECTIONS
US9021455B2 (en) Packed data objects
US20110153308A1 (en) Virtualization apparatus and processing method thereof
Miranda et al. A partial read barrier for efficient support of live object-oriented programming
US7200841B2 (en) Method and apparatus for performing lazy byteswapping optimizations during program code conversion
CN101271398B (en) Recognition method of multi-path branch structure
CN103218299A (en) Automatic generating method and system of optimized ant colony algorithm test case
CN105022667B (en) One kind being based on built-in browser CSS engine parallel methods
CN106775826A (en) A kind of method and system of use note mode loading code file
US9311059B2 (en) Software development tool that provides context-based data schema code hinting
US10140266B2 (en) Profile-based optimization of XSLT transformations
Kim et al. Small footprint JavaScript engine
Plakal et al. Concurrent garbage collection using program slices on multithreaded processors

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20150617

Termination date: 20180612

CF01 Termination of patent right due to non-payment of annual fee