File tree Expand file tree Collapse file tree 5 files changed +36
-31
lines changed
graalpython/com.oracle.graal.python.cext Expand file tree Collapse file tree 5 files changed +36
-31
lines changed Original file line number Diff line number Diff line change @@ -12,27 +12,17 @@ typedef struct {
1212 double ob_fval ;
1313} PyFloatObject ;
1414
15- // GraalPy addition
16- typedef struct {
17- GraalPyObject ob_base ;
18- double ob_fval ;
19- } GraalPyFloatObject ;
20-
2115#define _PyFloat_CAST (op ) \
2216 (assert(PyFloat_Check(op)), _Py_CAST(PyFloatObject*, op))
2317
18+ // GraalPy public API
19+ PyAPI_FUNC (double ) GraalPyFloat_AS_DOUBLE (PyObject * op );
20+
2421// Static inline version of PyFloat_AsDouble() trading safety for speed.
2522// It doesn't check if op is a double object.
2623static inline double PyFloat_AS_DOUBLE (PyObject * op ) {
27- #if 0 // GraalPy change
28- return _PyFloat_CAST (op )-> ob_fval ;
29- #else // GraalPy change
30- if (points_to_py_handle_space (op )) {
31- return ((GraalPyFloatObject * ) pointer_to_stub (op ))-> ob_fval ;
32- } else {
33- return _PyFloat_CAST (op )-> ob_fval ;
34- }
35- #endif // GraalPy change
24+ // GraalPy change
25+ return GraalPyFloat_AS_DOUBLE (op );
3626}
3727#define PyFloat_AS_DOUBLE (op ) PyFloat_AS_DOUBLE(_PyObject_CAST(op))
3828
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ extern "C" {
1313# error "this header requires Py_BUILD_CORE define"
1414#endif
1515
16+ // GraalPy change
17+ #include "graalpy/handles.h"
18+
1619/* GC information is stored BEFORE the object structure. */
1720typedef struct {
1821 // Pointer to next object in the list.
Original file line number Diff line number Diff line change @@ -58,8 +58,6 @@ whose size is determined when the object is allocated.
5858
5959#include "pystats.h"
6060
61- #include "graalpy/handles.h"
62-
6361/* Py_DEBUG implies Py_REF_DEBUG. */
6462#if defined(Py_DEBUG ) && !defined(Py_REF_DEBUG )
6563# define Py_REF_DEBUG
@@ -1029,20 +1027,6 @@ static inline int PyType_CheckExact(PyObject *op) {
10291027# define PyType_CheckExact (op ) PyType_CheckExact(_PyObject_CAST(op))
10301028#endif
10311029
1032- // GraalPy additions
1033- PyAPI_FUNC (void ) GraalPyPrivate_DebugTrace (void );
1034-
1035- typedef struct {
1036- PyObject_HEAD
1037- int32_t handle_table_index ;
1038- } GraalPyObject ;
1039-
1040- typedef struct {
1041- GraalPyObject ob_base ;
1042- Py_ssize_t ob_size ;
1043- PyObject * * ob_item ;
1044- } GraalPyVarObject ;
1045-
10461030#ifdef __cplusplus
10471031}
10481032#endif
Original file line number Diff line number Diff line change 8383#include "pycore_global_objects.h" // _PY_NSMALLPOSINTS
8484#include "pycore_gc.h" // PyGC_Head
8585
86+ #include "graalpy/handles.h"
87+
8688#define SRC_CS "utf-8"
8789
8890/* Flags definitions representing global (debug) options. */
@@ -125,6 +127,24 @@ typedef struct {
125127 PyGC_Head * reachable ;
126128} GraalPyGC_Cycle ;
127129
130+ PyAPI_FUNC (void ) GraalPyPrivate_DebugTrace (void );
131+
132+ typedef struct {
133+ PyObject_HEAD
134+ int32_t handle_table_index ;
135+ } GraalPyObject ;
136+
137+ typedef struct {
138+ GraalPyObject ob_base ;
139+ Py_ssize_t ob_size ;
140+ PyObject * * ob_item ;
141+ } GraalPyVarObject ;
142+
143+ typedef struct {
144+ GraalPyObject ob_base ;
145+ double ob_fval ;
146+ } GraalPyFloatObject ;
147+
128148typedef struct gc_generation GCGeneration ;
129149
130150// {{start CAPI_BUILTINS}}
Original file line number Diff line number Diff line change @@ -2659,6 +2659,14 @@ PyFloat_Unpack8(const char *data, int le)
26592659
26602660// GraalPy additions
26612661
2662+ double GraalPyFloat_AS_DOUBLE (PyObject * op ) {
2663+ if (points_to_py_handle_space (op )) {
2664+ return ((GraalPyFloatObject * ) pointer_to_stub (op ))-> ob_fval ;
2665+ } else {
2666+ return _PyFloat_CAST (op )-> ob_fval ;
2667+ }
2668+ }
2669+
26622670// not quite as in CPython, this assumes that x is already a double. The rest of
26632671// the implementation is in the Float constructor in Java
26642672PyAPI_FUNC (PyObject * )
You can’t perform that action at this time.
0 commit comments