-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
gh-137838: Fix JIT trace buffer overrun by increasing possible exit stubs #138177
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
Changes from all commits
31a5157
650e55d
5d816a2
b4aad3c
a6fd711
917c6f0
57f6c39
ef3c108
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix JIT trace buffer overrun by increasing possible exit stubs. | ||
Patch by Donghee Na. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -591,9 +591,8 @@ translate_bytecode_to_trace( | |
|
||
for (;;) { | ||
target = INSTR_IP(instr, code); | ||
// Need space for _DEOPT | ||
max_length--; | ||
|
||
// One for possible _DEOPT, one because _CHECK_VALIDITY itself might _DEOPT | ||
max_length-=2; | ||
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. Needs comment on why 2: |
||
uint32_t opcode = instr->op.code; | ||
uint32_t oparg = instr->op.arg; | ||
|
||
|
@@ -1283,15 +1282,19 @@ uop_optimize( | |
_Py_BloomFilter_Init(&dependencies); | ||
_PyUOpInstruction buffer[UOP_MAX_TRACE_LENGTH]; | ||
OPT_STAT_INC(attempts); | ||
char *env_var = Py_GETENV("PYTHON_UOPS_OPTIMIZE"); | ||
bool is_noopt = true; | ||
if (env_var == NULL || *env_var == '\0' || *env_var > '0') { | ||
is_noopt = false; | ||
} | ||
Comment on lines
+1285
to
+1289
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. Why was this change made? I think the previous code (without the additional variable) made more sense. |
||
int length = translate_bytecode_to_trace(frame, instr, buffer, UOP_MAX_TRACE_LENGTH, &dependencies, progress_needed); | ||
if (length <= 0) { | ||
// Error or nothing translated | ||
return length; | ||
} | ||
assert(length < UOP_MAX_TRACE_LENGTH); | ||
OPT_STAT_INC(traces_created); | ||
char *env_var = Py_GETENV("PYTHON_UOPS_OPTIMIZE"); | ||
if (env_var == NULL || *env_var == '\0' || *env_var > '0') { | ||
if (!is_noopt) { | ||
length = _Py_uop_analyze_and_optimize(frame, buffer, | ||
length, | ||
curr_stackentries, &dependencies); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, why/how does the behavior differ? Sounds like a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should open another issue for this.