WebAssembly Compiler Reflection Code Annotation Scanning

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing compilation methods for WebAssembly (Wasm) struggle with efficiently compiling code that includes reflection functionality, leading to larger compilation results and reduced performance due to unnecessary functions being compiled.

Innovation Solution

A method and compiler that scan reflection functionality code, use annotations to identify required classes and functions, and compile only those specified, thereby reducing the size of the compilation result and improving performance by implementing 'compilation on demand'.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If all functions in depended classes are compiled together, then the code is complete and can be executed, but the compilation result size increases and performance decreases

Engineering Contradiction:
Improvecode executabilityVSAvoidcompilation result size
Core Design Contradiction:
ReliabilityVSQuantity of substance

Solution Approach 1:

The patent extracts only the necessary functions from depended classes based on annotation information. The compiler scans reflection functionality code, obtains class and function information through annotations, and selectively compiles only those functions that are actually needed, rather than compiling all functions in all depended classes.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent segments the compilation process into two stages: first scanning and analyzing reflection functionality code to identify required classes and functions through annotations, then selectively compiling only the identified functions. This segmentation allows the compiler to process code in a more controlled, demand-driven manner.

Inventive Principle:
Principle #1Segmentation

2Reliability

If all functions in depended classes are compiled together, then the code is complete and can be executed, but the compiler complexity and workload increase

Engineering Contradiction:
Improvecode executabilityVSAvoidcompiler complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent performs preliminary scanning and analysis of reflection functionality code before compilation. The compiler first scans the code to identify which classes and functions are needed based on annotations, and only then proceeds to compile the selected functions. This preliminary action reduces the compiler's workload during the actual compilation process.

Inventive Principle:
Principle #10Preliminary action

3Adaptability or versatility

If more code is loaded into linear memory, then the Wasm virtual machine has more functionality available, but the performance decreases

Engineering Contradiction:
Improvevirtual machine functionalityVSAvoidvirtual machine performance
Core Design Contradiction:
Adaptability or versatilityVSProductivity

Solution Approach 1:

The patent extracts only the necessary code into the Wasm virtual machine's linear memory. By scanning annotations in the source code, the compiler identifies which classes and functions are actually needed and includes only those in the compilation result, rather than loading all possible code into memory.

Inventive Principle:
Principle #2Taking out (Extraction)

Data Source

PatentUS20250199785A1Compilation methods, compilers, and wasm virtual machines
Publication Date: 2025.06.19 ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
  • US20250199785A1 patent drawing
  • US20250199785A1 patent drawing
  • US20250199785A1 patent drawing

AI summary

Compiling code comprising reflection functionality is described. A computer-implemented method includes scanning, by a compiler, reflection functionality code starting from a program entry of the code, and obtaining, based on an annotation and as a used class, a class used in the reflection functionality code and a function used by the class. Code of the used class and the function used by the class are added, by the compiler to a list of code to be compiled, in a class upon which the code comprising reflection functionality depends, where the code of the used class and the function used by the class are obtained based on the annotation. The list of code to be compiled is compiled by the compiler to obtain WebAssembly bytecode. The computer-implemented method can be applied to a blockchain.