FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-125174: Mark objects as statically allocated. by markshannon · Pull Request #127797 · python/cpython · GitHub

Repository navigation

GH-125174: Mark objects as statically allocated. - #127797

Merged
markshannon merged 11 commits into
python:mainfrom
faster-cpython:refcnt-with-flags
Dec 11, 2024
Merged

markshannon merged 11 commits into
python:mainfrom
faster-cpython:refcnt-with-flags

Conversation

markshannon commented Dec 10, 2024 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

This PR is a follow up to #125251 which made checking for immortal objects more robust.

This adds the ability to check whether objects are statically allocated or not, which should assist finalization and safety checks.

ericsnowcurrently left a comment

Copy link
Copy Markdown
Member

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 Quality

Mostly LGTM. I've left a couple of minor comments. This will be a nice improvement.

Comment thread Include/refcount.h

Copy link
Copy Markdown
Member

Out of curiosity, how disruptive is adding a new field to the object structure?

Copy link
Copy Markdown
Member Author

Out of curiosity, how disruptive is adding a new field to the object structure?

It doesn't change the size of the PyObject struct or the offsets of ob_refcnt and ob_type.
Changing any of those would be very disruptive.

ericsnowcurrently left a comment

Copy link
Copy Markdown
Member

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 Quality

LGTM

Copy link
Copy Markdown
Member

This appears to be causing lots of compiler warnings on Windows. Here's what the "Files changed tab looks like on this PR:

These warnings are now showing up on the "files changed" tab on every PR

Comment thread Include/refcount.h
#if SIZEOF_VOID_P > 4
/* If an object has been freed, it will have a negative full refcnt
* If it has not it been freed, will have a very large refcnt */
if (op->ob_refcnt_full <= 0 || op->ob_refcnt > (UINT32_MAX - (1<<20))) {

Copy link
Copy Markdown
Member

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 Quality

Apparently UINT32_MAX is not defined in all builds, so this breaks a buildbot.

Copy link
Copy Markdown
Member Author

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 Quality

We use UINT32_MAX all over the place, so it must be defined. Maybe we're missing a #include somewhere.

Copy link
Copy Markdown
Member Author

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 Quality

Looks like it's a C++ build that failing, which might explain it

Copy link
Copy Markdown
Member Author

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 Quality

srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 8, 2025
* Set a bit in the unused part of the refcount on 64 bit machines and the free-threaded build.

* Use the top of the refcount range on 32 bit machines
markshannon deleted the refcnt-with-flags branch January 10, 2025 16:23
willy-b added a commit to willy-b/cpython-fork-for-sending-documentation-fixes that referenced this pull request Sep 23, 2026
- Replace "pad" field with "ob_flags":
  At python@bc262de#diff-87272721a5cf1cd9915d6f503f6a7bbefa2f26c935c7ce83ca78706afd0ad05aR155
  it seems _padding was replaced with ob_flags as part of python#127797

- Add backticks around some new mentions of flag and field names to be consistent in styling
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL