Inline Cache Optimization for Dynamic Object Concurrency

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Dynamic languages like JavaScript face challenges in achieving high-performance shared-memory concurrency due to inefficiencies in locking mechanisms and inline cache implementations, leading to slow execution and lack of effective optimizations.

Innovation Solution

The introduction of an index structure in the object model for dynamically typed objects allows concurrent execution of data accesses without creating race conditions, with inline cache initializations offloaded to an interpreter and delayed synchronization to reduce overhead, and the use of a flat array type to optimize array data access.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If locking mechanisms are added around each object access to ensure concurrency semantics, then reliability of concurrent execution is improved, but execution speed deteriorates significantly

Engineering Contradiction:
Improveconcurrency semanticsVSAvoidexecution speed
Core Design Contradiction:
ReliabilityVSSpeed

Solution Approach 1:

The patent extracts the locking mechanism from individual object access points and replaces it with a global sequential execution model. Instead of adding locks around each access, the system removes locks entirely and uses a different architectural approach where one thread executes sequentially while another performs type specialization, eliminating the speed penalty of locking while maintaining concurrency safety.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent introduces an intermediary mechanism where type specialization is performed separately from object access. The type-specialized code acts as an intermediary layer that pre-processes type information, allowing the main execution thread to run without locks while the type specialization thread handles the complex type-checking operations that would otherwise require synchronization.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Productivity

If inline cache uses self-modifying code to optimize JavaScript execution, then productivity is improved, but device complexity increases due to concurrency difficulties

Engineering Contradiction:
Improveexecution efficiencyVSAvoidconcurrency implementation complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent segments the JavaScript execution into two distinct threads: one dedicated to sequential execution of self-modifying inline cache code, and another dedicated to type specialization. This segmentation allows each thread to focus on its specific function without interfering with the other, maintaining the productivity benefits of self-modifying code while reducing concurrency complexity through clear separation of concerns.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent performs type specialization as a preliminary action before the main execution thread needs to access type information. By pre-computing type specializations in advance and storing them for later use, the system eliminates the need for complex synchronization during type checking, as the type information is already prepared and available when needed.

Inventive Principle:
Principle #10Preliminary action

3Adaptability or versatility

If out-of-line memory is allocated for additional object properties in dynamic languages, then adaptability is improved, but loss of time increases due to allocation overhead

Engineering Contradiction:
Improveobject property flexibilityVSAvoidallocation overhead
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

The patent performs preliminary allocation of property storage space when objects are created, rather than allocating memory on-demand when properties are added. By pre-allocating sufficient space for expected properties and using inline storage within the object structure, the system reduces the frequency of out-of-line allocations and the associated time overhead, while still maintaining the adaptability to add properties when needed.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentEP3039535B1Concurrent inline cache optimization in accessing dynamically typed objects
Publication Date: 2022.05.04 APPLE INC
  • EP3039535B1 patent drawingFigure 1
  • EP3039535B1 patent drawingFigure 2
  • EP3039535B1 patent drawingFigure 3

AI summary

A method and an apparatus for concurrent accessing of dynamically type objects based on inline cache code are described. Inline cache initialization in a single thread may be off loaded to an interpreter without incurring unnecessary synchronization overhead. A thread bias mechanism may be provided to detect whether a code block is executed in a single thread. Further, the number of inline cache initializations performed via a compiler, such as baseline JIT compiler, can be reduced to improve processing performance.