-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
GH-139922: add interpreter types to InternalDocs/interpreter.md #148035
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -507,6 +507,36 @@ After the last `DEOPT_IF` has passed, a hit should be recorded with | |
| After an optimization has been deferred in the adaptive instruction, | ||
| that should be recorded with `STAT_INC(BASE_INSTRUCTION, deferred)`. | ||
|
|
||
| ## Interpreter types | ||
| There are three different types of interpreters to choose from based on compiler support: | ||
|
|
||
| * traditional switch-case interpreter | ||
|
|
||
| Supported by all compilers covered in PEP 7. | ||
|
|
||
| * computed-gotos interpreter | ||
|
|
||
| Enabled using configure option `--with-computed-gotos` and used by default on supported compilers. | ||
| It uses [Labels as Values](https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html) | ||
| for more efficient dispatching. | ||
|
|
||
| * tail-calling interpreter | ||
|
|
||
| Enabled using configure option `--with-tail-call-interp` (or `--tail-call-interp` for build.bat on Windows). | ||
| It uses [tail calls](https://clang.llvm.org/docs/AttributeReference.html#musttail) and the | ||
| [preserve_none](https://clang.llvm.org/docs/AttributeReference.html#preserve-none) | ||
| calling convention between the small C functions that implement individual Python opcodes. | ||
|
|
||
| Not all compilers support these and if they do not all targets might be supported (for example, | ||
| MSVC currently only supports x64 and only in optimized builds). | ||
|
|
||
| In addition, compilers must do [escape analysis](https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-musttail) | ||
| of the lifetimes of automatic variables, function parameters, and temporaries to ensure proper tail-calls. They | ||
| emit a compile error in case of a violation or detection failure. The ability to detect this varies depending on the compiler and | ||
| also on the optimization level. [Introducing additional scopes](https://github.com/python/cpython/blob/3908593039bde9d4b591ab09919003ee57418d64/Python/bytecodes.c#L2526), | ||
| [extracting problematic code paths into a separate function](https://github.com/python/cpython/pull/143068/files#diff-729a985b0cb8b431cb291f1edb561bbbfea22e3f8c262451cd83328a0936a342R3724) | ||
| or [returning a pointer instead of taking it as an output parameter](https://github.com/python/cpython/blob/3908593039bde9d4b591ab09919003ee57418d64/Include/internal/pycore_ceval.h#L489-L492) | ||
| is particularly helpful to the MSVC compiler in this regard. Using `restrict` is another (currently unused) remedy. | ||
|
||
|
|
||
| Additional resources | ||
| -------------------- | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
See #148036 for a (current) list of supported MSVC configurations.