8000 Update HPy inlined files: eb07982 · oracle/graalpython@0112b83 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0112b83

Browse files
committed
Update HPy inlined files: eb07982
1 parent 9452db7 commit 0112b83

21 files changed

+399
-86
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
/*
33
DO NOT EDIT THIS FILE!
44
5-
This file is automatically generated by tools/autogen.py from tools/public_api.h.
5+
This file is automatically generated by hpy.tools.autogen.hpyfunc.autogen_hpyfunc_declare_h
6+
See also hpy.tools.autogen and hpy/tools/public_api.h
7+
68
Run this to regenerate:
79
make autogen
810

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
/*
33
DO NOT EDIT THIS FILE!
44
5-
This file is automatically generated by tools/autogen.py from tools/public_api.h.
5+
This file is automatically generated by hpy.tools.autogen.hpyslot.autogen_hpyslot_h
6+
See also hpy.tools.autogen and hpy/tools/public_api.h
7+
68
Run this to regenerate:
79
make autogen
810

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
/*
33
DO NOT EDIT THIS FILE!
44
5-
This file is automatically generated by tools/autogen.py from tools/public_api.h.
5+
This file is automatically generated by hpy.tools.autogen.trampolines.autogen_impl_h
6+
See also hpy.tools.autogen and hpy/tools/public_api.h
7+
68
Run this to regenerate:
79
make autogen
810
@@ -268,6 +270,11 @@ HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceOr)(HPyContext ctx, HPy h1, HP
268270
return _py2h(PyNumber_InPlaceOr(_h2py(h1), _h2py(h2)));
269271
}
270272

273+
HPyAPI_STORAGE int _HPy_IMPL_NAME(Callable_Check)(HPyContext ctx, HPy h)
274+
{
275+
return PyCallable_Check(_h2py(h));
276+
}
277+
271278
HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_SetString)(HPyContext ctx, HPy h_type, const char *message)
272279
{
273280
PyErr_SetString(_h2py(h_type), message);
@@ -448,3 +455,8 @@ HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Dict_New)(HPyContext ctx)
448455
return _py2h(PyDict_New());
449456
}
450457

458+
HPyAPI_STORAGE int _HPy_IMPL_NAME(Tuple_Check)(HPyContext ctx, HPy h)
459+
{
460+
return PyTuple_Check(_h2py(h));
461+
}
462+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef HPY_COMMON_RUNTIME_CALL_H
2+
#define HPY_COMMON_RUNTIME_CALL_H
3+
4+
#include <Python.h>
5+
#include "hpy.h"
6+
7+
_HPy_HIDDEN HPy
8+
ctx_CallTupleDict(HPyContext ctx, HPy callable, HPy args, HPy kw);
9+
10+
#endif /* HPY_COMMON_RUNTIME_CALL_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.dev875+g7c832a2"
4-
#define HPY_GIT_REVISION "7c832a2"
3+
#define HPY_VERSION "0.1.dev950+g98f448a"
4+
#define HPY_GIT_REVISION "98f448a"

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
/*
33
DO NOT EDIT THIS FILE!
44
5-
This file is automatically generated by tools/autogen.py from tools/public_api.h.
5+
This file is automatically generated by hpy.tools.autogen.hpyfunc.autogen_cpython_hpyfunc_trampoline_h
6+
See also hpy.tools.autogen and hpy/tools/public_api.h
7+
68
Run this to regenerate:
79
make autogen
810

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ HPy_AsPyObject(HPyContext ctx, HPy h)
272272
#include "../common/hpydef.h"
273273
#include "../common/hpytype.h"
274274
#include "../common/hpymodule.h"
275+
#include "../common/runtime/ctx_call.h"
275276
#include "../common/runtime/ctx_module.h"
276277
#include "../common/runtime/ctx_type.h"
277278
#include "../common/runtime/ctx_listbuilder.h"
@@ -315,6 +316,12 @@ _HPy_Cast(HPyContext ctx, HPy h)
315316
return ctx_Cast(ctx, h);
316317
}
317318

319+
HPyAPI_FUNC(HPy)
320+
HPy_CallTupleDict(HPyContext ctx, HPy callable, HPy args, HPy kw)
321+
{
322+
return ctx_CallTupleDict(ctx, callable, args, kw);
323+
}
324+
318325
HPyAPI_FUNC(HPyListBuilder)
319326
HPyListBuilder_New(HPyContext ctx, HPy_ssize_t initial_size)
320327
{

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
/*
33
DO NOT EDIT THIS FILE!
44
5-
This file is automatically generated by tools/autogen.py from tools/public_api.h.
5+
This file is automatically generated by hpy.tools.autogen.ctx.autogen_ctx_h
6+
See also hpy.tools.autogen and hpy/tools/public_api.h
7+
68
Run this to regenerate:
79
make autogen
810
@@ -138,6 +140,9 @@ struct _HPyContext_s {
138140
HPy (*ctx_InPlaceAnd)(HPyContext ctx, HPy h1, HPy h2);
139141
HPy (*ctx_InPlaceXor)(HPyContext ctx, HPy h1, HPy h2);
140142
HPy (*ctx_InPlaceOr)(HPyContext ctx, HPy h1, HPy h2);
143+
int (*ctx_Callable_Check)(HPyContext ctx, HPy h);
144+
HPy (*ctx_CallTupleDict)(HPyContext ctx, HPy callable, HPy args, HPy kw);
145+
void (*ctx_FatalError)(HPyContext ctx, const char *message);
141146
void (*ctx_Err_SetString)(HPyContext ctx, HPy h_type, const char *message);
142147
void (*ctx_Err_SetObject)(HPyContext ctx, HPy h_type, HPy h_value);
143148
int (*ctx_Err_Occurred)(HPyContext ctx);
@@ -183,7 +188,7 @@ struct _HPyContext_s {
183188
int (*ctx_List_Append)(HPyContext ctx, HPy h_list, HPy h_item);
184189
int (*ctx_Dict_Check)(HPyContext ctx, HPy h);
185190
HPy (*ctx_Dict_New)(HPyContext ctx);
186-
void (*ctx_FatalError)(HPyContext ctx, const char *message);
191+
int (*ctx_Tuple_Check)(HPyContext ctx, HPy h);
187192
HPy (*ctx_Tuple_FromArray)(HPyContext ctx, HPy items[], HPy_ssize_t n);
188193
HPy (*ctx_FromPyObject)(HPyContext ctx, cpy_PyObject *obj);
189194
cpy_PyObject *(*ctx_AsPyObject)(HPyContext ctx, HPy h);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
/*
33
DO NOT EDIT THIS FILE!
44
5-
This file is automatically generated by tools/autogen.py from tools/public_api.h.
5+
This file is automatically generated by hpy.tools.autogen.hpyfunc.autogen_hpyfunc_trampoline_h
6+
See also hpy.tools.autogen and hpy/tools/public_api.h
7+
68
Run this to regenerate:
79
make autogen
810

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
/*
33
DO NOT EDIT THIS FILE!
44
5-
This file is automatically generated by tools/autogen.py from tools/public_api.h.
5+
This file is automatically generated by hpy.tools.autogen.trampolines.autogen_trampolines_h
6+
See also hpy.tools.autogen and hpy/tools/public_api.h
7+
68
Run this to regenerate:
79
make autogen
810
@@ -228,6 +230,14 @@ static inline HPy HPy_InPlaceOr(HPyContext ctx, HPy h1, HPy h2) {
228230
return ctx->ctx_InPlaceOr ( ctx, h1, h2 );
229231
}
230232

233+
static inline int HPyCallable_Check(HPyContext ctx, HPy h) {
234+
return ctx->ctx_Callable_Check ( ctx, h );
235+
}
236+
237+
static inline HPy HPy_CallTupleDict(HPyContext ctx, HPy callable, HPy args, HPy kw) {
238+
return ctx->ctx_CallTupleDict ( ctx, callable, args, kw );
239+
}
240+
231241
static inline void HPyErr_SetString(HPyContext ctx, HPy h_type, const char *message) {
232242
ctx->ctx_Err_SetString ( ctx, h_type, message );
233243
}
@@ -404,6 +414,10 @@ static inline HPy HPyDict_New(HPyContext ctx) {
404414
return ctx->ctx_Dict_New ( ctx );
405415
}
406416

417+
static inline int HPyTuple_Check(HPyContext ctx, HPy h) {
418+
return ctx->ctx_Tuple_Check ( ctx, h );
419+
}
420+
407421
static inline HPy HPyTuple_FromArray(HPyContext ctx, HPy items[], HPy_ssize_t n) {
408422
return ctx->ctx_Tuple_FromArray ( ctx, items, n );
409423
}
Lines changed: 38 additions & 0 deletions
< 10000 td data-grid-cell-id="diff-9bd2e8a21b3cb8a82ad9efba857680336c4ef96da99360470ab2e89a4c541f82-empty-0-0" data-selected="false" role="gridcell" style="background-color:var(--bgColor-accent-muted, var(--color-accent-subtle));flex-grow:1" tabindex="-1" valign="top" class="focusable-grid-cell diff-hunk-cell left-side" colSpan="4">
@@ -0,0 +1,38 @@
Original file line numberDiff line numberDiff line change
1+
#include <Python.h>
2+
#include "hpy.h"
3+
4+
#ifdef HPY_UNIVERSAL_ABI
5+
// for _h2py and _py2h
6+
# include "handles.h"
7+
#endif
8+
9+
_HPy_HIDDEN HPy
10+
ctx_CallTupleDict(HPyContext ctx, HPy callable, HPy args, HPy kw)
11+
{
12+
PyObject *obj;
13+
if (!HPy_IsNull(args) && !HPyTuple_Check(ctx, args)) {
14+
HPyErr_SetString(ctx, ctx->h_TypeError,
15+
"HPy_CallTupleDict requires args to be a tuple or null handle");
16+
return HPy_NULL;
17+
}
18+
if (!HPy_IsNull(kw) && !HPyDict_Check(ctx, kw)) {
19+
HPyErr_SetString(ctx, ctx->h_TypeError,
20+
"HPy_CallTupleDict requires kw to be a dict or null handle");
21+
return HPy_NULL;
22+
}
23+
if (HPy_IsNull(kw)) {
24+
obj = PyObject_CallObject(_h2py(callable), _h2py(args));
25+
}
26+
else if (!HPy_IsNull(args)){
27+
obj = PyObject_Call(_h2py(callable), _h2py(args), _h2py(kw));
28+
}
29+
else {
30+
// args is null, but kw is not, so we need to create an empty args tuple
31+
// for CPython's PyObject_Call
32+
HPy items[] = {};
33+
HPy empty_tuple = HPyTuple_FromArray(ctx, items, 0);
34+
obj = PyObject_Call(_h2py(callable), _h2py(empty_tuple), _h2py(kw));
35+
HPy_Close(ctx, empty_tuple);
36+
}
37+
return _py2h(obj);
38+
}
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-
__version__ = "0.1.dev875+g7c832a2"
4-
__git_revision__ = "7c832a2"
3+
__version__ = "0.1.dev950+g98f448a"
4+
__git_revision__ = "98f448a"

graalpython/lib-graalpython/modules/hpy/test/support.py

Lines changed: 77 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -198,33 +198,35 @@ def compile_module(self, ExtensionTemplate, main_src, name, extra_sources):
198198

199199
def make_module(self, ExtensionTemplate, main_src, name, extra_sources):
200200
"""
201-
Compile&load a modulo into memory. This is NOT a proper import: e.g. the module
202-
is not put into sys.modules
201+
Compile & load a module. This is NOT a proper import: e.g.
202+
the module is not put into sys.modules
203203
"""
204-
so_filename = self.compile_module(ExtensionTemplate, main_src, name,
205-
extra_sources)
206-
if self.hpy_abi == 'universal':
207-
return self.load_universal_module(name, so_filename)
208-
else:
209-
return self.load_cython_module(name, so_filename)
210-
211-
def load_universal_module(self, name, so_filename):
212-
assert self.hpy_abi == 'universal'
213-
import hpy.universal
214-
spec = Spec(name, so_filename)
215-
return hpy.universal.load_from_spec(spec)
216 D7AE -
217-
def load_cython_module(self, name, so_filename):
218-
assert self.hpy_abi == 'cpython'
219-
# we've got a normal CPython module compiled with the CPython API/ABI,
220-
# let's load it normally. It is important to do the imports only here,
221-
# because this file will be imported also by PyPy tests which runs on
222-
# Python2
223-
import importlib.util
224-
from importlib.machinery import ExtensionFileLoader
225-
spec = importlib.util.spec_from_file_location(name, so_filename)
226-
module = importlib.util.module_from_spec(spec)
227-
spec.loader.exec_module(module)
204+
mod_filename = self.compile_module(
205+
ExtensionTemplate, main_src, name, extra_sources)
206+
return self.load_module(name, mod_filename)
207+
208+
def load_module(self, name, mod_filename):
209+
# It is important to do the imports only here, because this file will
210+
# be imported also by PyPy tests which runs on Python2
211+
import importlib
212+
import sys
213+
import os
214+
if name in sys.modules:
215+
raise ValueError(
216+
"Test module {!r} already present in sys.modules".format(name))
217+
importlib.invalidate_caches()
218+
mod_dir = os.path.dirname(mod_filename)
219+
sys.path.insert(0, mod_dir)
220+
try:
221+
module = importlib.import_module(name)
222+
assert sys.modules[name] is module
223+
finally:
224+
# assert that the module import didn't change the sys.path entry
225+
# that was added above, then remove the entry.
226+
assert sys.path[0] == mod_dir
227+
del sys.path[0]
228+
if name in sys.modules:
229+
del sys.modules[name]
228< F438 /code>230
return module
229231

230232

@@ -242,9 +244,34 @@ def make_module(self, main_src, name='mytest', extra_sources=()):
242244
return self.compiler.make_module(ExtensionTemplate, main_src, name,
243245
extra_sources)
244246

245-
def should_check_refcount(self):
246-
# defaults to True on CPython, but is set to False by e.g. PyPy
247-
return sys.implementation.name == 'cpython'
247+
def supports_refcounts(self):
248+
""" Returns True if the underlying Python implementation supports
249+
reference counts.
250+
251+
By default returns True on CPython and False on other
252+
implementations.
253+
"""
254+
return sys.implementation.name == "cpython"
255+
256+
def supports_ordinary_make_module_imports(self):
257+
""" Returns True if `.make_module(...)` loads modules using a
258+
standard Python import mechanism (e.g. `importlib.import_module`).
259+
260+
By default returns True because the base implementation of
261+
`.make_module(...)` uses an ordinary import. Sub-classes that
262+
override `.make_module(...)` may also want to override this
263+
method.
264+
"""
265+
return True
266+
267+
def supports_sys_executable(self):
268+
""" Returns True is `sys.executable` is set to a value that allows
269+
a Python equivalent to the current Python to be launched via, e.g.,
270+
`subprocess.run(...)`.
271+
272+
By default returns `True` if sys.executabl 10000 e is set to a true value.
273+
"""
274+
return bool(getattr(sys, "executable", None))
248275

249276

250277
# the few functions below are copied and adapted from cffi/ffiplatform.py
@@ -263,32 +290,41 @@ def c_compile(tmpdir, ext, hpy_devel, hpy_abi, compiler_verbose=0, debug=None):
263290
os.environ[key] = value
264291
return outputfilename
265292

293+
266294
def _build(tmpdir, ext, hpy_devel, hpy_abi, compiler_verbose=0, debug=None):
267295
# XXX compact but horrible :-(
268296
from distutils.core import Distribution
269-
import distutils.errors, distutils.log
297+
import distutils.errors
298+
import distutils.log
270299
#
271300
dist = Distribution()
272301
dist.parse_config_files()
273-
options = dist.get_option_dict('build_ext')
274302
if debug is None:
275303
debug = sys.flags.debug
276-
options['debug'] = ('ffiplatform', debug)
277-
options['force'] = ('ffiplatform', True)
278-
options['build_lib'] = ('ffiplatform', tmpdir)
279-
options['build_temp'] = ('ffiplatform', tmpdir)
280-
#
304+
options_build_ext = dist.get_option_dict('build_ext')
305+
options_build_ext['debug'] = ('ffiplatform', debug)
306+
options_build_ext['force'] = ('ffiplatform', True)
307+
options_build_ext['build_lib'] = ('ffiplatform', tmpdir)
308+
options_build_ext['build_temp'] = ('ffiplatform', tmpdir)
309+
options_build_py = dist.get_option_dict('build_py')
310+
options_build_py['build_lib'] = ('ffiplatform', tmpdir)
311+
281312
# this is the equivalent of passing --hpy-abi from setup.py's command line
282313
dist.hpy_abi = hpy_abi
283-
hpy_devel.fix_distribution(dist, hpy_ext_modules=[ext])
284-
#
314+
dist.hpy_ext_modules = [ext]
315+
hpy_devel.fix_distribution(dist)
316+
285317
old_level = distutils.log.set_threshold(0) or 0
286318
try:
287319
distutils.log.set_verbosity(compiler_verbose)
288320
dist.run_command('build_ext')
289321
cmd_obj = dist.get_command_obj('build_ext')
290-
[soname] = cmd_obj.get_outputs()
322+
outputs = cmd_obj.get_outputs()
323+
if hpy_abi == "cpython":
324+
[mod_filename] = [x for x in outputs if not x.endswith(".py")]
325+
else:
326+
[mod_filename] = [x for x in outputs if x.endswith(".py")]
291327
finally:
292328
distutils.log.set_threshold(old_level)
293-
#
294-
return soname
329+
330+
return mod_filename

0 commit comments

Comments
 (0)
0