Dynamic Type Generation via Template Method Cloning

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Emitting code at runtime for dynamic types is currently difficult, time-consuming, and error-prone, requiring developers to manually write procedures in low-level languages that are then compiled into assemblies, making it cumbersome to generate complex functions and modify existing code.

Innovation Solution

A process that clones a previously compiled method, injecting custom code at marked locations to alter its behavior, and compiling the resulting dynamic code, which reduces complexity and error by leveraging a compiler-generated template method.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If developers manually write procedures in low-level languages to emit code at runtime for dynamic types, then code generation is possible, but the process becomes difficult, time-consuming, and error-prone

Engineering Contradiction:
Improvecode generation efficiencyVSAvoidcomplexity of code generation process
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent applies preliminary action by pre-compiling template methods into assembly code before runtime needs them. These template methods contain placeholder instructions that will be replaced with custom code later. This preparation work is done in advance, so when dynamic code generation is needed at runtime, the system only needs to perform simple substitution operations rather than generating entire procedures from scratch in low-level languages.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent uses copying by creating clones of pre-compiled template methods. Instead of manually writing new low-level procedures each time dynamic code is needed, the system copies existing template method structures and injects custom logic into them. This copying approach reuses proven, compiler-optimized code frameworks while allowing customization, dramatically reducing the effort and error rate compared to manual low-level programming.

Inventive Principle:
Principle #26Copying

2Adaptability or versatility

If developers manually write procedures in low-level languages to emit code at runtime, then dynamic type code can be generated, but the process becomes cumbersome and error-prone

Engineering Contradiction:
Improveflexibility of dynamic code generationVSAvoidease of code generation
Core Design Contradiction:
Adaptability or versatilityVSEase of operation

Solution Approach 1:

The patent introduces an intermediary layer consisting of template methods that act as mediators between the high-level customization needs and the low-level assembly code requirements. Developers work with high-level template definitions and customization parameters rather than directly writing assembly instructions. The template system automatically handles the translation and injection processes, providing an intermediary interface that is both adaptable to different customization needs and easy to operate.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Ease of manufacture

If pre-compiled template methods are cloned and custom code is injected, then code generation is simplified, but compilation time may increase

Engineering Contradiction:
Improvesimplicity of code generation processVSAvoidcompilation time
Core Design Contradiction:
Ease of manufactureVSLoss of time

Solution Approach 1:

The patent applies preliminary action by performing the complex compilation work in advance when template methods are created, rather than at runtime when they are needed. The template methods are pre-compiled into assembly with placeholder instructions during the development phase. At runtime, only simple code injection and final linking operations are required, which are much faster than full compilation. This shifts the time investment to when it doesn't impact performance-critical operations.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS9141356B2Process for generating dynamic type
Publication Date: 2015.09.22 MICROSOFT TECHNOLOGY LICENSING LLC
  • US9141356B2 patent drawing
  • US9141356B2 patent drawing
  • US9141356B2 patent drawing

AI summary

A process for generating dynamic type is disclosed. A compiler generated template method including a mark for custom instruction is selected for cloning. Dynamic code is injected at the mark for the custom instructions. The template method including the injected dynamic code is compiled.