Compiler Devirtualization Guard Code for Dynamic Class Loading

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing compiler optimization techniques are less effective for object-oriented languages like Java that support dynamic class loading, as they struggle to handle runtime polymorphism and dynamic class loading events, leading to inefficiencies in inter-procedural optimizations.

Innovation Solution

The method of inner preexistence involves devirtualizing virtual procedure calls by inlining and adding guard code to ensure thread-local privatization of objects, allowing for compiler optimizations within the devirtualized procedure, including inlining, eliminating runtime type-checking, and applying other optimizations.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Loss of time

If direct devirtualization is applied to eliminate guard tests, then runtime overhead is reduced, but the technique becomes less effective when dynamic class loading is permitted

Engineering Contradiction:
Improveruntime overheadVSAvoideffectiveness with dynamic class loading
Core Design Contradiction:
Loss of timeVSAdaptability or versatility

Solution Approach 1:

The patent implements a dynamic approach by introducing guard code that can detect class loading events at runtime. The system transitions from static devirtualization to a dynamic model where the virtual call can be replaced with a direct call if no class loading occurs, but reverts to virtual call if class loading is detected, thus adapting to runtime conditions.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent employs feedback mechanisms through guard code that monitors class loading events. The guard code provides feedback to the runtime system about whether class loading has occurred, which then determines whether to execute the inlined procedure or jump to the virtual call site, enabling adaptive optimization based on runtime behavior.

Inventive Principle:
Principle #23Feedback

2Loss of time

If inlining is applied to reduce procedure call overhead, then execution time is reduced, but handling runtime polymorphism and dynamic class loading becomes more complex

Engineering Contradiction:
Improveprocedure call overheadVSAvoidcomplexity in handling runtime polymorphism
Core Design Contradiction:
Loss of timeVSDevice complexity

Solution Approach 1:

The patent segments the procedure call handling into multiple parts: guard code insertion, inlined procedure body, and fallback virtual call site. This segmentation allows the system to apply inlining optimization while maintaining the ability to handle runtime polymorphism through the guard code and fallback mechanism.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent introduces guard code as an intermediary between the virtual call site and the inlined procedure. This guard code acts as a mediator that checks for class loading events and determines whether to proceed with the inlined procedure or jump to the virtual call site, thus managing the complexity of runtime polymorphism.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Reliability

If guard code is inserted to ensure validity of inlined procedure, then correctness is maintained, but runtime overhead increases

Engineering Contradiction:
Improvecorrectness of inlined procedureVSAvoidruntime overhead
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent applies partial action by inserting guard code only at specific virtual call sites where inlining is performed, rather than universally. The guard code performs a minimal check for class loading events, and only jumps to the virtual call site if the check fails, thus maintaining correctness while minimizing runtime overhead through selective application.

Inventive Principle:
Principle #16Partial or excessive action

Data Source

PatentUS7716657B2Compiler optimization with privatizing of a non-final object
Publication Date: 2010.05.11 X CORP
  • US7716657B2 patent drawing
  • US7716657B2 patent drawing
  • US7716657B2 patent drawing

AI summary

A method for compiler optimization particularly well suited to object-oriented language that permit dynamic class loading. The method permits the compiler optimization of code associated with a potentially polymorphic object that is a call parameter to a virtual procedure where the procedure is a candidate for devirtualization through inlining. The method includes steps for guarded devirtualizing of the procedure, insertion of code to ensure privatization of the object before the procedure is executed, creation of a guard assumptions associated with the object and application of known optimization techniques to the code associated with the object.