-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8357689: Refactor JVMCI to enable replay compilation in Graal #25433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,6 +22,7 @@ | |||||
*/ | ||||||
package jdk.vm.ci.code; | ||||||
|
||||||
import java.util.Arrays; | ||||||
import java.util.Collections; | ||||||
import java.util.IdentityHashMap; | ||||||
import java.util.Set; | ||||||
|
@@ -291,10 +292,12 @@ public boolean equals(Object o) { | |||||
} | ||||||
if (o instanceof VirtualObject) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename
Suggested change
|
||||||
VirtualObject l = (VirtualObject) o; | ||||||
if (!l.type.equals(type) || l.values.length != values.length) { | ||||||
int lValuesLength = (l.values == null) ? 0 : l.values.length; | ||||||
int valuesLength = (values == null) ? 0 : values.length; | ||||||
if (!l.type.equals(type) || lValuesLength != valuesLength) { | ||||||
return false; | ||||||
} | ||||||
for (int i = 0; i < values.length; i++) { | ||||||
for (int i = 0; i < valuesLength; i++) { | ||||||
/* | ||||||
* Virtual objects can form cycles. Calling equals() could therefore lead to | ||||||
* infinite recursion. | ||||||
|
@@ -311,4 +314,15 @@ public boolean equals(Object o) { | |||||
private static boolean same(Object o1, Object o2) { | ||||||
return o1 == o2; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Returns a copy of the array containing the Java kinds of the values stored in this | ||||||
* virtual object. | ||||||
* | ||||||
* @return a copy of the array containing the Java kinds of the values or {@code null} if the | ||||||
* values have not been initialized. | ||||||
*/ | ||||||
public JavaKind[] getSlotKinds() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comments as for BytecodeFrame.getSlotKinds. This applies to all other non-primitive array return values added by this PR. |
||||||
return (slotKinds == null) ? null : Arrays.copyOf(slotKinds, slotKinds.length); | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ | |
import jdk.vm.ci.meta.ResolvedJavaField; | ||
import jdk.vm.ci.meta.ResolvedJavaMethod; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* A {@link CompiledCode} with additional HotSpot-specific information required for installing the | ||
* code in HotSpot's code cache. | ||
|
@@ -188,4 +190,97 @@ public int getOffset(ResolvedJavaField field) { | |
} | ||
}); | ||
} | ||
|
||
/** | ||
* Returns a copy of the compiled machine code. | ||
*/ | ||
public byte[] getTargetCode() { | ||
return (targetCode == null) ? null : Arrays.copyOf(targetCode, targetCode.length); | ||
} | ||
|
||
/** | ||
* Gets the size of the compiled machine code in bytes. | ||
*/ | ||
public int getTargetCodeSize() { | ||
return targetCodeSize; | ||
} | ||
|
||
/** | ||
* Returns a copy of the array of {@link Site} objects associated with this compiled code. | ||
*/ | ||
public Site[] getSites() { | ||
return (sites == null) ? null : Arrays.copyOf(sites, sites.length); | ||
} | ||
|
||
/** | ||
* Returns a copy of the array of {@link Assumption} objects associated with this compiled code. | ||
*/ | ||
public Assumption[] getAssumptions() { | ||
return (assumptions == null) ? null : Arrays.copyOf(assumptions, assumptions.length); | ||
} | ||
|
||
/** | ||
* Returns a copy of the array of {@link ResolvedJavaMethod} objects representing the methods | ||
* whose bytecodes were used as input to the compilation. If the compilation did not record | ||
* method dependencies, this method returns {@code null}. Otherwise, the first element of the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. null -> empty list? |
||
* returned array is the root method of the compilation. | ||
* | ||
* @return a copy of the array of methods associated with this compiled code or {@code null} | ||
* if no methods were recorded | ||
*/ | ||
public ResolvedJavaMethod[] getMethods() { | ||
return (methods == null) ? null : Arrays.copyOf(methods, methods.length); | ||
} | ||
|
||
/** | ||
* Returns a copy of the array of {@link Comment} objects associated with this compiled code. | ||
*/ | ||
public Comment[] getComments() { | ||
return Arrays.copyOf(comments, comments.length); | ||
} | ||
|
||
/** | ||
* Returns a copy of the data section containing serialized constants for the emitted machine code. | ||
*/ | ||
public byte[] getDataSection() { | ||
return (dataSection == null) ? null : Arrays.copyOf(dataSection, dataSection.length); | ||
} | ||
|
||
/** | ||
* Gets the minimum alignment of the data section. | ||
*/ | ||
public int getDataSectionAlignment() { | ||
return dataSectionAlignment; | ||
} | ||
|
||
/** | ||
* Returns a copy of the array of {@link DataPatch} objects representing the relocations in the | ||
* {@linkplain #getDataSection() data section}. | ||
* | ||
* @return a copy of the array of data section patches or {@code null} if there are no patches | ||
*/ | ||
public DataPatch[] getDataSectionPatches() { | ||
return (dataSectionPatches == null) ? null : Arrays.copyOf(dataSectionPatches, dataSectionPatches.length); | ||
} | ||
|
||
/** | ||
* Checks if this compiled code is immutable and position independent. | ||
*/ | ||
public boolean isImmutablePIC() { | ||
return isImmutablePIC; | ||
} | ||
|
||
/** | ||
* Gets the total size of the stack frame of this compiled method. | ||
*/ | ||
public int getTotalFrameSize() { | ||
return totalFrameSize; | ||
} | ||
|
||
/** | ||
* Gets the deoptimization rescue slot associated with this compiled code. | ||
*/ | ||
public StackSlot getDeoptRescueSlot() { | ||
return deoptRescueSlot; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind that
slotKinds
is being converted to a List. In that context, can we return the list without making a copy? Or is the caller expected to be able to mutate the return value?