|
| 1 | +diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h |
| 2 | +index a99fe7b..2f5e3ee 100644 |
| 3 | +--- a/numpy/core/include/numpy/ndarrayobject.h |
| 4 | ++++ b/numpy/core/include/numpy/ndarrayobject.h |
| 5 | +@@ -225,7 +225,7 @@ NPY_TITLE_KEY_check(PyObject *key, PyObject *value) |
| 6 | + if (key == title) { |
| 7 | + return 1; |
| 8 | + } |
| 9 | +-#ifdef PYPY_VERSION |
| 10 | ++#if defined(PYPY_VERSION) || defined(GRAALVM_PYTHON) |
| 11 | + /* |
| 12 | + * On PyPy, dictionary keys do not always preserve object identity. |
| 13 | + * Fall back to comparison by value. |
| 14 | +diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c |
| 15 | +index 2ab58bb..d7a7823 100644 |
| 16 | +--- a/numpy/core/src/multiarray/compiled_base.c |
| 17 | ++++ b/numpy/core/src/multiarray/compiled_base.c |
| 18 | +@@ -1391,6 +1391,7 @@ fail: |
| 19 | + NPY_NO_EXPORT PyObject * |
| 20 | + arr_add_docstring(PyObject *NPY_UNUSED(dummy), PyObject *args) |
| 21 | + { |
| 22 | ++#if 0 // GraalPy change |
| 23 | + PyObject *obj; |
| 24 | + PyObject *str; |
| 25 | + const char *docstr; |
| 26 | +@@ -1482,6 +1483,7 @@ arr_add_docstring(PyObject *NPY_UNUSED(dummy), PyObject *args) |
| 27 | + } |
| 28 | + |
| 29 | + #undef _ADDDOC |
| 30 | ++#endif // GraalPy change |
| 31 | + |
| 32 | + Py_RETURN_NONE; |
| 33 | + } |
| 34 | +diff --git a/numpy/core/src/multiarray/shape.c b/numpy/core/src/multiarray/shape.c |
| 35 | +index dc7151a..377ec99 100644 |
| 36 | +--- a/numpy/core/src/multiarray/shape.c |
| 37 | ++++ b/numpy/core/src/multiarray/shape.c |
| 38 | +@@ -104,6 +104,11 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck, |
| 39 | + "cannot resize an array with refcheck=True on PyPy.\n" |
| 40 | + "Use the np.resize function or refcheck=False"); |
| 41 | + return NULL; |
| 42 | ++#elif defined(GRAALVM_PYTHON) |
| 43 | ++ PyErr_SetString(PyExc_ValueError, |
| 44 | ++ "cannot resize an array with refcheck=True on GraalPy.\n" |
| 45 | ++ "Use the np.resize function or refcheck=False"); |
| 46 | ++ return NULL; |
| 47 | + #else |
| 48 | + refcnt = PyArray_REFCOUNT(self); |
| 49 | + #endif /* PYPY_VERSION */ |
| 50 | +diff --git a/numpy/core/src/multiarray/temp_elide.c b/numpy/core/src/multiarray/temp_elide.c |
| 51 | +index 0bf500e..ad7a06e 100644 |
| 52 | +--- a/numpy/core/src/multiarray/temp_elide.c |
| 53 | ++++ b/numpy/core/src/multiarray/temp_elide.c |
| 54 | +@@ -58,7 +58,7 @@ |
| 55 | + * supported too by using the appropriate Windows APIs. |
| 56 | + */ |
| 57 | + |
| 58 | +-#if defined HAVE_BACKTRACE && defined HAVE_DLFCN_H && ! defined PYPY_VERSION |
| 59 | ++#if defined HAVE_BACKTRACE && defined HAVE_DLFCN_H && ! defined PYPY_VERSION && !defined(GRAALVM_PYTHON) |
| 60 | + /* 1 prints elided operations, 2 prints stacktraces */ |
| 61 | + #define NPY_ELIDE_DEBUG 0 |
| 62 | + #define NPY_MAX_STACKSIZE 10 |
| 63 | +diff --git a/numpy/core/src/npymath/ieee754.c.src b/numpy/core/src/npymath/ieee754.c.src |
| 64 | +index 5d8cb06..2b25696 100644 |
| 65 | +--- a/numpy/core/src/npymath/ieee754.c.src |
| 66 | ++++ b/numpy/core/src/npymath/ieee754.c.src |
| 67 | +@@ -395,6 +395,11 @@ int npy_get_floatstatus_barrier(char* param) |
| 68 | + * By using a volatile, the compiler cannot reorder this call |
| 69 | + */ |
| 70 | + if (param != NULL) { |
| 71 | ++ // GraalPy change: the pointer needs to be dereferenced to establish |
| 72 | ++ // a data dependency to to ensure the compiler won't reorder the call |
| 73 | ++ if (points_to_py_handle_space(param)) { |
| 74 | ++ param = (char*)pointer_to_stub(param); |
| 75 | ++ } |
| 76 | + volatile char NPY_UNUSED(c) = *(char*)param; |
| 77 | + } |
| 78 | + |
| 79 | +diff --git a/numpy/core/src/npymath/ieee754.cpp b/numpy/core/src/npymath/ieee754.cpp |
| 80 | +index ebc1dbe..2934bda 100644 |
| 81 | +--- a/numpy/core/src/npymath/ieee754.cpp |
| 82 | ++++ b/numpy/core/src/npymath/ieee754.cpp |
| 83 | +@@ -465,6 +465,11 @@ npy_get_floatstatus_barrier(char *param) |
| 84 | + * By using a volatile, the compiler cannot reorder this call |
| 85 | + */ |
| 86 | + if (param != NULL) { |
| 87 | ++ // GraalPy change: the pointer needs to be dereferenced to establish |
| 88 | ++ // a data dependency to to ensure the compiler won't reorder the call |
| 89 | ++ if (points_to_py_handle_space(param)) { |
| 90 | ++ param = (char*)pointer_to_stub(param); |
| 91 | ++ } |
| 92 | + volatile char NPY_UNUSED(c) = *(char *)param; |
| 93 | + } |
| 94 | + |
0 commit comments