Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Document how to add a bytecode specialization in Interpreter.md file #130831

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
Loading
from
Open
Prev Previous commit
Next Next commit
Update section for Step1, reworded as per review comments for clarity
  • Loading branch information
faizanoor3001 committed Mar 4, 2025
commit cb03b20c0b9458804c1d993d2dde8b16e0b3e11f
10 changes: 6 additions & 4 deletions 10 InternalDocs/interpreter.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,7 @@ Let's use the example of [`CONTAINS_OP`](../Doc/library/dis.rst#contains_op):
op(_CONTAINS_OP, ...);
```

- Add a uop that calls the specializing function `_SPECIALIZE_CONTAINS_OP`.
For example.
- Add a uop that calls the specializing function:

```c
specializing op(_SPECIALIZE_CONTAINS_OP, (counter/1, left, right -- left, right)) {
Expand All @@ -542,8 +541,11 @@ Let's use the example of [`CONTAINS_OP`](../Doc/library/dis.rst#contains_op):
}
```

- The original `CONTAINS_OP` is now a new macro consisting of
`_SPECIALIZE_CONTAINS_OP` and `_CONTAINS_OP`.
- Create a macro for the original bytecode name:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"intruction" reads better to me here.

Suggested change
- Create a macro for the original bytecode name:
- Create a macro for the original instruction name:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also might be worth mentioning here what should go in that macro, but it also seems pretty clear based on the example.


```c
macro(CONTAINS_OP) = _SPECIALIZE_CONTAINS_OP + _CONTAINS_OP;
```

2. Define the cache structure in [Include/internal/pycore_code.h](../Include/internal/pycore_code.h),
at the very least, a 16-bit counter is needed.
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.