cpython/Include/internal
Hood Chatham 6b179adb8c
gh-106213: Make Emscripten trampolines work with JSPI (GH-106219)
There is a WIP proposal to enable webassembly stack switching which have been
implemented in v8:

https://github.com/WebAssembly/js-promise-integration

It is not possible to switch stacks that contain JS frames so the Emscripten JS
trampolines that allow calling functions with the wrong number of arguments
don't work in this case. However, the js-promise-integration proposal requires
the [type reflection for Wasm/JS API](https://github.com/WebAssembly/js-types)
proposal, which allows us to actually count the number of arguments a function
expects.

For better compatibility with stack switching, this PR checks if type reflection
is available, and if so we use a switch block to decide the appropriate
signature. If type reflection is unavailable, we should use the current EMJS
trampoline.

We cache the function argument counts since when I didn't cache them performance
was negatively affected.

Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: Brett Cannon <brett@python.org>
2023-09-15 15:04:21 -07:00
..
pycore_abstract.h gh-106320: Remove private AC converter functions (#108505) 2023-08-26 04:05:17 +02:00
pycore_asdl.h
pycore_ast.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_ast_state.h gh-104656: Rename typeparams AST node to type_params (#104657) 2023-05-21 21:25:09 -07:00
pycore_atexit.h gh-107211: No longer export internal functions (4) (#107217) 2023-07-25 03:16:28 +00:00
pycore_atomic.h gh-108337: Add pyatomic.h header (#108701) 2023-08-31 21:41:18 +00:00
pycore_atomic_funcs.h
pycore_bitutils.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_blocks_output_buffer.h gh-108220: Internal header files require Py_BUILD_CORE to be defined (#108221) 2023-08-21 19:15:52 +02:00
pycore_bytes_methods.h
pycore_bytesobject.h gh-107211: No longer export internal functions (5) (#108423) 2023-08-24 16:06:53 +00:00
pycore_call.h gh-106320: Remove private _Py_Identifier API (#108593) 2023-08-29 02:29:46 +02:00
pycore_capsule.h gh-108240: Add pycore_capsule.h internal header file (#108596) 2023-08-29 01:20:02 +00:00
pycore_ceval.h gh-106320: Remove private _PyEval function (#108433) 2023-08-24 20:25:22 +02:00
pycore_ceval_state.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_code.h GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300) 2023-09-13 10:25:45 -07:00
pycore_codecs.h gh-108220: Internal header files require Py_BUILD_CORE to be defined (#108221) 2023-08-21 19:15:52 +02:00
pycore_compile.h gh-107211: No longer export internal functions (5) (#108423) 2023-08-24 16:06:53 +00:00
pycore_complexobject.h gh-107211: No longer export internal functions (5) (#108423) 2023-08-24 16:06:53 +00:00
pycore_condvar.h gh-108765: Move standard includes to Python.h (#108769) 2023-09-01 21:03:20 +02:00
pycore_context.h gh-106320: Remove private _PyContext_NewHamtForTests() (#108434) 2023-08-24 19:37:41 +02:00
pycore_descrobject.h gh-106320: Move _PyMethodWrapper_Type to internal C API (#107064) 2023-07-22 20:57:59 +00:00
pycore_dict.h gh-106320: Remove private _Py_Identifier API (#108593) 2023-08-29 02:29:46 +02:00
pycore_dict_state.h
pycore_dtoa.h gh-107211: No longer export internal functions (1) (#107213) 2023-07-25 03:44:11 +02:00
pycore_emscripten_signal.h GH-108614: Unbreak emscripten build (GH-109132) 2023-09-08 17:54:45 +01:00
pycore_emscripten_trampoline.h gh-106213: Make Emscripten trampolines work with JSPI (GH-106219) 2023-09-15 15:04:21 -07:00
pycore_exceptions.h
pycore_faulthandler.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_fileutils.h gh-106320: Fix test_peg_generator: _Py_UniversalNewlineFgetsWithSize() (#108609) 2023-08-29 03:40:13 +00:00
pycore_fileutils_windows.h gh-108220: Internal header files require Py_BUILD_CORE to be defined (#108221) 2023-08-21 19:15:52 +02:00
pycore_floatobject.h gh-106320: Remove private float C API functions (#108430) 2023-08-24 19:09:49 +02:00
pycore_flowgraph.h gh-106149: move CFG and basicblock definitions into flowgraph.c, use them as opaque types in compile.c (#107639) 2023-08-10 13:03:47 +01:00
pycore_format.h
pycore_frame.h gh-107149: Make PyUnstable_ExecutableKinds public (#108440) 2023-08-31 09:56:06 +02:00
pycore_function.h gh-106581: Project through calls (#108067) 2023-08-17 11:29:58 -07:00
pycore_gc.h gh-105268: Add _Py_FROM_GC() function to pycore_gc.h (#105362) 2023-06-06 14:44:48 +02:00
pycore_genobject.h gh-107211: No longer export internal functions (5) (#108423) 2023-08-24 16:06:53 +00:00
pycore_getopt.h
pycore_gil.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_global_objects.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_global_objects_fini_generated.h Run make regen-global-objects (#108714) 2023-08-31 15:37:14 +02:00
pycore_global_strings.h Run make regen-global-objects (#108714) 2023-08-31 15:37:14 +02:00
pycore_hamt.h
pycore_hashtable.h gh-107211: No longer export internal functions (5) (#108423) 2023-08-24 16:06:53 +00:00
pycore_identifier.h gh-106320: Remove private _Py_Identifier API (#108593) 2023-08-29 02:29:46 +02:00
pycore_import.h gh-107211: No longer export internal functions (5) (#108423) 2023-08-24 16:06:53 +00:00
pycore_initconfig.h gh-108634: PyInterpreterState_New() no longer calls Py_FatalError() (#108748) 2023-09-01 12:43:30 +02:00
pycore_instruments.h gh-109039: Branch prediction for Tier 2 interpreter (#109038) 2023-09-11 18:20:24 +00:00
pycore_interp.h GH-108716: Turn off deep-freezing of code objects. (GH-108722) 2023-09-08 10:34:40 +01:00
pycore_intrinsics.h gh-108220: Internal header files require Py_BUILD_CORE to be defined (#108221) 2023-08-21 19:15:52 +02:00
pycore_list.h gh-106320: Remove private _PyList functions (#108451) 2023-08-24 19:44:34 +00:00
pycore_long.h gh-106320: Remove private _PyLong_Sign() (#108743) 2023-09-01 09:13:07 +02:00
pycore_memoryobject.h gh-106320: Remove private _PyManagedBuffer_Type (#108431) 2023-08-24 19:07:54 +02:00
pycore_modsupport.h gh-106320: Create pycore_modsupport.h header file (#106355) 2023-07-03 09:39:11 +00:00
pycore_moduleobject.h gh-106320: Remove private _PyModule API (#107070) 2023-07-22 21:41:11 +00:00
pycore_namespace.h gh-107211: No longer export internal functions (4) (#107217) 2023-07-25 03:16:28 +00:00
pycore_object.h gh-106213: Make Emscripten trampolines work with JSPI (GH-106219) 2023-09-15 15:04:21 -07:00
pycore_object_state.h gh-108634: Py_TRACE_REFS uses a hash table (#108663) 2023-08-31 18:33:34 +02:00
pycore_obmalloc.h gh-107211: No longer export internal functions (6) (#108424) 2023-08-24 17:28:35 +02:00
pycore_obmalloc_init.h
pycore_opcode_metadata.h gh-109287: Desugar inst(X) to op(X); macro(X) = X (#109294) 2023-09-15 08:39:05 -07:00
pycore_opcode_utils.h gh-105481: remove regen-opcode. Generated _PyOpcode_Caches in regen-cases. (#108367) 2023-08-23 18:39:00 +01:00
pycore_optimizer.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_parser.h
pycore_pathconfig.h gh-107211: No longer export internal functions (6) (#108424) 2023-08-24 17:28:35 +02:00
pycore_pyarena.h gh-107211: Fix test_peg_generator (#108435) 2023-08-24 17:47:44 +00:00
pycore_pyerrors.h gh-106320: Remove private _PyErr_WriteUnraisableMsg() (#108863) 2023-09-05 01:54:55 +02:00
pycore_pyhash.h gh-107211: No longer export internal functions (6) (#108424) 2023-08-24 17:28:35 +02:00
pycore_pylifecycle.h gh-107211: No longer export internal functions (7) (#108425) 2023-08-24 17:40:56 +02:00
pycore_pymath.h
pycore_pymem.h gh-107211: No longer export internal functions (4) (#107217) 2023-07-25 03:16:28 +00:00
pycore_pymem_init.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_pystate.h gh-108987: Fix _thread.start_new_thread() race condition (#109135) 2023-09-11 17:27:03 +02:00
pycore_pystats.h gh-108753: Enhance pystats (#108754) 2023-09-06 15:54:59 +00:00
pycore_pythonrun.h gh-106320: Remove private pythonrun API (#108599) 2023-08-29 04:18:52 +02:00
pycore_pythread.h gh-106320: Remove private _PyThread_at_fork_reinit() function (#108601) 2023-08-29 02:38:23 +00:00
pycore_range.h
pycore_runtime.h gh-106213: Make Emscripten trampolines work with JSPI (GH-106219) 2023-09-15 15:04:21 -07:00
pycore_runtime_init.h gh-108634: Py_TRACE_REFS uses a hash table (#108663) 2023-08-31 18:33:34 +02:00
pycore_runtime_init_generated.h Run make regen-global-objects (#108714) 2023-08-31 15:37:14 +02:00
pycore_setobject.h gh-107211: No longer export internal functions (7) (#108425) 2023-08-24 17:40:56 +02:00
pycore_signal.h gh-106320: Remove private _PyOS_IsMainThread() function (#108605) 2023-08-29 03:20:31 +00:00
pycore_sliceobject.h
pycore_strhex.h gh-107211: No longer export pycore_strhex.h functions (#108229) 2023-08-21 18:12:22 +00:00
pycore_structseq.h gh-107211: No longer export internal functions (4) (#107217) 2023-07-25 03:16:28 +00:00
pycore_symtable.h gh-107211: Rename PySymtable_Lookup() to _PySymtable_Lookup() (#107212) 2023-07-25 00:54:09 +00:00
pycore_sysmodule.h gh-106320: Remove private _PySys functions (#108452) 2023-08-24 20:02:09 +00:00
pycore_time.h gh-107211: No longer export PyTime internal functions (#108422) 2023-08-24 17:17:40 +02:00
pycore_token.h gh-107211: No longer export internal functions (7) (#108425) 2023-08-24 17:40:56 +02:00
pycore_traceback.h gh-106320: Remove private _PyTraceback functions (#108453) 2023-08-24 23:35:47 +00:00
pycore_tracemalloc.h gh-107211: No longer export internal functions (3) (#107215) 2023-07-25 02:25:45 +00:00
pycore_tuple.h gh-106320: Remove _PyTuple_MaybeUntrack() C API (#107143) 2023-07-23 19:16:21 +00:00
pycore_typeobject.h gh-107211: No longer export internal functions (7) (#108425) 2023-08-24 17:40:56 +02:00
pycore_typevarobject.h gh-104549: Set __module__ on TypeAliasType (#104550) 2023-05-18 15:56:15 -07:00
pycore_ucnhash.h
pycore_unicodeobject.h gh-106320: Remove private _Py_Identifier API (#108593) 2023-08-29 02:29:46 +02:00
pycore_unicodeobject_generated.h Run make regen-global-objects (#108714) 2023-08-31 15:37:14 +02:00
pycore_unionobject.h
pycore_uops.h gh-108765: Cleanup #include in Python/*.c files (#108977) 2023-09-06 15:56:08 +02:00
pycore_warnings.h gh-107211: No longer export internal functions (3) (#107215) 2023-07-25 02:25:45 +00:00
pycore_weakref.h gh-105927: Remove _PyWeakref_GetWeakrefCount() (#106007) 2023-06-23 03:00:56 +00:00