forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compile-only library for performance optimizations
The new library has two artifacts: - performance-annotation that provides an Android-specified annotation to selectively disable inlining in ART. The @NeverInline annotation must use the exact package name and class name it uses but it's only realized on Android targets, following the same expect/actual pattern used by Kotlin's built-in annotations (@JvmInline for instance). - performance-unsafe to allow Android targets to compile against the sun.misc.Unsafe API. These two artifacts are compile-only and not published. They are for internal use only. Relnote: N/A Test: N/A Change-Id: I6c2b6eaeedd61c2a020cf38220d971075fe3c01c
- Loading branch information
Showing
11 changed files
with
377 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# Bug component: 612128 | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Bug component: 1137062 | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[email protected] | ||
[email protected] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This library is a **compile-time** only dependency. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2024 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import androidx.build.KotlinTarget | ||
import androidx.build.PlatformIdentifier | ||
import androidx.build.Publish | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile | ||
|
||
plugins { | ||
id("AndroidXPlugin") | ||
id("com.android.library") | ||
} | ||
|
||
androidXMultiplatform { | ||
android() | ||
jvm() | ||
mac() | ||
linux() | ||
ios() | ||
watchosDeviceArm64() | ||
watchos() | ||
tvos() | ||
mingwX64() | ||
|
||
defaultPlatform(PlatformIdentifier.JVM) | ||
|
||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
api(libs.kotlinStdlib) | ||
} | ||
} | ||
|
||
androidMain { | ||
dependsOn(commonMain) | ||
} | ||
|
||
// Workaround for https://youtrack.jetbrains.com/issue/KT-51763 | ||
// Make sure commonization runs before any compilation task. | ||
tasks.withType(KotlinNativeCompile).configureEach { | ||
it.dependsOn(tasks.named("commonize")) | ||
} | ||
} | ||
} | ||
|
||
android { | ||
namespace = "androidx.performance.annotation" | ||
} | ||
|
||
androidx { | ||
name = "Performance - Annotation" | ||
publish = Publish.NONE | ||
inceptionYear = "2024" | ||
description = "Provides source annotations for performance optimizations." | ||
kotlinTarget = KotlinTarget.KOTLIN_1_9 | ||
} |
21 changes: 21 additions & 0 deletions
21
...e-annotation/src/androidMain/kotlin/dalvik/annotation/optimization/NeverInline.android.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2024 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dalvik.annotation.optimization | ||
|
||
@Retention(AnnotationRetention.BINARY) | ||
@Target(AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION) | ||
public actual annotation class NeverInline() |
35 changes: 35 additions & 0 deletions
35
...erformance-annotation/src/commonMain/kotlin/dalvik/annotation/optimization/NeverInline.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2024 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
@file:OptIn(ExperimentalMultiplatform::class) | ||
|
||
package dalvik.annotation.optimization | ||
|
||
/** | ||
* Indicates that an API should never be inlined by ART on Android. | ||
* | ||
* [NeverInline] can be used to annotate methods that should not be inlined into other methods. | ||
* Methods that are not called frequently, are never speed-critical, or are only used for debugging | ||
* do not necessarily need to run quickly. Applying this annotation to prevent these methods from | ||
* being inlined will return some size improvements in .odex files. | ||
* | ||
* Prefer using the `AndroidNeverInline` typealias instead of this annotation directly to emphasize | ||
* it only affects Android targets. | ||
*/ | ||
@Retention(AnnotationRetention.BINARY) | ||
@Target(AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION) | ||
@OptionalExpectation | ||
public expect annotation class NeverInline() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This library is a **compile-time** only dependency for Android. | ||
It is not to be used for other targets. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2024 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import androidx.build.Publish | ||
|
||
plugins { | ||
id("AndroidXPlugin") | ||
id("java-library") | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
androidx { | ||
name = "Performance - Unsafe" | ||
publish = Publish.NONE | ||
inceptionYear = "2024" | ||
description = "Compile-time support for sun.misc.Unsafe." | ||
} |
Oops, something went wrong.