IP Library › Granted Patent US 12,625,706
Granted Patent B2
US 12,625,706 · App. 18/898,309 · Granted May 12, 2026

Instruction translation method and related device thereof

Inventors: Xianzhe Liu (Shanghai, CN); Jianjiang Zeng (Shanghai, CN); Yandong Lv (Shanghai, CN)
Assignee: HUAWEI TECHNOLOGIES CO., LTD.
G06F9/3017G06F9/4552
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,625,706
App. No.
18/898,309
Granted
May 12, 2026
Kind
B2
Abstract

Embodiments of this application disclose an instruction translation method. The method includes: obtaining a return instruction of a function call instruction; obtaining a first address mapping result based on a second address indicated in the return instruction; storing the first address mapping result in a running stack space; and obtaining a first translation result of the return instruction, where the first translation result is a binary translation result of the return instruction, and the second translation result indicates to obtain, from a target location, an instruction indicated by the first address mapping result and execute the instruction. In this application, a running stack space of a source program is reused, thereby saving a storage space. In addition, an address of a return instruction does not need to be checked each time the return instruction is translated, thereby reducing overheads during translation and increasing program running efficiency.

Claims (54)

1 . An instruction translation method, comprising:

obtaining a return instruction of a function call instruction to instruct to call an instruction indicated by a first address, and the return instruction is used to instruct to execute, after the instruction indicated by the first address is executed according to the function call instruction, an instruction indicated by a second address;

obtaining a first address mapping result based on the second address, wherein the first address mapping result is a mapping result of the second address;

storing the first address mapping result in a running stack space; and

obtaining a first translation result of the return instruction based on the return instruction, wherein the first translation result is a translation result of the return instruction, and the first translation result indicates to obtain, from the running stack space, an instruction indicated by the first address mapping result and execute the instruction.

2 . The method according to claim 1 , wherein the storing the first address mapping result in the running stack space comprises:

storing the first address mapping result at a target location in the running stack space, wherein the target location is a location corresponding to the second address in the running stack space.

3 . The method according to claim 1 wherein the second address is a source program counter (SPC), and the first address mapping result is a target program counter (TPC) of the second address.

4 . The method according to claim 1 , wherein after the storing the first address mapping result in the running stack space, the method further comprising:

replacing the first address mapping result in the running stack space with the second address based on an access request for the second address.

5 . The method according to claim 1 , wherein after the storing the first address mapping result in the running stack space, the second address is modified, the method further comprising:

obtaining a second address mapping result based on a modified second address, wherein the second address mapping result is a mapping result of the modified second address; and

executing an instruction indicated by the second address mapping result, and skipping executing the first address mapping result.

6 . The method according to claim 5 , wherein the obtaining the second address mapping result of the second address based on the modified second address comprises:

performing an address mapping on the modified second address, to obtain the second address mapping result.

7 . The method according to claim 1 , further comprising:

obtaining a second translation result based on the function call instruction, wherein the second translation result is a translation result of the function call instruction.

8 . An apparatus for an instruction translation, comprising:

a processor; and

a memory coupled to the processor to store instructions, which when executed by the processor, cause the apparatus to:

obtain a return instruction of a function call instruction to instruct to call an instruction indicated by a first address, and the return instruction is used to instruct to execute, after the instruction indicated by the first address is executed according to the function call instruction, an instruction indicated by a second address;

obtain a first address mapping result based on the second address, wherein the first address mapping result is a mapping result of the second address;

store the first address mapping result in a running stack space; and

obtain a first translation result of the return instruction based on the return instruction, wherein the first translation result is a translation result of the return instruction, and the first translation result indicates to obtain, from the running stack space, an instruction indicated by the first address mapping result and execute the instruction.

9 . The apparatus according to claim 8 , wherein the apparatus is further caused to

store the first address mapping result at a target location in the running stack space, wherein the target location is a location corresponding to the second address in the running stack space.

10 . The apparatus according to claim 8 , wherein the second address is a source program counter (SPC), and the first address mapping result is a target program counter (TPC) of the second address.

11 . The apparatus according to claim 8 , wherein the apparatus is further caused to:

after the first address mapping result is stored in the running stack space, replace the first address mapping result in the running stack space with the second address based on an access request for the second address.

12 . The apparatus according to claim 8 , wherein after the first address mapping result is stored in the running stack space, the second address is modified, the apparatus is further caused to:

obtain a second address mapping result based on a modified second address, wherein the second address mapping result is a mapping result of the modified second address; and

execute an instruction indicated by the second address mapping result, and skip executing the first address mapping result.

13 . A non-transitory computer-readable storage medium having instructions stored therein, which when executed by a processor, cause the processor to perform

obtaining a return instruction of a function call instruction to instruct to call an instruction indicated by a first address, and the return instruction is used to instruct to execute, after the instruction indicated by the first address is executed according to the function call instruction, an instruction indicated by a second address;

obtaining a first address mapping result based on the second address, wherein the first address mapping result is a mapping result of the second address;

storing the first address mapping result in a running stack space; and

obtaining a first translation result of the return instruction based on the return instruction, wherein the first translation result is a translation result of the return instruction, and the first translation result indicates to obtain, from the running stack space, an instruction indicated by the first address mapping result and execute the instruction.

14 . A computing device, comprising:

a processor; and

a memory coupled to the processor to store instructions, which when executed by the processor, cause the processor to perform

obtaining a return instruction of a function call instruction to instruct to call an instruction indicated by a first address, and the return instruction is used to instruct to execute, after the instruction indicated by the first address is executed according to the function call instruction, an instruction indicated by a second address;

obtaining a first address mapping result based on the second address, wherein the first address mapping result is a mapping result of the second address;

storing the first address mapping result in a running stack space; and

obtaining a first translation result of the return instruction based on the return instruction, wherein the first translation result is a translation result of the return instruction, and the first translation result indicates to obtain, from the running stack space, an instruction indicated by the first address mapping result and execute the instruction.

15 . The non-transitory computer-readable storage medium according to claim 13 , wherein the storing the first address mapping result in the running stack space comprises:

storing the first address mapping result at a target location in the running stack space, wherein the target location is a location corresponding to the second address in the running stack space.

16 . The non-transitory computer-readable storage medium according to claim 13 , wherein the second address is a source program counter (SPC), and the first address mapping result is a target program counter (TPC) of the second address.

17 . The non-transitory computer-readable storage medium according to claim 13 , wherein after the storing the first address mapping result in the running stack space, the instructions when executed by the processor, further cause the processor to perform:

replacing the first address mapping result in the running stack space with the second address based on an access request for the second address.

18 . The computing device according to claim 14 , wherein the storing the first address mapping result in the running stack space comprises:

storing the first address mapping result at a target location in the running stack space, wherein the target location is a location corresponding to the second address in the running stack space.

19 . The computing device according to claim 14 , wherein the second address is a source program counter (SPC), and the first address mapping result is a target program counter (TPC) of the second address.

20 . The computing device according to claim 14 , wherein after the storing the first address mapping result in the running stack space, the instructions when executed by the processor, further cause the processor to perform:

replacing the first address mapping result in the running stack space with the second address based on an access request for the second address.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 27, 2024
From: LIU, XIANZHE; ZENG, JIANJIANG; LV, YANDONG
To: HUAWEI TECHNOLOGIES CO., LTD.
Reel/Frame 068726/0737 →
Priority Claims (1)
CN 202210346585.7 · Mar 31, 2022 · national
Continuity (2)
Continuation PCTCN2023084280 · Mar 28, 2023
Related Publication 20250013468A1 · Jan 9, 2025
References Cited (14)
US 6615300B1 · Banning et al. · 2003 [cited by applicant]
US 6711672B1 · Agesen · 2004 [cited by examiner]
US 7290253B1 · Agesen · 2007 [cited by examiner]
US 9477453B1 · Ince · 2016 [cited by examiner]
US 9817642B2 · Xekalakis · 2017 [cited by examiner]
US 20090254709A1 · Agesen · 2009 [cited by examiner]
US 20130024675A1 · Lovett · 2013 [cited by examiner]
US 20160179547A1 · Yamada · 2016 [cited by examiner]
US 20180285113A1 · Ko · 2018 [cited by examiner]
CN 106873944A · 2017 [cited by applicant]
Amanieu DAntras et al: “Optimizing Indirect Branches in Dynamic Binary Translators”, ACM Transactions on Architecture and Code Optimization, Association for Computing Machinery, Apr. 5, 2016, total 25 pages. [cited by applicant]
Raymond J. Hookway et al: “Digital FX!32: combining emulation and binary translation.” Digital Technical Journal, vol. 9, Issue 1. Jan. 1, 1997, total 10 pages. [cited by applicant]
Swaroop Sridhar et al: “HDTrans: a low-overhead dynamic translator.” Mar. 1, 2007, total 6 pages. [cited by applicant]
Jason D. Hiser et al: “Evaluating Indirect Branch Handling Mechanisms in Software Dynamic Translation Systems.” Jul. 2011, 28 pages. [cited by applicant]