Skip to content

Commit 95fc9bb

Browse files
committed
[GR-58469] Cut ties with Sulong managed.
PullRequest: graalpython/3503
2 parents 145616b + 43b65c2 commit 95fc9bb

File tree

65 files changed

+427
-491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+427
-491
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
[![](https://img.shields.io/badge/pyenv-graalpy-blue)](#start-replacing-cpython-with-graalpy)
55
</a> [![Join Slack][badge-slack]][slack] [![GraalVM on Twitter][badge-twitter]][twitter] [![License](https://img.shields.io/badge/license-UPL-green)](#license)
66

7-
GraalPy is a high-performance implementation of the [Python](https://www.python.org/) language for the JVM built on [GraalVM](https://www.graalvm.org/).
8-
GraalPy is a Python 3.11 compliant runtime.
7+
GraalPy is a high-performance implementation of the Python language for the JVM built on [GraalVM](https://www.graalvm.org/python).
8+
GraalPy is a Python 3.11 compliant runtime.
99
It has first-class support for embedding in Java and can turn Python applications into fast, standalone binaries.
1010
GraalPy is ready for production running pure Python code and has experimental support for many popular native extension modules.
1111

@@ -24,7 +24,7 @@ GraalPy is ready for production running pure Python code and has experimental su
2424
* Support for native extension modules is considered experimental, but you can already install [packages](docs/user/Python-Runtime.md#installing-packages) like *NumPy*, *PyTorch*, or *Tensorflow*; run [Hugging Face](https://huggingface.co/) models like *Stable Diffusion* or *GPT*
2525
![](docs/user/assets/mcd.svg#gh-light-mode-only)![](docs/user/assets/mcd-dark.svg#gh-dark-mode-only)<sup>
2626
We run the tests of the [most depended on PyPI packages](https://libraries.io/pypi) every day.
27-
For 96% of those packages a recent version can be installed on GraalPy and GraalPy passes about 50% of all tests of all packages combined.
27+
For 97% of those packages a recent version can be installed on GraalPy and GraalPy passes over 60% of all tests of all packages combined.
2828
We assume that CPython not passing 100% of all tests is due to problems in our infrastructure that may also affect GraalPy.
2929
Packages where CPython fails all tests are marked as "not tested" for both CPython and GraalPy.
3030
</sup>

bisect-benchmark.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Usage:
44
# - Create a temporary branch based on the main branch (or the bad commit)
55
# - Fill in this configuration file, preferably using the automated script
6-
# graalpython-apptests/scripts/create-bisect-config
6+
# graal-enterprise/graalpython-enterprise/scripts/create-bisect-config
77
# - Commit and push the file
88
# - The push command output should give you a link to create a PR. Open it, but
99
# don't create a PR. Instead, you should execute the job on your commit using

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "b8527c2fa08fc88554559a4a54c9294155c84c4f" }
1+
{ "overlay": "5f2c190a2db5461ac877a32df039c3584ae08148" }

docs/contributor/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ There are also different options for how the Python interpreter is run, passed v
273273
* `default` - run using the standard options
274274
* `default-multi` - run using a shared engine, which is the mode that is recommended to embedders that want to spawn multiple isolated Python contexts
275275
* `native` - same as `default`, its name is due to the fact that it runs C extensions using a mixture of LLVM bitcode interpreted and compiled via GraalVM and real native libraries
276-
* `sandboxed` - this name is historical - this configuration requires Oracle GraalVM and runs all C extensions purely as LLVM bitcode on the GraalVM, without any access to the native OS libraries, i.e., using the `--llvm.managed` option for GraalVM.
276+
* `sandboxed` - this name is historical - this configuration runs some modules such as the posix and sha3 modules with Java code instead of with native access.
277277
278278
### Configuration of the underlying GraalVM runtime
279279

docs/user/Embedding-Permissions.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ This approach is the most compatible with CPython and provides bare access to th
3535
By default, this implementation bypasses the Truffle abstraction layer, and therefore it is not sandboxed and does not support custom implementations of [Truffle FileSystem service-provider](https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html), and other Polyglot API providers related to system interfaces.
3636

3737
The native backend is chosen by default when GraalPy is started via the `graalpy` or any other Python related launcher.
38-
The exceptions are Python related launchers with `-managed` suffix available only in Oracle GraalVM (for example, `graalpy-managed`), which by default use the `java` POSIX backend.
3938

4039
#### Limitations of the Native Backend
4140

@@ -49,7 +48,7 @@ Known limitations are:
4948
This backend uses the [Truffle abstraction layer](https://github.com/oracle/graal/blob/master/truffle/docs/README.md) and therefore supports custom Polyglot API providers related to system interfaces and sandboxing.
5049
Because this abstraction is POSIX agnostic, it does not expose all the necessary functionality. Some functionality is emulated, and some functionality is unsupported.
5150

52-
The Java backend is the default when GraalPy is run via the `Context` API, that is, [embedded in Java applications](https://github.com/oracle/graal/blob/master/docs/reference-manual/embedding/embed-languages.md), or when it is launched using Python-related launchers with the `-managed` suffix (available only in Oracle GraalVM).
51+
The Java backend is the default when GraalPy is run via the `Context` API, that is, [embedded in Java applications](https://github.com/oracle/graal/blob/master/docs/reference-manual/embedding/embed-languages.md).
5352

5453
#### Limitations of the Java Backend
5554

docs/user/Python-Standalone-Applications.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ redirect_from: /reference-manual/python/standalone-binaries/
99
# Python Standalone Applications
1010

1111
GraalPy enables you to create a Python application or library as a native application or JAR file with no external dependencies.
12-
The [Truffle framework](https://github.com/oracle/graal/tree/master/truffle) on which GraalPy is built, combined with the [Sulong LLVM runtime](https://github.com/oracle/graal/tree/master/sulong) that GraalPy leverages for managed execution of Python's native extensions, completely virtualizes all filesystem accesses, including those to the standard library and installed packages.
12+
The [Truffle framework](https://github.com/oracle/graal/tree/master/truffle) on which GraalPy is built virtualizes all filesystem accesses, including those to the standard library and installed pure Python packages.
13+
Packages that include native code can still circumvent this, however!
1314

1415
GraalPy includes a module named `standalone` to create a Python binary for Linux, macOS, and Windows.
1516
The modules bundles all your application's resources into a single file.

docs/user/assets/mcd-dark.svg

Lines changed: 3 additions & 3 deletions
Loading

docs/user/assets/mcd.svg

Lines changed: 3 additions & 3 deletions
Loading

graalpython/com.oracle.graal.python.cext/CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,13 @@ if(WIN32)
4747
require_var(CAPI_INC_DIR)
4848
require_var(TRUFFLE_H_INC)
4949
require_var(TRUFFLE_NFI_H_INC)
50-
require_var(LLVM_MODE)
5150
require_var(GRAALPY_EXT)
5251

5352
if(NOT DEFINED SRC_DIR)
5453
set(SRC_DIR "${CMAKE_SOURCE_DIR}")
5554
endif()
5655

57-
set(TARGET_LIBPYTHON "python-${LLVM_MODE}")
56+
set(TARGET_LIBPYTHON "python-native")
5857

5958
######################################################################
6059
# common variables and compile/link options (for all build targets)
@@ -75,11 +74,7 @@ add_compile_definitions(
7574
GRAALVM_PYTHON_LLVM
7675
)
7776

78-
if(${LLVM_MODE} STREQUAL "native")
79-
add_compile_definitions(GRAALVM_PYTHON_LLVM_NATIVE)
80-
else()
81-
add_compile_definitions(GRAALVM_PYTHON_LLVM_MANAGED)
82-
endif()
77+
add_compile_definitions(GRAALVM_PYTHON_LLVM_NATIVE)
8378

8479

8580
if(WIN32)

graalpython/com.oracle.graal.python.cext/include/graalpy/handles.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,8 @@
4848
#define HANDLE_BASE 0x8000000000000000ULL
4949
#define IMMORTAL_REFCNT (INT64_MAX >> 1)
5050

51-
#ifdef GRAALVM_PYTHON_LLVM_MANAGED
52-
/*
53-
* We can't include sulong headers here, they include stdbool.h and CPython has a test that
54-
* Python.h won't pull in stdbool.h
55-
*/
56-
PyAPI_FUNC(int) points_to_py_handle_space(void* ptr);
57-
#define stub_to_pointer(STUB_PTR) (STUB_PTR)
58-
#define pointer_to_stub(O) (O)
59-
#else /* GRAALVM_PYTHON_LLVM_MANAGED */
60-
6151
#define points_to_py_handle_space(PTR) ((((uintptr_t) (PTR)) & HANDLE_BASE) != 0)
6252
#define stub_to_pointer(STUB_PTR) (((uintptr_t) (STUB_PTR)) | HANDLE_BASE)
6353
#define pointer_to_stub(PTR) ((PyObject *)(((uintptr_t) (PTR)) & ~HANDLE_BASE))
6454

65-
#endif /* GRAALVM_PYTHON_LLVM_MANAGED */
66-
6755
#endif /* SRC_HANDLES_H_ */

graalpython/com.oracle.graal.python.cext/include/internal/pycore_object.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ static inline void _PyObject_GC_UNTRACK(
195195
// Macros to accept any type for the parameter, and to automatically pass
196196
// the filename and the filename (if NDEBUG is not defined) where the macro
197197
// is called.
198-
#ifdef GRAALVM_PYTHON_LLVM_MANAGED
199-
# define _PyObject_GC_TRACK(op)
200-
# define _PyObject_GC_UNTRACK(op)
201-
#else
202198
#ifdef NDEBUG
203199
# define _PyObject_GC_TRACK(op) \
204200
_PyObject_GC_TRACK(_PyObject_CAST(op))
@@ -210,7 +206,6 @@ static inline void _PyObject_GC_UNTRACK(
210206
# define _PyObject_GC_UNTRACK(op) \
211207
_PyObject_GC_UNTRACK(__FILE__, __LINE__, _PyObject_CAST(op))
212208
#endif
213-
#endif
214209

215210
#ifdef Py_REF_DEBUG
216211
extern void _PyDebug_PrintTotalRefs(void);

graalpython/com.oracle.graal.python.cext/include/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static inline Py_ssize_t Py_REFCNT(PyObject *ob) {
139139
// bpo-39573: The Py_SET_TYPE() function must be used to set an object type.
140140
PyAPI_FUNC(PyTypeObject*) PyTruffle_TYPE(PyObject *ob);
141141
static inline PyTypeObject* Py_TYPE(PyObject *ob) {
142-
#if defined(GRAALVM_PYTHON) && !defined(GRAALVM_PYTHON_LLVM_MANAGED) && defined(NDEBUG)
142+
#if defined(GRAALVM_PYTHON) && defined(NDEBUG)
143143
return (pointer_to_stub(ob)->ob_type);
144144
#else
145145
return PyTruffle_TYPE(ob);

graalpython/com.oracle.graal.python.cext/src/capi.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@
4545

4646
#include "pycore_gc.h" // _PyGC_InitState
4747

48-
#ifdef GRAALVM_PYTHON_LLVM_MANAGED
49-
int points_to_py_handle_space(void* ptr) {
50-
return polyglot_is_value(ptr);
51-
}
52-
#endif
53-
5448
typedef struct arrayobject {
5549
PyObject_VAR_HEAD
5650
char *ob_item;
@@ -282,15 +276,11 @@ PyObject* _Py_EllipsisObjectReference;
282276
PyObject* _Py_NoneStructReference;
283277
PyObject* _Py_NotImplementedStructReference;
284278

285-
#ifndef GRAALVM_PYTHON_LLVM_MANAGED
286279
THREAD_LOCAL PyThreadState *tstate_current = NULL;
287-
#endif /* GRAALVM_PYTHON_LLVM_MANAGED */
288280

289281
static void initialize_globals() {
290-
#ifndef GRAALVM_PYTHON_LLVM_MANAGED
291282
// store the thread state into a thread local variable
292283
tstate_current = GraalPyTruffleThreadState_Get(&tstate_current);
293-
#endif /* GRAALVM_PYTHON_LLVM_MANAGED */
294284
_Py_NoneStructReference = GraalPyTruffle_None();
295285
_Py_NotImplementedStructReference = GraalPyTruffle_NotImplemented();
296286
_Py_EllipsisObjectReference = GraalPyTruffle_Ellipsis();
@@ -890,9 +880,7 @@ PyAPI_FUNC(void) initialize_graal_capi(TruffleEnv* env, void **builtin_closures,
890880
TRUFFLE_CONTEXT = (*env)->getTruffleContext(env);
891881
}
892882

893-
#ifndef GRAALVM_PYTHON_LLVM_MANAGED
894883
_PyGC_InitState(gc);
895-
#endif
896884

897885
initialize_builtins(builtin_closures);
898886
PyTruffle_Log(PY_TRUFFLE_LOG_FINE, "initialize_builtins: %fs", ((double) (clock() - t)) / CLOCKS_PER_SEC);

graalpython/com.oracle.graal.python.cext/src/capi.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@
8383
#include "pycore_global_objects.h" // _PY_NSMALLPOSINTS
8484
#include "pycore_gc.h" // PyGC_Head
8585

86-
#ifdef GRAALVM_PYTHON_LLVM_MANAGED
87-
#include <graalvm/llvm/polyglot.h>
88-
#endif
89-
9086
#define SRC_CS "utf-8"
9187

9288
/* Flags definitions representing global (debug) options. */
@@ -159,9 +155,7 @@ CAPI_BUILTINS
159155

160156
PyAPI_DATA(uint32_t) Py_Truffle_Options;
161157

162-
#ifndef GRAALVM_PYTHON_LLVM_MANAGED
163158
extern THREAD_LOCAL Py_LOCAL_SYMBOL PyThreadState *tstate_current;
164-
#endif /* GRAALVM_PYTHON_LLVM_MANAGED */
165159

166160
extern Py_LOCAL_SYMBOL int graalpy_finalizing;
167161

graalpython/com.oracle.graal.python.cext/src/floatobject.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ PyFloat_AsDouble(PyObject *op)
301301
{
302302
// GraalPy change: read from native object stub or upcall for managed
303303
if (points_to_py_handle_space(op)) {
304-
#ifndef GRAALVM_PYTHON_LLVM_MANAGED
305304
if (PyFloat_Check(op)) {
306305
double val = ((GraalPyFloatObject*) pointer_to_stub(op))->ob_fval;
307306
#ifndef NDEBUG
@@ -311,7 +310,6 @@ PyFloat_AsDouble(PyObject *op)
311310
#endif
312311
return val;
313312
}
314-
#endif /* GRAALVM_PYTHON_LLVM_MANAGED */
315313
return GraalPyTruffleFloat_AsDouble(op);
316314
}
317315

graalpython/com.oracle.graal.python.cext/src/gcmodule.c

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,8 +2426,6 @@ PyInit_gc(void)
24262426
}
24272427
#endif // GraalPy change
24282428

2429-
#ifndef GRAALVM_PYTHON_LLVM_MANAGED
2430-
24312429
/* C API for controlling the state of the garbage collector */
24322430
int
24332431
PyGC_Enable(void)
@@ -2503,37 +2501,6 @@ _PyGC_CollectNoFail(PyThreadState *tstate)
25032501
gcstate->collecting = 0;
25042502
return n;
25052503
}
2506-
#else
2507-
int
2508-
PyGC_Enable(void)
2509-
{
2510-
return 0;
2511-
}
2512-
2513-
int
2514-
PyGC_Disable(void)
2515-
{
2516-
return 0;
2517-
}
2518-
2519-
int
2520-
PyGC_IsEnabled(void)
2521-
{
2522-
return 0;
2523-
}
2524-
2525-
Py_ssize_t
2526-
PyGC_Collect(void)
2527-
{
2528-
return 0;
2529-
}
2530-
2531-
PyAPI_FUNC(Py_ssize_t)
2532-
_PyGC_CollectNoFail(PyThreadState *tstate)
2533-
{
2534-
return 0;
2535-
}
2536-
#endif
25372504

25382505
#if 0 // GraalPy change
25392506
void
@@ -2614,7 +2581,6 @@ _PyGC_Fini(PyInterpreterState *interp)
26142581
}
26152582
#endif // GraalPy change
26162583

2617-
#ifndef GRAALVM_PYTHON_LLVM_MANAGED
26182584
/* for debugging */
26192585
void
26202586
_PyGC_Dump(PyGC_Head *g)
@@ -2708,28 +2674,6 @@ _PyObject_GC_Link(PyObject *op)
27082674
}
27092675
}
27102676

2711-
#else
2712-
2713-
void
2714-
_PyGC_Dump(PyGC_Head *g) {}
2715-
2716-
void
2717-
PyObject_GC_Track(void *op_raw) {}
2718-
2719-
void
2720-
PyObject_GC_UnTrack(void *op_raw) {}
2721-
2722-
int
2723-
PyObject_IS_GC(PyObject *obj)
2724-
{
2725-
return 0;
2726-
}
2727-
2728-
void
2729-
_PyObject_GC_Link(PyObject *op) {}
2730-
2731-
#endif
2732-
27332677
static PyObject *
27342678
gc_alloc(size_t basicsize, size_t presize)
27352679
{
@@ -2783,8 +2727,6 @@ _PyObject_GC_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
27832727
return op;
27842728
}
27852729

2786-
#ifndef GRAALVM_PYTHON_LLVM_MANAGED
2787-
27882730
PyVarObject *
27892731
_PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
27902732
{
@@ -2869,42 +2811,3 @@ _GraalPyObject_GC_NotifyOwnershipTransfer(PyObject *op)
28692811
CALL_TRAVERSE(traverse, op, visit_strong_reachable, NULL);
28702812
}
28712813
}
2872-
#else
2873-
2874-
2875-
PyVarObject *
2876-
_PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
2877-
{
2878-
return NULL;
2879-
}
2880-
2881-
void
2882-
PyObject_GC_Del(void *op) {}
2883-
2884-
int
2885-
PyObject_GC_IsTracked(PyObject* obj)
2886-
{
2887-
return 0;
2888-
}
2889-
2890-
int
2891-
PyObject_GC_IsFinalized(PyObject *obj)
2892-
{
2893-
return 1;
2894-
}
2895-
2896-
2897-
void
2898-
GraalPyObject_GC_Del(void *op) {}
2899-
2900-
/* Exposes 'gc_collect_impl' such that we can call it from Java. */
2901-
PyAPI_FUNC(Py_ssize_t)
2902-
GraalPyGC_Collect(int generation)
2903-
{
2904-
return 0;
2905-
}
2906-
2907-
PyAPI_FUNC(void)
2908-
_GraalPyObject_GC_NotifyOwnershipTransfer(PyObject *op) {}
2909-
2910-
#endif

graalpython/com.oracle.graal.python.cext/src/listobject.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
static int
4444
_list_clear(PyListObject *a)
4545
{
46-
#ifndef GRAALVM_PYTHON_LLVM_MANAGED
4746
int64_t i;
4847
PyObject **item;
4948

@@ -62,14 +61,12 @@ _list_clear(PyListObject *a)
6261
/* Never fails; the return value can be ignored.
6362
Note that there is no guarantee that the list is actually empty
6463
at this point, because XDECREF may have populated it again! */
65-
#endif
6664
return 0;
6765
}
6866

6967
static int
7068
list_traverse(PyListObject *o, visitproc visit, void *arg)
7169
{
72-
#ifndef GRAALVM_PYTHON_LLVM_MANAGED
7370
int64_t size, i;
7471
PyObject **ob_item;
7572

@@ -86,7 +83,6 @@ list_traverse(PyListObject *o, visitproc visit, void *arg)
8683

8784
for (i = size; --i >= 0; )
8885
Py_VISIT(ob_item[i]);
89-
#endif
9086
return 0;
9187
}
9288

0 commit comments

Comments
 (0)