-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Get rid of frozen shapes #13289
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
Get rid of frozen shapes #13289
Conversation
❌ Tests Failed✖️no tests failed ✔️61985 tests passed(2 flakes) |
12422d9
to
b0cee81
Compare
f6a90fb
to
6e3eb3c
Compare
This comment was marked as resolved.
This comment was marked as resolved.
fa04a3e
to
e076cdd
Compare
shape.h
Outdated
#define SHAPE_ID_NUM_BITS 16 | ||
#define SHAPE_ID_OFFSET_NUM_BITS 15 |
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.
Unfortunately we still can't make shape_id_t
32bit long on 32bit platforms, because inlines caches (either ivar or CC for attr_reader
methods) need to pack both an attr_index_t
and a shape_id_t
in a single uintptr_t
.
So we'd need to either make these caches larger, or find some creative solution.
For the time being, I think we cal still use 1bit for frozen, as it still leaves 32k shapes on 32bits.
But if we want to eliminate other shape types like T_OBJECT
, we'll have to find a solution for these caches.
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.
#13500 would unlock all 32 bits.
e076cdd
to
46dce97
Compare
Instead `shape_id_t` higher bits contain flags, and the first one tells whether the shape is frozen. This has multiple benefits: - Can check if a shape is frozen with a single bit check instead of dereferencing a pointer. - Guarantees it is always possible to transition to frozen. - This allow reclaiming `FL_FREEZE` (not done yet). The downside is you have to be careful to preserve these flags when transitioning.
46dce97
to
cac5f1f
Compare
Freezing an object changes its `shape_id` This is necessary so that `setivar` routines can use the `shape_id` as a cache key and save on checking the frozen status every time. However for `getivar` routines, this causes needless cache misses. By clearing that bit we increase hit rate in codepaths that see both frozen and mutable objects.
cac5f1f
to
29a2d85
Compare
Instead
shape_id_t
higher bits contain flags, and the first one tells whether the shape is frozen.This has multiple benefits:
dereferencing a pointer.
FL_FREEZE
(TODO).shape_id
ongetivar
so that frozen status doesn't invalidate inline caches.