Eager Optimistic Promise Evaluation with Scope-Based De-optimization

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Functional programming languages and languages with functional components face challenges in efficiently implementing lazy evaluation, as existing eager and optimistic evaluation methods can lead to reliability issues due to potential over-optimism and lack of fallback mechanisms.

Innovation Solution

A method and system for generating executable code that determines programmatic expressions, compiles them into optimized code portions using assumptions and expression scopes, and de-optimizes when expressions are modified outside their scope, providing a fallback mechanism for efficient execution.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Speed

If eager and optimistic evaluation is used for promises, then code execution speed is improved, but reliability deteriorates due to potential over-optimism and lack of fallback mechanisms

Engineering Contradiction:
Improvecode execution speedVSAvoidevaluation reliability
Core Design Contradiction:
SpeedVSReliability

Solution Approach 1:

The patent sets up a fallback mechanism beforehand by tracking expression scopes and detecting modifications outside scopes. When a promise is evaluated eagerly, the system monitors for potential validity issues and automatically falls back to lazy evaluation if modifications are detected, cushioning against the reliability risks of over-optimistic eager evaluation.

Inventive Principle:
Principle #11Beforehand cushioning (Prior cushioning)

Solution Approach 2:

The evaluation strategy is made dynamic by allowing the system to switch between eager and lazy evaluation based on runtime conditions. The compiler generates code that can detect when promises are modified outside their expression scopes and dynamically adjust the evaluation approach, combining the speed benefits of eager evaluation with the reliability of lazy evaluation when needed.

Inventive Principle:
Principle #15Dynamics

2Productivity

If optimistic evaluation is performed without validation, then productivity is improved, but correctness deteriorates when assumptions are invalid

Engineering Contradiction:
Improvecode execution efficiencyVSAvoidevaluation correctness
Core Design Contradiction:
ProductivityVSManufacturing precision

Solution Approach 1:

The patent implements feedback mechanisms by generating runtime code that monitors promise modifications. The system evaluates promises optimistically upfront but provides feedback loops that detect when assumptions become invalid due to external modifications, triggering corrective actions to maintain evaluation correctness while preserving productivity.

Inventive Principle:
Principle #23Feedback

Solution Approach 2:

The compiler performs preliminary analysis to determine expression scopes and generate optimized evaluation code upfront. This preliminary action establishes the assumptions for eager evaluation, and the runtime system validates these assumptions, ensuring correctness while maintaining the productivity benefits of early optimization decisions.

Inventive Principle:
Principle #10Preliminary action

3Reliability

If lazy evaluation is implemented strictly, then reliability is improved, but speed deteriorates due to unnecessary evaluations

Engineering Contradiction:
Improveevaluation reliabilityVSAvoidcode execution speed
Core Design Contradiction:
ReliabilityVSSpeed

Solution Approach 1:

The patent applies local quality by allowing different evaluation strategies in different contexts. Within expression scopes where promises are guaranteed not to be modified, eager evaluation is used for speed. Outside these scopes, lazy evaluation is maintained for reliability. This localized application of evaluation strategies optimizes both speed and reliability according to the specific runtime context.

Inventive Principle:
Principle #3Local quality

Data Source

PatentUS9836288B2Eager and optimistic evaluation of promises
Publication Date: 2017.12.05 ORACLE INT CORP
  • US9836288B2 patent drawing
  • US9836288B2 patent drawing
  • US9836288B2 patent drawing

AI summary

The invention relates to a method for generating executable code from application source code. The method steps include determining a programmatic expression using the application source code and determining a first value for the programmatic expression. The method steps further include compiling the programmatic expression into a first optimized code portion using the first value, an assumption, and an expression scope. The method steps further include executing the application source code. The method steps further include determining that the programmatic expression is modified outside of the expression scope, invalidating the assumption, and de-optimizing the first optimized code portion.