Programming language support for integrating undo and exception handling
AssigneeMicrosoft Corporation
InventorsAvraham E. Shinnar, David Read Tarditi, Jr., Bjarne Steensgaard
Life of this patent
Estimating the term…
Abstract
Existing methods for returning program state to a previous state are often too heavy weight. Often these methods attempt to guarantee a series of properties to a programmer across a distributed environment or multiple threads. Instead, a program state reversion mechanism provides a light weight and efficient runtime solution for general purpose programming languages. For example, a series of program statements (e.g., methods, instructions, etc.) are indicated by a programmer in a state reversion language construct, such as a TryAll block. If an exception is thrown anywhere from within the TryAll block, the program is reverted to the pre-TryAll block state.
Claims22
A computerized method comprising:
- providing language constructs to applications programmers comprising program state reversion constructs;
- receiving, in a computer, a representation of a program having one or more program state reversion constructs comprising a reversion indication construct indicating a series of instructions to revert, wherein the series of instructions to revert comprises less than all of the instructions in a method;
- inserting code into the program comprising:
- code for recording program state before modifications are made by the series of instructions indicated by the reversion indication construct, and saving the program state in one or more data structures, and
- code for reverting program state to the recorded program state when an exception arises from the series of instructions indicated by the reversion indication construct;
- and
- executing the program and inserted code comprising:
- recording program state in the one or more data structures prior to executing the series of instructions indicated by the reversion indication construct, wherein the one or more data structures comprises a first linked list saving program state for value types that are changed in heap memory, a second linked list saving program state for value types that are changed in non-heap memory, a third linked list saving program state for object references that are changed in heap memory and a fourth linked list for saving program state for object references that are changed in non-heap memory;
- and
- upon generating an exception while executing the series of instructions indicated by the reversion indication construct, reverting program state according to the recorded program state.
A computer-readable storage medium having stored thereon computer-executable instructions for performing a method comprising:
- receiving, in a computer, a representation of a program having one or more program state reversion constructs comprising a reversion indication construct indicating a series of instructions to revert, wherein the series of instructions to revert comprises less than all of the instructions in a method;
- inserting code into the program comprising:
- code for recording program state before modifications are made by the series of instructions indicated by the reversion indication construct, and saving the program state in one or more data structures, and
- code for reverting program state to the recorded program state when an exception arises from the series of instructions indicated by the reversion indication construct;
- and
- executing the program and inserted code comprising:
- recording program state in the one or more data structures prior to executing the series of instructions indicated by the reversion indication construct, wherein the one or more data structures comprises a first linked list saving program state for value types that are changed in heap memory, a second linked list saving program state for value types that are changed in non-heap memory, a third linked list saving program state for object references that are changed in heap memory and a fourth linked list for saving program state for object references that are changed in non-heap memory;
- and
- upon generating an exception while executing the series of instructions indicated by the reversion indication construct, reverting program state according to the recorded program state.
A computer system comprising:
- computer memory and a central processing unit;
- a program comprising instructions and a reversion indicator identifying plural revertible instructions, wherein the plural revertible instructions comprises less than all of the instructions in a method;
- a compiler for modifying the program to record program state modifications made by the plural revertible instructions;
- a program state-modification data structure storing modifications to a stack made by the plural revertible instructions, the data structure comprising a first linked list saving program state for value types that are changed in heap memory, a second linked list saving program state for value types that are changed in non-heap memory, a third linked list saving program state for object references that are changed in hear memory and a fourth linked list for saving program state for object references that are changed in non-heap memory;
- and
- reversion logic for restoring the program state to state of program prior to execution of the reversion indicator according to the program state-modification data structure, upon receiving an exception thrown while executing the plural revertible instructions.
A computer-readable medium having thereon computer-executable instructions for performing a method comprising:
- providing language constructs comprising program state reversion constructs;
- receiving a representation of a program having one or more program state reversion constructs comprising a reversion indication construct indicating a series of instructions to revert;
- inserting code into the program comprising:
- code for recording program state before modifications are made by the series of instructions indicated by the reversion indication construct, and
- code for reverting program state to recorded values when an exception arises from the series of instructions indicated by the reversion indication construct;
- and
- executing the program and inserted code comprising:
- recording program state prior to executing the series of instructions indicated by the reversion indication construct in a data structure indicated for stack modifications, the data structure comprising a first linked list saving program state for value types that are changed in heap memory, a second linked list saving program state for value types that are changed in non-heap memory, a third linked list saving program state for object references that are changed in heap memory and a fourth linked list for saving program state for object references that are changed in non-heap memory, and
- upon generating an exception while executing the series of instructions indicated by the reversion indication construct, reverting program state according to the recorded program state.
Dependencies are inferred from the claim text.