Virtual Machine Native Method Handle Register Bypass

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

The Java Native Interface (JNI) requires static declaration and compilation of native functions, limiting its flexibility with struct or pointer arguments, and necessitates knowledge of native languages, making it inefficient for invoking native functions using MethodHandle objects.

Innovation Solution

A reduced overhead methodology that stores arguments directly into physical registers from memory accessible by the virtual machine, using a function descriptor and Application Binary Interface (ABI) to move arguments directly into CPU registers, eliminating the need for intermediate buffers and preprocessing each argument serially based on the function descriptor and ABI.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If an intermediate buffer is used to pass arguments from Java code to native function, then flexibility with different native functions is improved, but processing overhead increases

Engineering Contradiction:
Improveflexibility with different native functionsVSAvoidprocessing overhead
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

The patent uses an intermediate buffer as a mediator between Java arguments and native function parameters. The buffer serves as a temporary storage location where Java arguments are placed before being moved to machine registers by assembly routines. This intermediary approach enables flexible invocation of different native functions through a generic protocol while managing the trade-off of additional processing steps.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The argument passing process is segmented into distinct phases: Java code places arguments in buffer slots, assembly routines move arguments from buffer to registers, and native functions execute with registered parameters. This segmentation allows for systematic handling of different argument types and enables optimization of each phase independently.

Inventive Principle:
Principle #1Segmentation

2Adaptability or versatility

If JNI is used to invoke native functions, then ability to call native code is improved, but complexity of implementation increases

Engineering Contradiction:
Improveability to call native codeVSAvoidcomplexity of implementation
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent creates a universal MethodHandle-based interface that can invoke different native functions through a single generic protocol. Instead of requiring separate JNI declarations for each native function, the system uses a unified MethodHandle object that can be configured to call various native functions, reducing implementation complexity while maintaining versatility.

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

Solution Approach 2:

The system copies the functionality of traditional JNI into the MethodHandle framework, allowing native function invocation capabilities to be replicated through a different, more flexible mechanism. This copying approach enables the same native code calling capability to be achieved without the complexity of traditional JNI static declarations.

Inventive Principle:
Principle #26Copying

3Adaptability or versatility

If assembly routines are used to move arguments from buffer to registers, then ability to pass complex arguments is improved, but processing overhead increases

Engineering Contradiction:
Improveability to pass complex argumentsVSAvoidprocessing overhead
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

The patent replaces high-level Java argument passing mechanisms with low-level assembly routines that directly manipulate machine registers. This substitution enables precise control over argument transmission, allowing complex arguments including structs and pointers to be efficiently passed to native functions by bypassing Java's type system limitations.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

Data Source

PatentUS11875168B2Optimizing execution of foreign method handles on a virtual machine
Publication Date: 2024.01.16 ORACLE INT CORP
  • US11875168B2 patent drawing
  • US11875168B2 patent drawing
  • US11875168B2 patent drawing

AI summary

Techniques for reducing overhead in native function calls are disclosed. The system may receive a method invocation instruction for invoking a particular method. The method invocation instruction includes a function descriptor, a method type, and an application binary interface (ABI) descriptor. The function descriptor includes a memory layout corresponding to any data returned by the function and memory layouts corresponding to each argument for the particular method. The system can select an ABI for processing the particular method based on the received ABI descriptor. The system can further associate each argument with a corresponding particular physical register into which the argument is to be loaded. The particular register is selected based on at least the selected ABI and the function descriptor. The system can cause a virtual machine to move each argument into the corresponding associated physical register.