Skip to content
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

GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code unit. #100223

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Dec 13, 2022

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.

@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
uint16_t cache;
struct {
uint8_t opcode;
uint8_t oparg;
Copy link
Member

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?

Copy link
Member Author

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;

@markshannon
Copy link
Member Author

Closing and reopening to kick CI

@markshannon markshannon reopened this Dec 14, 2022
@markshannon markshannon merged commit 6997e77 into python:main Dec 14, 2022
@bedevere-bot
Copy link

⚠️⚠️⚠️ 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.

@markshannon
Copy link
Member Author

Buildbot has run out of storage

@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
* 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)
  ...
miss-islington pushed a commit that referenced this pull request Dec 15, 2022
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants