Eliminating Redundant Reference Count Operations in Script Code IR

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional intermediate representations (IRs) for script code lack efficient means to track object references, leading to inefficient reference count operations and the generation of redundant code that consumes computing resources and can produce 'buggy' executable code.

Innovation Solution

Optimizing the IR by identifying and removing redundant reference count operations, specifically incref-decref pairs, through analysis and reordering of code to maintain accurate reference counts, thereby reducing the computational overhead and improving code quality.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If conventional IRs include built-in reference count operations for tracking object references, then reference tracking is performed, but redundant reference count operations are generated that consume computing resources

Engineering Contradiction:
Improvereference tracking accuracyVSAvoidexecution efficiency
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent extracts and removes redundant reference count operations (specifically incref-decref pairs) from the intermediate representation. By identifying and eliminating these redundant operations that do not affect the final reference count state, the system maintains accurate reference tracking while reducing the number of operations that need to be executed, thus improving execution efficiency without sacrificing reliability

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent changes the parameter of reference count operations by analyzing and reordering code to identify when incref and decref operations can be eliminated. By transforming the IR to recognize patterns where reference count operations are redundant (e.g., when an object is immediately reassigned or goes out of scope), the system modifies the operational parameters to exclude unnecessary increments and decrements, reducing computational overhead while maintaining accurate reference tracking

Inventive Principle:
Principle #35Parameter changes

2Extent of automation

If reference count operations are built into object creation and deletion operations in IR, then reference tracking is automatic, but the IR lacks opportunity for optimization

Engineering Contradiction:
Improveautomatic reference trackingVSAvoidIR structure complexity
Core Design Contradiction:
Extent of automationVSDevice complexity

Solution Approach 1:

The patent applies preliminary action by performing reference count optimization during the IR generation phase rather than at execution time. By analyzing the code structure and identifying redundant incref-decref pairs before the IR is executed, the system预先 removes unnecessary operations from the IR. This preliminary optimization reduces the complexity of the IR structure while maintaining automatic reference tracking, as the redundant operations are eliminated before the IR needs to be executed

Inventive Principle:
Principle #10Preliminary action

3Adaptability or versatility

If compilers translate source code to IR and then to machine code, then code portability is improved, but redundant reference count operations are not eliminated

Engineering Contradiction:
Improvecode portabilityVSAvoidcomputing resource consumption
Core Design Contradiction:
Adaptability or versatilityVSLoss of energy

Solution Approach 1:

The patent uses the intermediate representation as an intermediary opportunity to eliminate redundant reference count operations. By inserting optimization passes between the source code translation to IR and the IR translation to machine code, the system can analyze and remove redundant incref-decref pairs from the IR. This intermediary optimization reduces computing resource consumption in the generated machine code while preserving the portability benefits of using IR, as the optimization occurs at the IR level before machine code generation

Inventive Principle:
Principle #24Intermediary (Mediator)

Data Source

PatentUS9152400B2Eliminating redundant reference count operations in intermediate representation of script code
Publication Date: 2015.10.06 META PLATFORMS INC
  • US9152400B2 patent drawing
  • US9152400B2 patent drawing
  • US9152400B2 patent drawing

AI summary

The disclosure is related to optimizing generation of intermediate representation (IR) for a script code by eliminating redundant reference count code from the IR. The reference count code includes code that manages a reference count of an object, e.g., code that increments a reference count of the object (“incref code”) and an observer code which consumes or the execution of which depends on the reference count of the object. The IR is analyzed to identify redundant reference count code. Counters associated with the object are evaluated and upon satisfying the optimization criterion, the incref code is moved closer to the observer code. The incref code and the observer code that are adjacent to each other are identified as redundant code pair and the code pair is eliminated from the IR to generate an optimized IR. The optimized IR is further converted to an executable code.