发明名称 Observation and analysis based code optimization
摘要 Observation and analysis based optimization of software code is disclosed. An expected value is chosen for a dynamic attribute that cannot be determined, prior to execution of the associated software code, to be guaranteed to have that expected value at runtime. An optimized version of the software code is generated, including one or more optimizations based on an assumption that the dynamic attribute will have the expected value. Non-exhaustive examples of a dynamic attribute include a variable type; a location in memory; a location in which a global object, property, or variable is stored; the contents of a global function or method; and a value of a global property or variable. A check is performed during execution of the optimized version of the software code, prior to executing the portion that has been optimized based on the assumption, to verify that the dynamic attribute has the expected value. In the event that it is determined at runtime that the dynamic attribute does not have the expected value, execution reverts to backup code that is not based on the assumption that dynamic attribute will have the expected value.
申请公布号 US9195486(B2) 申请公布日期 2015.11.24
申请号 US201012847945 申请日期 2010.07.30
申请人 Apple Inc. 发明人 Porras Victor Leonel Hernandez;Lattner Christopher Arthur;Chen Jia-Hong;Christopher Eric Marshall;Hoover Roger Scott;Jouaux Francois;McCall Robert John;O'Brien Thomas John;Solanki Pratik
分类号 G06F9/45;G06F9/455;G06F11/30 主分类号 G06F9/45
代理机构 Downey Brand LLP 代理人 Downey Brand LLP
主权项 1. A computer-implemented method for optimizing a manner in which a software code is executed, comprising: during a compilation of the software code: determining, for a dynamic attribute associated with the software code, an expected value that the dynamic attribute will take on at a runtime of the software code, wherein the software code is dynamically typed, and determining the expected value comprises applying a static type inference analysis to the dynamically typed software code; generating an un-optimized version of the software code, wherein the un-optimized version is based on an assumption that the dynamic attribute will not have the expected value; generating an optimized version of the software code, wherein the optimized version is based on an assumption that the dynamic attribute will have the expected value; and modifying the optimized version to include code that is configured to cause the optimized version during execution to: transition into executing to the un-optimized version in an event it is determined that the dynamic attribute does not have the expected value, and revert to executing the optimized version subsequent to the transition, in the event it is determined that in at least a threshold number of instances observed subsequent to the transition the dynamic attribute has had the expected value.
地址 Cupertino CA US