Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-137838: Move _PyUOpInstruction buffer to PyInterpreterState#138918
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
fe3c1afcd868b9daf4730e09af56be0b25b61b32eea39b4c1f32f7a7fd15eb8471832bd12b705c628ffcb175416ad15aaf07e6ba1f13260eab39a5560541dc877f3a99af48c2989fa8e4dff8167e5261c08adf269051791928485a0c2a74fa49bcabf88ee3b05825f5File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #ifndef Py_CORE_UOP_H | ||
| #define Py_CORE_UOP_H | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| #ifndef Py_BUILD_CORE | ||
| # error "this header requires Py_BUILD_CORE define" | ||
| #endif | ||
| #include <stdint.h> | ||
| /* Depending on the format, | ||
| * the 32 bits between the oparg and operand are: | ||
| * UOP_FORMAT_TARGET: | ||
| * uint32_t target; | ||
| * UOP_FORMAT_JUMP | ||
| * uint16_t jump_target; | ||
| * uint16_t error_target; | ||
| */ | ||
| typedef struct _PyUOpInstruction{ | ||
| uint16_t opcode:15; | ||
| uint16_t format:1; | ||
| uint16_t oparg; | ||
| union { | ||
| uint32_t target; | ||
| struct { | ||
| uint16_t jump_target; | ||
| uint16_t error_target; | ||
| }; | ||
| }; | ||
| uint64_t operand0; // A cache entry | ||
| uint64_t operand1; | ||
| #ifdef Py_STATS | ||
| uint64_t execution_count; | ||
| #endif | ||
| } _PyUOpInstruction; | ||
| // This is the length of the trace we project initially. | ||
| #define UOP_MAX_TRACE_LENGTH 1200 | ||
| #define UOP_BUFFER_SIZE (UOP_MAX_TRACE_LENGTH * sizeof(_PyUOpInstruction)) | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif /* !Py_INTERNAL_UOP_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -23,6 +23,7 @@ | ||
| #include "pycore_runtime_init.h" // _PyRuntimeState_INIT | ||
| #include "pycore_stackref.h" // Py_STACKREF_DEBUG | ||
| #include "pycore_time.h" // _PyTime_Init() | ||
| #include "pycore_uop.h" // UOP_BUFFER_SIZE | ||
| #include "pycore_uniqueid.h" // _PyObject_FinalizePerThreadRefcounts() | ||
| @@ -556,6 +557,11 @@ init_interpreter(PyInterpreterState *interp, | ||
| #ifdef Py_GIL_DISABLED | ||
| _Py_brc_init_state(interp); | ||
| #endif | ||
| #ifdef _Py_TIER2 | ||
| // Ensure the buffer is to be set as NULL. | ||
| interp->jit_uop_buffer = NULL; | ||
| #endif | ||
| llist_init(&interp->mem_free_queue.head); | ||
| llist_init(&interp->asyncio_tasks_head); | ||
| interp->asyncio_tasks_lock = (PyMutex){0}; | ||
| @@ -571,6 +577,7 @@ init_interpreter(PyInterpreterState *interp, | ||
| } | ||
| interp->_code_object_generation = 0; | ||
| interp->jit = false; | ||
| interp->compiling = false; | ||
| interp->executor_list_head = NULL; | ||
| interp->executor_deletion_list_head = NULL; | ||
| interp->executor_deletion_list_remaining_capacity = 0; | ||
| @@ -803,6 +810,10 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate) | ||
| #ifdef _Py_TIER2 | ||
| _Py_ClearExecutorDeletionList(interp); | ||
| if (interp->jit_uop_buffer != NULL) { | ||
| _PyObject_VirtualFree(interp->jit_uop_buffer, UOP_BUFFER_SIZE); | ||
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brandtbucher _PyObject_VirtualFree doesn’t return a value, and the current CPython codebase doesn’t check whether it succeeds or not | ||
| interp->jit_uop_buffer = NULL; | ||
| } | ||
| #endif | ||
| _PyAST_Fini(interp); | ||
| _PyAtExit_Fini(interp); | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.