mirror of
https://github.com/python/cpython.git
synced 2025-11-24 04:17:38 +00:00
[3.14] gh-128627: Use __builtin_wasm_test_function_pointer_signature for Emscripten trampoline (GH-137470) (#139039)
Some checks are pending
Tests / Windows MSI (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / Windows MSI (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
gh-128627: Use __builtin_wasm_test_function_pointer_signature for Emscripten trampoline (GH-137470)
With https://github.com/llvm/llvm-project/pull/150201 being merged, there is
now a better way to generate the Emscripten trampoline, instead of including
hand-generated binary WASM content. Requires Emscripten 4.0.12.
(cherry picked from commit 2629ee4eb0)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
This commit is contained in:
parent
7a2854eb12
commit
0e4e608f03
9 changed files with 129 additions and 201 deletions
38
Python/emscripten_trampoline_inner.c
Normal file
38
Python/emscripten_trampoline_inner.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// This file must be compiled with -mgc to enable the extra wasm-gc
|
||||
// instructions. It has to be compiled separately because not enough JS runtimes
|
||||
// support wasm-gc yet. If the JS runtime does not support wasm-gc (or has buggy
|
||||
// support like iOS), we will use the JS trampoline fallback.
|
||||
|
||||
// We can't import Python.h here because it is compiled/linked with -nostdlib.
|
||||
// We don't need to know what's inside PyObject* anyways. We could just call it
|
||||
// void* everywhere. There are two reasons to do this:
|
||||
// 1. to improve readability
|
||||
// 2. eventually when we are comfortable requiring wasm-gc, we can merge this
|
||||
// into emscripten_trampoline.c without worrying about it.
|
||||
typedef void PyObject;
|
||||
|
||||
typedef PyObject* (*three_arg)(PyObject*, PyObject*, PyObject*);
|
||||
typedef PyObject* (*two_arg)(PyObject*, PyObject*);
|
||||
typedef PyObject* (*one_arg)(PyObject*);
|
||||
typedef PyObject* (*zero_arg)(void);
|
||||
|
||||
#define TRY_RETURN_CALL(ty, args...) \
|
||||
if (__builtin_wasm_test_function_pointer_signature((ty)func)) { \
|
||||
return ((ty)func)(args); \
|
||||
}
|
||||
|
||||
__attribute__((export_name("trampoline_call"))) PyObject*
|
||||
trampoline_call(int* success,
|
||||
void* func,
|
||||
PyObject* self,
|
||||
PyObject* args,
|
||||
PyObject* kw)
|
||||
{
|
||||
*success = 1;
|
||||
TRY_RETURN_CALL(three_arg, self, args, kw);
|
||||
TRY_RETURN_CALL(two_arg, self, args);
|
||||
TRY_RETURN_CALL(one_arg, self);
|
||||
TRY_RETURN_CALL(zero_arg);
|
||||
*success = 0;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue