System and method for redundant array copy removal in a pointer-free language
AssigneeOracle International Corporation
InventorMarcus Lagergren
Life of this patent
Estimating the term…
Abstract
A system and method for redundant array copy removal in a virtual machine (VM), or other runtime environment, and particularly for use in a system that includes a Java Virtual Machine (JVM). In pointer free languages array copy operations are common and time consuming. Embodiments of the present invention enable the compiler to detect situations where the compiled code can safely use the source array as the destination array without performing any copy operation. By avoiding array copy operations, the performance of the application is improved.
Claims18
A system for redundant array copy removal in a virtual machine environment, comprising:
- a computer including a microprocessor;
- a virtual machine running on the computer, that executes one or more software applications;
- a bytecode compiler that compiles application bytecode into compiled bytecode for execution by the virtual machine;
- a memory space for storage of the application bytecode and the compiled bytecode;
- an escape analyzer logic within the bytecode compiler that determines whether array equivalence guards can be added to the compiled bytecode, to allow for redundant array copy removal, including
- determining, within the compiled bytecode, one or more array copy operations that include a source array and a destination array, and
- determining those array copy operations that can be modified using a guarded array copy, including, for each candidate array copy operation, the requirements that
- the source array and destination array are allocated within a same scope,
- the source array does not escape the scope,
- the source array and its aliases will not be modified as a result of the array copy,
- neither the destination array nor its aliases escape prior to the array copy, and
- the source and destination arrays are of the same type or the destination array is a more generic array than the source array;
- and
- wherein, upon the requirements being satisfied, the bytecode compiler then replaces, within the compiled bytecode, one or more of those array copy operations that have been determined can be modified, with a guarded array copy operation that indicates criteria whereby its source array is to be used as its destination array, which guarded array copy is implemented as code that
- compares the length of the source array indicated by the array copy operation, with the length of the destination array indicated by the array copy operation, and
- compares the starting position within the source array as indicated by the array copy operation with the starting position of the destination array as indicated by the array copy operation,
- to determine that the source array can be used as its destination array.
A method for redundant array copy removal in a virtual machine environment, comprising the steps of:
- executing one or more software applications on a virtual machine;
- providing a bytecode compiler that compiles application bytecode into compiled bytecode for execution by the virtual machine;
- providing a memory space for storage of the application bytecode and the compiled bytecode;
- adding array equivalence guards to the compiled bytecode, to allow for redundant array copy removal, including
- determining, within the compiled bytecode, one or more array copy operations that include a source array and a destination array, and
- determining those array copy operations that can be modified using a guarded array copy, including, for each candidate array copy operation, the requirements that
- the source array and destination array are allocated within a same scope,
- the source array does not escape the scope,
- the source array and its aliases will not be modified as a result of the array copy,
- neither the destination array nor its aliases escape prior to the array copy, and
- the source and destination arrays are of the same type or the destination array is a more generic array than the source array;
- and
- upon the requirements being satisfied, replacing, within the compiled bytecode, one or more of those array copy operations that have been determined can be modified, with a guarded array copy operation that indicates criteria whereby its source array is to be used as its destination array, which guarded array copy is implemented as code that
- compares the length of the source array indicated by the array copy operation, with the length of the destination array indicated by the array copy operation, and
- compares the starting position within the source array as indicated by the array copy operation with the starting position of the destination array as indicated by the array copy operation,
- to determine that the source array can be used as its destination array.
A non-transitory computer readable medium, including instructions stored thereon which when executed cause the computer to perform the steps comprising:
- executing one or more software applications on a virtual machine;
- providing a bytecode compiler that compiles application bytecode into compiled bytecode for execution by the virtual machine;
- providing a memory space for storage of the application bytecode and the compiled bytecode;
- adding array equivalence guards to the compiled bytecode, to allow for redundant array copy removal, including
- determining, within the compiled bytecode, one or more array copy operations that include a source array and a destination array, and
- determining those array copy operations that can be modified using a guarded array copy, including, for each candidate array copy operation, the requirements that
- the source array and destination array are allocated within a same scope,
- the source array does not escape the scope,
- the source array and its aliases will not be modified as a result of the array copy,
- neither the destination array nor its aliases escape prior to the array copy, and
- the source and destination arrays are of the same type or the destination array is a more generic array than the source array;
- and
- upon the requirements being satisfied, replacing, within the compiled bytecode, one or more of those array copy operations that have been determined can be modified, with a guarded array copy operation that indicates criteria whereby its source array is to be used as its destination array, which guarded array copy is implemented as code that
- compares the length of the source array indicated by the array copy operation, with the length of the destination array indicated by the array copy operation, and
- compares the starting position within the source array as indicated by the array copy operation with the starting position of the destination array as indicated by the array copy operation,
- to determine that the source array can be used as its destination array.
Dependencies are inferred from the claim text.