IP Library › Granted Patent US 10,303,449
Granted Patent B2
US 10,303,449 · App. 15/908,664 · Granted May 28, 2019

Compiling non-native constants

Inventors: Brian Goetz (Williston, VT); Maurizio Cimadamore (Donabate, IE); Vicente A. Romero Zaldivar (Miami, FL)
Assignee: Oracle International Corporation
G06F8/4441G06F8/41G06F8/443G06F8/52G06F8/4435G06F8/4443
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 10,303,449
App. No.
15/908,664
Granted
May 28, 2019
Kind
B2
Abstract

Techniques for compiling non-native constants are disclosed. While compiling source code instructions, a compiler determines that a particular source code expression is associated with a command to the compiler to resolve the particular source code expression as a constant during compilation. The compiler is not configured to recognize the particular source code expression as constant without the command signaling to the compiler that the particular source code expression is constant. Based on the command, the compiler executes the particular source code expression to obtain a constant value. The compiler generates compiled instructions based on the source code instructions, in which the constant value is substituted for at least one reference to the particular source code expression.

Claims (36)

1. One or more non-transitory machine-readable media storing instructions which, when executed by one or more processors, cause:

determining, by a compiler, that a first source code expression in a plurality of source code instructions is associated with a first command to the compiler to resolve the first source code expression as a first non-native constant during compilation of the plurality of source code instructions, wherein the compiler is not configured to recognize the first source code expression as constant without the first command signaling to the compiler that the first source code expression is constant;

executing, by the compiler, the first source code expression based on the first command to obtain a first constant value for the first non-native constant;

generating, by the compiler, one or more compiled instructions at least by substituting the first constant value for at least one reference to the first source code expression;

determining, by the compiler, that a second source code expression in the plurality of source code instructions is associated with a second command to the compiler to resolve the second source code expression as a second non-native constant during compilation of the plurality of source code instructions, wherein the compiler is not configured to recognize the second source code expression as constant without the second command signaling to the compiler that the second source code expression is constant;

attempting to execute, by the compiler, the second source code expression based on the second command to obtain a second constant value for the second non-native constant; and

while attempting to execute the second source code expression:

determining that the second source code expression is not resolvable as the second non-native constant,

wherein determining that the second source code expression is not resolvable as the second non-native constant comprises identifying a non-constant input to the second source code expression, and

generating an error based on determining that the second source code expression is not resolvable as the second non-native constant.

2. The one or more media of claim 1 , wherein the first source code expression comprises a call to a method, and wherein the first command to the compiler comprises a method modifier indicating that the method is a pure function of one or more inputs.

3. The one or more media of claim 1 , wherein the first command to the compiler indicates that the first source code expression is implemented using a programming interface for defining constants.

4. The one or more media of claim 1 , further storing instructions which, when executed by one or more processors, cause:

reducing, by the compiler, a third source code expression to a third constant value, the third source code expression comprising a particular reference to the first source code expression and a reference to at least one other constant.

5. The one or more media of claim 1 , wherein the first source code expression comprises a call to a factory method for generating method handles, and wherein the first constant value comprises a method handle.

6. The one or more media of claim 1 , wherein the compiler is a virtual machine compiler configured to compile instructions that are executable by a virtual machine.

7. The one or more media of claim 1 , wherein the plurality of source code instructions comprises a source code instruction for writing the first constant value to compiled instructions.

8. A system comprising:

at least one device including a hardware processor;

the system being configured to perform operations comprising:

determining, by a compiler, that a first source code expression in a plurality of source code instructions is associated with a first command to the compiler to resolve the first source code expression as a first non-native constant during compilation of the plurality of source code instructions, wherein the compiler is not configured to recognize the first source code expression as constant without the first command signaling to the compiler that the first source code expression is constant;

executing, by the compiler, the first source code expression based on the first command to obtain a first constant value for the first non-native constant;

generating, by the compiler, one or more compiled instructions at least by substituting the first constant value for at least one reference to the first source code expression;

determining, by the compiler, that a second source code expression in the plurality of source code instructions is associated with a second command to the compiler to resolve the second source code expression as a second non-native constant during compilation of the plurality of source code instructions, wherein the compiler is not configured to recognize the second source code expression as constant without the second command signaling to the compiler that the second source code expression is constant;

attempting to execute, by the compiler, the second source code expression based on the second command to obtain a second constant value for the second non-native constant; and

while attempting to execute the second source code expression:

determining that the second source code expression is not resolvable as the second non-native constant,

wherein determining that the second source code expression is not resolvable as the second non-native constant comprises identifying a non-constant input to the second source code expression, and

generating an error based on determining that the second source code expression is not resolvable as the second non-native constant.

9. The system of claim 8 , wherein the first source code expression comprises a call to a method, and wherein the first command comprises a method modifier indicating that the method is a pure function of one or more inputs.

10. The system of claim 8 , wherein the first command indicates that the first source code expression is implemented using a programming interface for defining constants.

11. The system of claim 8 , wherein the operations further comprise:

reducing, by the compiler, a third source code expression to a third constant value, the third source code expression comprising a particular reference to the first source code expression and a reference to at least one other constant.

12. The system of claim 8 , wherein the first source code expression comprises a call to a factory method for generating method handles, and wherein the first constant value comprises a method handle.

13. The system of claim 8 , wherein the compiler is a virtual machine compiler configured to compile instructions that are executable by a virtual machine.

14. The system of claim 8 , wherein the plurality of source code instructions comprises a source code instruction for writing the first constant value to compiled instructions.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Mar 6, 2018
From: GOETZ, BRIAN; CIMADAMORE, MAURIZIO; ROMERO ZALDIVAR, VICENTE A.
To: ORACLE INTERNATIONAL CORPORATION
Reel/Frame 045121/0357 →
Continuity (2)
Provisional Application 62539342 · Jul 31, 2017
Related Publication 20190034178A1 · Jan 31, 2019