Skip to content

Commit 683927d

Browse files
add inline markers
1 parent 7551b65 commit 683927d

7 files changed

Lines changed: 99 additions & 24 deletions

‎Include/internal/pycore_uop_ids.h‎

Lines changed: 23 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Include/internal/pycore_uop_metadata.h‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Python/bytecodes.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3171,6 +3171,29 @@ dummy_func(
31713171
#endif
31723172
}
31733173

3174+
// Exact same as _PUSH_FRAME. But marks a frame as inlineable
3175+
// to the tier 2 redundancy eliminator.
3176+
// TODO: add support to pseudo for uops.
3177+
op(_PUSH_FRAME_INLINEABLE, (new_frame: _PyInterpreterFrame* -- unused if (0))) {
3178+
// Write it out explicitly because it's subtly different.
3179+
// Eventually this should be the only occurrence of this code.
3180+
assert(tstate->interp->eval_frame == NULL);
3181+
SYNC_SP();
3182+
_PyFrame_SetStackPointer(frame, stack_pointer);
3183+
new_frame->previous = frame;
3184+
CALL_STAT_INC(inlined_py_calls);
3185+
frame = tstate->current_frame = new_frame;
3186+
tstate->py_recursion_remaining--;
3187+
LOAD_SP();
3188+
LOAD_IP(0);
3189+
#if LLTRACE && TIER_ONE
3190+
lltrace = maybe_lltrace_resume_frame(frame, &entry_frame, GLOBALS());
3191+
if (lltrace < 0) {
3192+
goto exit_unwind;
3193+
}
3194+
#endif
3195+
}
3196+
31743197
macro(CALL_BOUND_METHOD_EXACT_ARGS) =
31753198
unused/1 + // Skip over the counter
31763199
_CHECK_PEP_523 +

‎Python/executor_cases.c.h‎

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Python/optimizer_analysis.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ function_decide_inlineable(PyFunctionObject *func)
743743
if (func == NULL) {
744744
return 0;
745745
}
746-
PyCodeObject *co = func->func_code;
746+
PyCodeObject *co = (PyCodeObject *)func->func_code;
747747
if (co == NULL) {
748748
return 0;
749749
}
@@ -823,7 +823,9 @@ peephole_opt(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer, int buffer_s
823823
co = (PyCodeObject *)func->func_code;
824824
}
825825
frame_depth--;
826-
function_decide_inlineable(func);
826+
if (function_decide_inlineable(func)) {
827+
push_frame[frame_depth]->opcode = _PUSH_FRAME_INLINEABLE;
828+
}
827829
assert(frame_depth >= 1);
828830
break;
829831
}

‎Python/tier2_redundancy_eliminator_bytecodes.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,17 @@ dummy_func(void) {
323323
new_frame->push_frame = this_instr;
324324
}
325325

326+
// This should be identical to _PUSH_FRAME!
327+
op(_PUSH_FRAME_INLINEABLE, (new_frame: _Py_UOpsAbstractFrame * -- unused if (0))) {
328+
SYNC_SP();
329+
ctx->frame->stack_pointer = stack_pointer;
330+
ctx->frame->after_call_stackentries = STACK_LEVEL();
331+
ctx->frame = new_frame;
332+
ctx->curr_frame_depth++;
333+
stack_pointer = new_frame->stack_pointer;
334+
new_frame->push_frame = this_instr;
335+
}
336+
326337
op(_SET_IP, (instr_ptr/4 --)) {
327338
ctx->frame->instr_ptr = (_PyUOpInstruction *)instr_ptr;
328339
}

‎Python/tier2_redundancy_eliminator_cases.c.h‎

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)