-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Extract RefCount implementation from header to cpp file #6827
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
Conversation
I'd like to explore using @gottesmm FYI |
I will leave a real review to @gparker42, but is there any reason to merge it into the *.cpp file. Why not just keep it as a local header. |
I've outlined my reasoning in the Pr description: basically we want to expose a compiler independent interface to the swift.exe source which can be built with MSVC, whilst allowing the use of GCC/Clang built ins in the runtime, which must be built with Clang. |
@swift-ci please test |
I misunderstood what you were doing. I thought you were moving everything from the .h into the .cpp file. For future reference, the word you are looking for is "out of line", i.e. move definition of ref count implementation out of line into *.cpp file. The phrase is a much clearer signal that you are leaving the declaration in the header. This looks fine to me, but I defer to @gparker42. This is his area. |
Sorry, my bad - just learning all the C++ stuff |
I have rewritten all of this code in #5282 which is expected to land soon. Did you measure the performance and look at the generated code of the .cpp implementation? Inlining optimization is important for the refcount implementation, and moving the code to a .cpp file will prevent inlining in the absence of tricks like link-time optimization. |
I think #5282's implementation is |
I had no idea about Perf. Can try checking though, but its likely we can close this PR now that there's some conversion to Atomic As per your pull request - thats awesome! As long as it doesn't use compiler insitrinsics I'm happy. Atomic is fully supported with MsvC |
Sounds good. Let us know how #5282 fares with MSVC (before or after it gets merged). |
RefCount.h
is part of the runtime. The runtime must be built with Clang.RefCount.h
uses clang/gcc specific atomic builtins.However, RefCount.h is included by HeapObject.h, which is included from Metadata.h, which is included from IRGen.
IRGen can be built with MSVC, so therefore RefCount must also be able to be built with MSVC.
MSVC doesn't have these builtins, so we need to extract the compiler-specific implementation to the runtime, so we expose a compiler-independent interface to the compiler-independent swiftc compiler