Methods and systems for avoiding or deferring data copies are disclosed. Using a virtual machine, it is determined whether a set of program code comprises references to a data object after an operation to generate a copy of the data object. If not, a set of optimized program code is generated in which the operation to copy the data object is replaced with an operation to update a reference. Using the virtual machine, it is determined whether the set of program code comprises an operation to generate a copy of a buffer object. If so, a set of further optimized program code is generated, comprising an allocation of one or more memory pages to store the buffer object with a copy-on-write parameter instead of the operation to generate the copy of the buffer object.
Legal claims defining the scope of protection, as filed with the USPTO.
1. A computer-implemented method, comprising: using a virtual machine to perform: determining whether a set of program code comprises one or more references to a data object after an operation to generate a copy of the data object, wherein the set of program code is executable using the virtual machine; if the set of program code does not comprise one or more references to the data object after the operation to generate the copy of the data object, generating a set of optimized program code, comprising replacing the operation to generate the copy of the data object in the set of program code with an operation to update a reference in the set of optimized program code; determining whether the set of program code comprises an operation to generate a copy of a buffer object; and if the set of program code comprises the operation to generate the copy of the buffer object, generating a set of further optimized program code, wherein the set of further optimized program code comprises an allocation of one or more memory pages to store the buffer object with a copy-on-write parameter instead of the operation to generate the copy of the buffer object.
2. The method as recited in claim 1 , wherein the operation to update the reference comprises an operation to make an output object of a function reference the data object, wherein the data object is built by the function.
3. The method as recited in claim 1 , wherein the copy of the data object comprises an immutable object.
4. The method as recited in claim 1 , further comprising: executing the set of further optimized program code using the virtual machine, comprising: attempting to write to at least one of the memory pages storing the buffer object; and in response to the attempting to write, causing a copy of the at least one memory page to be generated.
5. A non-transitory, computer-readable storage medium storing program instructions computer-executable to perform: determining whether a set of program code comprises one or more references to a data object after an operation to generate a copy of the data object, wherein the set of program code is executable using a virtual machine; if the set of program code does not comprise one or more references to the data object after the operation to generate the copy of the data object, generating a set of optimized program code, comprising replacing the operation to generate the copy of the data object in the set of program code with an operation to update a reference in the set of optimized program code; determining whether the set of program code comprises an operation to generate a copy of a buffer object; and if the set of program code comprises the operation to generate the copy of the buffer object, generating a set of further optimized program code, wherein the set of further optimized program code comprises an allocation of one or more memory pages to store the buffer object with a copy-on-write parameter instead of the operation to generate the copy of the buffer object.
6. The non-transitory, computer-readable storage medium as recited in claim 5 , wherein the operation to update the reference comprises an operation to make an output object of a function reference the data object, wherein the data object is built by the function.
7. The non-transitory, computer-readable storage medium as recited in claim 5 , wherein the copy of the data object comprises an immutable object.
8. The non-transitory, computer-readable storage medium as recited in claim 5 , wherein the program instructions are further computer-executable to perform: executing the set of further optimized program code using the virtual machine, comprising: attempting to write to at least one of the memory pages storing the buffer object; and in response to the attempting to write, causing a copy of the at least one memory page to be generated.
9. The non-transitory, computer-readable storage medium as recited in claim 5 , wherein the set of optimized program code comprises a truncation or reallocation of memory storing the object.
10. A computer system, comprising: one or more hardware computing devices comprising one or more processors; and a virtual machine implemented by the one or more hardware computing devices, wherein the virtual machine is configured to: determining whether a set of program code comprises one or more references to a data object after an operation to generate a copy of the data object, wherein the set of program code is executable using the virtual machine; if the set of program code does not comprise one or more references to the data object after the operation to generate the copy of the data object, generating a set of optimized program code, comprising replacing the operation to generate the copy of the data object in the set of program code with an operation to update a reference in the set of optimized program code; determining whether the set of program code comprises an operation to generate a copy of a buffer object; and if the set of program code comprises the operation to generate the copy of the buffer object, generating a set of further optimized program code, wherein the set of further optimized program code comprises an allocation of one or more memory pages to store the buffer object with a copy-on-write parameter instead of the operation to generate the copy of the buffer object.
11. The computer system as recited in claim 10 , wherein the operation to update the reference comprises an operation to make an output object of a function reference the data object, wherein the data object is built by the function.
12. The computer system as recited in claim 10 , wherein the copy of the data object comprises an immutable object.
13. The computer system as recited in claim 10 , wherein the virtual machine is further configured to perform: executing the set of further optimized program code using the virtual machine, comprising: attempting to write to at least one of the memory pages storing the buffer object; and in response to the attempting to write, causing a copy of the at least one memory page to be generated.
14. The computer system as recited in claim 10 , wherein the set of optimized program code comprises a truncation or reallocation of memory storing the object.
Cooperative Patent Classification codes for this invention. Click any code to explore related patents in that topic.
March 14, 2013
August 18, 2015
Browse 5M+ US patents with plain-English claim translations and AI-generated analysis.