Dynamic code injection
AssigneeInternational Business Machines Corporation
InventorsMichael H. Dawson, Graeme Johnson, San Hong Li
Life of this patent
Estimating the term…
Abstract
Embodiments of the present invention disclose an approach for inserting code into a running thread of execution. A computer sets a first set of bits to a first value, wherein the first value indicates that a first set of instructions should be inserted onto a stack. The computer executes a second set of instructions associated with a first safepoint, wherein the second set of instructions comprises one or more instructions to determine if the first set of bits is set to the first value. The computer determines that the first set of bits is set to the first value, and the computer inserts the first set of instructions onto the stack.
Claims16
A computer program product for inserting code into a running thread of execution, the computer program product comprising:
- one or more computer-readable storage media and program instructions stored on the one or more computer-readable storage media, the program instructions comprising:
- program instructions to set a first one or more bits to a first value, wherein the first value indicates that no set of instructions should be inserted onto a stack of a thread until the first one or more bits is set to a second value;
- program instructions to execute a first set of instructions associated with a first safepoint, wherein the first set of instructions comprises one or more instructions to determine if a second one or more bits is set to a third value, wherein the third value indicates that a second set of instructions should be inserted onto the stack of the thread;
- program instructions to determine that the second one or more bits is set to the third value;
- program instructions to set a third one or more bits to a fourth value, wherein the fourth value indicates that the second set of instructions should be inserted onto the stack, based at least in part on execution of a third set of instructions associated with a second safepoint;
- program instructions to set the first one or more bits to the second value, wherein the second value indicates that the thread can safely execute the third set of instructions associated with the second safepoint and insert the second set of instructions onto the stack;
- program instructions to execute the third set of instructions associated with the second safepoint;
- and
- program instructions to insert the second set of instructions onto the stack.
A computer system for inserting code into a running thread of execution, the computer system comprising:
- one or more computer processors;
- one or more computer-readable storage media;
- program instructions stored on the computer-readable storage media for execution by at least one of the one or more processors, the program instructions comprising:
- program instructions to set a first one or more bits to a first value, wherein the first value indicates that no set of instructions should be inserted onto a stack of a thread until the first one or more bits is set to a second value;
- program instructions to execute a first set of instructions associated with a first safepoint, wherein the first set of instructions comprises one or more instructions to determine if a second one or more bits is set to a third value, wherein the third value indicates that a second set of instructions should be inserted onto the stack of the thread;
- program instructions to determine that the second one or more bits is set to the third value;
- program instructions to set a third one or more bits to a fourth value, wherein the fourth value indicates that the second set of instructions should be inserted onto the stack, based at least in part on execution of a third set of instructions associated with a second safepoint;
- program instructions to set the first one or more bits to the second value, wherein the second value indicates that the thread can safely execute the third set of instructions associated with the second safepoint and insert the second set of instructions onto the stack;
- program instructions to execute the third set of instructions associated with the second safepoint;
- and
- program instructions to insert the second set of instructions onto the stack.
Dependencies are inferred from the claim text.