dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.16k stars 4.71k forks source link

[mscorlib] Moving more of the String functions to managed code #5758

Closed jamesqo closed 4 years ago

jamesqo commented 8 years ago

As it stands, many 'high-level' string functions like IndexOf, LastIndexOf, Replace etc. are implemented natively when they could be written in managed code. I noticed this was done with one of the string.Replace overloads in f007485, so maybe it would be good to do this to make the code more accessible to newcomers, if they aren't familiar with how the C++ code maps to C#.

jkotas commented 8 years ago

We have looked into this in the past and moved everything that could be moved without significant perf loss. Moving more depends on having pretty good managed optimizations for all coreclr architectures.

This makes sense to consider only once RyuJIT or better codegen is available for all architectures that coreclr runs on (x86, x64, arm, arm64).

BTW: The managed implementations of all string methods are available in corert repo.

jamesqo commented 8 years ago

@jkotas Ah, so that's why the implementations in the corert repo are managed; since it's compiled AOT and optimized by the C++ compiler, they get better codegen than the JIT implementation which is still a work-in-progress for some of the platforms you mention (arm, arm64). Thanks for clearing that up, makes sense now.

joperezr commented 4 years ago

Closing as from @jkotas response above there is nothing left to be done here. @jamesqo feel free to reopen if you think otherwise.