gh-114058: Foundations of the Tier2 redundancy eliminator (GH-115085)

---------

Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
Co-authored-by: Jules <57632293+JuliaPoo@users.noreply.github.com>
Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com>
This commit is contained in:
Ken Jin 2024-02-13 21:24:48 +08:00 committed by GitHub
parent ccc76c3e88
commit 7cce857622
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 3137 additions and 140 deletions

View file

@ -17,8 +17,6 @@
#include "pycore_uop_metadata.h" // Uop tables
#undef NEED_OPCODE_METADATA
#define UOP_MAX_TRACE_LENGTH 512
#define MAX_EXECUTORS_SIZE 256
@ -308,8 +306,6 @@ BRANCH_TO_GUARD[4][2] = {
[POP_JUMP_IF_NOT_NONE - POP_JUMP_IF_FALSE][1] = _GUARD_IS_NOT_NONE_POP,
};
#define TRACE_STACK_SIZE 5
#define CONFIDENCE_RANGE 1000
#define CONFIDENCE_CUTOFF 333
@ -323,10 +319,11 @@ BRANCH_TO_GUARD[4][2] = {
#define ADD_TO_TRACE(OPCODE, OPARG, OPERAND, TARGET) \
DPRINTF(2, \
" ADD_TO_TRACE(%s, %d, %" PRIu64 ")\n", \
" ADD_TO_TRACE(%s, %d, %" PRIu64 ", %d)\n", \
_PyUOpName(OPCODE), \
(OPARG), \
(uint64_t)(OPERAND)); \
(uint64_t)(OPERAND), \
TARGET); \
assert(trace_length < max_length); \
trace[trace_length].opcode = (OPCODE); \
trace[trace_length].oparg = (OPARG); \
@ -825,11 +822,13 @@ uop_optimize(
char *uop_optimize = Py_GETENV("PYTHONUOPSOPTIMIZE");
if (uop_optimize == NULL || *uop_optimize > '0') {
err = _Py_uop_analyze_and_optimize(frame, buffer,
UOP_MAX_TRACE_LENGTH, curr_stackentries, &dependencies);
UOP_MAX_TRACE_LENGTH,
curr_stackentries, &dependencies);
if (err <= 0) {
return err;
}
}
assert(err == 1);
_PyExecutorObject *executor = make_executor_from_uops(buffer, &dependencies);
if (executor == NULL) {
return -1;