[x] ~Introduce a new IR::Lambda intrinsic to represent lambda factories in a single instruction, to make it easier to identify queries~ (this brings too many complications and it's wasteful; detecting queries isn't really difficult and it's easier to just rely on lambda devirtualization instead)
[x] General refactor/rewrite
[x] Allow single-def vars used inside regions to be SSA renamed (ILImporter.AnalyseVars())
Support for sources other than arrays:
[x] Fallback to IEnumerator
[x] Specialized source for Array, List<>, string
[x] Specialized source for Enumerable.Range()
[ ] Specialize/devirtualize and inline boxed enumerators (ImmutableArray, ArraySegment)
Operators/stages:
Concretization:
[x] ToArray
[x] ToList
[x] ToHashSet
[x] ToDictionary
Aggregation:
[x] Aggregate
[x] Support for "unseeded" aggregates (throws if source is empty, somewhat tricky to implement)
[x] Count (predicated only)
[ ] #23
Min, Max (vectorized in .NET 7)
Search:
[x] Any, All
[x] First[OrDefault]
[ ] Last[OrDefault] (will probably need some trickery to implement efficiently for random-access sources)
[ ] Single[OrDefault]
ElementAt[OrDefault] (not profitable)
Stages:
[x] Select
[x] Where
[x] Cast, OfType
[x] Skip, Take
[x] SelectMany
Buffering:
[ ] Reverse (idea: could have an option to disable buffering for fast reverse)
[ ] Order* (this will be tricky since there's no other stable sort function in the BCL)
Other:
[x] Support for loop consumed queries (port for the front-to-back rewrite)
[x] #24
Otherwise we may leak memory for e.g. File.ReadLines()
~Offer options to preserve behavior (alt: opt-in/out attributes)~
Infrastructure:
ILImporter.AnalyseVars()
)Support for sources other than arrays:
IEnumerator
Array
,List<>
,string
Enumerable.Range()
ImmutableArray
,ArraySegment
)Operators/stages:
ToArray
ToList
ToHashSet
ToDictionary
Aggregate
Count
(predicated only)Min
,Max
(vectorized in .NET 7)Any
,All
First
[OrDefault
]Last
[OrDefault
] (will probably need some trickery to implement efficiently for random-access sources)Single
[OrDefault
]ElementAt
[OrDefault
] (not profitable)Select
Where
Cast
,OfType
Skip
,Take
SelectMany
Reverse
(idea: could have an option to disable buffering for fast reverse)Order*
(this will be tricky since there's no other stable sort function in the BCL)Other:
File.ReadLines()
Known bugs:
.ToArray().ToArray()
)