Patent ID: 6662354
Filing Date: 2003-12-09
Classification: G06F

Abstract:
A method of translating compiled programming code from a first code state to a second code state, the programming code in the first code state comprising a plurality of basic blocks, each basic block comprising a set of instructions, at least one basic block ending in a dynamic branch, the dynamic branch being a transfer to one of a set of destinations based on a calculation of a destination address, the method comprising the steps of:identifying the plurality of basic blocks in the first code state of the programming code; identifying links between the identified basic blocks; constructing a control flow graph/representation (CFG) of the programming code based on the identified basic blocks and identified links, the CFG being in a preliminary form; identifying at least one basic block ending in a dynamic branch; exploring, based on the CFG, all identified basic blocks that lead to the dynamic branch as far back as is necessary to fully determine a set of destination addresses for the dynamic branch, the set of destination addresses defining the set of destinations from the dynamic branch, wherein the exploring step includes the substeps of: (a). for each explored basic block, constructing a corresponding code graph/representation (code graph) of the instructions in such basic block, wherein each code graph is a rooted directed acyclic graph having interconnected nodes, and each node being one of: an instruction node representing an instruction in the corresponding basic block; an argument node representing an argument in the corresponding basic block; an apply node edging to an instruction node and to an argument node and representing the application of such argument node to such instruction node, the apply node in certain instances also being an argument node edged to by another node; a stack node edging to a pair of argument nodes and acting as an argument node having the pair of argument nodes; a missing argument node representing a missing argument supplied from a different basic block; and, an alias node edged to by a stack node or apply node and edging to an argument remote from such stack node, and representing such remote argument to such stack node; (b). noting that a first code graph corresponding to a first basic block contains a missing/insufficiently defined argument node; (c). locating, based on the CFG, a second basic block that immediately precedes the first basic block, a second code graph corresponding to the second basic block; (d). constructing a new code graph having the first code graph and the second code graph by replacing the missing argument node in the first code graph with the second code graph; and, (e). traversing each code graph including the new code graph to determine the set of destination addresses from the dynamic branch; examining the set of destinations to identify a branch table; updating the CFG to reflect the set of destinations and the identified branch table; and, translating the programming code from the first code state to the second code state based at least in part on the updated CFG.