1. A method for optimizing a program, comprising: determining reusability of code called by a function call of a subclass test function included in an execution-target program, on the basis of whether or not access to a global memory within said code includes only access for reading out type information specified in said function call and information traceable from said type information; storing an execution result of code determined to be reusable and specified information specified in said function call of said code in a storage device as profile information of said code, in association with type information actually accessed within said code; reading out, in response to detection of said function call of the subclass test function that calls the code determined to be reusable, the profile information of said code from said storage device, and reusing said execution result of said profile information provided that the specified information of said profile information matches specified information specified in said detected function call; and monitoring said type information associated with said execution result included in said profile information stored in said storage device, and prohibiting, in response to a change made to said type information, reuse of said execution result associated with said type information.