Skip to content

Commit f832e4f

Browse files
committed
Update HPy inlined files: 6d3b941
1 parent 0112b83 commit f832e4f

File tree

16 files changed

+156
-33
lines changed

16 files changed

+156
-33
lines changed

graalpython/com.oracle.graal.python.cext/include/common/autogen_hpyfunc_declare.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#define _HPyFunc_DECLARE_HPyFunc_SETATTROFUNC(SYM) static int SYM(HPyContext ctx, HPy, HPy, HPy)
3232
#define _HPyFunc_DECLARE_HPyFunc_REPRFUNC(SYM) static HPy SYM(HPyContext ctx, HPy)
3333
#define _HPyFunc_DECLARE_HPyFunc_HASHFUNC(SYM) static HPy_hash_t SYM(HPyContext ctx, HPy)
34-
#define _HPyFunc_DECLARE_HPyFunc_RICHCMPFUNC(SYM) static HPy SYM(HPyContext ctx, HPy, HPy, int)
34+
#define _HPyFunc_DECLARE_HPyFunc_RICHCMPFUNC(SYM) static HPy SYM(HPyContext ctx, HPy, HPy, HPy_RichCmpOp)
3535
#define _HPyFunc_DECLARE_HPyFunc_GETITERFUNC(SYM) static HPy SYM(HPyContext ctx, HPy)
3636
#define _HPyFunc_DECLARE_HPyFunc_ITERNEXTFUNC(SYM) static HPy SYM(HPyContext ctx, HPy)
3737
#define _HPyFunc_DECLARE_HPyFunc_DESCRGETFUNC(SYM) static HPy SYM(HPyContext ctx, HPy, HPy, HPy)
@@ -63,7 +63,7 @@ typedef int (*HPyFunc_setattrfunc)(HPyContext ctx, HPy, char *, HPy);
6363
typedef int (*HPyFunc_setattrofunc)(HPyContext ctx, HPy, HPy, HPy);
6464
typedef HPy (*HPyFunc_reprfunc)(HPyContext ctx, HPy);
6565
typedef HPy_hash_t (*HPyFunc_hashfunc)(HPyContext ctx, HPy);
66-
typedef HPy (*HPyFunc_richcmpfunc)(HPyContext ctx, HPy, HPy, int);
66+
typedef HPy (*HPyFunc_richcmpfunc)(HPyContext ctx, HPy, HPy, HPy_RichCmpOp);
6767
typedef HPy (*HPyFunc_getiterfunc)(HPyContext ctx, HPy);
6868
typedef HPy (*HPyFunc_iternextfunc)(HPyContext ctx, HPy);
6969
typedef HPy (*HPyFunc_descrgetfunc)(HPyContext ctx, HPy, HPy, HPy);

graalpython/com.oracle.graal.python.cext/include/common/autogen_hpyslot.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ typedef enum {
5555
HPy_tp_init = 60,
5656
HPy_tp_new = 65,
5757
HPy_tp_repr = 66,
58+
HPy_tp_richcompare = 67,
5859
HPy_nb_matrix_multiply = 75,
5960
HPy_nb_inplace_matrix_multiply = 76,
6061
HPy_tp_destroy = 1000,
@@ -104,6 +105,7 @@ typedef enum {
104105
#define _HPySlot_SIG__HPy_tp_init HPyFunc_INITPROC
105106
#define _HPySlot_SIG__HPy_tp_new HPyFunc_KEYWORDS
106107
#define _HPySlot_SIG__HPy_tp_repr HPyFunc_REPRFUNC
108+
#define _HPySlot_SIG__HPy_tp_richcompare HPyFunc_RICHCMPFUNC
107109
#define _HPySlot_SIG__HPy_nb_matrix_multiply HPyFunc_BINARYFUNC
108110
#define _HPySlot_SIG__HPy_nb_inplace_matrix_multiply HPyFunc_BINARYFUNC
109111
#define _HPySlot_SIG__HPy_tp_destroy HPyFunc_DESTROYFUNC

graalpython/com.oracle.graal.python.cext/include/common/macros.h

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,30 @@
4141
#define HPyTuple_Pack(ctx, n, ...) (HPyTuple_FromArray(ctx, (HPy[]){ __VA_ARGS__ }, n))
4242

4343
/* Rich comparison opcodes */
44-
#define HPy_LT 0
45-
#define HPy_LE 1
46-
#define HPy_EQ 2
47-
#define HPy_NE 3
48-
#define HPy_GT 4
49-
#define HPy_GE 5
44+
typedef enum {
45+
HPy_LT = 0,
46+
HPy_LE = 1,
47+
HPy_EQ = 2,
48+
HPy_NE = 3,
49+
HPy_GT = 4,
50+
HPy_GE = 5,
51+
} HPy_RichCmpOp;
52+
53+
// this needs to be a macro because val1 and val2 can be of arbitrary types
54+
#define HPy_RETURN_RICHCOMPARE(ctx, val1, val2, op) \
55+
do { \
56+
bool result; \
57+
switch (op) { \
58+
case HPy_EQ: result = ((val1) == (val2)); break; \
59+
case HPy_NE: result = ((val1) != (val2)); break; \
60+
case HPy_LT: result = ((val1) < (val2)); break; \
61+
case HPy_GT: result = ((val1) > (val2)); break; \
62+
case HPy_LE: result = ((val1) <= (val2)); break; \
63+
case HPy_GE: result = ((val1) >= (val2)); break; \
64+
default: \
65+
HPy_FatalError(ctx, "Invalid value for HPy_RichCmpOp"); \
66+
} \
67+
if (result) \
68+
return HPy_Dup(ctx, ctx->h_True); \
69+
return HPy_Dup(ctx, ctx->h_False); \
70+
} while (0)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef HPY_COMMON_RUNTIME_CTX_OBJECT_H
2+
#define HPY_COMMON_RUNTIME_CTX_OBJECT_H
3+
4+
#include <Python.h>
5+
#include "hpy.h"
6+
7+
_HPy_HIDDEN void ctx_Dump(HPyContext ctx, HPy h);
8+
9+
#endif /* HPY_COMMON_RUNTIME_CTX_OBJECT_H */
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
// automatically generated by setup.py:get_scm_config()
3-
#define HPY_VERSION "0.1.dev950+g98f448a"
4-
#define HPY_GIT_REVISION "98f448a"
3+
#define HPY_VERSION "0.1.dev965+g6d3b941"
4+
#define HPY_GIT_REVISION "6d3b941"

graalpython/com.oracle.graal.python.cext/include/cpython/autogen_hpyfunc_trampolines.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@
9595
{ \
9696
return (IMPL(_HPyGetContext(), _py2h(arg0))); \
9797
}
98-
#define _HPyFunc_TRAMPOLINE_HPyFunc_RICHCMPFUNC(SYM, IMPL) \
99-
static cpy_PyObject *SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, int arg2) \
100-
{ \
101-
return _h2py(IMPL(_HPyGetContext(), _py2h(arg0), _py2h(arg1), arg2)); \
102-
}
10398
#define _HPyFunc_TRAMPOLINE_HPyFunc_GETITERFUNC(SYM, IMPL) \
10499
static cpy_PyObject *SYM(cpy_PyObject *arg0) \
105100
{ \

graalpython/com.oracle.graal.python.cext/include/cpython/hpy.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ HPy_AsPyObject(HPyContext ctx, HPy h)
274274
#include "../common/hpymodule.h"
275275
#include "../common/runtime/ctx_call.h"
276276
#include "../common/runtime/ctx_module.h"
277+
#include "../common/runtime/ctx_object.h"
277278
#include "../common/runtime/ctx_type.h"
278279
#include "../common/runtime/ctx_listbuilder.h"
279280
#include "../common/runtime/ctx_tracker.h"
@@ -322,6 +323,12 @@ HPy_CallTupleDict(HPyContext ctx, HPy callable, HPy args, HPy kw)
322323
return ctx_CallTupleDict(ctx, callable, args, kw);
323324
}
324325

326+
HPyAPI_FUNC(void)
327+
_HPy_Dump(HPyContext ctx, HPy h)
328+
{
329+
return ctx_Dump(ctx, h);
330+
}
331+
325332
HPyAPI_FUNC(HPyListBuilder)
326333
HPyListBuilder_New(HPyContext ctx, HPy_ssize_t initial_size)
327334
{

graalpython/com.oracle.graal.python.cext/include/cpython/hpyfunc_trampolines.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,13 @@
6060
Py_TYPE(self)->tp_free(self); \
6161
}
6262

63+
/* this needs to be written manually because HPy has a different type for
64+
"op": HPy_RichCmpOp instead of int */
65+
#define _HPyFunc_TRAMPOLINE_HPyFunc_RICHCMPFUNC(SYM, IMPL) \
66+
static cpy_PyObject * \
67+
SYM(PyObject *self, PyObject *obj, int op) \
68+
{ \
69+
return _h2py(IMPL(_HPyGetContext(), _py2h(self), _py2h(obj), op)); \
70+
}
71+
6372
#endif // HPY_CPYTHON_HPYFUNC_TRAMPOLINES_H

graalpython/com.oracle.graal.python.cext/include/universal/autogen_ctx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,5 @@ struct _HPyContext_s {
206206
int (*ctx_Tracker_Add)(HPyContext ctx, HPyTracker ht, HPy h);
207207
void (*ctx_Tracker_ForgetAll)(HPyContext ctx, HPyTracker ht);
208208
void (*ctx_Tracker_Close)(HPyContext ctx, HPyTracker ht);
209+
void (*ctx_Dump)(HPyContext ctx, HPy h);
209210
};

graalpython/com.oracle.graal.python.cext/include/universal/autogen_hpyfunc_trampolines.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -266,22 +266,6 @@ typedef struct {
266266
return a.result; \
267267
}
268268

269-
typedef struct {
270-
cpy_PyObject *arg0;
271-
cpy_PyObject *arg1;
272-
int arg2;
273-
cpy_PyObject * result;
274-
} _HPyFunc_args_RICHCMPFUNC;
275-
276-
#define _HPyFunc_TRAMPOLINE_HPyFunc_RICHCMPFUNC(SYM, IMPL) \
277-
static cpy_PyObject *SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, int arg2) \
278-
{ \
279-
_HPyFunc_args_RICHCMPFUNC a = { arg0, arg1, arg2 }; \
280-
_HPy_CallRealFunctionFromTrampoline( \
281-
_ctx_for_trampolines, HPyFunc_RICHCMPFUNC, IMPL, &a); \
282-
return a.result; \
283-
}
284-
285269
typedef struct {
286270
cpy_PyObject *arg0;
287271
cpy_PyObject * result;

0 commit comments

Comments
 (0)