Move PaletteReportLockContention to a new API version.
It was added in https://r.android.com/1801129, which means it went into
T and hence isn't in the first version of the Palette API.
Also add some comments to separate the API versions, and align
libartpalette.map.txt with the one in system/libartpalette after
https://r.android.com/2164906.
Test: m
Bug: 196334695
Change-Id: I68579fe8a64022d8ee7c828609240e4e3c29b32d
diff --git a/libartpalette/apex/palette.cc b/libartpalette/apex/palette.cc
index 75a3878..9a50683 100644
--- a/libartpalette/apex/palette.cc
+++ b/libartpalette/apex/palette.cc
@@ -110,6 +110,8 @@
extern "C" {
+// Methods in version 1 API, corresponding to SDK level 31.
+
palette_status_t PaletteSchedSetPriority(int32_t tid, int32_t java_priority) {
PaletteSchedSetPriorityMethod m = PaletteLoader::Instance().GetPaletteSchedSetPriorityMethod();
return m(tid, java_priority);
@@ -218,6 +220,8 @@
return m(env);
}
+// Methods in version 2 API, corresponding to SDK level 33.
+
palette_status_t PaletteReportLockContention(JNIEnv* env,
int32_t wait_ms,
const char* filename,
diff --git a/libartpalette/include/palette/palette_method_list.h b/libartpalette/include/palette/palette_method_list.h
index 066f24f..6db389c 100644
--- a/libartpalette/include/palette/palette_method_list.h
+++ b/libartpalette/include/palette/palette_method_list.h
@@ -23,8 +23,8 @@
#include "jni.h"
-// Methods in version 1 API
#define PALETTE_METHOD_LIST(M) \
+ /* Methods in version 1 API, corresponding to SDK level 31. */ \
M(PaletteSchedSetPriority, int32_t tid, int32_t java_priority) \
M(PaletteSchedGetPriority, int32_t tid, /*out*/int32_t* java_priority) \
M(PaletteWriteCrashThreadStacks, const char* stacks, size_t stacks_len) \
@@ -53,6 +53,7 @@
M(PaletteShouldReportJniInvocations, bool*) \
M(PaletteNotifyBeginJniInvocation, JNIEnv* env) \
M(PaletteNotifyEndJniInvocation, JNIEnv* env) \
+ /* Methods in version 2 API, corresponding to SDK level 33. */ \
M(PaletteReportLockContention, JNIEnv* env, \
int32_t wait_ms, \
const char* filename, \
diff --git a/libartpalette/libartpalette.map.txt b/libartpalette/libartpalette.map.txt
index 6401010..be5d9b4 100644
--- a/libartpalette/libartpalette.map.txt
+++ b/libartpalette/libartpalette.map.txt
@@ -14,12 +14,12 @@
# limitations under the License.
#
-LIBARTPALETTE_1 {
+LIBARTPALETTE_1 { # introduced=31
global:
# --- VERSION 01 API ---
PaletteSchedSetPriority; # apex
PaletteSchedGetPriority; # apex
- PaletteWriteCrashThreadStacks; #apex
+ PaletteWriteCrashThreadStacks; # apex
PaletteTraceEnabled; # apex
PaletteTraceBegin; # apex
PaletteTraceEnd; # apex
@@ -27,16 +27,21 @@
PaletteAshmemCreateRegion; # apex
PaletteAshmemSetProtRegion; # apex
PaletteCreateOdrefreshStagingDirectory; # apex
- PaletteShouldReportDex2oatCompilation; #apex
- PaletteNotifyStartDex2oatCompilation; #apex
- PaletteNotifyEndDex2oatCompilation; #apex
- PaletteNotifyDexFileLoaded; #apex
- PaletteNotifyOatFileLoaded; #apex
- PaletteShouldReportJniInvocations; #apex
- PaletteNotifyBeginJniInvocation; #apex
- PaletteNotifyEndJniInvocation; #apex
- PaletteReportLockContention; #apex
+ PaletteShouldReportDex2oatCompilation; # apex
+ PaletteNotifyStartDex2oatCompilation; # apex
+ PaletteNotifyEndDex2oatCompilation; # apex
+ PaletteNotifyDexFileLoaded; # apex
+ PaletteNotifyOatFileLoaded; # apex
+ PaletteShouldReportJniInvocations; # apex
+ PaletteNotifyBeginJniInvocation; # apex
+ PaletteNotifyEndJniInvocation; # apex
local:
*;
};
+
+LIBARTPALETTE_2 { # introduced=33
+ global:
+ # --- VERSION 02 API ---
+ PaletteReportLockContention; # apex
+} LIBARTPALETTE_1;
diff --git a/libartpalette/system/palette_fake.cc b/libartpalette/system/palette_fake.cc
index bbf8f2d..e1e05c9 100644
--- a/libartpalette/system/palette_fake.cc
+++ b/libartpalette/system/palette_fake.cc
@@ -25,6 +25,8 @@
#include "palette_system.h"
+// Methods in version 1 API, corresponding to SDK level 31.
+
// Cached thread priority for testing. No thread priorities are ever affected.
static std::mutex g_tid_priority_map_mutex;
static std::map<int32_t, int32_t> g_tid_priority_map;
@@ -129,6 +131,8 @@
return PALETTE_STATUS_OK;
}
+// Methods in version 2 API, corresponding to SDK level 33.
+
palette_status_t PaletteReportLockContention(JNIEnv* env ATTRIBUTE_UNUSED,
int32_t wait_ms ATTRIBUTE_UNUSED,
const char* filename ATTRIBUTE_UNUSED,