Skip to content

Commit 6d07363

Browse files
committed
[GR-9957] Get sklearn linear regression example working with Sulong's dynamic cast mechanism
PullRequest: graalpython/88
2 parents 2db020f + 25e53a7 commit 6d07363

Some content is hidden

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

66 files changed

+1732
-362
lines changed

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
overlay: "2081dc054251c6658f7ce8f4b6671a474edbf2f6",
2+
overlay: "03b824f947adf9a67c80c3e8a27646d43a687bfb",
33

44
// ======================================================================================================
55
//

graalpython/com.oracle.graal.python.cext/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ default: ${TARGET_LIB} ${MODULE_TARGETS} ${HEADER_TARGETS}
5555

5656
CFLAGS=${LLVM_TARGET_FLAGS} -ggdb -emit-llvm
5757
OPT_FLAGS=-mem2reg -globalopt -simplifycfg -constprop -always-inline -instcombine -dse -loop-simplify -reassociate -licm -gvn
58-
WARNINGS=-Wno-int-to-pointer-cast -Wno-int-conversion -Wno-incompatible-pointer-types-discards-qualifiers
59-
INCLUDES=-I${VPATH}/include
58+
WARNINGS=-Wno-int-to-pointer-cast -Wno-int-conversion -Wno-incompatible-pointer-types-discards-qualifiers -Wno-pointer-type-mismatch
59+
INCLUDES=-I${POLYGLOT_INC} -I${VPATH}/include
6060

6161

6262
rebuild:

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include "unicodeobject.h"
7272
#include "pystate.h"
7373
#include "pyarena.h"
74+
#include "compile.h"
7475
#include "pythonrun.h"
7576
#include "ceval.h"
7677
#include "pyerrors.h"
@@ -106,6 +107,10 @@
106107
#include "code.h"
107108
#include "pyfpe.h"
108109
#include "memoryobject.h"
110+
#include "pystrhex.h"
111+
#include "codecs.h"
112+
#include "frameobject.h"
113+
#include "traceback.h"
109114

110115
#define PY_TRUFFLE_CEXT ((void*)polyglot_import("python_cext"))
111116
#define PY_BUILTIN ((void*)polyglot_import("python_builtins"))
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
/* Copyright (c) 2018, 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+
#ifndef Py_CODECREGISTRY_H
8+
#define Py_CODECREGISTRY_H
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
/* ------------------------------------------------------------------------
14+
15+
Python Codec Registry and support functions
16+
17+
18+
Written by Marc-Andre Lemburg ([email protected]).
19+
20+
Copyright (c) Corporation for National Research Initiatives.
21+
22+
------------------------------------------------------------------------ */
23+
24+
/* Register a new codec search function.
25+
26+
As side effect, this tries to load the encodings package, if not
27+
yet done, to make sure that it is always first in the list of
28+
search functions.
29+
30+
The search_function's refcount is incremented by this function. */
31+
32+
PyAPI_FUNC(int) PyCodec_Register(
33+
PyObject *search_function
34+
);
35+
36+
/* Codec registry lookup API.
37+
38+
Looks up the given encoding and returns a CodecInfo object with
39+
function attributes which implement the different aspects of
40+
processing the encoding.
41+
42+
The encoding string is looked up converted to all lower-case
43+
characters. This makes encodings looked up through this mechanism
44+
effectively case-insensitive.
45+
46+
If no codec is found, a KeyError is set and NULL returned.
47+
48+
As side effect, this tries to load the encodings package, if not
49+
yet done. This is part of the lazy load strategy for the encodings
50+
package.
51+
52+
*/
53+
54+
#ifndef Py_LIMITED_API
55+
PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
56+
const char *encoding
57+
);
58+
59+
PyAPI_FUNC(int) _PyCodec_Forget(
60+
const char *encoding
61+
);
62+
#endif
63+
64+
/* Codec registry encoding check API.
65+
66+
Returns 1/0 depending on whether there is a registered codec for
67+
the given encoding.
68+
69+
*/
70+
71+
PyAPI_FUNC(int) PyCodec_KnownEncoding(
72+
const char *encoding
73+
);
74+
75+
/* Generic codec based encoding API.
76+
77+
object is passed through the encoder function found for the given
78+
encoding using the error handling method defined by errors. errors
79+
may be NULL to use the default method defined for the codec.
80+
81+
Raises a LookupError in case no encoder can be found.
82+
83+
*/
84+
85+
PyAPI_FUNC(PyObject *) PyCodec_Encode(
86+
PyObject *object,
87+
const char *encoding,
88+
const char *errors
89+
);
90+
91+
/* Generic codec based decoding API.
92+
93+
object is passed through the decoder function found for the given
94+
encoding using the error handling method defined by errors. errors
95+
may be NULL to use the default method defined for the codec.
96+
97+
Raises a LookupError in case no encoder can be found.
98+
99+
*/
100+
101+
PyAPI_FUNC(PyObject *) PyCodec_Decode(
102+
PyObject *object,
103+
const char *encoding,
104+
const char *errors
105+
);
106+
107+
#ifndef Py_LIMITED_API
108+
/* Text codec specific encoding and decoding API.
109+
110+
Checks the encoding against a list of codecs which do not
111+
implement a str<->bytes encoding before attempting the
112+
operation.
113+
114+
Please note that these APIs are internal and should not
115+
be used in Python C extensions.
116+
117+
XXX (ncoghlan): should we make these, or something like them, public
118+
in Python 3.5+?
119+
120+
*/
121+
PyAPI_FUNC(PyObject *) _PyCodec_LookupTextEncoding(
122+
const char *encoding,
123+
const char *alternate_command
124+
);
125+
126+
PyAPI_FUNC(PyObject *) _PyCodec_EncodeText(
127+
PyObject *object,
128+
const char *encoding,
129+
const char *errors
130+
);
131+
132+
PyAPI_FUNC(PyObject *) _PyCodec_DecodeText(
133+
PyObject *object,
134+
const char *encoding,
135+
const char *errors
136+
);
137+
138+
/* These two aren't actually text encoding specific, but _io.TextIOWrapper
139+
* is the only current API consumer.
140+
*/
141+
PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalDecoder(
142+
PyObject *codec_info,
143+
const char *errors
144+
);
145+
146+
PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalEncoder(
147+
PyObject *codec_info,
148+
const char *errors
149+
);
150+
#endif
151+
152+
153+
154+
/* --- Codec Lookup APIs --------------------------------------------------
155+
156+
All APIs return a codec object with incremented refcount and are
157+
based on _PyCodec_Lookup(). The same comments w/r to the encoding
158+
name also apply to these APIs.
159+
160+
*/
161+
162+
/* Get an encoder function for the given encoding. */
163+
164+
PyAPI_FUNC(PyObject *) PyCodec_Encoder(
165+
const char *encoding
166+
);
167+
168+
/* Get a decoder function for the given encoding. */
169+
170+
PyAPI_FUNC(PyObject *) PyCodec_Decoder(
171+
const char *encoding
172+
);
173+
174+
/* Get an IncrementalEncoder object for the given encoding. */
175+
176+
PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
177+
const char *encoding,
178+
const char *errors
179+
);
180+
181+
/* Get an IncrementalDecoder object function for the given encoding. */
182+
183+
PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
184+
const char *encoding,
185+
const char *errors
186+
);
187+
188+
/* Get a StreamReader factory function for the given encoding. */
189+
190+
PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
191+
const char *encoding,
192+
PyObject *stream,
193+
const char *errors
194+
);
195+
196+
/* Get a StreamWriter factory function for the given encoding. */
197+
198+
PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
199+
const char *encoding,
200+
PyObject *stream,
201+
const char *errors
202+
);
203+
204+
/* Unicode encoding error handling callback registry API */
205+
206+
/* Register the error handling callback function error under the given
207+
name. This function will be called by the codec when it encounters
208+
unencodable characters/undecodable bytes and doesn't know the
209+
callback name, when name is specified as the error parameter
210+
in the call to the encode/decode function.
211+
Return 0 on success, -1 on error */
212+
PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
213+
214+
/* Lookup the error handling callback function registered under the given
215+
name. As a special case NULL can be passed, in which case
216+
the error handling callback for "strict" will be returned. */
217+
PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
218+
219+
/* raise exc as an exception */
220+
PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
221+
222+
/* ignore the unicode error, skipping the faulty input */
223+
PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
224+
225+
/* replace the unicode encode error with ? or U+FFFD */
226+
PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
227+
228+
/* replace the unicode encode error with XML character references */
229+
PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
230+
231+
/* replace the unicode encode error with backslash escapes (\x, \u and \U) */
232+
PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
233+
234+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
235+
/* replace the unicode encode error with backslash escapes (\N, \x, \u and \U) */
236+
PyAPI_FUNC(PyObject *) PyCodec_NameReplaceErrors(PyObject *exc);
237+
#endif
238+
239+
#ifndef Py_LIMITED_API
240+
PyAPI_DATA(const char *) Py_hexdigits;
241+
#endif
242+
243+
#ifdef __cplusplus
244+
}
245+
#endif
246+
#endif /* !Py_CODECREGISTRY_H */
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* Copyright (c) 2018, 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+
#ifndef Py_COMPILE_H
8+
#define Py_COMPILE_H
9+
10+
#ifndef Py_LIMITED_API
11+
#include "code.h"
12+
13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif
16+
17+
/* Public interface */
18+
struct _node; /* Declare the existence of this type */
19+
PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
20+
/* XXX (ncoghlan): Unprefixed type name in a public API! */
21+
22+
#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
23+
CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \
24+
CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \
25+
CO_FUTURE_GENERATOR_STOP)
26+
#define PyCF_MASK_OBSOLETE (CO_NESTED)
27+
#define PyCF_SOURCE_IS_UTF8 0x0100
28+
#define PyCF_DONT_IMPLY_DEDENT 0x0200
29+
#define PyCF_ONLY_AST 0x0400
30+
#define PyCF_IGNORE_COOKIE 0x0800
31+
32+
#ifndef Py_LIMITED_API
33+
typedef struct {
34+
int cf_flags; /* bitmask of CO_xxx flags relevant to future */
35+
} PyCompilerFlags;
36+
#endif
37+
38+
/* Future feature support */
39+
40+
typedef struct {
41+
int ff_features; /* flags set by future statements */
42+
int ff_lineno; /* line number of last future statement */
43+
} PyFutureFeatures;
44+
45+
#define FUTURE_NESTED_SCOPES "nested_scopes"
46+
#define FUTURE_GENERATORS "generators"
47+
#define FUTURE_DIVISION "division"
48+
#define FUTURE_ABSOLUTE_IMPORT "absolute_import"
49+
#define FUTURE_WITH_STATEMENT "with_statement"
50+
#define FUTURE_PRINT_FUNCTION "print_function"
51+
#define FUTURE_UNICODE_LITERALS "unicode_literals"
52+
#define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL"
53+
#define FUTURE_GENERATOR_STOP "generator_stop"
54+
55+
struct _mod; /* Declare the existence of this type */
56+
#define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar)
57+
PyAPI_FUNC(PyCodeObject *) PyAST_CompileEx(
58+
struct _mod *mod,
59+
const char *filename, /* decoded from the filesystem encoding */
60+
PyCompilerFlags *flags,
61+
int optimize,
62+
PyArena *arena);
63+
PyAPI_FUNC(PyCodeObject *) PyAST_CompileObject(
64+
struct _mod *mod,
65+
PyObject *filename,
66+
PyCompilerFlags *flags,
67+
int optimize,
68+
PyArena *arena);
69+
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(
70+
struct _mod * mod,
71+
const char *filename /* decoded from the filesystem encoding */
72+
);
73+
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromASTObject(
74+
struct _mod * mod,
75+
PyObject *filename
76+
);
77+
78+
/* _Py_Mangle is defined in compile.c */
79+
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
80+
81+
#define PY_INVALID_STACK_EFFECT INT_MAX
82+
PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
83+
84+
PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena);
85+
86+
#ifdef __cplusplus
87+
}
88+
#endif
89+
90+
#endif /* !Py_LIMITED_API */
91+
92+
/* These definitions must match corresponding definitions in graminit.h.
93+
There's code in compile.c that checks that they are the same. */
94+
#define Py_single_input 256
95+
#define Py_file_input 257
96+
#define Py_eval_input 258
97+
98+
#endif /* !Py_COMPILE_H */

0 commit comments

Comments
 (0)