Skip to content

Commit d4ba173

Browse files
committed
Merge commit 'dbc51fccb2a2b1857a0e3deeeaee0bd182630024' into release/graal-vm/1.0
2 parents e4608bb + dbc51fc commit d4ba173

File tree

229 files changed

+9373
-3171
lines changed

Some content is hidden

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

229 files changed

+9373
-3171
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
This changelog summarizes major changes between GraalVM versions of the Python
44
language runtime. The main focus is on user-observable behavior of the engine.
55

6+
## Version 1.0.0 RC13
7+
8+
* Support marshal.dumps and marshal.loads for code objects and some other built-in objects
9+
* Fix installation of NumPy in a venv
10+
* Initial support for module mmap
11+
* Support debugging with workspace files in the Chrome debugger
12+
* Support the PEP 553 breakpoint() message
13+
* Support running weak reference callbacks and signals on the main thread
14+
615
## Version 1.0.0 RC12
716

817
* Support the `__class__` variable in the class scope

ci.jsonnet

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
overlay: "3cf78c3623442ad827eed58a1780784a6eb95676",
2+
overlay: "d20cc2abdeb3cfb022e1a8035e40e350e5cfe5fc",
33

44
// ======================================================================================================
55
//
@@ -88,6 +88,7 @@
8888

8989
local darwinMixin = {
9090
capabilities +: ["darwin_sierra", "amd64"],
91+
timelimit: TIME_LIMIT["1h"],
9192
packages +: {
9293
"pip:astroid": "==1.1.0",
9394
"pip:pylint": "==1.1.0",
@@ -127,7 +128,7 @@
127128

128129
local labsjdk8Mixin = {
129130
downloads +: {
130-
JAVA_HOME: utils.download("labsjdk", "8u172-jvmci-0.48"),
131+
JAVA_HOME: utils.download("labsjdk", "8u192-jvmci-0.54"),
131132
EXTRA_JAVA_HOMES : { pathlist: [utils.download("oraclejdk", "11+20")] },
132133
},
133134
environment +: {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3+
#
4+
# The Universal Permissive License (UPL), Version 1.0
5+
#
6+
# Subject to the condition set forth below, permission is hereby granted to any
7+
# person obtaining a copy of this software, associated documentation and/or
8+
# data (collectively the "Software"), free of charge and under any and all
9+
# copyright rights in the Software, and any and all patent rights owned or
10+
# freely licensable by each licensor hereunder covering either (i) the
11+
# unmodified Software as contributed to or provided by such licensor, or (ii)
12+
# the Larger Works (as defined below), to deal in both
13+
#
14+
# (a) the Software, and
15+
#
16+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
17+
# one is included with the Software each a "Larger Work" to which the Software
18+
# is contributed by such licensors),
19+
#
20+
# without restriction, including without limitation the rights to copy, create
21+
# derivative works of, display, perform, and distribute the Software and make,
22+
# use, sell, offer for sale, import, export, have made, and have sold the
23+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
24+
# either these or other terms.
25+
#
26+
# This license is subject to the following condition:
27+
#
28+
# The above copyright notice and either this complete permission notice or at a
29+
# minimum a reference to the UPL must be included in all copies or substantial
30+
# portions of the Software.
31+
#
32+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38+
# SOFTWARE.
39+
40+
import mmap
41+
42+
# create 64 MB anonymous mmap
43+
size = 64*1024
44+
mm = mmap.mmap(-1, size)
45+
data = b"Hello World"
46+
ndata = len(data)
47+
niter = size // ndata
48+
49+
50+
def fill():
51+
# sequential access
52+
mm.seek(0)
53+
for i in range(niter):
54+
mm.write(data)
55+
56+
57+
def measure(num):
58+
for i in range(num):
59+
fill()
60+
print(mm[0:ndata])
61+
62+
63+
def __benchmark__(num=100):
64+
measure(num)
65+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3+
#
4+
# The Universal Permissive License (UPL), Version 1.0
5+
#
6+
# Subject to the condition set forth below, permission is hereby granted to any
7+
# person obtaining a copy of this software, associated documentation and/or
8+
# data (collectively the "Software"), free of charge and under any and all
9+
# copyright rights in the Software, and any and all patent rights owned or
10+
# freely licensable by each licensor hereunder covering either (i) the
11+
# unmodified Software as contributed to or provided by such licensor, or (ii)
12+
# the Larger Works (as defined below), to deal in both
13+
#
14+
# (a) the Software, and
15+
#
16+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
17+
# one is included with the Software each a "Larger Work" to which the Software
18+
# is contributed by such licensors),
19+
#
20+
# without restriction, including without limitation the rights to copy, create
21+
# derivative works of, display, perform, and distribute the Software and make,
22+
# use, sell, offer for sale, import, export, have made, and have sold the
23+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
24+
# either these or other terms.
25+
#
26+
# This license is subject to the following condition:
27+
#
28+
# The above copyright notice and either this complete permission notice or at a
29+
# minimum a reference to the UPL must be included in all copies or substantial
30+
# portions of the Software.
31+
#
32+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38+
# SOFTWARE.
39+
40+
import mmap
41+
import tempfile
42+
43+
# create temporary file
44+
data = b"Hello World"
45+
ndata = len(data)
46+
47+
48+
def fill(mm, size):
49+
# sequential access
50+
mm.seek(0)
51+
for i in range(size // ndata):
52+
mm.write(data)
53+
54+
55+
def measure(num):
56+
tmp_path = tempfile.mkstemp()
57+
with open(tmp_path[1], "wb") as f:
58+
f.write(b'\x00' * (64 * 1024))
59+
60+
with open(tmp_path[1], "r+b") as f:
61+
mm = mmap.mmap(f.fileno(), 0)
62+
size = mm.size()
63+
for i in range(num):
64+
fill(mm, size)
65+
print(mm[0:ndata])
66+
67+
68+
def __benchmark__(num=100):
69+
measure(num)
70+

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

Lines changed: 1 addition & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates.
2+
* Copyright (c) 2016, 2019, Oracle and/or its affiliates.
33
*
44
* All rights reserved.
55
*
@@ -57,100 +57,6 @@ bool truffle_cannot_be_handle(void *nativeHandle);
5757
// wrapping functions
5858
void *truffle_decorate_function(void *function, void *wrapper);
5959

60-
/*
61-
* All function below here are deprecated and will be removed in a future release.
62-
* Use the equivalent functions from <polyglot.h> instead.
63-
*/
64-
65-
void *truffle_import(const char *name); // renamed to polyglot_import
66-
void *truffle_import_cached(const char *name); // no replacement, use polyglot_import
67-
68-
void *truffle_address_to_function(void *address); // deprecated, does nothing
69-
70-
void *truffle_get_arg(int i); // renamed to polyglot_get_arg
71-
72-
// Predicates:
73-
bool truffle_is_executable(const void *object); // renamed to polyglot_can_execute
74-
bool truffle_is_null(const void *object); // renamed to polyglot_is_null
75-
bool truffle_has_size(const void *object); // renamed to polyglot_has_array_elements
76-
bool truffle_is_boxed(const void *object); // no replacement
77-
bool truffle_is_truffle_object(const void *object); // renamed to polyglot_is_value
78-
79-
// Execute: deprecated, use typecast to function pointer instead
80-
void *truffle_execute(void *object, ...);
81-
int truffle_execute_i(void *object, ...);
82-
long truffle_execute_l(void *object, ...);
83-
char truffle_execute_c(void *object, ...);
84-
float truffle_execute_f(void *object, ...);
85-
double truffle_execute_d(void *object, ...);
86-
bool truffle_execute_b(void *object, ...);
87-
88-
// Invoke:
89-
void *truffle_invoke(void *object, const char *name, ...); // renamed to polyglot_invoke
90-
int truffle_invoke_i(void *object, const char *name, ...); // deprecated, use polyglot_as_i32(polyglot_invoke(...))
91-
long truffle_invoke_l(void *object, const char *name, ...); // deprecated, use polyglot_as_i64(polyglot_invoke(...))
92-
char truffle_invoke_c(void *object, const char *name, ...); // deprecated, use polyglot_as_i8(polyglot_invoke(...))
93-
float truffle_invoke_f(void *object, const char *name, ...); // deprecated, use polyglot_as_float(polyglot_invoke(...))
94-
double truffle_invoke_d(void *object, const char *name, ...); // deprecated, use polyglot_as_double(polyglot_invoke(...))
95-
bool truffle_invoke_b(void *object, const char *name, ...); // deprecated, use polyglot_as_boolean(polyglot_invoke(...))
96-
97-
// GetSize
98-
int truffle_get_size(const void *object); // renamed to polyglot_get_array_size
99-
100-
// Unbox
101-
int truffle_unbox_i(void *object); // renamed to polyglot_as_i32
102-
long truffle_unbox_l(void *object); // renamed to polyglot_as_i64
103-
char truffle_unbox_c(void *object); // renamed to polyglot_as_i8
104-
float truffle_unbox_f(void *object); // renamed to polyglot_as_float
105-
double truffle_unbox_d(void *object); // renamed to polyglot_as_double
106-
bool truffle_unbox_b(void *object); // renamed to polyglot_as_boolean
107-
108-
// Read
109-
void *truffle_read(void *object, const char *name); // renamed to polyglot_get_member
110-
int truffle_read_i(void *object, const char *name); // deprecated, use polyglot_as_i32(polyglot_get_member(...))
111-
long truffle_read_l(void *object, const char *name); // deprecated, use polyglot_as_i64(polyglot_get_member(...))
112-
char truffle_read_c(void *object, const char *name); // deprecated, use polyglot_as_i8(polyglot_get_member(...))
113-
float truffle_read_f(void *object, const char *name); // deprecated, use polyglot_as_float(polyglot_get_member(...))
114-
double truffle_read_d(void *object, const char *name); // deprecated, use polyglot_as_double(polyglot_get_member(...))
115-
bool truffle_read_b(void *object, const char *name); // deprecated, use polyglot_as_boolean(polyglot_get_member(...))
116-
117-
void *truffle_read_idx(void *object, int idx); // renamed to polyglot_get_array_element
118-
int truffle_read_idx_i(void *object, int idx); // deprecated, use polyglot_as_i32(polyglot_get_array_element(...))
119-
long truffle_read_idx_l(void *object, int idx); // deprecated, use polyglot_as_i64(polyglot_get_array_element(...))
120-
char truffle_read_idx_c(void *object, int idx); // deprecated, use polyglot_as_i8(polyglot_get_array_element(...))
121-
float truffle_read_idx_f(void *object, int idx); // deprecated, use polyglot_as_float(polyglot_get_array_element(...))
122-
double truffle_read_idx_d(void *object, int idx); // deprecated, use polyglot_as_double(polyglot_get_array_element(...))
123-
bool truffle_read_idx_b(void *object, int idx); // deprecated, use polyglot_as_boolean(polyglot_get_array_element(...))
124-
125-
// Write
126-
void truffle_write(void *object, const char *name, void *value); // renamed to polyglot_put_member
127-
void truffle_write_i(void *object, const char *name, int value); // deprecated, use polyglot_put_member
128-
void truffle_write_l(void *object, const char *name, long value); // deprecated, use polyglot_put_member
129-
void truffle_write_c(void *object, const char *name, char value); // deprecated, use polyglot_put_member
130-
void truffle_write_f(void *object, const char *name, float value); // deprecated, use polyglot_put_member
131-
void truffle_write_d(void *object, const char *name, double value); // deprecated, use polyglot_put_member
132-
void truffle_write_b(void *object, const char *name, bool value); // deprecated, use polyglot_put_member
133-
134-
void truffle_write_idx(void *object, int idx, void *value); // renamed to polyglot_set_array_element
135-
void truffle_write_idx_i(void *object, int idx, int value); // deprecated, use polyglot_set_array_element
136-
void truffle_write_idx_l(void *object, int idx, long value); // deprecated, use polyglot_set_array_element
137-
void truffle_write_idx_c(void *object, int idx, char value); // deprecated, use polyglot_set_array_element
138-
void truffle_write_idx_f(void *object, int idx, float value); // deprecated, use polyglot_set_array_element
139-
void truffle_write_idx_d(void *object, int idx, double value); // deprecated, use polyglot_set_array_element
140-
void truffle_write_idx_b(void *object, int idx, bool value); // deprecated, use polyglot_set_array_element
141-
142-
// Strings
143-
void *truffle_read_string(const char *string); // deprecated, use polyglot_from_string instead
144-
void *truffle_read_n_string(const char *string, int n); // deprecated, use polyglot_from_string_n instead
145-
void *truffle_read_bytes(const char *bytes); // deprecated, no replacement
146-
void *truffle_read_n_bytes(const char *bytes, int n); // deprecated, no replacement
147-
const char *truffle_string_to_cstr(const char *string); // deprecated, use polyglot_as_string instead
148-
void truffle_free_cstr(const char *truffle_allocated_cstr); // deprecated, no replacement
149-
150-
void *truffle_sulong_function_to_native_pointer(void *sulongFunctionPointer, const void *signature); // deprecated, no replacement
151-
152-
void *truffle_polyglot_eval(const char *mimeType, const char *code); // deprecated, use polyglot_eval instead
153-
15460
#if defined(__cplusplus)
15561
}
15662
#endif
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/* Copyright (c) 2019, Oracle and/or its affiliates.
2+
* Copyright (C) 1996-2017 Python Software Foundation
3+
*
4+
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
5+
*/
6+
7+
#include "../src/capi.h"
8+
9+
typedef enum
10+
{
11+
ACCESS_DEFAULT,
12+
ACCESS_READ,
13+
ACCESS_WRITE,
14+
ACCESS_COPY
15+
} access_mode;
16+
17+
typedef struct {
18+
PyObject_HEAD
19+
char * data;
20+
Py_ssize_t size;
21+
Py_ssize_t pos; /* relative to offset */
22+
#ifdef MS_WINDOWS
23+
long long offset;
24+
#else
25+
off_t offset;
26+
#endif
27+
int exports;
28+
29+
#ifdef MS_WINDOWS
30+
HANDLE map_handle;
31+
HANDLE file_handle;
32+
char * tagname;
33+
#endif
34+
35+
#ifdef UNIX
36+
int fd;
37+
#endif
38+
39+
PyObject *weakreflist;
40+
access_mode access;
41+
} mmap_object;
42+
43+
44+
POLYGLOT_DECLARE_TYPE(mmap_object);
45+
static PyTypeObject mmap_object_type = PY_TRUFFLE_TYPE("mmap.mmap", NULL, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, sizeof(mmap_object));
46+
47+
int mmap_getbuffer(PyObject *self, Py_buffer *view, int flags) {
48+
// TODO(fa) readonly flag
49+
return PyBuffer_FillInfo(view, (PyObject*)self, ((mmap_object *)self)->data, PyObject_Size((PyObject *)self), 0, flags);
50+
}
51+
52+
static PyObject* mmap_init_bufferprotocol(PyObject* self, PyObject* mmap_type) {
53+
assert(PyType_Check(mmap_type));
54+
initialize_type_structure(&mmap_object_type, mmap_type, polyglot_mmap_object_typeid());
55+
56+
polyglot_invoke(PY_TRUFFLE_CEXT, "PyTruffle_SetBufferProcs", native_to_java(mmap_type), (getbufferproc) mmap_getbuffer, (releasebufferproc) NULL);
57+
return Py_None;
58+
}
59+
60+
static struct PyMethodDef module_functions[] = {
61+
{"init_bufferprotocol", mmap_init_bufferprotocol, METH_O, NULL},
62+
{NULL, NULL} /* sentinel */
63+
};
64+
65+
static struct PyModuleDef mmapmodule = {
66+
PyModuleDef_HEAD_INIT,
67+
"_mmap",
68+
NULL,
69+
-1,
70+
module_functions,
71+
NULL,
72+
NULL,
73+
NULL,
74+
NULL
75+
};
76+
77+
PyMODINIT_FUNC
78+
PyInit__mmap(void)
79+
{
80+
PyObject *dict, *module;
81+
82+
module = PyModule_Create(&mmapmodule);
83+
if (module == NULL) {
84+
return NULL;
85+
}
86+
dict = PyModule_GetDict(module);
87+
if (!dict) {
88+
return NULL;
89+
}
90+
91+
return module;
92+
}

0 commit comments

Comments
 (0)