摘要 |
Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, for receiving source code that contains a hot function that calls a multiversioned function, where a function definition of the multiversioned function specifies a first version and an alternative second version, and generating compiled code that includes a first and a second clone of the hot function, and a first and a second version of the multiversioned function. In the compiled code, the first clone of the hot function includes a direct call to the first version of the multiversioned function, and the second clone of the hot function includes a direct call to the second version of the multiversioned function. |
主权项 |
1. A computer-implemented method comprising:
receiving source code that contains a cold function and a hot function, the hot function calls a multiversioned function, wherein a function definition of the multiversioned function specifies a first version and an alternative second version; conducting a dispatch check, wherein the dispatch check is hoisted from the hot function to the cold function for initiation; generating compiled code that includes: (1) a first clone of the hot function and a first version of the multiversioned function, wherein the first clone of the hot function includes a direct call to the first version of the multiversioned function, and (2) a second clone of the hot function and a second version of the multiversioned function, wherein the second clone of the hot function includes a direct call to the second version of the multiversioned function, wherein the cold function, the hot function, the first clone, the first version, the second clone, and the second version are distinct from each other; determining whether to use the first version of the multiversioned function or the second version of the multiversioned function, the determination based at least in part on the dispatch check; and selecting, based on the determination, either the first clone and first version of the multiversioned function or the second clone and the second version of the multiversioned function. |