WO2015021809A1 - Procédé et appareil d'exécution de code langage dynamique - Google Patents

Procédé et appareil d'exécution de code langage dynamique Download PDF

Info

Publication number
WO2015021809A1
WO2015021809A1 PCT/CN2014/078956 CN2014078956W WO2015021809A1 WO 2015021809 A1 WO2015021809 A1 WO 2015021809A1 CN 2014078956 W CN2014078956 W CN 2014078956W WO 2015021809 A1 WO2015021809 A1 WO 2015021809A1
Authority
WO
WIPO (PCT)
Prior art keywords
code
dynamic language
language code
cache
bytecode
Prior art date
Application number
PCT/CN2014/078956
Other languages
English (en)
Chinese (zh)
Inventor
孙昌青
谭柱成
Original Assignee
优视科技有限公司
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 优视科技有限公司 filed Critical 优视科技有限公司
Publication of WO2015021809A1 publication Critical patent/WO2015021809A1/fr

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44568Immediately runnable code

Definitions

  • DYNAMIC LANGUAGE CODE EXECUTION METHOD AND APPARATUS The present application claims priority to Chinese Patent Application No. 201310357191.2, entitled “Dynamic Language Code Execution Method and Apparatus", filed on August 15, 2013, the entire contents of which are incorporated herein by reference. This is incorporated herein by reference.
  • TECHNICAL FIELD The present invention relates to the field of mobile communication technologies, and in particular, to a dynamic language code execution method and apparatus.
  • a primary object of the present invention is to provide a dynamic language code execution method and apparatus to solve the problem of relatively large overhead when dynamic language code is executed in the prior art.
  • a dynamic language code execution method comprises: when the dynamic language code is executed, caching the code generated when the dynamic language code is executed, obtaining the cache code of the dynamic language code; and acquiring the cache code of the dynamic language code and the dynamic language code when the dynamic language code is executed again The dynamic code is executed based on the cache code.
  • the code generated when the dynamic language code is executed is cached, and the step of obtaining the cache code of the dynamic language code includes: when the dynamic language code is executed, buffering the bytecode generated when the dynamic language code is executed, The bytecode is used as the cache code for the dynamic language code.
  • the step of obtaining the cache code of the dynamic language code and executing the dynamic language code based on the cache code of the dynamic language code comprises: acquiring the bytecode when the dynamic language code is executed again, and acquiring the word The section code is converted to native code; the dynamic language code is executed by executing native code.
  • the step of buffering the bytecode generated when the dynamic language code is executed includes: establishing a bytecode cache hash table; and buffering the bytecode generated when the dynamic language code is executed into the bytecode cache hash table, wherein When the bytecode is cached, the identifier of the dynamic language code identifies the cached bytecode.
  • the step of obtaining the bytecode includes: obtaining the bytecode corresponding to the dynamic language code by the identifier of the dynamic language code.
  • the step of obtaining the cache code of the dynamic language code includes: when the dynamic language code is executed, the native code generated when the dynamic language code is executed is cached, and Use the native code as the cache code.
  • the step of obtaining the cache code of the dynamic language code and executing the dynamic language code based on the cache code of the dynamic language code comprises: obtaining the native code when the dynamic language code is executed again, by executing the native code Execute dynamic language code.
  • the step of caching the native code generated when the dynamic language code is executed comprises: establishing a native code cache hash table; and buffering the native code generated when the dynamic language code is executed into a native code cache hash table, wherein the cached native code is cached When the identifier of the dynamic language code is identified, the cached native code is identified.
  • the step of obtaining the native code includes: obtaining the native code corresponding to the dynamic language code by the identifier of the dynamic language code.
  • the dynamic language code execution method further includes: determining whether there is a cache code of the dynamic language code; wherein, if it is determined that the cache code of the dynamic language code exists, performing the dynamic on the cache code Language code; if it is determined that there is no cache code of the dynamic language code, the cache code of the dynamic language code generated when the dynamic language code is executed is obtained, and the generated cache code is added to the cache.
  • another dynamic language code execution method comprising: obtaining an execution request of a dynamic language code; determining whether the dynamic language generation exists a cache code of the code, the code generated when the dynamic language code is executed; if the cache code of the dynamic language code exists, the dynamic language code is executed on the basis of the cache code.
  • executing the dynamic language code on the basis of the cache code comprises: determining a type of the cache code, the cache code including a bytecode and a native code of the dynamic language code; if the cache The code is a native code of the dynamic language code, and the native code is executed to implement the dynamic language code; if the cache code is a bytecode of the dynamic language code, the bytecode is converted Being native code, and executing the native code to implement execution of the dynamic language code. Further, the method further includes: if there is no cache code of the dynamic language code, storing a cache code generated when the dynamic language code is executed.
  • storing the cache code corresponding to the dynamic language code includes: storing a bytecode generated when the dynamic language code is executed, and using the bytecode as a cache code of the dynamic language code; or storing The native code generated when the dynamic language code is executed, and the native code is used as a cache code of the dynamic language code; or, the native code corresponding to the dynamic language code issued by the WebApp publisher or the Web Server is stored. Further, storing the bytecode generated when the dynamic language code is executed, including: storing the bytecode in a pre-established bytecode hash table, and pairing the word according to the identifier of the dynamic language code The section code is identified.
  • storing the native code generated when the dynamic language code is executed comprises: storing the native code in a pre-established native code hash table, and identifying the native code according to the identifier of the dynamic language code .
  • a dynamic language code execution apparatus comprises: a cache unit, configured to cache code generated when the dynamic language code is executed when the dynamic language code is executed, obtain a cache code of the dynamic language code, and an execution unit, configured to acquire the dynamic language when the dynamic language code is executed again The code's cache code and execute the dynamic language based on the cache code of the dynamic language code Code.
  • the cache unit is configured to cache the bytecode generated when the dynamic language code is executed when the dynamic language code is executed, and use the bytecode as the cache code of the dynamic language code;
  • the execution unit is configured to convert the bytecode into a native code. Code; Execute dynamic language code by executing native code.
  • the cache unit is configured to cache the bytecode generated when the dynamic language code is executed in the following manner: Establish a bytecode cache hash table, and cache the bytecode generated when the dynamic language code is executed to the bytecode cache hash. In the table, where the bytecode is cached, the identifier of the dynamic language code identifies the cached bytecode.
  • the execution unit is configured to obtain the bytecode in the following manner: the bytecode corresponding to the dynamic language code is obtained by the identifier of the dynamic language code. Further, the cache unit is configured to cache the native code generated when the dynamic language code is executed when the dynamic language code is executed, and use the native code as the cache code, and the execution unit is configured to execute the dynamic language code by executing the native code. Further, the cache unit is configured to cache the native code generated when the dynamic language code is executed in the following manner: Establish a native code cache hash table, and cache the native code generated when the dynamic language code is executed into the native code cache hash table, where When the native code is cached, the identifier of the dynamic language code identifies the cached native code.
  • the execution unit is used to obtain the native code in the following manner:
  • the native code corresponding to the dynamic language code is obtained by the identification of the dynamic language code.
  • the dynamic language code execution apparatus further includes: a determining unit, configured to determine, before the execution of the dynamic language code, whether there is a cache code of the dynamic language code, wherein the execution unit is configured to determine, when the cache code of the dynamic language code exists, The dynamic language code is executed on the basis of the cache code, and the cache unit is configured to obtain the cache code of the dynamic language code generated when the dynamic language code is executed, and add the generated cache code to the cache code when the dynamic language code is not present. In the cache.
  • a dynamic language code execution apparatus comprising: an obtaining unit, configured to acquire an execution request of a dynamic language code; and a determining unit, configured to determine whether the existence a cache code of the dynamic language code, the cache code is a code generated when the dynamic language code is executed; an execution unit, configured to: when the cache code of the dynamic language code exists, on the cache code Executing the dynamic language code.
  • the execution unit includes: a first determining subunit, configured to determine a type of the cache code, the cache code includes a bytecode and a native code of the dynamic language code; and a first execution subunit, When the cache code is a native code of the dynamic language code, executing the native code to implement execution of the dynamic language code; a conversion subunit, configured to: when the cache code is a word of the dynamic language code When the code is coded, the bytecode is converted into a native code.
  • the device further includes: a cache unit, configured to store, when the cache code of the dynamic language code does not exist, a cache code generated when the dynamic language code is executed.
  • a computer readable medium having program code executable by a processor, the program code causing a processor to perform the steps of: obtaining an execution request of a dynamic language code; Whether there is a cache code of the dynamic language code, the cache code being code generated when the dynamic language code is executed; if there is a cache code of the dynamic language code, performing the dynamic on the cache code Language code.
  • the code generated when the dynamic language code is executed is cached when the dynamic language code is executed, the cache code of the dynamic language code is obtained, and when the dynamic language code is executed again, the cache of the dynamic language code is directly obtained.
  • the code executes the dynamic language code on the basis of the cache code of the dynamic language code, so that the step of code generation is not necessary to be repeated on the basis of the dynamic language code, and the problem that the overhead of the dynamic language code execution in the prior art is relatively large is solved. , in turn, achieves the effect of reducing the overhead of dynamic language code execution.
  • FIG. 1 is a schematic diagram of a dynamic language code execution apparatus according to a first embodiment of the present invention
  • FIG. 2 is a schematic diagram of a dynamic language code execution apparatus according to a second embodiment of the present invention.
  • FIG. 3 is a flowchart of a method of executing a dynamic language code according to a first embodiment of the present invention
  • Embodiments of the present invention provide a dynamic language code execution apparatus for executing a dynamic language code.
  • 1 is a schematic diagram of a dynamic language code execution apparatus according to a first embodiment of the present invention. As shown in FIG. 1, the dynamic language code execution device includes a cache unit 10 and an execution unit 20.
  • the cache unit 10 is configured to cache code generated when the dynamic language code is executed when the dynamic language code is executed, to obtain a cache code of the dynamic language code.
  • the dynamic language of the present invention refers to a programming language in which the program structure can be changed at runtime (for example, a new function can be introduced at runtime, and an existing function can be deleted, etc.).
  • JS scripting language, Ruby (object-oriented programming) language, and Python (object-oriented, literal translation computer programming language) are all dynamic languages.
  • a JS script language code is described as an example of a dynamic language code.
  • the cache unit 10 may cache the code generated when the JS scripting language code is executed, thereby obtaining the cache code of the JS scripting language code.
  • the cache code can be either bytecode or native code.
  • the JS scripting language code is analyzed and processed, a corresponding parse tree is generated, and corresponding bytecodes are further generated, and the native code is generated by the JIT method.
  • the cache unit 10 can be cached.
  • the generated bytecode can also cache the generated native code.
  • the execution unit 20 is configured to acquire the cache code of the dynamic language code when the dynamic language code is executed again, and execute the dynamic language code on the basis of the cache code of the dynamic language code.
  • the execution unit 20 may obtain, from the cache unit 10, the cache code cached into the cache unit 10 by the dynamic language code when it was previously executed, and execute the dynamic language code based on the cache code. For example, when the JS scripting language code is executed again, if the bytecode of the JS scripting language code is cached in the cache unit 10, the execution unit 20 may obtain the JS scripting language code from the cache unit 10 and cache it to the cache unit when it was previously executed. Bytecode in 10, and The bytecode is converted into native code, and the JS scripting language code is executed by executing the native code. At this time, the bytecode generation processing is omitted, and the system overhead is saved.
  • the execution unit 20 obtains the JS script language code from the cache unit 10 and caches it to the cache unit 10 when it is executed.
  • the native code in the implementation of the JS scripting language code by executing the native code not only omits the bytecode generation process, but also omits the native code generation process, further saving system overhead.
  • the cache unit 10 may cache the bytecode generated when the dynamic language code is executed, and use the bytecode as the dynamic language code. Cache code.
  • the execution unit 20 may convert the bytecode buffered in the cache unit 10 into a native code, and execute the dynamic language code by executing the native code.
  • the cache unit 10 may cache the bytecode generated when the JS scripting language code is executed, and use the bytecode as the cache code of the dynamic language code.
  • the execution unit 20 may convert the bytecode of the JS scripting language code buffered in the cache unit 10 into a native code, and execute the JS scripting language code by executing the native code.
  • the cache unit 10 may be a bytecode buffer hash table.
  • the bytecode cache hash table can cache the bytecode generated when the dynamic language code is executed.
  • the cached bytecode can be identified by the identifier of the dynamic language code.
  • the identifier of the dynamic language code may be the file name of the dynamic language code, so the bytecode may be identified according to the file name of the dynamic language code.
  • the execution unit 20 can obtain the bytecode corresponding to the dynamic language code by using the identifier of the dynamic language code.
  • the file name of the JS scripting language code may be in the form of document.url + index, so when the bytecode generated when the JS scripting language code is executed is cached in the bytecode buffer hash table, the The bytecode keyword generated by the file name of the JS scripting language code document.url + index identifies the corresponding bytecode of the cache.
  • the execution unit 20 can obtain the bytecode corresponding to the JS scripting language code by using the bytecode keyword generated by the file name document.url+index of the JS scripting language code.
  • the cache unit 10 may also cache the native code.
  • the cache unit 10 can cache the native code generated when the dynamic language code is executed, and use the native code as the cache code of the dynamic language code.
  • the execution unit 20 may directly acquire the native code cached in the cache unit 10, and execute the dynamic language code by executing the native code.
  • the cache unit 10 can cache the native code generated when the JS scripting language code is executed, and use the native code as a dynamic language code. Save the code.
  • the execution unit 20 may directly acquire the native code of the JS scripting language code cached in the cache unit 10, and execute the JS scripting language code by executing the native code.
  • the cache unit 10 may be a native code cache hash table.
  • the native code cache hash table can cache native code generated when dynamic language code is executed.
  • the cached bytecode can be identified by the identifier of the dynamic language code.
  • the identifier of the dynamic language code may be the file name of the dynamic language code, so the native code may be identified according to the file name of the dynamic language code.
  • the execution unit 20 can acquire the native code corresponding to the dynamic language code by using the identifier of the dynamic language code.
  • the file name of the JS scripting language code can be in the form of document.url + index, so when the native code generated when the JS scripting language code is executed is cached in the native code cache hash table, the JS script can be passed.
  • the native code key generated by the file name of the language code document.url + index identifies the corresponding native code of the cache.
  • the execution unit 20 can obtain the native code corresponding to the JS scripting language code by using the native code keyword generated by the file name document.url + index of the JS scripting language code.
  • 2 is a schematic diagram of a dynamic language code execution apparatus according to a second embodiment of the present invention. This embodiment can be used as a preferred embodiment of the embodiment shown in FIG.
  • the dynamic language code execution device includes a cache unit 10, an execution unit 20, and a determination unit 30.
  • the functions of the cache unit 10 and the execution unit 20 are the same as those of the cache unit 10 and the execution unit 20 in the embodiment shown in FIG. 1, and details are not described herein again.
  • the determining unit 30 is configured to determine whether the cache code of the dynamic language code exists before the execution of the dynamic language code. Specifically, the determining unit 30 may determine, according to the identifier of the dynamic language code, whether the cache code corresponding to the dynamic language code exists in the cache unit 10.
  • the determining unit 30 may determine, according to the bytecode keyword generated by the identifier of the dynamic language code, whether the bytecode corresponding to the dynamic language code exists in the cache unit 10; the determining unit 30 may also generate the identifier according to the identifier of the dynamic language code.
  • the native code keyword determines whether the native code corresponding to the dynamic language code exists in the cache unit 10; the determining unit 30 can also determine the cache unit 10 according to the bytecode keyword and the native code keyword generated by the identifier of the dynamic language code. Whether the bytecode and the native code corresponding to the dynamic language code exist at the same time.
  • execution unit 20 may execute the dynamic language code on a cached code basis.
  • the execution unit 20 may convert the bytecode into a native code, and execute the dynamic language code by executing the native code; when determining the existence of the native code of the dynamic language code, Execution unit 20 may execute native code to execute the dynamic language code.
  • a cache code of the dynamic language code is generated, and the cache unit 10 can cache the generated cache code.
  • the text format JS file or code may be analyzed to generate a corresponding parse tree, and the corresponding bytecode is further generated, and the JIT method is used to generate the native code.
  • the cache unit 10 can cache the generated bytecode and native code to update the cache unit 10.
  • the dynamic language code cached in the cache unit 10 may be cached according to the bytecode keyword generated by the identifier of the dynamic language code.
  • the corresponding bytecode is converted into native code, and the dynamic language code is executed by executing native code to reduce the execution overhead of the dynamic language code.
  • the native code corresponding to the dynamic language code cached in the cache unit 10 may be obtained according to the native code keyword generated by the identifier of the dynamic language code, and the dynamic language code is executed by executing the native code.
  • Embodiments of the present invention provide a dynamic language code execution method for executing a dynamic language code. It should be noted that the steps shown in the flowchart of the accompanying drawings may be executed in a computer system such as a set of computer executable instructions, and, although the logical order is shown in the flowchart, in some cases, The steps shown or described may be performed in an order different than that herein.
  • the embodiment of the present invention further provides a dynamic language code execution method, which can be executed by the dynamic language code execution device provided by the embodiment of the present invention.
  • the dynamic language code execution device of the embodiment of the present invention can also be used.
  • the dynamic language code execution method provided by the embodiment of the present invention is executed.
  • the dynamic language code execution method of the embodiment includes the following steps: Step S101: When the dynamic language code is executed, the code generated when the dynamic language code is executed is cached, and the cache code of the dynamic language code is obtained.
  • the dynamic language code may be a JS scripting language code. Need to execute JS scripts When the language code is used, the code generated when the JS scripting language code is executed can be cached, thereby obtaining the cache code of the JS scripting language code.
  • the JS script language code when executed, the JS file or code in the text format is analyzed and processed, a corresponding parse tree is generated, and corresponding bytecodes are further generated, and the native code is generated by the JIT method. Therefore, the bytecode generated when the JS scripting language code is executed may be cached, so that the cache code of the JS scripting language code is bytecode; or the native code generated when the JS scripting language code is executed may be cached, thereby obtaining the The cache code of the JS scripting language code is a native code; the bytecode and the native code generated when the JS scripting language code is executed may also be cached, thereby obtaining the cache code of the JS scripting language code as a bytecode and a native code.
  • the bytecode cache hash table may be first established, so that the bytecode generated when the cached dynamic language code is executed may be the bytecode.
  • the bytecode generated during the execution of the cached dynamic language code is cached in the cache hash table.
  • the cached bytecode can be identified according to the identifier of the dynamic language code. For example, the bytecode can be identified based on a bytecode keyword generated by the filename of the dynamic language code.
  • the native code cache hash table may be first established, so that the native code generated when the cached dynamic language code is executed may be the native code cache hash table.
  • the native code generated when the dynamic language code is executed is cached, that is, the native code generated when the dynamic language code is executed is cached into the native code cache hash table.
  • the native code generated when the dynamic language code is executed is cached into the native code cache hash table.
  • the cached native code can be identified according to the identifier of the dynamic language code. For example, the native code can be identified based on the native code keywords generated by the filename of the dynamic language code.
  • Step S102 when the dynamic language code is executed again, acquire the cache code of the dynamic language code and execute the dynamic language code on the basis of the cache code of the dynamic language code.
  • the cache code of the dynamic language code when the dynamic language code is executed again, the cache code of the dynamic language code may be acquired and executed on the basis of the cache code of the dynamic language code.
  • the byte code buffered by the dynamic language code when executed previously may be obtained, and the dynamic language code is executed on the basis of the byte code code, and the native code cached by the dynamic language code when executed previously may also be obtained.
  • the bytecode cached by the JS scripting language code at the time of execution may be obtained, and the bytecode is converted into native code, and the JS scripting language code is executed by executing the native code; Can get the native code cached by the JS scripting language code before execution, and will be JS scripting language
  • the code generates a bytecode, and executes the JS scripting language code by executing the cached native code corresponding to the bytecode; and can also obtain the bytecode and the native code cached by the JS scripting language code before execution, by executing the cached native code.
  • the code executes the JS scripting language code.
  • the cache code of the dynamic language code may be obtained by using a bytecode keyword generated by the identifier of the dynamic language code to obtain a cached bytecode corresponding to the dynamic language code; and the cache code for obtaining the dynamic language code may also be used.
  • the cached code corresponding to the dynamic language code is obtained by the native code keyword generated by the identifier of the dynamic language code, and the cache code of the dynamic language code may further include the dynamic language obtained by using the bytecode keyword generated by the identifier of the dynamic language code.
  • the cached bytecode and the native code keyword corresponding to the code obtain the cached native code corresponding to the dynamic language code.
  • the dynamic language code execution method may further include determining whether there is a cache code of the dynamic language code. If it is determined that the cache code of the dynamic language code exists, the dynamic language code is executed on the basis of the cache code; if it is determined that the cache code of the dynamic language code does not exist, the cache code of the dynamic language code generated when the dynamic language code is executed is acquired , and add the generated cache code to the cache.
  • the bytecode keyword generated by the identifier of the dynamic language code may be used to determine whether there is a cached bytecode corresponding to the dynamic language code, if it is determined that a dynamic language exists
  • the bytecode of the cache corresponding to the code can be converted into native code, and the dynamic language code is executed by executing the native code.
  • the native code keyword generated by the identifier of the dynamic language code (such as a file name, etc.) may also be used to determine whether there is a cached native code corresponding to the dynamic language code, and if it is determined that there is a cache corresponding to the dynamic language code.
  • the native code can execute dynamic language code by executing native code. If it is determined that there is no cached bytecode corresponding to the dynamic language code and the corresponding cached native code, the corresponding bytecode and the corresponding native code may be generated when the dynamic language code is executed, and the generated correspondence may be The bytecode and corresponding native code are added to the cache, for example, and can be added to the bytecode cache hash table and the native code cache hash table, respectively. Thus, when the dynamic language code is executed again, the execution overhead of the dynamic language code can be reduced by executing the cached bytecode or the cached native code.
  • 4 is a flow chart of a method of executing a JS scripting language code in accordance with an embodiment of the present invention.
  • the JS scripting language code execution method can be used as a preferred embodiment of the embodiment shown in Fig. 4, wherein the features can be combined with the features in the embodiment shown in Fig. 3.
  • the JS scripting language code execution method of this embodiment includes the following steps: Step S401: Acquire a JS scripting language code execution request. After receiving the JS scripting language code execution request, it is determined that the JS scripting language code needs to be executed. Step S402, initializing a bytecode buffer hash table.
  • the bytecode buffer hash table may be a bytecode buffer hash table in the foregoing embodiment for buffering the bytecode generated during execution.
  • the bytecode buffer hash table may be given a certain value, so that the bytecode buffer hash table may further store the bytecode based on the storage space corresponding to the given value, for initializing , you can also clear the bytecode stored in the bytecode cache hash table before.
  • Step S403 initializing a native code cache hash table.
  • the native code cache hash table may cache the hash table for the native code in the previous embodiment for caching the native code generated during execution.
  • it is possible to assign a certain value to the native code cache hash table so that the native code cache hash table can further store the native code based on the storage space corresponding to the given value.
  • it can also be Clear the previously stored bytecode in the native code cache hash table.
  • Step S404 determining whether the bytecode buffer can be used.
  • the file name of the JS scripting language code can be document.url + index, with document.url + index as the identifier of the JS scripting language code.
  • Hash Keyl is a bytecode keyword that can be generated according to the file name document.url + index of the JS scripting language code, and Hash Keyl can identify the JS scripting language code.
  • Hash Value 1 can identify the corresponding bytecode generated after the JS scripting language code is compiled. For determining whether the bytecode buffer can be used, the Hash Keyl may be used to find the Hash Value 1 bytecode corresponding to the Hash Key1 according to the Hash Keyl, if there is a Hash Value 1 bytecode corresponding to the Hash Key1.
  • step S405A1 loading the JS scripting language code.
  • step S405A2 the JS script language code is compiled into a bytecode. Before compiling the JS scripting language code to bytecode, the compiled JS scripting language code can be analyzed and processed, a corresponding parse tree is generated, and the corresponding bytecode is further generated.
  • Step S405A3 buffering the bytecode.
  • the condition that the JS script language code can use the bytecode cache may include the JS scripting language code that can use the bytecode corresponding to the HTTP cache and the JS scripting language code in the bytecode cache. There is no corresponding record in the table.
  • the bytecode can be cached by establishing a bytecode buffer hash table. The bytecode buffered in the bytecode buffer hash table can be marked by the identifier of the JS scripting language code, for example, by Hash Value 1.
  • the cache bytecode can cache the internal JS scripting language code and the external JS scripting language code that are currently applied. Cache bytecode can also cache some common JS scripting language framework code, so that cross-application caching can be achieved. Step S405A4, updating the corresponding record in the bytecode buffer hash table.
  • the bytecode of the JS scripting language code may be cached into a bytecode buffer hash table to update the bytecode record cached in the bytecode buffer hash table.
  • Step S405B Obtain a bytecode cache corresponding to the JS script language code from the bytecode cache hash table.
  • step S406 it is determined whether the native code cache can be used. When the JIT is called, the bytecode is first searched in the native code cache hash table for the cached native code corresponding to the bytecode before being converted into the native code.
  • the file name of the JS scripting language code can be document.url + index, with document.url + index as the identifier of the JS scripting language code.
  • the Hash Key2 may be a native code keyword generated according to the address of the bytecode, and may identify the bytecode, where the Hash Key2 may be the Hash Valuel in step S404.
  • Hash Value2 can identify the corresponding native code after the bytecode conversion.
  • the hash code may be used in the native code cache hash table to find whether there is a cached native code corresponding to Hash Value2, if there is a hash of the hash corresponding to the hash code in the native code cache hash table.
  • the code indicates that the native code cache can be used. If the native code of the cache corresponding to Hash Value2 does not exist in the native code cache hash table, the native code cache cannot be used. After judging, if it is determined that the native code buffer is not available, step S407A1 is performed; if it is determined that the native code buffer can be used, step S407B is performed. Step S407A1, converting the bytecode to a native code. Step S407 A2, the native code is cached. Native code can be cached by creating a native code cache hash table. Native code cached in the native code cache hash table can be tagged with the identity of the JS scripting language code. For example, you can mark it with Hash Value2.
  • the native code of all hotspot codes of the current application may be cached. Step S407A3, updating the corresponding record in the native code cache hash table.
  • the native code of the JS scripting language code may be cached into a native code cache hash table to update the native code record cached in the native code cache hash table. In this way, when the JS scripting language code is executed again, the native code corresponding to the JS scripting language code can be obtained from the native code cache hash table by using the identifier of the JS scripting language code, and the native code is executed to execute the JS.
  • Script language Word code which can improve the execution efficiency, which can reduce the execution cost of the JS scripting language code.
  • Step S407B Obtain a native code cache corresponding to the bytecode from the native code cache hash table. If the native code corresponding to the JS scripting language code can be found in the native code cache hash table according to the identifier of the JS scripting language code, the native code can be obtained from the native code cache hash table. Step S408, executing a native code.
  • the JS scripting language code can be executed by executing native code.
  • the effect of reducing the execution overhead of the JS scripting language code is achieved.
  • the JS scripting language code execution method can be implemented on a Firefox 23 browser.
  • the JS script language code execution method of the embodiment of the present invention can reduce the overhead of loading and executing the game by the client, and improve the loading efficiency.
  • the HTML5 large game BananaBread provided by mozilla is loaded for the first time on the Firefox 23 browser, the overhead of executing the JS function of the game using the JS script language code execution method of the embodiment of the present invention is obviously reduced.
  • the native code corresponding to the dynamic language sent by the WebAPP publisher to the browser may be directly cached and executed; in order to reduce the execution overhead of the dynamic language code, The corresponding native code that converts the JS scripting language code into the browser through the Web Server providing tool is directly cached and executed by the Web Server. From the above description, it can be seen that the embodiment of the present invention achieves the effect of reducing the overhead of dynamic language code execution. Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general-purpose computing device, which can be concentrated on a single computing device or distributed over a network composed of multiple computing devices.
  • the invention is not limited to any specific combination of hardware and software.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

L'invention concerne un procédé et un appareil d'exécution de code langage dynamique. Le procédé d'exécution de code langage dynamique consiste à : durant l'exécution d'un code langage dynamique, mettre en mémoire tampon un code généré durant l'exécution d'un code langage dynamique, pour obtenir un code mis en mémoire tampon du code langage dynamique ; durant la réexécution du code langage dynamique, acquérir le code mis en mémoire tampon du code langage dynamique et exécuter le code langage dynamique sur la base du code mis en mémoire tampon du code langage dynamique. La présente invention réduit les surdébits d'exécution de code langage dynamique.
PCT/CN2014/078956 2013-08-15 2014-05-30 Procédé et appareil d'exécution de code langage dynamique WO2015021809A1 (fr)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310357191.2 2013-08-15
CN2013103571912A CN103412754A (zh) 2013-08-15 2013-08-15 动态语言代码执行方法和装置

Publications (1)

Publication Number Publication Date
WO2015021809A1 true WO2015021809A1 (fr) 2015-02-19

Family

ID=49605767

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/078956 WO2015021809A1 (fr) 2013-08-15 2014-05-30 Procédé et appareil d'exécution de code langage dynamique

Country Status (2)

Country Link
CN (1) CN103412754A (fr)
WO (1) WO2015021809A1 (fr)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103412754A (zh) * 2013-08-15 2013-11-27 优视科技有限公司 动态语言代码执行方法和装置
US9558096B2 (en) * 2014-03-21 2017-01-31 Marvell World Trade Ltd. Method and apparatus for supporting performance analysis
CN105786465A (zh) * 2014-12-23 2016-07-20 远光软件股份有限公司 一种脚本语言执行方法及装置
CN104598227A (zh) * 2014-12-31 2015-05-06 国家电网公司 一种修改系统展示页面内容的方法
CN106557350B (zh) * 2015-09-30 2019-12-13 北京金山安全软件有限公司 应用程序安装包中java字节码转换方法、装置及设备
CN106445505A (zh) * 2016-08-31 2017-02-22 恒生电子股份有限公司 一种代码处理方法及装置
CN107015839B (zh) * 2016-09-27 2020-07-17 阿里巴巴集团控股有限公司 一种实现前端事件代理的方法及装置
CN109144601A (zh) * 2018-06-22 2019-01-04 北京奇艺世纪科技有限公司 在ios应用内调用函数的方法及系统
CN110941433B (zh) * 2019-11-13 2022-03-22 佛山职业技术学院 一种边缘辅助部署第三方应用到微控制器方法及系统
CN116450250B (zh) * 2023-06-16 2023-09-19 天津金城银行股份有限公司 一种动态脚本执行方法、系统及存储介质

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1729453A (zh) * 2002-12-23 2006-02-01 英特尔公司 永久高速缓存装置和方法
CN103412754A (zh) * 2013-08-15 2013-11-27 优视科技有限公司 动态语言代码执行方法和装置

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010042241A1 (en) * 2000-01-21 2001-11-15 Fujitsu Limited Apparatus and method for executing program using just-in time-compiler system
JP2007179153A (ja) * 2005-12-27 2007-07-12 Toshiba Corp スクリプトプログラム実行装置、スクリプトプログラム実行方法及び光ディスク装置
US9250938B2 (en) * 2008-10-15 2016-02-02 Microsoft Technology Licensing, Llc Caching runtime generated code

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1729453A (zh) * 2002-12-23 2006-02-01 英特尔公司 永久高速缓存装置和方法
CN103412754A (zh) * 2013-08-15 2013-11-27 优视科技有限公司 动态语言代码执行方法和装置

Also Published As

Publication number Publication date
CN103412754A (zh) 2013-11-27

Similar Documents

Publication Publication Date Title
WO2015021809A1 (fr) Procédé et appareil d'exécution de code langage dynamique
WO2016192556A1 (fr) Procédé, dispositif et terminal d'invocation d'interface
US8752016B2 (en) Converting JavaScript into a device-independent representation
US8627298B2 (en) Using appropriate level of code to be executed in runtime environment using metadata describing versions of resources being used by code
US8984497B2 (en) Source code converting, method program, and systems for first programming language to a code in a second programming language
US9811321B1 (en) Script compilation
US9182953B2 (en) Hybrid dynamic code compiling device, method, and service system thereof
US10678994B2 (en) Method and system for reusing HTML content
WO2016177341A1 (fr) Procédé et dispositif d'appel d'interface, et terminal
US10671384B1 (en) Proactive seeding of build Artifacts
US9876880B2 (en) Creation of a binding based on a description associated with a server
KR101689745B1 (ko) 스크립트에 의한 동적 리소스 정보를 처리하는 웹 브라우징 시스템 및 방법
US9880943B2 (en) Cache management in a multi-threaded environment
JP6379654B2 (ja) 処理実行プログラム、処理実行方法、及び情報処理装置
CN111723314B (zh) 网页展示方法、装置、电子设备及计算机可读存储介质
US11500652B2 (en) Method and system for application loading
CN103544276B (zh) 一种采用虚拟机显示脚本文件的方法及装置
JP5535184B2 (ja) ブラウザ実行スクリプト変換システムおよびブラウザ実行スクリプト変換プログラム
US20160274996A1 (en) Method to efficiently implement synchronization using software managed address translation
CN106293746B (zh) 浏览器脚本的更新方法及系统
US20140052772A1 (en) Http performance enhancement based on delta transfer
CN107643892B (zh) 接口处理方法、装置、存储介质和处理器
US11689630B2 (en) Request processing method and apparatus, electronic device, and computer storage medium
CN112650502A (zh) 批处理任务处理方法、装置、计算机设备和存储介质
CN104965909A (zh) 一种动态web内容的请求处理方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14836484

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 06.07.2016)

122 Ep: pct application non-entry in european phase

Ref document number: 14836484

Country of ref document: EP

Kind code of ref document: A1