Add borrow checker to fast dfa engine - #23572
Conversation
0f34c27 to
879c7c9
Compare
DMD perf check
|
| * the `-preview=fastdfa` switch). It is subject to change and may be removed | ||
| * at a later date without notice; do not rely on it in production code. | ||
| */ | ||
| enum __fastdfa_returnborrow; |
There was a problem hiding this comment.
I presume the leading double underscore is because it is experimental? do we have a plan to remove that, e.g. remove the leading underscores and add a deprecated alias __fastdfa_returnborrow = fastdfa_returnborrow;
There was a problem hiding this comment.
Yes, it would become an in-language attribute i.e. @escape(return^)
The borrow checker is an integrated part of the escape analysis, but I left it out before to focus on the basics and not have to deal with the many to many problem which I didn't figure out how to solve (the LLM figured it out pretty much instantly).
| // walk; the later convergence drops it from the lattice. The borrow | ||
| // checker needs it to dispatch the borrow-source relationship. | ||
| ParameterDFAInfo.Inferrable tempUserForSource = paramInfo.userSupplied; | ||
| const isBorrow = tempUserForSource.willEscape(-3) |
There was a problem hiding this comment.
what's with all the -3s?
There was a problem hiding this comment.
Destination location.
I haven't bothered defining an enum as positive numbers match to user parameters.
| // only infer ByValue/PointerTo relationships, which would silently | ||
| // downgrade a user declared `Borrows` (via the __fastdfa_returnborrow UDA). | ||
| ParameterDFAInfo.Inferrable tempUser = paramInfo.userSupplied; | ||
| if (tempUser.willEscape(-3) == ParameterDFAInfo.EscapedRelationship.Borrows) |
| ParameterDFAInfo.Inferrable tempUser = paramInfo.userSupplied; | ||
| if (tempUser.willEscape(-3) == ParameterDFAInfo.EscapedRelationship.Borrows) | ||
| escapesInto = paramInfo.userSupplied.escapesInto; | ||
| int outputParamId = -3; |
879c7c9 to
d2358fb
Compare
There was a problem hiding this comment.
There ya go, @WalterBright. Anything else before you want a post in development?
Pretty much entirely written by DeepSeek V4 flash in the span of about 2 and half hours.
I'm very happy with the results.
Oh and those plan files are fully intended to be merged; it's a little something for @LightBender to learn from for PhobosV3 legal stuff.