Skip to content

Commit 8367688

Browse files
committed
Sort open handles by generation in HPy debug context
1 parent 5a76a3e commit 8367688

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ PList doInt(VirtualFrame frame, int generation) {
132132
private static Object[] getOpenDebugHandles(GraalHPyDebugContext debugContext, int generation) {
133133
ArrayList<GraalHPyHandle> openHandles = debugContext.getOpenHandles(generation);
134134
int n = openHandles.size();
135+
openHandles.sort((a, b) -> Integer.compare(debugContext.getGenerationForHandle(b), debugContext.getGenerationForHandle(a)));
135136
Object[] result = new Object[n];
136137
PythonObjectFactory factory = PythonObjectFactory.getUncached();
137138
// do reverse order to match order expected by HPy tests

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyDebugContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public int getCurrentGeneration() {
9393
return currentGeneration;
9494
}
9595

96+
public int getGenerationForHandle(GraalHPyHandle handle) {
97+
return generationTable[handle.getIdDebug(this)];
98+
}
99+
96100
public int newGeneration() {
97101
return ++currentGeneration;
98102
}

0 commit comments

Comments
 (0)