-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[const evaluator] Parameterize allocation of symbolic values in the constant interpreter. #23456
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
[const evaluator] Parameterize allocation of symbolic values in the constant interpreter. #23456
Conversation
@marcrasi Based on the discussion here: #21869, I have changed the constant interpreter and symbolic value factories to use a callback (provided by the client) to perform allocation instead of the AST Context. This enables using a short-lived bump allocator especially for checking pound_asserts, at the same time enables cloning the symbolic values to a longer-lived allocation (and also allows using ASTContext.allocate, if needed). |
@swift-ci Please test |
@swift-ci Please test macOS Platform |
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.
LGTM. Some comments inline.
include/swift/SIL/SILConstants.h
Outdated
@@ -177,6 +177,8 @@ class SymbolicValue { | |||
} auxInfo; | |||
|
|||
public: | |||
using Allocator = std::function<void *(unsigned long, unsigned)>; |
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.
It would be good to document what the first and second parameters mean.
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.
Also: could you get away with llvm::function_ref here rather than std::function? Given that the bump pointer allocator is stack allocated in EmitDFDiagnostics::run() , using the allocator anywhere after that will be a problem already -- so we shouldn't pay the price of std::function.
ac27102
to
b5bc22a
Compare
@devincoughlin @marcrasi I have changed the design from using closures to using an explicit abstract class: |
@swift-ci Please test |
Build failed |
@swift-ci Please test Linux Platform |
b5bc22a
to
8906a1f
Compare
constant interpreter. Based on this, change to a short-lived bump allocator for storing symbolic values in the pass that checks #assert.
8906a1f
to
bb7363d
Compare
Fixed an obsolete comment. |
@swift-ci Please test |
Build failed |
@swift-ci Please test macOS Platform |
Build failed |
@swift-ci Please test macOS Platform |
@marcrasi Just wondering if this new design looks okay to you. |
Yes, LGTM! |
Based on this feature, change to a short-lived bump allocator for storing symbolic values in the pass that checks #assert.