-
Notifications
You must be signed in to change notification settings - Fork 442
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
Add some more global operator new / delete overrides #4465
Conversation
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.
Tentative approval, will run P4Testgen with this and check whether I see any difference in memory usage.
It shouldn't be. It's just a correctness thing. |
Yes, not expecting any differences, but it is sensitive to gc change since it is one of the few tools using the garbage collector over longer stretches of time. |
Right. You can just throw |
lib/gc.cpp
Outdated
auto *rv = ::operator new(size, UseGC, 0, 0); | ||
if (!rv && emergency_ptr && emergency_ptr + size < emergency_pool + sizeof(emergency_pool)) { | ||
rv = emergency_ptr; | ||
size += -size & 0xf; // align to 16 bytes |
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.
Not your code but this particular piece looks a little funky to me. I had to pause a bit to think what negating an unsigned means and what this is trying to do. Testing for the right behavior in case of a bad alloc seems tricky.
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.
You'd just need to get used to calculate masks on-fly :) I changed this thing, is it more clear now?
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.
Yes, thanks for indulging me!
… that is not relevant in year 2024
Note that the former is required if e.g. LLVM is used with P4C (for backend).
Some cleanups here as well