| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -2715,6 +2715,10 @@ void Py_LeaveRecursiveCall(void) | |
|
|
||
| ///////////////////// Experimental UOp Interpreter ///////////////////// | ||
|
|
||
| #undef JUMP_POP_DISPATCH | ||
| #define JUMP_POP_DISPATCH(x, n) \ | ||
|
Comment thread
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis seems unnecessary. The superblock generator should be converting each conditional jump into a conditional exit, followed by an unconditional jump. POP_JUMP_IF_TRUE label becomes: False branch more likelyEXIT_IF_TRUE True branch more likelyEXIT_IF_FALSE JUMP_FORWARD label As for which branch is more likely, we will need to record which way branches go.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOkay, just so I understand correctly, the idea is that EXIT_IF_TRUE/FALSE doesn't pop, and continues in the bytecode at the original POP_JUMP_IF_TRUE instruction, which will pop. So the "False branch more likely" (i.e., branch not likely) version will have to actually translate to EXIT_IF_TRUE; POP_TOP. We could special-case this in the translator: it would have put such a list of uops in the expansion for POP_JUMP_IF_TRUE and friends, and we'd have to add hand-written cases to the uop executor for EXIT_IF_TRUE etc. In the other case (branch likely) the JUMP_FORWARD label could just be SAVE_IP label; superblock generation would then continue from the bytecode at label. That's not something I currently do -- a simplistic approach could do the SAVE_IP followed by EXIT_TRACE, and we can iterate later on continuing from label. But recording which way branches go is something for a future PR; again the most simplistic thing to do for now is to assume that branching is less likely than not branching (i.e., always generate EXIT_IF_TRUE; POP_TOP for now). Honestly, for now I think I'll stick to just making the generator explicitly translate JUMPBY(n) into the correct sequence of JUMPBY, STACK_SHRINK and DISPATCH. Nothing should follow JUMPBY then.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think it makes more sense to consume the condition before exiting These two instructions, POP_JUMP_IF_TRUE and POP_JUMP_IF_FALSE (the None variants can be broken down into LOAD_CONST None; IS_OP; POP_JUMP...) are special, so don't worry too much about fitting them into the more general framework. There are a number of approaches, for exits. Here are three:
Option 3 makes the superblock creation more complex, but simplifies the tier2 interpreter. If option 3 is too complex for this PR, option 2 should work as a temporary step. So for option 3, using the example above of POP_JUMP_IF_TRUE label we get: False branch more likely POP_JUMP_IF_TRUE_UOP uop_label:
...
uop_label:
SAVE_IP label
EXIT
True branch more likely POP_JUMP_IF_FALSE_UOP uop_label:
SAVE_IP label
...
uop_label:
EXIT
Sorry, something went wrong.
All reactions
|
||
| do { frame->prev_instr += (x); stack_pointer -= (n); goto exit; } while (0) | ||
|
|
||
| #undef DEOPT_IF | ||
| #define DEOPT_IF(COND, INSTNAME) \ | ||
| if ((COND)) { \ | ||
| Expand Down Expand Up | @@ -2772,6 +2776,13 @@ _PyUopExecute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject | |
| #define ENABLE_SPECIALIZATION 0 | ||
| #include "executor_cases.c.h" | ||
|
|
||
| case JUMP_TO_TOP: | ||
| { | ||
| pc = 0; | ||
| CHECK_EVAL_BREAKER(); | ||
| break; | ||
| } | ||
|
|
||
| case SAVE_IP: | ||
| { | ||
| frame->prev_instr = ip_offset + oparg; | ||
| Expand All | @@ -2795,6 +2806,12 @@ _PyUopExecute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject | |
| } | ||
| } | ||
|
|
||
| exit: | ||
| DPRINTF(2, "Jumping!\n"); | ||
| _PyFrame_SetStackPointer(frame, stack_pointer); | ||
| Py_DECREF(self); | ||
| return frame; | ||
|
|
||
| unbound_local_error: | ||
| format_exc_check_arg(tstate, PyExc_UnboundLocalError, | ||
| UNBOUNDLOCAL_ERROR_MSG, | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCan we leave dispatch to the code generator?
The saved instruction pointer (frame->prev_instr) is part of the VM state like any other, so shouldn't need special casing. Unless the necessary information is not otherwise present. All the information necessary is in JUMPBY(oparg).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOkay, so you're saying that for Tier 2 the code generator should just replace JUMPBY(<expr>) with something Tier-2-appropriate. That could actually work. There are three places where we shouldn't do that, SEND, JUMP_BACKWARD and ENTER_EXECUTOR, we can exclude those by forbidding something they use.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySEND will probably need to be broken up into two micro ops, one that does the send, and another that does the jump. The SEND jump should be a more-or-less normal jump. We also need to track where we are sending from, to handle the matching YIELD_VALUE, so I'd "forbid" SEND for now.
I think you already handle JUMP_BACKWARD and ENTER_EXECUTOR correctly. They complete the loop, or exit.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.