IP Library › Granted Patent US 12,333,319
Granted Patent B2
US 12,333,319 · App. 18/129,782 · Granted Jun 17, 2025

Tracing just-in-time WASM compiler

Inventor: Katelyn Tera Gadd (Seattle, WA)
Assignee: Microsoft Technology Licensing, LLC.
G06F9/4552G06F9/45508
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,333,319
App. No.
18/129,782
Granted
Jun 17, 2025
Kind
B2
Abstract

An interpreter interacts with a tracing Just-In-Time (JIT) WebAssembly (WASM) compiler to compile frequently-executed interpreter opcodes into WASM code. The interpreter monitors the frequency of the execution of targeted locations of the interpreter opcodes of a web application to determine the most frequently executed linear sequences of the interpreter opcodes. The execution of the WASM code is monitored for execution failure before replacing the linear sequence of opcodes with an entry point opcode that immediately executes the WASM code without monitoring the execution failure of the WASM code.

Claims (63)

1. A system comprising:

one or more processors; and

a memory that stores an interpreter and a tracing Just-In-Time (JIT) WebAssembly (WASM) compiler that are configured to be executed by the one or more processors within a web browser in a sandbox execution environment,

wherein the interpreter includes instructions that perform acts to:

obtain a plurality of interpreter opcodes of a web application to execute;

insert at least one prepare point opcode in a select location of the plurality of interpreter opcodes;

upon execution of the at least one prepare point opcode for more than a first threshold value, invoke the tracing JIT WASM compiler to transform a linear sequence of the plurality of interpreter opcodes into WASM code;

upon successful compilation of the linear sequence of the plurality of interpreter opcodes into WASM code, replace the at least one prepare point opcode into a monitoring point opcode, wherein the monitoring point opcode is associated with the WASM code;

upon execution of the monitoring point opcode, initiate execution of the WASM code in a WASM runtime and monitor execution frequency of the monitoring point opcode; and

upon successful execution of the WASM code for more than a third threshold value, replace the monitoring point opcode with an entry point opcode.

2. The system of claim 1 , wherein the interpreter includes instructions that perform acts to:

track execution status of the monitoring point opcode; and

upon the WASM code failing to execute successfully for more than a second threshold value, discard the monitoring point opcode and resume interpretation of the opcodes associated with the monitoring point opcode.

3. The system of claim 1 , wherein the interpreter includes instructions that perform acts to:

receive in the browser, bytecodes of a web application; and

transform the bytecodes of the web application into the plurality of interpreter opcodes, wherein the bytecodes of the web application differ from the interpreter opcodes.

4. The system of claim 1 , wherein the interpreter includes instructions that perform acts to:

upon execution of the entry point opcode, initiate execution of the WASM code without monitoring execution frequency of the WASM code.

5. The system of claim 1 , wherein the interpreter includes instructions that perform acts to:

insert the at least one prepare point at a beginning of a method, start of basic block after a function call or at target of a backward branch.

6. The system of claim 1 , wherein the interpreter includes instructions that perform acts to:

upon the linear sequence of the plurality of interpreter opcodes failing to compile into WASM code, replace the prepare point opcode with no_op opcode.

7. The system of claim 1 , wherein the JIT WASM compiler includes instructions that perform acts to: compile the linear sequence of the plurality of interpreter opcodes until an unsupported opcode is reached.

8. The system of claim 1 ,

wherein the interpreter includes instructions that perform acts to: recognize an execution failure during execution of the WASM code for a failed opcode; and return control back to the interpreter.

9. A computer-implemented method of an interpreter, comprising:

obtaining within a browser, a plurality of interpreter opcodes associated with a web application, wherein the browser includes the interpreter and a tracing Just-in-Time (JIT) WebAssembly (WASM) compiler;

executing each of the plurality of interpreter opcodes;

tracking execution of a select one of the plurality of interpreter opcodes, wherein the select one of the plurality of interpreter opcodes comprises a prepare point opcode;

upon the execution of the prepare point opcode exceeding a first threshold value, invoking the tracing JIT WASM compiler to compile a sequence of the plurality of interpreter opcodes starting immediately after the prepare point opcode into WASM code;

upon successful compilation of the sequence of the plurality of interpreter opcodes, replacing the prepare point opcode into a monitoring point opcode, wherein the monitoring point opcode is associated with the WASM code;

upon execution of the monitoring point opcode, initiating execution of the WASM code in a WASM runtime and monitoring execution frequency of the monitoring point opcode; and

upon successful execution of the WASM code for more than a third threshold value, replacing the monitoring point opcode with an entry point opcode.

10. The computer-implemented method of claim 9 , further comprising:

upon the WASM code failing to successfully execute more than a second threshold value, discarding the WASM code and interpreting the interpreter opcodes associated with the discarded WASM code.

11. The computer-implemented method of claim 9 , wherein the select one of the plurality of interpreter opcodes is positioned at a start of a method, at a start of basic block after a function call and/or at a target of a backward branch.

12. The computer-implemented method of claim 9 , further comprising:

upon unsuccessful compilation of the sequence of the plurality of interpreter opcodes, stopping the tracking of the select one of the plurality of interpreter opcodes.

13. The computer-implemented method of claim 9 , further comprising:

compiling, by the tracing JIT WASM compiler, interpreter opcodes starting immediately after the select one of the plurality of interpreter opcodes until an unsupported opcode is reached.

14. The computer-implemented method of claim 9 , further comprising:

operating the interpreter and the JIT compiler in a sandbox execution environment; and

wherein the interpreter and the JIT compiler share data of an interpreter stack frame.

15. The computer-implemented method of claim 9 , further comprising:

receiving in the browser, bytecodes of a web application; and

transforming the bytecodes of the web application into the plurality of interpreter opcodes, wherein the bytecodes of the web application differ from the interpreter opcodes.

16. One or more hardware storage devices having stored thereon computer executable instructions that are structured to be executable by one or more processors of a computing device to thereby cause the computing device to performing actions that:

configure a sandbox execution environment in a web browser, wherein an interpreter and a tracing Just-in-Time (JIT) WebAssembly (WASM) compiler execute within the sandbox execution environment;

receive a plurality of interpreter opcodes of a web application to execute, wherein at least one of the plurality of interpreter opcodes including a prepare point opcode;

upon execution of the prepare point opcode by the interpreter for over a threshold value, initiate the tracing JIT WASM compiler to compile a trace, wherein the trace includes WASM code for a linear sequence of the plurality of interpreter opcodes starting from a location of the prepare point opcode until an unsupported opcode is reached;

replace the prepare point opcode with a monitoring point opcode;

upon execution of the monitoring point opcode, initiate execution of the trace in a WASM runtime environment and monitor execution frequency of the monitoring point opcode; and

upon successful execution of the trace in the WASM runtime environment for more than a third threshold value, replace the monitoring point opcode with an entry point opcode.

17. The one or more hardware storage devices of claim 16 , having computer executable instructions that perform actions that:

track execution status of the monitoring point opcode; and

upon the trace failing to execute successfully for more than a second threshold value, discard the monitoring point opcode and the trace.

18. The one or more hardware storage devices of claim 16 , having computer executable instructions that perform actions that:

track execution status of the monitoring point opcode; and

upon the WASM code failing to execute successfully for more than a second threshold value, discard the monitoring point opcode and resume interpretation of the opcodes associated with the monitoring point opcode.

19. The one or more hardware storage devices of claim 18 , having computer executable instructions that perform actions that:

upon execution of the entry point opcode, initiate execution of the WASM code without monitoring execution frequency of the WASM code.

20. The one or more hardware storage devices of claim 16 , having computer executable instructions that perform actions that:

insert the at least one prepare point at a beginning of a method, start of basic block after a function call or at target of a backward branch of the web application.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Apr 4, 2023
From: GADD, KATELYN TERA
To: MICROSOFT TECHNOLOGY LICENSING, LLC.
Reel/Frame 063220/0647 →
Continuity (1)
Related Publication 20240330029A1 · Oct 3, 2024
References Cited (24)
US 5970249A · Hoelzle et al. · 1999 [cited by applicant]
US 5995754A · Holzle · 1999 [cited by examiner]
US 6009517A · Bak et al. · 1999 [cited by applicant]
US 6513156B2 · Bak et al. · 2003 [cited by applicant]
US 11188361B1 · Hildenbrand · 2021 [cited by examiner]
US 20110314452A1 · Tillmann · 2011 [cited by examiner]
US 20120159193A1 · Spradlin · 2012 [cited by examiner]
US 20140237458A1 · Elias · 2014 [cited by examiner]
US 20140282431A1 · Delio, Jr. · 2014 [cited by examiner]
US 20150169357A1 · Busaba · 2015 [cited by examiner]
US 20190114150A1 · Ogasawara · 2019 [cited by examiner]
US 20190340103A1 · Nelson · 2019 [cited by examiner]
US 20200241855A1 · McCallum · 2020 [cited by examiner]
US 20200341741A1 · Brooker · 2020 [cited by examiner]
US 20210103453A1 · Wang · 2021 [cited by examiner]
US 20210182040A1 · Tiwary · 2021 [cited by examiner]
US 20220197777A1 · Souders · 2022 [cited by examiner]
US 20220207146A1 · Rozas · 2022 [cited by examiner]
US 20240143329A1 · Sun · 2024 [cited by examiner]
Sansonetti, Mono and WebAssembly—Updates on Static Compilation Jan. 16, 2018 retrieved from https://www.mono-project.com/news/2018/01/16/mono-static-webassembly-compilation/ on Oct. 7, 2024 (Year: 2018). [cited by examiner]
Rossberg, et al., “Bringing the Web Up to Speed with WebAssembly”, In Journal of Communications of the ACM, vol. 61, Issue 12, Dec. 2018, pp. 107-115. [cited by applicant]
Salim, et al., “TruffleWasm: AWebAssembly Interpreter on GraalVM”, In Proceedings of the 16th ACM SGIPLAN/SIGOPS International Conference on Virtual Execution Environments, Mar. 17, 2020, 13 Pages. [cited by applicant]
Smith, Will, “TraceMonkey: Trace-based Just-in-Time Compilation for JavaScript and Other Dynamic Languages”, Retrieved From: https://www.cs.cornell.edu/courses/cs6120/2020fa/blog/tracemonkey/, Nov. 29, 2020, 10 Pages. [cited by applicant]
Titzer, Benl. , “A Fast In-Place Interpreter for WebAssembly”, In Proceedings of the ACM on Programming Languages, vol. 6, Issue OOPSLA2, Article 148, Oct. 31, 2022, 27 Pages. [cited by applicant]