Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[monodroid] Use more standard C++ features, performance improvements (#…
…6159) C++ features: * Use C++20 concepts to improve compile-time correctness verification * Use `std::vector` for dynamic heap buffers * Use `std::array` for static stack buffers * Use `std::unique_ptr` instead of the home-grown equivalent (also for C-allocated memory) * Use C++20 structure designators Optimizations: * Add string routines (`ends_with()` and `find_last()`) optimized for the stack string types (derived from `string_base`) * Count assemblies at build time and pre-allocate enough memory (in the form of a `std::vector` instance) to store information about the bundled assemblies, thus avoiding 2 allocations per assembly (one `realloc()` and one `malloc()`) making the bundled assemblies loading algorithm closer to O(1) instead of the previous O(n*2). * Use character arrays instead of "plain" string literals to optimize some string operations. These changes improve plain XA test app startup time by around 11% Additionally, rename `string_segment::append(const char*)` to `string_segment::append_c(const char*)`. We [found that][0] the C++ compiler preferred the non-`template` `append(const char*)` overload over the `template<size_t S> append(const char (&s)[S])` overload, meaning `append("foo")` would hit the slower `strlen()`-based method. Likewise create `assign_c(const char*)` and `starts_with_c(const char*)` member functions. Finally, [upon review][1] of the exported symbols, we found that many symbols that we didn't want to export were being exported: % $HOME/android-toolchain/ndk/toolchains/llvm/prebuilt/darwin-x86_64/bin/x86_64-linux-android-nm -D -C bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/lib/x86_64/libmono-android.debug.so … 000000000003e480 T std::terminate() 0000000000014f80 T operator delete[](void*) 0000000000014f90 T operator delete[](void*, std::nothrow_t const&) 0000000000014fa0 T operator delete[](void*, unsigned long) 0000000000014f50 T operator delete(void*) 0000000000014f60 T operator delete(void*, std::nothrow_t const&) 0000000000014f70 T operator delete(void*, unsigned long) 0000000000014ef0 T operator new[](unsigned long) 0000000000014f30 T operator new[](unsigned long, std::nothrow_t const&) 0000000000014e90 T operator new(unsigned long) 0000000000014ed0 T operator new(unsigned long, std::nothrow_t const&) Update our declarations of these functions so that they are instead *weak* symbols, or otherwise no longer exported: 0000000000011e10 W operator delete[](void*) 0000000000011dfc W operator delete(void*) 0000000000011dec W operator new[](unsigned long) 0000000000011da8 W operator new(unsigned long) [0]: #6159 (comment) [1]: #6159 (comment)
- Loading branch information
Showing
23 changed files
with
485 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.