Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-106210 Remove Emscripten import trampoline #106211

Merged
merged 4 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed Emscripten import trampoline as it was no longer necessary for Pyodide.
14 changes: 2 additions & 12 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,16 +839,6 @@ _PyImport_ClearExtension(PyObject *name, PyObject *filename)
}


/*******************/

#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
#include <emscripten.h>
EM_JS(PyObject*, _PyImport_InitFunc_TrampolineCall, (PyModInitFunction func), {
return wasmTable.get(func)();
});
#endif // __EMSCRIPTEN__ && PY_CALL_TRAMPOLINE


/*****************************/
/* single-phase init modules */
/*****************************/
Expand Down Expand Up @@ -1285,7 +1275,7 @@ import_find_extension(PyThreadState *tstate, PyObject *name,
else {
if (def->m_base.m_init == NULL)
return NULL;
mod = _PyImport_InitFunc_TrampolineCall(def->m_base.m_init);
mod = def->m_base.m_init();
if (mod == NULL)
return NULL;
if (PyObject_SetItem(modules, name, mod) == -1) {
Expand Down Expand Up @@ -1400,7 +1390,7 @@ create_builtin(PyThreadState *tstate, PyObject *name, PyObject *spec)
/* Cannot re-init internal module ("sys" or "builtins") */
return import_add_module(tstate, name);
}
mod = _PyImport_InitFunc_TrampolineCall(*p->initfunc);
mod = (*p->initfunc)();
if (mod == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion Python/importdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ _PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *fp)

/* Package context is needed for single-phase init */
oldcontext = _PyImport_SwapPackageContext(newcontext);
m = _PyImport_InitFunc_TrampolineCall(p0);
m = p0();
_PyImport_SwapPackageContext(oldcontext);

if (m == NULL) {
Expand Down
6 changes: 0 additions & 6 deletions Python/importdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ extern PyObject *_PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *);

typedef PyObject *(*PyModInitFunction)(void);

#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
extern PyObject *_PyImport_InitFunc_TrampolineCall(PyModInitFunction func);
#else
#define _PyImport_InitFunc_TrampolineCall(func) (func)()
#endif

/* Max length of module suffix searched for -- accommodates "module.slb" */
#define MAXSUFFIXSIZE 12

Expand Down