-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Java.Interop] JniTypeManager optimizations (#582)
Replace the `JniRuntime.JniBuiltinArrayMappings` field and its associated `Lazy<T>` initializer with new methods `JniRuntime.GetBuiltInTypeArraySignature()` and `JniRuntime.GetBuiltInTypeSignature()`, which removes an array initialization from the `JniRuntime` static constructor and an array iteration from `JniRuntime.JniTypeManager.GetTypeSignature()`. Additionally, use `Type.GetTypeCode(Type)` to more quickly map builtin types such as `string` to `java/lang/String`. Additionally, add a new `JniRuntime.CreationOptions.JniAddNativeMethodRegistrationAttributePresent` property which controls whether or not `JniRuntime.JniTypeManager.TryRegisterNativeMembers()` attempts to look for the `[JniAddNativeMethodRegistration]` custom attribute on methods. This is a seldom used attribute, and if no types in the app use the attribute, this can save precious startup time by removing the `method.GetCustomAttribute()` calls. These changes together improve Xamarin.Android startup time, saving ~262ms: * Before: Total(ms) Self(ms) Calls Method name 344 9 199 Java.Interop.JniRuntime/JniTypeManager:GetTypeSignature (System.Type) * After: Total(ms) Self(ms) Calls Method name 82 9 199 Java.Interop.JniRuntime/JniTypeManager:GetTypeSignature (System.Type)
- Loading branch information
Showing
8 changed files
with
289 additions
and
103 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
Oops, something went wrong.