Runtime Type Identification Using Pointer Bit Encoding

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing runtime type identification (RTTI) methods in object-oriented programming languages are inefficient due to the need for multiple pointer dereferences and high memory consumption, especially in operations like dynamic_cast, which impact performance and are error-prone in maintaining class inheritance relationships.

Innovation Solution

Generating class inheritance relationship tables during compilation and encoding type identification data in unused bits of memory addresses of pointers, allowing for efficient RTTI by reducing the number of dereferences and memory usage, and automating the process to improve runtime performance.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If traditional RTTI methods are used with multiple pointer dereferences, then type identification can be performed, but runtime performance deteriorates and operation complexity increases

Engineering Contradiction:
Improvetype identification accuracyVSAvoidruntime performance
Core Design Contradiction:
Measurement precisionVSProductivity

Solution Approach 1:

The patent applies preliminary action by encoding type identification information into pointer memory addresses during compilation. The compiler modifies pointers to include type IDs in unused bits of the memory address, so that runtime type identification can be performed by simply reading the pointer value without any dereferencing operations. This pre-prepared information enables fast RTTI at runtime.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent extracts type identification information from separate data structures and embeds it directly into the pointer itself. By taking out the type ID from external class metadata and incorporating it into the pointer's memory address, the system eliminates the need for multiple pointer dereferences to access type information, thereby improving runtime performance.

Inventive Principle:
Principle #2Taking out (Extraction)

2Loss of information

If type identification data is stored separately from pointers, then type information can be maintained, but memory consumption increases

Engineering Contradiction:
Improvetype information preservationVSAvoidmemory consumption
Core Design Contradiction:
Loss of informationVSQuantity of substance

Solution Approach 1:

The patent merges type identification information with the pointer by embedding the type ID into unused bits of the pointer's memory address. This combining of the pointer and type ID into a single data structure eliminates the need for separate storage of type information, thereby reducing memory consumption while preserving complete type identification capability.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The patent makes the pointer multi-functional by enabling it to serve both as a memory address reference and as a type identification carrier. The same pointer value simultaneously provides the object's location and its type information, eliminating redundant storage and reducing overall memory consumption.

Inventive Principle:
Principle #6Universality (Multi-functionality)

3Measurement precision

If manual maintenance of class inheritance relationships is required, then type identification can be implemented, but ease of operation deteriorates and error probability increases

Engineering Contradiction:
Improveinheritance relationship accuracyVSAvoidmaintenance complexity
Core Design Contradiction:
Measurement precisionVSEase of operation

Solution Approach 1:

The patent applies self-service by enabling the compiler to automatically generate and encode type identification information based on the source code's class inheritance relationships. The compilation process automatically analyzes the inheritance structure, assigns unique type IDs, and embeds them into pointers without requiring any manual intervention, thereby eliminating maintenance complexity and reducing errors.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The patent performs preliminary analysis of class inheritance relationships during compilation. The compiler pre-processes the source code to understand the inheritance hierarchy, generates appropriate type IDs, and encodes them into pointers before runtime execution. This preliminary preparation eliminates the need for manual maintenance during operation.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS11307837B2Runtime type identification of an object utilizing class inheritance relationships
Publication Date: 2022.04.19 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US11307837B2 patent drawing
  • US11307837B2 patent drawing
  • US11307837B2 patent drawing

AI summary

Embodiments of the present disclosure relate to runtime type identification (RTTI) of an object. In an embodiment, a computer-implemented method is disclosed. A class inheritance relationship between a plurality of classes in at least one source code section is generated. Respective type identifications are assigned to identify the classes in the class inheritance relationship. In accordance with presence of a first operation related to accessing a target pointer to an object of a target class of the classes, a type identification for the target class is caused to be recorded with at least one bit of a memory address of the target pointer that can be omitted in addressing the target pointer. RTTI is caused to be performed based on the class inheritance relationship and the at least one bit of the memory address of the target pointer. In other embodiments, a system and a computer program product are disclosed.