Skip to content

Commit 906cad2

Browse files
committed
Address review feedback
1 parent b6f3eba commit 906cad2

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

graalpython/com.oracle.graal.python.cext/src/capi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ void PyTruffle_PrimitiveArrayFree(void* array) {
898898
free(array);
899899
}
900900

901-
void PyTruffle_ObjectArrayFree(PyObject** array, int size) {
901+
void PyTruffle_ObjectArrayFree(PyObject** array, int32_t size) {
902902
for (int i = 0; i < size; i++) {
903903
Py_DECREF(array[i]);
904904
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -909,28 +909,28 @@ Object get(Object obj,
909909
@CApiBuiltin(ret = Int, args = {PyObject, ConstCharPtrAsTruffleString}, call = Direct)
910910
abstract static class PyObject_SetDoc extends CApiBinaryBuiltinNode {
911911
@Specialization
912-
int set(PBuiltinFunction obj, TruffleString value,
913-
@Cached WriteAttributeToDynamicObjectNode write) {
912+
static int set(PBuiltinFunction obj, TruffleString value,
913+
@Shared("write") @Cached WriteAttributeToDynamicObjectNode write) {
914914
write.execute(obj, T___DOC__, value);
915915
return 1;
916916
}
917917

918918
@Specialization
919-
int set(PBuiltinMethod obj, TruffleString value,
920-
@Cached WriteAttributeToDynamicObjectNode write) {
919+
static int set(PBuiltinMethod obj, TruffleString value,
920+
@Shared("write") @Cached WriteAttributeToDynamicObjectNode write) {
921921
set(obj.getFunction(), value, write);
922922
return 1;
923923
}
924924

925925
@Specialization
926-
int set(GetSetDescriptor obj, TruffleString value,
927-
@Cached WriteAttributeToDynamicObjectNode write) {
926+
static int set(GetSetDescriptor obj, TruffleString value,
927+
@Shared("write") @Cached WriteAttributeToDynamicObjectNode write) {
928928
write.execute(obj, T___DOC__, value);
929929
return 1;
930930
}
931931

932932
@Specialization(guards = "isType.execute(type)", limit = "1")
933-
int set(PythonNativeClass type, TruffleString value,
933+
static int set(PythonNativeClass type, TruffleString value,
934934
@SuppressWarnings("unused") @Cached IsTypeNode isType,
935935
// TODO we should write to tp_doc, this writes to __doc__ in the type dict
936936
@Cached("createForceType()") WriteAttributeToObjectNode write) {
@@ -940,7 +940,8 @@ int set(PythonNativeClass type, TruffleString value,
940940

941941
@Fallback
942942
@SuppressWarnings("unused")
943-
int set(Object obj, Object value) {
943+
static int set(Object obj, Object value) {
944+
CompilerDirectives.transferToInterpreterAndInvalidate();
944945
throw CompilerDirectives.shouldNotReachHere("Don't know how to set doc for " + obj.getClass());
945946
}
946947
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import java.util.Arrays;
5454
import java.util.HashMap;
5555
import java.util.HashSet;
56-
import java.util.IdentityHashMap;
5756
import java.util.Map;
5857
import java.util.Objects;
5958
import java.util.concurrent.ConcurrentHashMap;
@@ -103,6 +102,7 @@
103102
import com.oracle.graal.python.runtime.exception.PException;
104103
import com.oracle.graal.python.util.Function;
105104
import com.oracle.graal.python.util.PythonUtils;
105+
import com.oracle.graal.python.util.WeakIdentityHashMap;
106106
import com.oracle.truffle.api.CallTarget;
107107
import com.oracle.truffle.api.CompilerAsserts;
108108
import com.oracle.truffle.api.CompilerDirectives;
@@ -197,7 +197,7 @@ public final class CApiContext extends CExtContext {
197197
private boolean loadNativeLibrary = true;
198198
public RootCallTarget signatureContainer;
199199

200-
private final IdentityHashMap<Object, Object> procWrappers = new IdentityHashMap<>();
200+
private final WeakIdentityHashMap<Object, Object> procWrappers = new WeakIdentityHashMap<>();
201201

202202
public static TruffleLogger getLogger(Class<?> clazz) {
203203
return PythonLanguage.getLogger(LOGGER_CAPI_NAME + "." + clazz.getSimpleName());

0 commit comments

Comments
 (0)