Deferred Constant Pool Generation in JavaScript Compilation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Traditional compilation methods for interpreted programming languages like JavaScript often prevent certain optimizations when generating constant pools during initial code generation, leading to inefficient code and potential errors.

Innovation Solution

Deferred constant pool generation is implemented, where the initial intermediate representation is generated without constants, undergoing optimization processing first, and then a constant pool is created before generating machine code, allowing for more extensive optimizations without errors.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If constant pool generation is performed during initial code generation, then constants are stored centrally for efficient access, but certain optimizations cannot be performed leading to inefficient code and potential errors

Engineering Contradiction:
Improvecode correctnessVSAvoidoptimization capability
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent applies preliminary action by generating the intermediate representation without constants first, performing all necessary optimizations on the constant-free intermediate representation, and only then generating the constant pool. This preliminary optimization phase allows the compiler to perform dead constant elimination, constant folding, and other optimizations that would be impossible or error-prone if constants were present during initial code generation.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The compilation process is segmented into distinct phases: (1) generate intermediate representation without constants, (2) perform optimizations on the constant-free intermediate representation, (3) generate the constant pool from the optimized intermediate representation, and (4) generate final machine code. This segmentation allows each phase to focus on specific tasks without the interference of constant-related complications.

Inventive Principle:
Principle #1Segmentation

2Productivity

If constant pool generation is deferred until after optimization, then more extensive optimizations can be performed, but the process takes longer than traditional methods

Engineering Contradiction:
Improveoptimization capabilityVSAvoidcompilation time
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The patent changes the parameter of constant presence in the intermediate representation from 'present' to 'absent' during the optimization phase. By controlling whether constants are included in the intermediate representation based on the compilation phase, the system enables extensive optimizations without constants while avoiding the time penalty of generating and managing constant pools during optimization.

Inventive Principle:
Principle #35Parameter changes

3Ease of manufacture

If constants are identified and stored in a constant pool during initial code generation, then constants are centrally stored for efficient access, but errors may occur and optimizations are limited

Engineering Contradiction:
Improveconstant managementVSAvoiderror avoidance
Core Design Contradiction:
Ease of manufactureVSReliability

Solution Approach 1:

The patent inverts the traditional approach by not generating constants during initial code generation, but instead generating the intermediate representation without constants and creating the constant pool afterward from the optimized intermediate representation. This inversion eliminates errors associated with premature constant generation while maintaining efficient constant management.

Inventive Principle:
Principle #13The other way round (Inversion)

Data Source

PatentUS8806457B2Deferred constant pool generation
Publication Date: 2014.08.12 APPLE INC
  • US8806457B2 patent drawing
  • US8806457B2 patent drawing
  • US8806457B2 patent drawing

AI summary

Deferred constant pool generation is disclosed. Optimization processing is performed with respect to an intermediate representation of a source code. The optimized intermediate representation is used to generate a constant pool. In some embodiments, the source code comprises JavaScript, which is used to generate a low level virtual machine (LLVM) or other intermediate representation (IR), which intermediate representation is optimized prior to a constant pool being generated.