@@ -60,8 +60,6 @@ jit_error(const char *message)
6060 PyErr_Format (PyExc_RuntimeWarning , "JIT %s (%d)" , message , hint );
6161}
6262
63- static size_t _Py_jit_shim_size = 0 ;
64-
6563static int
6664address_in_executor_array (_PyExecutorObject * * ptrs , size_t count , uintptr_t addr )
6765{
@@ -104,13 +102,6 @@ _PyJIT_AddressInJitCode(PyInterpreterState *interp, uintptr_t addr)
104102 if (interp == NULL ) {
105103 return 0 ;
106104 }
107- if (_Py_jit_entry != _Py_LazyJitShim && _Py_jit_shim_size != 0 ) {
108- uintptr_t start = (uintptr_t )_Py_jit_entry ;
109- uintptr_t end = start + _Py_jit_shim_size ;
110- if (addr >= start && addr < end ) {
111- return 1 ;
112- }
113- }
114105 if (address_in_executor_array (interp -> executor_ptrs , interp -> executor_count , addr )) {
115106 return 1 ;
116107 }
@@ -727,75 +718,6 @@ _PyJIT_Compile(_PyExecutorObject *executor, const _PyUOpInstruction trace[], siz
727718 return 0 ;
728719}
729720
730- /* One-off compilation of the jit entry shim
731- * We compile this once only as it effectively a normal
732- * function, but we need to use the JIT because it needs
733- * to understand the jit-specific calling convention.
734- * Don't forget to call _PyJIT_Fini later!
735- */
736- static _PyJitEntryFuncPtr
737- compile_shim (void )
738- {
739- _PyExecutorObject dummy ;
740- const StencilGroup * group ;
741- size_t code_size = 0 ;
742- size_t data_size = 0 ;
743- jit_state state = {0 };
744- group = & shim ;
745- code_size += group -> code_size ;
746- data_size += group -> data_size ;
747- combine_symbol_mask (group -> trampoline_mask , state .trampolines .mask );
748- combine_symbol_mask (group -> got_mask , state .got_symbols .mask );
749- // Round up to the nearest page:
750- size_t page_size = get_page_size ();
751- assert ((page_size & (page_size - 1 )) == 0 );
752- size_t code_padding = DATA_ALIGN - ((code_size + state .trampolines .size ) & (DATA_ALIGN - 1 ));
753- size_t padding = page_size - ((code_size + state .trampolines .size + code_padding + data_size + state .got_symbols .size ) & (page_size - 1 ));
754- size_t total_size = code_size + state .trampolines .size + code_padding + data_size + state .got_symbols .size + padding ;
755- unsigned char * memory = jit_alloc (total_size );
756- if (memory == NULL ) {
757- return NULL ;
758- }
759- unsigned char * code = memory ;
760- state .trampolines .mem = memory + code_size ;
761- unsigned char * data = memory + code_size + state .trampolines .size + code_padding ;
762- state .got_symbols .mem = data + data_size ;
763- // Compile the shim, which handles converting between the native
764- // calling convention and the calling convention used by jitted code
765- // (which may be different for efficiency reasons).
766- group = & shim ;
767- group -> emit (code , data , & dummy , NULL , & state );
768- code += group -> code_size ;
769- data += group -> data_size ;
770- assert (code == memory + code_size );
771- assert (data == memory + code_size + state .trampolines .size + code_padding + data_size );
772- if (mark_executable (memory , total_size )) {
773- jit_free (memory , total_size );
774- return NULL ;
775- }
776- _Py_jit_shim_size = total_size ;
777- return (_PyJitEntryFuncPtr )memory ;
778- }
779-
780- static PyMutex lazy_jit_mutex = { 0 };
781-
782- _Py_CODEUNIT *
783- _Py_LazyJitShim (
784- _PyExecutorObject * executor , _PyInterpreterFrame * frame , _PyStackRef * stack_pointer , PyThreadState * tstate
785- ) {
786- PyMutex_Lock (& lazy_jit_mutex );
787- if (_Py_jit_entry == _Py_LazyJitShim ) {
788- _PyJitEntryFuncPtr shim = compile_shim ();
789- if (shim == NULL ) {
790- PyMutex_Unlock (& lazy_jit_mutex );
791- Py_FatalError ("Cannot allocate core JIT code" );
792- }
793- _Py_jit_entry = shim ;
794- }
795- PyMutex_Unlock (& lazy_jit_mutex );
796- return _Py_jit_entry (executor , frame , stack_pointer , tstate );
797- }
798-
799721// Free executor's memory allocated with _PyJIT_Compile
800722void
801723_PyJIT_Free (_PyExecutorObject * executor )
@@ -812,22 +734,4 @@ _PyJIT_Free(_PyExecutorObject *executor)
812734 }
813735}
814736
815- // Free shim memory allocated with compile_shim
816- void
817- _PyJIT_Fini (void )
818- {
819- PyMutex_Lock (& lazy_jit_mutex );
820- unsigned char * memory = (unsigned char * )_Py_jit_entry ;
821- size_t size = _Py_jit_shim_size ;
822- if (size ) {
823- _Py_jit_entry = _Py_LazyJitShim ;
824- _Py_jit_shim_size = 0 ;
825- if (jit_free (memory , size )) {
826- PyErr_FormatUnraisable ("Exception ignored while "
827- "freeing JIT entry code" );
828- }
829- }
830- PyMutex_Unlock (& lazy_jit_mutex );
831- }
832-
833737#endif // _Py_JIT
0 commit comments