JavaScript Engine Caching Optimized Machine Code
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Conventional JAVASCRIPT engines face limitations in achieving high performance due to inefficient compilation times, inability to apply typical compiler optimizations, and underutilization of multi-core processors, particularly in embedded environments with limited hardware resources.
Innovation Solution
A web browsing method and apparatus that optimizes JAVASCRIPT code by caching machine codes, stub codes, and type information, using incremental optimization and compiler optimizations across multiple cores, allowing for simultaneous compilation and optimization of JAVASCRIPT code on separate processing cores.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Speed
If JIT compilation is used to improve JavaScript execution performance, then execution speed is improved, but compilation time is not separated from execution time causing overhead
Solution Approach 1:
The patent performs JIT compilation in advance during idle periods or when resources are available, separating compilation from execution time. This preliminary compilation action stores optimized machine code that can be directly executed later without incurring compilation overhead during actual JavaScript execution, thus resolving the contradiction between execution speed and compilation time overhead.
2Loss of time
If JIT compiler does not perform optimization to reduce compilation time, then compilation is faster, but inefficient machine codes are generated
Solution Approach 1:
The system performs full optimization during preliminary compilation phases when time is not constrained, generating efficient machine code. This optimized code is then cached and reused, eliminating the need for repeated compilation and optimization cycles, thus achieving both time efficiency and code optimization.
Solution Approach 2:
The compilation process is segmented into multiple phases: initial compilation, optimization, and execution. By separating these phases, the system can perform comprehensive optimization without blocking execution time, as each phase operates independently and optimized results are cached for reuse.
3Adaptability or versatility
If JavaScript engine needs to recompile machine code after it is released from main memory, then code can be reused, but compilation overhead increases
Solution Approach 1:
The patent creates and stores copies of optimized machine code in persistent storage or long-term cache. When the original code is released from main memory, these pre-generated copies can be quickly restored or regenerated without performing full compilation again, thus maintaining code reusability while minimizing compilation overhead.
4Productivity
If typical compiler optimization methods are applied to JavaScript, then code optimization is improved, but JavaScript's dynamic characteristics make optimization difficult
Solution Approach 1:
The system performs preliminary type inference and static analysis on JavaScript code before execution, gathering type information and usage patterns in advance. This preliminary action enables the application of typical compiler optimization methods by providing the static information that JavaScript's dynamic nature normally lacks, thus improving optimization effectiveness without excessive complexity.
Data Source
AI summary
A web browsing method and apparatus for enhancing a user's convenience in web browsing is provided in a system that uses a multi-core processor. The web browsing method and apparatus is applicable in a system, such as a smart phone that has a low computing power or that has a storage device like a flash memory operating in a rapid manner. Optimized machine codes are stored in files and incremental optimization is achieved, so the JAVASCRIPT® program of the web application has a small compilation overhead and achieves fast execution.


