The invention discloses a
JavaScript code optimization method based on a front-end
byte code technology. According to the method, a conversion tool chain from
JavaScript to WebAssembly is provided, acode segment merging strategy is designed, and then a
JavaScript performance optimization scheme is provided; and variable type information of each execution path of the program is obtained through dynamic
symbolic execution, and a code statement according with a conversion condition is obtained through a screening rule, a C code is generated from a JavaScript code by designing a JavaScript 2C conversion rule, and a WebAssembly
code segment is generated through Exscript compiling. And finally, the performance and function consistency before and after optimization are compared through a unit test idea, and the optimization of the
code segment is given up if the performance is reduced or the functions are inconsistent. On the other hand, a
code segment merging strategy is designed, on the basis of the
data dependence relation between the code segments, the code segment merging strategy is provided as the basis of
user code reconstruction, the purpose of reducing data interaction performance losses is achieved, and the execution efficiency of the program is further improved.