1. A method for upgrading software represented as a graph having a plurality of states and a plurality of state transitions where a plurality of tokens traverse the graph executing functions, comprising: identifying a target region of the graph; obtaining a new region for the graph; determining a correspondence between states of the target region of the graph and states of the new region for the graph; and replacing the target region of the graph with the new region for the graph using the correspondence between states of the target region of the graph and states of the new region for the graph.