GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code unit. by markshannon · Pull Request #100223 · python/cpython

Conversation

@markshannon

@markshannon markshannon commented Dec 13, 2022 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Replaces

typedef uint16_t _Py_CODEUNIT;

which omits important details and is arguably wrong, with

typedef union {
    int16_t cache;
    struct {
         uint8_t opcode;
         uint8_t oparg;
    };
} _Py_CODEUNIT;

which is clearer both to me and to the compiler.

  • Issue: Use a correct and transparent definition of "code unit" in C code #100222

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@markshannon
Redefine _Py_CODEUNIT as a union to clarify structure of code unit.
0c99a70
@markshannon
markshannon requested a review from iritkatriel as a code owner December 13, 2022 16:11
@markshannon markshannon changed the title Redefine _Py_CODEUNIT as a union to clarify structure of code unit. GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code unit. Dec 13, 2022
@bedevere-bot bedevere-bot mentioned this pull request Dec 13, 2022
Use a correct and transparent definition of "code unit" in C code #100222
Closed
iritkatriel
iritkatriel reviewed Dec 13, 2022
View reviewed changes
Comment thread Include/cpython/code.h
uint16_t cache;
struct {
uint8_t opcode;
uint8_t oparg;

@iritkatriel iritkatriel Dec 13, 2022

Copy link
Copy Markdown
Member

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.

Is the idea to later add more opargs here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@markshannon markshannon Dec 13, 2022

Copy link
Copy Markdown
Member Author

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.

Up to you.
I guess it depends on how you want to align the instructions.

16 bit alignment

typedef union {
    int16_t cache;
    struct {
         uint8_t opcode;
         uint8_t oparg0;
    };
    struct {
         uint8_t oparg1;
         uint8_t oparg2;
    };
} _Py_CODEUNIT;

32 bit alignment

typedef union {
    int32_t cache;
    struct {
         uint8_t opcode;
         uint8_t oparg0;
         uint8_t oparg1;
         uint8_t oparg2;
    };
} _Py_CODEUNIT;

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
iritkatriel
iritkatriel approved these changes Dec 13, 2022
View reviewed changes
@bedevere-bot bedevere-bot added the awaiting merge label Dec 13, 2022
@markshannon

markshannon commented Dec 14, 2022

Copy link
Copy Markdown
Member Author

Closing and reopening to kick CI

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon markshannon closed this Dec 14, 2022
@markshannon markshannon reopened this Dec 14, 2022
@markshannon
markshannon merged commit 6997e77 into python:main Dec 14, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Dec 14, 2022
@bedevere-bot

bedevere-bot commented Dec 14, 2022

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Fedora Stable Clang Installed 3.x has failed when building commit 6997e77.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/350/builds/2887) and take a look at the build logs.
  4. Check if the failure is related to this commit (6997e77) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/350/builds/2887

Summary of the results of the build (if available):

Click to see traceback logs
remote: Enumerating objects: 40226, done.        
remote: Counting objects:   0% (1/25295)        
remote: Counting objects:   1% (253/25295)        
remote: Counting objects:   2% (506/25295)        
remote: Counting objects:   3% (759/25295)        
remote: Counting objects:   4% (1012/25295)        
remote: Counting objects:   5% (1265/25295)        
remote: Counting objects:   6% (1518/25295)        
remote: Counting objects:   7% (1771/25295)        
remote: Counting objects:   8% (2024/25295)        
remote: Counting objects:   9% (2277/25295)        
remote: Counting objects:  10% (2530/25295)        
remote: Counting objects:  11% (2783/25295)        
remote: Counting objects:  12% (3036/25295)        
remote: Counting objects:  13% (3289/25295)        
remote: Counting objects:  14% (3542/25295)        
remote: Counting objects:  15% (3795/25295)        
remote: Counting objects:  16% (4048/25295)        
remote: Counting objects:  17% (4301/25295)        
remote: Counting objects:  18% (4554/25295)        
remote: Counting objects:  19% (4807/25295)        
remote: Counting objects:  20% (5059/25295)        
remote: Counting objects:  21% (5312/25295)        
remote: Counting objects:  22% (5565/25295)        
remote: Counting objects:  23% (5818/25295)        
remote: Counting objects:  24% (6071/25295)        
remote: Counting objects:  25% (6324/25295)        
remote: Counting objects:  26% (6577/25295)        
remote: Counting objects:  27% (6830/25295)        
remote: Counting objects:  28% (7083/25295)        
remote: Counting objects:  29% (7336/25295)        
remote: Counting objects:  30% (7589/25295)        
remote: Counting objects:  31% (7842/25295)        
remote: Counting objects:  32% (8095/25295)        
remote: Counting objects:  33% (8348/25295)        
remote: Counting objects:  34% (8601/25295)        
remote: Counting objects:  35% (8854/25295)        
remote: Counting objects:  36% (9107/25295)        
remote: Counting objects:  37% (9360/25295)        
remote: Counting objects:  38% (9613/25295)        
remote: Counting objects:  39% (9866/25295)        
remote: Counting objects:  40% (10118/25295)        
remote: Counting objects:  41% (10371/25295)        
remote: Counting objects:  42% (10624/25295)        
remote: Counting objects:  43% (10877/25295)        
remote: Counting objects:  44% (11130/25295)        
remote: Counting objects:  45% (11383/25295)        
remote: Counting objects:  46% (11636/25295)        
remote: Counting objects:  47% (11889/25295)        
remote: Counting objects:  48% (12142/25295)        
remote: Counting objects:  49% (12395/25295)        
remote: Counting objects:  50% (12648/25295)        
remote: Counting objects:  51% (12901/25295)        
remote: Counting objects:  52% (13154/25295)        
remote: Counting objects:  53% (13407/25295)        
remote: Counting objects:  54% (13660/25295)        
remote: Counting objects:  55% (13913/25295)        
remote: Counting objects:  56% (14166/25295)        
remote: Counting objects:  57% (14419/25295)        
remote: Counting objects:  58% (14672/25295)        
remote: Counting objects:  59% (14925/25295)        
remote: Counting objects:  60% (15177/25295)        
remote: Counting objects:  61% (15430/25295)        
remote: Counting objects:  62% (15683/25295)        
remote: Counting objects:  63% (15936/25295)        
remote: Counting objects:  64% (16189/25295)        
remote: Counting objects:  65% (16442/25295)        
remote: Counting objects:  66% (16695/25295)        
remote: Counting objects:  67% (16948/25295)        
remote: Counting objects:  68% (17201/25295)        
remote: Counting objects:  69% (17454/25295)        
remote: Counting objects:  70% (17707/25295)        
remote: Counting objects:  71% (17960/25295)        
remote: Counting objects:  72% (18213/25295)        
remote: Counting objects:  73% (18466/25295)        
remote: Counting objects:  74% (18719/25295)        
remote: Counting objects:  75% (18972/25295)        
remote: Counting objects:  76% (19225/25295)        
remote: Counting objects:  77% (19478/25295)        
remote: Counting objects:  78% (19731/25295)        
remote: Counting objects:  79% (19984/25295)        
remote: Counting objects:  80% (20236/25295)        
remote: Counting objects:  81% (20489/25295)        
remote: Counting objects:  82% (20742/25295)        
remote: Counting objects:  83% (20995/25295)        
remote: Counting objects:  84% (21248/25295)        
remote: Counting objects:  85% (21501/25295)        
remote: Counting objects:  86% (21754/25295)        
remote: Counting objects:  87% (22007/25295)        
remote: Counting objects:  88% (22260/25295)        
remote: Counting objects:  89% (22513/25295)        
remote: Counting objects:  90% (22766/25295)        
remote: Counting objects:  91% (23019/25295)        
remote: Counting objects:  92% (23272/25295)        
remote: Counting objects:  93% (23525/25295)        
remote: Counting objects:  94% (23778/25295)        
remote: Counting objects:  95% (24031/25295)        
remote: Counting objects:  96% (24284/25295)        
remote: Counting objects:  97% (24537/25295)        
remote: Counting objects:  98% (24790/25295)        
remote: Counting objects:  99% (25043/25295)        
remote: Counting objects: 100% (25295/25295)        
remote: Counting objects: 100% (25295/25295), done.        
remote: Compressing objects:   0% (1/11746)        
remote: Compressing objects:   1% (118/11746)        
remote: Compressing objects:   2% (235/11746)        
remote: Compressing objects:   2% (297/11746)        
remote: Compressing objects:   3% (353/11746)        
remote: Compressing objects:   4% (470/11746)        
remote: Compressing objects:   5% (588/11746)        
remote: Compressing objects:   6% (705/11746)        
remote: Compressing objects:   7% (823/11746)        
remote: Compressing objects:   7% (928/11746)        
remote: Compressing objects:   8% (940/11746)        
remote: Compressing objects:   9% (1058/11746)        
remote: Compressing objects:  10% (1175/11746)        
remote: Compressing objects:  11% (1293/11746)        
remote: Compressing objects:  12% (1410/11746)        
remote: Compressing objects:  13% (1527/11746)        
remote: Compressing objects:  14% (1645/11746)        
remote: Compressing objects:  14% (1647/11746)        
remote: Compressing objects:  15% (1762/11746)        
remote: Compressing objects:  16% (1880/11746)        
remote: Compressing objects:  17% (1997/11746)        
remote: Compressing objects:  18% (2115/11746)        
remote: Compressing objects:  19% (2232/11746)        
remote: Compressing objects:  20% (2350/11746)        
remote: Compressing objects:  21% (2467/11746)        
remote: Compressing objects:  22% (2585/11746)        
remote: Compressing objects:  23% (2702/11746)        
remote: Compressing objects:  24% (2820/11746)        
remote: Compressing objects:  25% (2937/11746)        
remote: Compressing objects:  26% (3054/11746)        
remote: Compressing objects:  27% (3172/11746)        
remote: Compressing objects:  27% (3247/11746)        
remote: Compressing objects:  28% (3289/11746)        
remote: Compressing objects:  29% (3407/11746)        
remote: Compressing objects:  30% (3524/11746)        
remote: Compressing objects:  31% (3642/11746)        
remote: Compressing objects:  32% (3759/11746)        
remote: Compressing objects:  33% (3877/11746)        
remote: Compressing objects:  34% (3994/11746)        
remote: Compressing objects:  35% (4112/11746)        
remote: Compressing objects:  36% (4229/11746)        
remote: Compressing objects:  37% (4347/11746)        
remote: Compressing objects:  38% (4464/11746)        
remote: Compressing objects:  39% (4581/11746)        
remote: Compressing objects:  40% (4699/11746)        
remote: Compressing objects:  41% (4816/11746)        
remote: Compressing objects:  42% (4934/11746)        
remote: Compressing objects:  43% (5051/11746)        
remote: Compressing objects:  44% (5169/11746)        
remote: Compressing objects:  45% (5286/11746)        
remote: Compressing objects:  46% (5404/11746)        
remote: Compressing objects:  47% (5521/11746)        
remote: Compressing objects:  48% (5639/11746)        
remote: Compressing objects:  49% (5756/11746)        
remote: Compressing objects:  50% (5873/11746)        
remote: Compressing objects:  51% (5991/11746)        
remote: Compressing objects:  52% (6108/11746)        
remote: Compressing objects:  53% (6226/11746)        
remote: Compressing objects:  54% (6343/11746)        
remote: Compressing objects:  55% (6461/11746)        
remote: Compressing objects:  56% (6578/11746)        
remote: Compressing objects:  57% (6696/11746)        
remote: Compressing objects:  58% (6813/11746)        
remote: Compressing objects:  59% (6931/11746)        
remote: Compressing objects:  60% (7048/11746)        
remote: Compressing objects:  61% (7166/11746)        
remote: Compressing objects:  62% (7283/11746)        
remote: Compressing objects:  63% (7400/11746)        
remote: Compressing objects:  64% (7518/11746)        
remote: Compressing objects:  65% (7635/11746)        
remote: Compressing objects:  66% (7753/11746)        
remote: Compressing objects:  67% (7870/11746)        
remote: Compressing objects:  68% (7988/11746)        
remote: Compressing objects:  69% (8105/11746)        
remote: Compressing objects:  70% (8223/11746)        
remote: Compressing objects:  71% (8340/11746)        
remote: Compressing objects:  72% (8458/11746)        
remote: Compressing objects:  73% (8575/11746)        
remote: Compressing objects:  74% (8693/11746)        
remote: Compressing objects:  75% (8810/11746)        
remote: Compressing objects:  76% (8927/11746)        
remote: Compressing objects:  77% (9045/11746)        
remote: Compressing objects:  78% (9162/11746)        
remote: Compressing objects:  79% (9280/11746)        
remote: Compressing objects:  80% (9397/11746)        
remote: Compressing objects:  81% (9515/11746)        
remote: Compressing objects:  82% (9632/11746)        
remote: Compressing objects:  83% (9750/11746)        
remote: Compressing objects:  84% (9867/11746)        
remote: Compressing objects:  85% (9985/11746)        
remote: Compressing objects:  86% (10102/11746)        
remote: Compressing objects:  87% (10220/11746)        
remote: Compressing objects:  88% (10337/11746)        
remote: Compressing objects:  89% (10454/11746)        
remote: Compressing objects:  90% (10572/11746)        
remote: Compressing objects:  91% (10689/11746)        
remote: Compressing objects:  92% (10807/11746)        
remote: Compressing objects:  93% (10924/11746)        
remote: Compressing objects:  94% (11042/11746)        
remote: Compressing objects:  95% (11159/11746)        
remote: Compressing objects:  96% (11277/11746)        
remote: Compressing objects:  97% (11394/11746)        
remote: Compressing objects:  98% (11512/11746)        
remote: Compressing objects:  99% (11629/11746)        
remote: Compressing objects: 100% (11746/11746)        
remote: Compressing objects: 100% (11746/11746), done.        
Receiving objects:   0% (1/40226)
fatal: write error: No space left on device
fatal: fetch-pack: invalid index-pack output

chmod: cannot access 'target/': No such file or directory

make: *** No rule to make target 'distclean'.  Stop.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Dec 14, 2022

Copy link
Copy Markdown
Member Author

Buildbot has run out of storage

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon
markshannon deleted the nice-codeunit branch December 14, 2022 11:25
carljm added a commit to carljm/cpython that referenced this pull request Dec 14, 2022
@carljm
Merge branch 'main' into typedocs
53d33a1
* main: (103 commits)
  pythongh-100248: Add missing `ssl_shutdown_timeout` parameter in `asyncio` docs (python#100249)
  Assorted minor fixes for specialization stats. (pythonGH-100219)
  pythongh-100176: venv: Remove redundant compat code for Python <= 3.2 (python#100177)
  pythonGH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code unit. (pythonGH-100223)
  pythongh-99955: undef ERROR and SUCCESS before redefining (fixes sanitizer warning) (python#100215)
  pythonGH-100206: use versionadded for the addition of sysconfig.get_default_scheme (python#100207)
  pythongh-81057: Move _Py_RefTotal to the "Ignored Globals" List (pythongh-100203)
  pythongh-81057: Move Signal-Related Globals to _PyRuntimeState (pythongh-100085)
  pythongh-81057: Move faulthandler Globals to _PyRuntimeState (pythongh-100152)
  pythongh-81057: Move tracemalloc Globals to _PyRuntimeState (pythongh-100151)
  pythonGH-100143: Improve collecting pystats for parts of runs (pythonGH-100144)
  pythongh-99955: standardize return values of functions in compiler's code-gen (python#100010)
  pythongh-79218: Define `MS_WIN64` macro for Mingw-w64 64bit on Windows (pythonGH-100137)
  Fix: typo (Indention) (pythonGH-99904)
  pythongh-96715 Remove redundant NULL check in `profile_trampoline` function (python#96716)
  pythongh-100176: remove incorrect version compatibility check from argument clinic (python#100190)
  clarify the 4300-digit limit on int-str conversion (python#100175)
  pythongh-70393: Clarify mention of "middle" scope (python#98839)
  pythongh-99688: Fix outdated tests in test_unary (python#99712)
  pythongh-100174: [Enum] Correct PowersOfThree example. (pythonGH-100178)
  ...
@carljm carljm mentioned this pull request Dec 15, 2022
GH-100222: fix typo _py_set_opocde -> _py_set_opcode #100259
Merged
miss-islington pushed a commit that referenced this pull request Dec 15, 2022
@carljm
GH-100222: fix typo _py_set_opocde -> _py_set_opcode (GH-100259)
bdd8674
Typo introduced in #100223.

Automerge-Triggered-By: GH:brandtbucher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iritkatriel iritkatriel iritkatriel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@markshannon @bedevere-bot @iritkatriel
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.