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 {
12
12
double ob_fval ;
13
13
} PyFloatObject ;
14
14
15
- // GraalPy addition
16
- typedef struct {
17
- GraalPyObject ob_base ;
18
- double ob_fval ;
19
- } GraalPyFloatObject ;
20
-
21
15
#define _PyFloat_CAST (op ) \
22
16
(assert(PyFloat_Check(op)), _Py_CAST(PyFloatObject*, op))
23
17
18
+ // GraalPy public API
19
+ PyAPI_FUNC (double ) GraalPyFloat_AS_DOUBLE (PyObject * op );
20
+
24
21
// Static inline version of PyFloat_AsDouble() trading safety for speed.
25
22
// It doesn't check if op is a double object.
26
23
static 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 );
36
26
}
37
27
#define PyFloat_AS_DOUBLE (op ) PyFloat_AS_DOUBLE(_PyObject_CAST(op))
38
28
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ extern "C" {
13
13
# error "this header requires Py_BUILD_CORE define"
14
14
#endif
15
15
16
+ // GraalPy change
17
+ #include "graalpy/handles.h"
18
+
16
19
/* GC information is stored BEFORE the object structure. */
17
20
typedef struct {
18
21
// 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.
58
58
59
59
#include "pystats.h"
60
60
61
- #include "graalpy/handles.h"
62
-
63
61
/* Py_DEBUG implies Py_REF_DEBUG. */
64
62
#if defined(Py_DEBUG ) && !defined(Py_REF_DEBUG )
65
63
# define Py_REF_DEBUG
@@ -1029,20 +1027,6 @@ static inline int PyType_CheckExact(PyObject *op) {
1029
1027
# define PyType_CheckExact (op ) PyType_CheckExact(_PyObject_CAST(op))
1030
1028
#endif
1031
1029
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
-
1046
1030
#ifdef __cplusplus
1047
1031
}
1048
1032
#endif
Original file line number Diff line number Diff line change 83
83
#include "pycore_global_objects.h" // _PY_NSMALLPOSINTS
84
84
#include "pycore_gc.h" // PyGC_Head
85
85
86
+ #include "graalpy/handles.h"
87
+
86
88
#define SRC_CS "utf-8"
87
89
88
90
/* Flags definitions representing global (debug) options. */
@@ -125,6 +127,24 @@ typedef struct {
125
127
PyGC_Head * reachable ;
126
128
} GraalPyGC_Cycle ;
127
129
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
+
128
148
typedef struct gc_generation GCGeneration ;
129
149
130
150
// {{start CAPI_BUILTINS}}
Original file line number Diff line number Diff line change @@ -2659,6 +2659,14 @@ PyFloat_Unpack8(const char *data, int le)
2659
2659
2660
2660
// GraalPy additions
2661
2661
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
+
2662
2670
// not quite as in CPython, this assumes that x is already a double. The rest of
2663
2671
// the implementation is in the Float constructor in Java
2664
2672
PyAPI_FUNC (PyObject * )
You can’t perform that action at this time.
0 commit comments