Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

Method and device for pre-generating machine code instruction in JavaScript scripting language

A scripting language and machine code technology, applied in the field of pre-generated machine code instructions, can solve problems such as low efficiency, high time consumption, repeated generation, etc., to achieve the effect of improving the generation speed and avoiding repeated generation of actions

Inactive Publication Date: 2013-05-01
HUAWEI TECH CO LTD
View PDF4 Cites 9 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0011] In the process of realizing the above-mentioned generation of machine code based on the intermediate code, the inventor found that there are two defects in the prior art: on the one hand, if the instruction types of the two intermediate codes are the same, then the generated machine code instructions will have the same Repeated generation of machine code instructions is not efficient
On the other hand, a piece of intermediate code may generate many machine code instructions, so when the requested memory space is insufficient, it will cause several actions to re-apply for the instruction storage space, and it is necessary to copy the contents of the old instruction storage space to the new instruction storage space, resulting in high time-consuming

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method and device for pre-generating machine code instruction in JavaScript scripting language
  • Method and device for pre-generating machine code instruction in JavaScript scripting language
  • Method and device for pre-generating machine code instruction in JavaScript scripting language

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0041] Embodiments of the present invention provide a method for pre-generating machine code instructions in the JavaScript scripting language, such as figure 1 As shown, the method includes:

[0042] 101. Obtain the intermediate code in the JavaScript script.

[0043] In the actual application scenario, when the web browser operates the JS engine, it will download the JavaScript script from the Internet, then parse it according to the source program in the script to generate a syntax tree, and then generate the intermediate code or bytecode according to the syntax tree.

[0044] 102. Query the total instruction length of the machine code instruction corresponding to the intermediate code from the machine code template, and apply for an instruction storage space capable of accommodating the machine code instruction.

[0045] The instruction storage space is used to store machine code instructions corresponding to the intermediate code. The machine code template is a file tha...

Embodiment 2

[0067] Embodiments of the present invention provide a method for pre-generating machine code instructions in the JavaScript scripting language, such as figure 2 As shown, the method includes:

[0068] 201. Obtain the intermediate code in the JavaScript script.

[0069] In the actual application scenario, when the web browser operates the JS engine, it will download the JavaScript script from the Internet, then parse it according to the source program in the script to generate a syntax tree, and then generate the intermediate code or bytecode according to the syntax tree.

[0070] 202. Apply for an instruction storage space capable of accommodating the total length of the instruction by querying the total instruction length of the machine code instruction corresponding to the intermediate code.

[0071] The instruction storage space is used to store machine code instructions corresponding to the intermediate code. The machine code template is a file that is preconfigured and...

Embodiment 3

[0110] Based on the above method embodiment, the embodiment of the present invention also provides a device for pre-generating machine code instructions in the JavaScript scripting language, such as image 3 shown, including:

[0111] The obtaining module 31 is used to obtain the intermediate code in the JavaScript script.

[0112] In the actual application scenario, when the web browser operates the JS engine, it will download the JavaScript script from the Internet, then parse the source program in the script to generate a syntax tree, and then generate the intermediate code or bytecode according to the syntax tree, and obtain Intermediate code in JavaScript scripts.

[0113] The application module 32 is used to query the total instruction length of the machine code instruction corresponding to the intermediate code from the machine code template, and apply for an instruction storage space capable of accommodating the machine code instruction; the instruction storage space ...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The embodiment of the invention discloses a method and device for pre-generating a machine code instruction in a JavaScript scripting language, relates to the field of compilation of a dynamic language and solves the problem of improving the generating speed of a machine code. The concrete scheme comprises the following steps of: obtaining an intermediate code of a JavaScript script, applying for an instruction storage space capable of accommodating the total length of the instruction through querying the total length of the instruction of the machine code instruction which corresponds to the intermediate code, copying the machine code instruction in a machine code template, which corresponds to the intermediate code, to the instruction storage space, and modifying the machine code instruction relative to a pseudo register and intermediate value information according to the intermediate code. The method and the device, provided by the invention, are used for causing the intermediate code to generate the machine code instruction.

Description

technical field [0001] The invention relates to the field of dynamic language compilation, in particular to a method and device for pre-generating machine code instructions in JavaScript scripting language. Background technique [0002] JS (JavaScript) is an object-based and event-driven interpreted scripting language that can be embedded in Web pages. It is mainly interpreted and executed on the web browser, which can make the webpage have dynamic effects (such as: scrolling of pictures and text; dynamic switching, display and hiding of layers; operation of HTML (HypertextMarkupLanguage, hypertext markup language) elements); The input verification of the form can be carried out (such as: the legality of the mailbox, phone number, zip code, the length and content verification of the input content, etc.). [0003] When the web browser operates the JS engine, it will download the JavaScript script from the Internet, and then parse and generate a syntax tree according to the s...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
IPC IPC(8): G06F9/44
Inventor 张振龙
Owner HUAWEI TECH CO LTD
Features
  • Generate Ideas
  • Intellectual Property
  • Life Sciences
  • Materials
  • Tech Scout
Why Patsnap Eureka
  • Unparalleled Data Quality
  • Higher Quality Content
  • 60% Fewer Hallucinations
Social media
Patsnap Eureka Blog
Learn More