Skip to content

Commit 5000033

Browse files
authored
Fix missing lazy-related symbols for the JIT (#34)
* fix missing `PyLazyImport_CheckExact` * fix missing lazy-related symbols * fix missing lazy-related symbols * `extern` seems enough * Export _PyImport_LoadLazyImportTstate for JIT
1 parent c4ed3c4 commit 5000033

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

Include/internal/pycore_import.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ extern PyObject *
3636
_PyImport_ResolveName(PyThreadState *tstate, PyObject *name, PyObject *globals, int level);
3737
extern PyObject *
3838
_PyImport_GetAbsName(PyThreadState *tstate, PyObject *name, PyObject *globals, int level);
39-
extern PyObject *
39+
// Symbol is exported for the JIT on Windows builds.
40+
PyAPI_FUNC(PyObject *)
4041
_PyImport_LoadLazyImportTstate(PyThreadState *tstate, PyObject *lazy_import);
4142
extern PyObject *
4243
_PyImport_LazyImportModuleLevelObject(PyThreadState *tstate, PyObject *name, PyObject *builtins, PyObject *globals,

Include/internal/pycore_lazyimportobject.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
/* Lazy object interface */
44

5-
#ifndef Py_LAZYIMPORTOBJECT_H
6-
#define Py_LAZYIMPORTOBJECT_H
5+
#ifndef Py_INTERNAL_LAZYIMPORTOBJECT_H
6+
#define Py_INTERNAL_LAZYIMPORTOBJECT_H
7+
78
#ifdef __cplusplus
89
extern "C" {
910
#endif
1011

12+
#ifndef Py_BUILD_CORE
13+
# error "this header requires Py_BUILD_CORE define"
14+
#endif
15+
1116
PyAPI_DATA(PyTypeObject) PyLazyImport_Type;
1217
#define PyLazyImport_CheckExact(op) Py_IS_TYPE((op), &PyLazyImport_Type)
1318

@@ -28,4 +33,4 @@ PyAPI_FUNC(PyObject *) _PyLazyImport_New(PyObject *import_func, PyObject *from,
2833
#ifdef __cplusplus
2934
}
3035
#endif
31-
#endif /* !Py_LAZYIMPORTOBJECT_H */
36+
#endif /* !Py_INTERNAL_LAZYIMPORTOBJECT_H */

Python/bytecodes.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
#include "pycore_audit.h" // _PySys_Audit()
1212
#include "pycore_backoff.h"
1313
#include "pycore_cell.h" // PyCell_GetRef()
14+
#include "pycore_ceval.h" // _PyEval_LazyImportName(), _PyEval_LazyImportFrom()
1415
#include "pycore_code.h"
1516
#include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS
1617
#include "pycore_function.h"
18+
#include "pycore_import.h" // _PyImport_LoadLazyImportTstate()
1719
#include "pycore_instruments.h"
1820
#include "pycore_interpolation.h" // _PyInterpolation_Build()
1921
#include "pycore_intrinsics.h"
22+
#include "pycore_lazyimportobject.h" // PyLazyImport_CheckExact()
2023
#include "pycore_long.h" // _PyLong_ExactDealloc(), _PyLong_GetZero()
2124
#include "pycore_moduleobject.h" // PyModuleObject
2225
#include "pycore_object.h" // _PyObject_GC_TRACK()
@@ -2939,7 +2942,7 @@ dummy_func(
29392942
b = res ? PyStackRef_True : PyStackRef_False;
29402943
}
29412944

2942-
inst(IMPORT_NAME, (level, fromlist -- res)) {
2945+
inst(IMPORT_NAME, (level, fromlist -- res)) {
29432946
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 2);
29442947
PyObject *res_o;
29452948
if (!(oparg & 0x02)) {

Python/jit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
#include "pycore_floatobject.h"
1212
#include "pycore_frame.h"
1313
#include "pycore_function.h"
14+
#include "pycore_import.h"
1415
#include "pycore_interpframe.h"
1516
#include "pycore_interpolation.h"
1617
#include "pycore_intrinsics.h"
18+
#include "pycore_lazyimportobject.h"
1719
#include "pycore_list.h"
1820
#include "pycore_long.h"
1921
#include "pycore_opcode_metadata.h"

Tools/jit/template.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
#include "pycore_frame.h"
1313
#include "pycore_function.h"
1414
#include "pycore_genobject.h"
15+
#include "pycore_import.h"
1516
#include "pycore_interpframe.h"
1617
#include "pycore_interpolation.h"
1718
#include "pycore_intrinsics.h"
19+
#include "pycore_lazyimportobject.h"
1820
#include "pycore_jit.h"
1921
#include "pycore_list.h"
2022
#include "pycore_long.h"

0 commit comments

Comments
 (0)