Skip to content

Commit ba719f2

Browse files
committed
Make POL hash method final
1 parent d662648 commit ba719f2

File tree

7 files changed

+12
-18
lines changed

7 files changed

+12
-18
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/DefaultPythonBooleanExports.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ static Object getLazyPythonClass(@SuppressWarnings("unused") Boolean value) {
9494
}
9595

9696
@ExportMessage
97-
static long hash(Boolean value) {
98-
return hash((boolean) value);
97+
static long hashWithState(Boolean value, @SuppressWarnings("unused") ThreadState state) {
98+
return hash(value);
9999
}
100100

101101
@Ignore

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/DefaultPythonDoubleExports.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ static Object getLazyPythonClass(@SuppressWarnings("unused") Double value) {
8080
}
8181

8282
@ExportMessage
83-
static long hash(Double number) {
84-
return hash(number.doubleValue());
83+
static long hashWithState(Double number, @SuppressWarnings("unused") ThreadState state) {
84+
return hash(number);
8585
}
8686

8787
// Adapted from CPython _Py_HashDouble

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/DefaultPythonIntegerExports.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ static Object getLazyPythonClass(@SuppressWarnings("unused") Integer value) {
9393
}
9494

9595
@ExportMessage
96-
static long hash(Integer value) {
97-
return hash(value.intValue());
96+
static long hashWithState(Integer value, @SuppressWarnings("unused") ThreadState state) {
97+
return hash(value);
9898
}
9999

100100
@Ignore

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/DefaultPythonLongExports.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ static Object getLazyPythonClass(@SuppressWarnings("unused") Long value) {
115115
}
116116

117117
@ExportMessage
118-
static long hash(Long value) {
119-
return hash(value.longValue());
118+
static long hashWithState(Long value, @SuppressWarnings("unused") ThreadState state) {
119+
return hash(value);
120120
}
121121

122122
@Ignore

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/DefaultPythonObjectExports.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static Object getLazyPythonClass(@SuppressWarnings("unused") Object value) {
135135

136136
@ExportMessage
137137
@TruffleBoundary
138-
static long hash(Object receiver) {
138+
static long hashWithState(Object receiver, @SuppressWarnings("unused") ThreadState state) {
139139
return receiver.hashCode();
140140
}
141141

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/DefaultPythonStringExports.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static byte[] getBufferBytes(String str) {
102102

103103
@ExportMessage
104104
@TruffleBoundary
105-
static long hash(String self) {
105+
static long hashWithState(String self, @SuppressWarnings("unused") ThreadState state) {
106106
return self.hashCode();
107107
}
108108

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonObjectLibrary.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,13 @@ public boolean isHashable(Object receiver) {
243243
* result of a {@link PArguments#getThreadState} call. It ensures that we can use fastcalls and
244244
* pass the thread state in the frame arguments.
245245
*/
246-
public long hashWithState(Object receiver, ThreadState threadState) {
247-
if (threadState == null) {
248-
CompilerDirectives.transferToInterpreterAndInvalidate();
249-
throw new AbstractMethodError(receiver.getClass().getCanonicalName());
250-
}
251-
return hash(receiver);
252-
}
246+
public abstract long hashWithState(Object receiver, ThreadState threadState);
253247

254248
/**
255249
* Potentially slower way to get the Python hash for the receiver. If a Python {@link Frame} is
256250
* available to the caller, {@link #hashWithState} should be preferred.
257251
*/
258-
public long hash(Object receiver) {
252+
public final long hash(Object receiver) {
259253
return hashWithState(receiver, null);
260254
}
261255

0 commit comments

Comments
 (0)