Revert "Revert "ART: introduce PALette abstraction layer""
This reverts commit e6e01a0a00de80704ccb21c48d5d8bdee4470b77.
Bug: 122824298
Test: art/test/testrunner/run_build_test_target.py -j50 art-test-javac
Test: m out/target/common/obj/PACKAGING/hiddenapi-stub-flags.txt
Test: frameworks/rs/build_rs.py
Change-Id: If7b9ddca3daa80b75b3541abd283bf47d5b81118
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 67d85c1..bd306b6 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -384,6 +384,7 @@
art_hiddenapi_tests \
art_imgdiag_tests \
art_libartbase_tests \
+ art_libartpalette_tests \
art_libdexfile_external_tests \
art_libdexfile_support_tests \
art_libdexfile_tests \
diff --git a/build/apex/runtests.sh b/build/apex/runtests.sh
index 48814df..da73857 100755
--- a/build/apex/runtests.sh
+++ b/build/apex/runtests.sh
@@ -168,6 +168,13 @@
|| fail_check "Cannot find library '$1' in mounted image"
}
+function check_no_library {
+ # TODO: Use $TARGET_ARCH (e.g. check whether it is "arm" or "arm64") to improve
+ # the precision of this test?
+ [[ ! -f "$mount_point/lib/$1" && ! -f "$mount_point/lib64/$1" ]] \
+ || die "Found unwanted library '$1' in mounted image"
+}
+
function check_java_library {
[[ -f "$mount_point/javalib/$1" ]] || fail_check "Cannot find java library '$1' in mounted image"
}
@@ -196,6 +203,8 @@
check_library libart-dexlayout.so
check_library libart.so
check_library libartbase.so
+ check_library libartpalette.so
+ check_no_library libartpalette-system.so
check_library libdexfile.so
check_library libdexfile_external.so
check_library libopenjdkjvm.so
diff --git a/compiler/Android.bp b/compiler/Android.bp
index 0d92b05..0ebaa5f 100644
--- a/compiler/Android.bp
+++ b/compiler/Android.bp
@@ -182,7 +182,6 @@
generated_sources: ["art_compiler_operator_srcs"],
shared_libs: [
"libbase",
- "libcutils", // for atrace.
],
include_dirs: ["art/disassembler"],
header_libs: [
@@ -197,7 +196,6 @@
name: "libart-compiler_static_base_defaults",
static_libs: [
"libbase",
- "libcutils",
],
}
@@ -256,9 +254,10 @@
},
shared_libs: [
"libart",
+ "libartbase",
+ "libartpalette",
"libprofile",
"libdexfile",
- "libartbase",
],
target: {
@@ -317,10 +316,11 @@
},
},
shared_libs: [
+ "libartbased",
"libartd",
+ "libartpalette",
"libprofiled",
"libdexfiled",
- "libartbased",
],
}
diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp
index 6a4a88e..20d41b4 100644
--- a/dex2oat/Android.bp
+++ b/dex2oat/Android.bp
@@ -64,8 +64,6 @@
target: {
android: {
- // For atrace.
- shared_libs: ["libcutils"],
static_libs: [
"libz",
],
@@ -93,11 +91,6 @@
cc_defaults {
name: "libart-dex2oat_static_base_defaults",
- target: {
- android: {
- static_libs: ["libcutils"],
- },
- },
static_libs: [
"libbase",
"libz",
diff --git a/dexlayout/Android.bp b/dexlayout/Android.bp
index 5aa8236..838510b 100644
--- a/dexlayout/Android.bp
+++ b/dexlayout/Android.bp
@@ -29,16 +29,18 @@
target: {
android: {
shared_libs: [
- "libdexfile",
"libartbase",
+ "libartpalette",
+ "libdexfile",
"libprofile",
"libbase",
],
},
not_windows: {
shared_libs: [
- "libdexfile",
"libartbase",
+ "libartpalette",
+ "libdexfile",
"libprofile",
"libbase",
],
@@ -46,8 +48,9 @@
windows: {
cflags: ["-Wno-thread-safety"],
static_libs: [
- "libdexfile",
"libartbase",
+ "libartpalette",
+ "libdexfile",
"libprofile",
"libbase",
],
diff --git a/imgdiag/Android.bp b/imgdiag/Android.bp
index 972c8f7..39720a0 100644
--- a/imgdiag/Android.bp
+++ b/imgdiag/Android.bp
@@ -31,9 +31,6 @@
"libbase",
],
target: {
- android: {
- shared_libs: ["libcutils"],
- },
host: {
shared_libs: ["libziparchive"],
},
diff --git a/libartbase/Android.bp b/libartbase/Android.bp
index 509b072..1ca7011 100644
--- a/libartbase/Android.bp
+++ b/libartbase/Android.bp
@@ -61,7 +61,7 @@
shared_libs: [
"liblog",
// For ashmem.
- "libcutils",
+ "libartpalette",
// For common macros.
"libbase",
],
@@ -80,7 +80,7 @@
"libz",
"liblog",
// For ashmem.
- "libcutils",
+ "libartpalette",
// For common macros.
"libbase",
],
@@ -99,7 +99,7 @@
"libz",
"liblog",
// For ashmem.
- "libcutils",
+ "libartpalette",
// For common macros.
"libbase",
],
@@ -128,7 +128,7 @@
name: "libartbase_static_base_defaults",
static_libs: [
"libbase",
- "libcutils",
+ "libartpalette",
"liblog",
"libz",
"libziparchive",
diff --git a/libartbase/base/systrace.h b/libartbase/base/systrace.h
index d995dce..30bba49 100644
--- a/libartbase/base/systrace.h
+++ b/libartbase/base/systrace.h
@@ -17,33 +17,52 @@
#ifndef ART_LIBARTBASE_BASE_SYSTRACE_H_
#define ART_LIBARTBASE_BASE_SYSTRACE_H_
-#define ATRACE_TAG ATRACE_TAG_DALVIK
-#include <cutils/trace.h>
-
#include <sstream>
#include <string>
#include "android-base/stringprintf.h"
#include "macros.h"
+#include "palette/palette.h"
namespace art {
+inline bool ATraceEnabled() {
+ int enabled = 0;
+ if (UNLIKELY(PaletteTraceEnabled(&enabled) == PaletteStatus::kOkay && enabled != 0)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+inline void ATraceBegin(const char* name) {
+ PaletteTraceBegin(name);
+}
+
+inline void ATraceEnd() {
+ PaletteTraceEnd();
+}
+
+inline void ATraceIntegerValue(const char* name, int32_t value) {
+ PaletteTraceIntegerValue(name, value);
+}
+
class ScopedTrace {
public:
explicit ScopedTrace(const char* name) {
- ATRACE_BEGIN(name);
+ ATraceBegin(name);
}
template <typename Fn>
explicit ScopedTrace(Fn fn) {
- if (ATRACE_ENABLED()) {
- ATRACE_BEGIN(fn().c_str());
+ if (UNLIKELY(ATraceEnabled())) {
+ ATraceBegin(fn().c_str());
}
}
explicit ScopedTrace(const std::string& name) : ScopedTrace(name.c_str()) {}
~ScopedTrace() {
- ATRACE_END();
+ ATraceEnd();
}
};
@@ -54,7 +73,7 @@
}
~ScopedTraceNoStart() {
- ATRACE_END();
+ ATraceEnd();
}
// Message helper for the macro. Do not use directly.
@@ -63,7 +82,7 @@
ScopedTraceMessageHelper() {
}
~ScopedTraceMessageHelper() {
- ATRACE_BEGIN(buffer_.str().c_str());
+ ATraceBegin(buffer_.str().c_str());
}
std::ostream& stream() {
@@ -77,7 +96,7 @@
#define SCOPED_TRACE \
::art::ScopedTraceNoStart APPEND_TOKENS_AFTER_EVAL(trace, __LINE__) ; \
- (ATRACE_ENABLED()) && ::art::ScopedTraceNoStart::ScopedTraceMessageHelper().stream()
+ (ATraceEnabled()) && ::art::ScopedTraceNoStart::ScopedTraceMessageHelper().stream()
} // namespace art
diff --git a/libartpalette/Android.bp b/libartpalette/Android.bp
new file mode 100644
index 0000000..778109d
--- /dev/null
+++ b/libartpalette/Android.bp
@@ -0,0 +1,116 @@
+//
+// Copyright (C) 2019 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.
+//
+
+cc_defaults {
+ name: "libartpalette_defaults",
+ defaults: ["art_defaults"],
+ host_supported: true,
+ export_include_dirs: ["include"],
+}
+
+// libartpalette-system is the implementation of the abstraction layer. It is
+// only available as a shared library on Android.
+art_cc_library {
+ name: "libartpalette-system",
+ defaults: ["libartpalette_defaults"],
+
+ target: {
+ android: {
+ srcs: ["system/palette_android.cc",],
+ header_libs: ["libbase_headers"],
+ shared_libs: [
+ "libcutils",
+ "liblog",
+ "libprocessgroup",
+ ],
+ },
+ host: {
+ header_libs: ["libbase_headers"],
+ srcs: ["system/palette_fake.cc",],
+ },
+ darwin: {
+ enabled: false,
+ },
+ windows: {
+ enabled: false,
+ },
+ },
+ static: {
+ enabled: false,
+ },
+ version_script: "libartpalette.map.txt",
+}
+
+// libartpalette is the dynamic loader of the platform abstraction
+// layer. It is only used on Android. For other targets, it just
+// implements a fake platform implementation.
+art_cc_library {
+ name: "libartpalette",
+ defaults: ["libartpalette_defaults"],
+ required: ["libartpalette-system"], // libartpalette.so dlopen()'s libartpalette-system.
+ header_libs: ["libbase_headers"],
+ target: {
+ // Targets supporting dlopen build the client library which loads
+ // and binds the methods in the libartpalette-system library.
+ android: {
+ srcs: ["apex/palette.cc"],
+ shared: {
+ shared_libs: ["liblog"],
+ },
+ static: {
+ static_libs: ["liblog"],
+ },
+ version_script: "libartpalette.map.txt",
+ },
+ linux_bionic: {
+ header_libs: ["libbase_headers"],
+ srcs: ["system/palette_fake.cc"],
+ shared: {
+ shared_libs: ["liblog"],
+ },
+ version_script: "libartpalette.map.txt",
+ },
+ linux_glibc: {
+ header_libs: ["libbase_headers"],
+ srcs: ["system/palette_fake.cc"],
+ shared: {
+ shared_libs: ["liblog"],
+ },
+ version_script: "libartpalette.map.txt",
+ },
+ // Targets without support for dlopen just use the sources for
+ // the system library which actually implements functionality.
+ darwin: {
+ enabled: true,
+ header_libs: ["libbase_headers"],
+ srcs: ["system/palette_fake.cc"],
+ },
+ windows: {
+ enabled: true,
+ header_libs: ["libbase_headers"],
+ srcs: ["system/palette_fake.cc"],
+ },
+ }
+}
+
+art_cc_test {
+ name: "art_libartpalette_tests",
+ defaults: ["art_gtest_defaults"],
+ host_supported: true,
+ srcs: ["apex/palette_test.cc"],
+ shared_libs: ["libartpalette"],
+ test_per_src: true,
+}
diff --git a/libartpalette/apex/palette.cc b/libartpalette/apex/palette.cc
new file mode 100644
index 0000000..8c17057
--- /dev/null
+++ b/libartpalette/apex/palette.cc
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include "palette/palette.h"
+
+#include <dlfcn.h>
+#include <stdlib.h>
+
+#include <android/log.h>
+#include <android-base/macros.h>
+
+namespace {
+
+// Logging tag.
+static constexpr const char* kLogTag = "libartpalette";
+
+// Name of the palette library present in the /system partition.
+static constexpr const char* kPaletteSystemLibrary = "libartpalette-system.so";
+
+// Generic method used when a dynamically loaded palette instance does not
+// support a method.
+enum PaletteStatus PaletteMethodNotSupported() {
+ return PaletteStatus::kNotSupported;
+}
+
+// Declare type aliases for pointers to each function in the interface.
+#define PALETTE_METHOD_TYPE_ALIAS(Name, ...) \
+ using Name ## Method = PaletteStatus(*)(__VA_ARGS__);
+PALETTE_METHOD_LIST(PALETTE_METHOD_TYPE_ALIAS)
+#undef PALETTE_METHOD_TYPE_ALIAS
+
+// Singleton class responsible for dynamically loading the palette library and
+// binding functions there to method pointers.
+class PaletteLoader {
+ public:
+ static PaletteLoader& Instance() {
+ static PaletteLoader instance;
+ return instance;
+ }
+
+ // Accessor methods to get instances of palette methods.
+#define PALETTE_LOADER_METHOD_ACCESSOR(Name, ...) \
+ Name ## Method Get ## Name ## Method() const { return Name ## Method ## _; }
+PALETTE_METHOD_LIST(PALETTE_LOADER_METHOD_ACCESSOR)
+#undef PALETTE_LOADER_METHOD_ACCESSOR
+
+ private:
+ PaletteLoader();
+
+ static void* OpenLibrary();
+ static void* GetMethod(void* palette_lib, const char* name);
+
+ // Handle to the palette library from dlopen().
+ void* palette_lib_;
+
+ // Fields to store pointers to palette methods.
+#define PALETTE_LOADER_METHOD_FIELD(Name, ...) \
+ const Name ## Method Name ## Method ## _;
+ PALETTE_METHOD_LIST(PALETTE_LOADER_METHOD_FIELD)
+#undef PALETTE_LOADER_METHOD_FIELD
+
+ DISALLOW_COPY_AND_ASSIGN(PaletteLoader);
+};
+
+void* PaletteLoader::OpenLibrary() {
+ void* handle = dlopen(kPaletteSystemLibrary, RTLD_NOW | RTLD_LOCAL | RTLD_NODELETE);
+ if (handle == nullptr) {
+ // dlerror message includes details of error and file being opened.
+ __android_log_assert(nullptr, kLogTag, "%s", dlerror());
+ }
+ return handle;
+}
+
+void* PaletteLoader::GetMethod(void* palette_lib, const char* name) {
+ void* method = nullptr;
+ if (palette_lib != nullptr) {
+ method = dlsym(palette_lib, name);
+ }
+ if (method == nullptr) {
+ return reinterpret_cast<void*>(PaletteMethodNotSupported);
+ }
+ // TODO(oth): consider new GetMethodSignature() in the Palette API which
+ // would allow sanity checking the type signatures.
+ return method;
+}
+
+PaletteLoader::PaletteLoader() :
+ palette_lib_(OpenLibrary())
+#define PALETTE_LOADER_BIND_METHOD(Name, ...) \
+ , Name ## Method ## _(reinterpret_cast<Name ## Method>(GetMethod(palette_lib_, #Name)))
+ PALETTE_METHOD_LIST(PALETTE_LOADER_BIND_METHOD)
+#undef PALETTE_LOADER_BIND_METHOD
+{
+}
+
+} // namespace
+
+extern "C" {
+
+enum PaletteStatus PaletteGetVersion(/*out*/int32_t* version) {
+ PaletteGetVersionMethod m = PaletteLoader::Instance().GetPaletteGetVersionMethod();
+ return m(version);
+}
+
+enum PaletteStatus PaletteSchedSetPriority(int32_t tid, int32_t java_priority) {
+ PaletteSchedSetPriorityMethod m = PaletteLoader::Instance().GetPaletteSchedSetPriorityMethod();
+ return m(tid, java_priority);
+}
+
+enum PaletteStatus PaletteSchedGetPriority(int32_t tid, /*out*/int32_t* java_priority) {
+ PaletteSchedGetPriorityMethod m = PaletteLoader::Instance().GetPaletteSchedGetPriorityMethod();
+ return m(tid, java_priority);
+}
+
+enum PaletteStatus PaletteTraceEnabled(/*out*/int32_t* enabled) {
+ PaletteTraceEnabledMethod m = PaletteLoader::Instance().GetPaletteTraceEnabledMethod();
+ return m(enabled);
+}
+
+enum PaletteStatus PaletteTraceBegin(/*in*/const char* name) {
+ PaletteTraceBeginMethod m = PaletteLoader::Instance().GetPaletteTraceBeginMethod();
+ return m(name);
+}
+
+enum PaletteStatus PaletteTraceEnd() {
+ PaletteTraceEndMethod m = PaletteLoader::Instance().GetPaletteTraceEndMethod();
+ return m();
+}
+
+enum PaletteStatus PaletteTraceIntegerValue(/*in*/const char* name, int32_t value) {
+ PaletteTraceIntegerValueMethod m = PaletteLoader::Instance().GetPaletteTraceIntegerValueMethod();
+ return m(name, value);
+}
+
+} // extern "C"
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
new file mode 100644
index 0000000..8bbe0ee
--- /dev/null
+++ b/libartpalette/apex/palette_test.cc
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include "palette/palette.h"
+
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "gtest/gtest.h"
+
+namespace {
+
+pid_t GetTid() {
+#ifdef __BIONIC__
+ return gettid();
+#else // __BIONIC__
+ return syscall(__NR_gettid);
+#endif // __BIONIC__
+}
+
+} // namespace
+
+class PaletteClientTest : public testing::Test {};
+
+TEST_F(PaletteClientTest, GetVersion) {
+ int32_t version = -1;
+ PaletteStatus status = PaletteGetVersion(&version);
+ ASSERT_EQ(PaletteStatus::kOkay, status);
+ ASSERT_GE(version, 1);
+}
+
+TEST_F(PaletteClientTest, SchedPriority) {
+ int32_t tid = GetTid();
+ int32_t saved_priority;
+ EXPECT_EQ(PaletteStatus::kOkay, PaletteSchedGetPriority(tid, &saved_priority));
+
+ EXPECT_EQ(PaletteStatus::kInvalidArgument, PaletteSchedSetPriority(tid, /*java_priority=*/ 0));
+ EXPECT_EQ(PaletteStatus::kInvalidArgument, PaletteSchedSetPriority(tid, /*java_priority=*/ -1));
+ EXPECT_EQ(PaletteStatus::kInvalidArgument, PaletteSchedSetPriority(tid, /*java_priority=*/ 11));
+
+ EXPECT_EQ(PaletteStatus::kOkay, PaletteSchedSetPriority(tid, /*java_priority=*/ 1));
+ EXPECT_EQ(PaletteStatus::kOkay, PaletteSchedSetPriority(tid, saved_priority));
+}
+
+TEST_F(PaletteClientTest, Trace) {
+ int32_t enabled;
+ EXPECT_EQ(PaletteStatus::kOkay, PaletteTraceEnabled(&enabled));
+ EXPECT_EQ(PaletteStatus::kOkay, PaletteTraceBegin("Hello world!"));
+ EXPECT_EQ(PaletteStatus::kOkay, PaletteTraceEnd());
+ EXPECT_EQ(PaletteStatus::kOkay, PaletteTraceIntegerValue("Beans", /*value=*/ 3));
+}
diff --git a/libartpalette/include/palette/palette.h b/libartpalette/include/palette/palette.h
new file mode 100644
index 0000000..1f58403
--- /dev/null
+++ b/libartpalette/include/palette/palette.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#ifndef ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_H_
+#define ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_H_
+
+#include "palette_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+// Palette method signatures are defined in palette_method_list.h.
+
+#define PALETTE_METHOD_DECLARATION(Name, ...) \
+ enum PaletteStatus Name(__VA_ARGS__);
+#include "palette_method_list.h"
+PALETTE_METHOD_LIST(PALETTE_METHOD_DECLARATION)
+#undef PALETTE_METHOD_DECLARATION
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif // ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_H_
diff --git a/libartpalette/include/palette/palette_method_list.h b/libartpalette/include/palette/palette_method_list.h
new file mode 100644
index 0000000..dc4ec52
--- /dev/null
+++ b/libartpalette/include/palette/palette_method_list.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#ifndef ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_METHOD_LIST_H_
+#define ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_METHOD_LIST_H_
+
+#include <stdint.h>
+
+// Methods in version 1 API
+#define PALETTE_METHOD_LIST(M) \
+ M(PaletteGetVersion, /*out*/int32_t* version) \
+ M(PaletteSchedSetPriority, int32_t tid, int32_t java_priority) \
+ M(PaletteSchedGetPriority, int32_t tid, /*out*/int32_t* java_priority) \
+ M(PaletteTraceEnabled, /*out*/int32_t* enabled) \
+ M(PaletteTraceBegin, const char* name) \
+ M(PaletteTraceEnd) \
+ M(PaletteTraceIntegerValue, const char* name, int32_t value)
+
+#endif // ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_METHOD_LIST_H_
diff --git a/libartpalette/include/palette/palette_types.h b/libartpalette/include/palette/palette_types.h
new file mode 100644
index 0000000..837086e
--- /dev/null
+++ b/libartpalette/include/palette/palette_types.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#ifndef ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_TYPES_H_
+#define ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_TYPES_H_
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+// Return values for palette functions.
+enum PaletteStatus {
+ kOkay = 0,
+ kCheckErrno = 1,
+ kInvalidArgument = 2,
+ kNotSupported = 3,
+};
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif // ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_TYPES_H_
diff --git a/libartpalette/libartpalette.map.txt b/libartpalette/libartpalette.map.txt
new file mode 100644
index 0000000..0920835
--- /dev/null
+++ b/libartpalette/libartpalette.map.txt
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2019 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.
+#
+
+LIBARTPALETTE_1 {
+ global:
+ # --- VERSION 01 API ---
+ PaletteGetVersion;
+ PaletteSchedSetPriority;
+ PaletteSchedGetPriority;
+ PaletteTraceEnabled;
+ PaletteTraceBegin;
+ PaletteTraceEnd;
+ PaletteTraceIntegerValue;
+
+ local:
+ *;
+};
diff --git a/libartpalette/system/palette_android.cc b/libartpalette/system/palette_android.cc
new file mode 100644
index 0000000..aed3862
--- /dev/null
+++ b/libartpalette/system/palette_android.cc
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#define ATRACE_TAG ATRACE_TAG_DALVIK
+
+#include "palette/palette.h"
+
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#include <mutex>
+
+#include <android-base/logging.h>
+#include <android-base/macros.h>
+#include <cutils/sched_policy.h>
+#include <cutils/trace.h>
+#include <log/event_tag_map.h>
+#include <utils/Thread.h>
+
+#include "palette_system.h"
+
+enum PaletteStatus PaletteGetVersion(int32_t* version) {
+ *version = art::palette::kPaletteVersion;
+ return PaletteStatus::kOkay;
+}
+
+// Conversion map for "nice" values.
+//
+// We use Android thread priority constants to be consistent with the rest
+// of the system. In some cases adjacent entries may overlap.
+//
+static const int kNiceValues[art::palette::kNumManagedThreadPriorities] = {
+ ANDROID_PRIORITY_LOWEST, // 1 (MIN_PRIORITY)
+ ANDROID_PRIORITY_BACKGROUND + 6,
+ ANDROID_PRIORITY_BACKGROUND + 3,
+ ANDROID_PRIORITY_BACKGROUND,
+ ANDROID_PRIORITY_NORMAL, // 5 (NORM_PRIORITY)
+ ANDROID_PRIORITY_NORMAL - 2,
+ ANDROID_PRIORITY_NORMAL - 4,
+ ANDROID_PRIORITY_URGENT_DISPLAY + 3,
+ ANDROID_PRIORITY_URGENT_DISPLAY + 2,
+ ANDROID_PRIORITY_URGENT_DISPLAY // 10 (MAX_PRIORITY)
+};
+
+enum PaletteStatus PaletteSchedSetPriority(int32_t tid, int32_t managed_priority) {
+ if (managed_priority < art::palette::kMinManagedThreadPriority ||
+ managed_priority > art::palette::kMaxManagedThreadPriority) {
+ return PaletteStatus::kInvalidArgument;
+ }
+ int new_nice = kNiceValues[managed_priority - art::palette::kMinManagedThreadPriority];
+
+ // TODO: b/18249098 The code below is broken. It uses getpriority() as a proxy for whether a
+ // thread is already in the SP_FOREGROUND cgroup. This is not necessarily true for background
+ // processes, where all threads are in the SP_BACKGROUND cgroup. This means that callers will
+ // have to call setPriority twice to do what they want :
+ //
+ // Thread.setPriority(Thread.MIN_PRIORITY); // no-op wrt to cgroups
+ // Thread.setPriority(Thread.MAX_PRIORITY); // will actually change cgroups.
+ if (new_nice >= ANDROID_PRIORITY_BACKGROUND) {
+ set_sched_policy(tid, SP_BACKGROUND);
+ } else if (getpriority(PRIO_PROCESS, tid) >= ANDROID_PRIORITY_BACKGROUND) {
+ set_sched_policy(tid, SP_FOREGROUND);
+ }
+
+ if (setpriority(PRIO_PROCESS, tid, new_nice) != 0) {
+ return PaletteStatus::kCheckErrno;
+ }
+ return PaletteStatus::kOkay;
+}
+
+enum PaletteStatus PaletteSchedGetPriority(int32_t tid, /*out*/int32_t* managed_priority) {
+ errno = 0;
+ int native_priority = getpriority(PRIO_PROCESS, tid);
+ if (native_priority == -1 && errno != 0) {
+ *managed_priority = art::palette::kNormalManagedThreadPriority;
+ return PaletteStatus::kCheckErrno;
+ }
+
+ for (int p = art::palette::kMinManagedThreadPriority;
+ p <= art::palette::kMaxManagedThreadPriority;
+ p = p + 1) {
+ int index = p - art::palette::kMinManagedThreadPriority;
+ if (native_priority >= kNiceValues[index]) {
+ *managed_priority = p;
+ return PaletteStatus::kOkay;
+ }
+ }
+ *managed_priority = art::palette::kMaxManagedThreadPriority;
+ return PaletteStatus::kOkay;
+}
+
+enum PaletteStatus PaletteTraceEnabled(/*out*/int32_t* enabled) {
+ *enabled = (ATRACE_ENABLED() != 0) ? 1 : 0;
+ return PaletteStatus::kOkay;
+}
+
+enum PaletteStatus PaletteTraceBegin(const char* name) {
+ ATRACE_BEGIN(name);
+ return PaletteStatus::kOkay;
+}
+
+enum PaletteStatus PaletteTraceEnd() {
+ ATRACE_END();
+ return PaletteStatus::kOkay;
+}
+
+enum PaletteStatus PaletteTraceIntegerValue(const char* name, int32_t value) {
+ ATRACE_INT(name, value);
+ return PaletteStatus::kOkay;
+}
diff --git a/libartpalette/system/palette_fake.cc b/libartpalette/system/palette_fake.cc
new file mode 100644
index 0000000..0961e77
--- /dev/null
+++ b/libartpalette/system/palette_fake.cc
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include "palette/palette.h"
+
+#include <map>
+#include <mutex>
+
+#include <android-base/macros.h> // For ATTRIBUTE_UNUSED
+
+#include "palette_system.h"
+
+enum PaletteStatus PaletteGetVersion(int32_t* version) {
+ *version = art::palette::kPaletteVersion;
+ return PaletteStatus::kOkay;
+}
+
+// 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;
+
+enum PaletteStatus PaletteSchedSetPriority(int32_t tid, int32_t priority) {
+ if (priority < art::palette::kMinManagedThreadPriority ||
+ priority > art::palette::kMaxManagedThreadPriority) {
+ return PaletteStatus::kInvalidArgument;
+ }
+ std::lock_guard guard(g_tid_priority_map_mutex);
+ g_tid_priority_map[tid] = priority;
+ return PaletteStatus::kOkay;
+}
+
+enum PaletteStatus PaletteSchedGetPriority(int32_t tid,
+ /*out*/int32_t* priority) {
+ std::lock_guard guard(g_tid_priority_map_mutex);
+ if (g_tid_priority_map.find(tid) == g_tid_priority_map.end()) {
+ g_tid_priority_map[tid] = art::palette::kNormalManagedThreadPriority;
+ }
+ *priority = g_tid_priority_map[tid];
+ return PaletteStatus::kOkay;
+}
+
+enum PaletteStatus PaletteTraceEnabled(/*out*/int32_t* enabled) {
+ *enabled = 0;
+ return PaletteStatus::kOkay;
+}
+
+enum PaletteStatus PaletteTraceBegin(const char* name ATTRIBUTE_UNUSED) {
+ return PaletteStatus::kOkay;
+}
+
+enum PaletteStatus PaletteTraceEnd() {
+ return PaletteStatus::kOkay;
+}
+
+enum PaletteStatus PaletteTraceIntegerValue(const char* name ATTRIBUTE_UNUSED,
+ int32_t value ATTRIBUTE_UNUSED) {
+ return PaletteStatus::kOkay;
+}
diff --git a/libartpalette/system/palette_system.h b/libartpalette/system/palette_system.h
new file mode 100644
index 0000000..b28e00d
--- /dev/null
+++ b/libartpalette/system/palette_system.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#ifndef ART_LIBARTPALETTE_SYSTEM_PALETTE_SYSTEM_H_
+#define ART_LIBARTPALETTE_SYSTEM_PALETTE_SYSTEM_H_
+
+#include <stdint.h>
+
+namespace art {
+namespace palette {
+
+static constexpr int32_t kPaletteVersion = 1;
+
+// Managed thread definitions
+static constexpr int32_t kNormalManagedThreadPriority = 5;
+static constexpr int32_t kMinManagedThreadPriority = 1;
+static constexpr int32_t kMaxManagedThreadPriority = 10;
+static constexpr int32_t kNumManagedThreadPriorities =
+ kMaxManagedThreadPriority - kMinManagedThreadPriority + 1;
+
+} // namespace palette
+} // namespace art
+
+#endif // ART_LIBARTPALETTE_SYSTEM_PALETTE_SYSTEM_H_
diff --git a/libdexfile/Android.bp b/libdexfile/Android.bp
index 428c2c8..feb5e38 100644
--- a/libdexfile/Android.bp
+++ b/libdexfile/Android.bp
@@ -47,9 +47,8 @@
shared_libs: [
// For MemMap.
"libartbase",
+ "libartpalette",
"liblog",
- // For atrace.
- "libcutils",
// For common macros.
"libbase",
],
@@ -64,9 +63,8 @@
"libz",
// For MemMap.
"libartbase",
+ "libartpalette",
"liblog",
- // For atrace.
- "libcutils",
// For common macros.
"libbase",
],
@@ -81,9 +79,8 @@
"libz",
// For MemMap.
"libartbase",
+ "libartpalette",
"liblog",
- // For atrace.
- "libcutils",
// For common macros.
"libbase",
],
@@ -102,7 +99,6 @@
name: "libdexfile_static_base_defaults",
static_libs: [
"libbase",
- "libcutils",
"liblog",
"libz",
"libziparchive",
diff --git a/libprofile/Android.bp b/libprofile/Android.bp
index fd32c5f..986adce 100644
--- a/libprofile/Android.bp
+++ b/libprofile/Android.bp
@@ -25,10 +25,8 @@
android: {
shared_libs: [
"libartbase",
+ "libartpalette",
"libdexfile",
- "libartbase",
- // For atrace.
- "libcutils",
"libbase",
],
static_libs: [
@@ -41,10 +39,8 @@
not_windows: {
shared_libs: [
"libartbase",
+ "libartpalette",
"libdexfile",
- "libartbase",
- // For atrace.
- "libcutils",
"libziparchive",
"libz",
"libbase",
@@ -55,10 +51,8 @@
cflags: ["-Wno-thread-safety"],
static_libs: [
"libartbase",
+ "libartpalette",
"libdexfile",
- "libartbase",
- // For atrace.
- "libcutils",
"libziparchive",
"libz",
"libbase",
@@ -78,7 +72,6 @@
name: "libprofile_static_base_defaults",
static_libs: [
"libbase",
- "libcutils",
"libz",
"libziparchive",
],
diff --git a/oatdump/Android.bp b/oatdump/Android.bp
index 0e4d5b3..f56265c 100644
--- a/oatdump/Android.bp
+++ b/oatdump/Android.bp
@@ -19,11 +19,6 @@
defaults: ["art_defaults"],
host_supported: true,
srcs: ["oatdump.cc"],
- target: {
- android: {
- shared_libs: ["libcutils"],
- },
- },
// b/79417743, oatdump 32-bit tests failed with clang lld
use_clang_lld: false,
header_libs: [
diff --git a/runtime/Android.bp b/runtime/Android.bp
index a3081e9..a08ba70 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -392,14 +392,11 @@
"jni_platform_headers",
],
shared_libs: [
+ "libartpalette",
"libnativebridge",
"libnativeloader",
"libbacktrace",
"liblog",
- // For atrace, properties, ashmem.
- "libcutils",
- // For set_sched_policy.
- "libprocessgroup",
// For common macros.
"libbase",
],
@@ -424,9 +421,9 @@
},
},
static_libs: [
+ "libartpalette",
"libbacktrace",
"libbase",
- "libcutils",
"libdexfile_external", // libunwindstack dependency
"libdexfile_support", // libunwindstack dependency
"liblog",
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 5a52818..7aec661 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -107,15 +107,15 @@
blocked_tid_(kLogLockContentions ? blocked_tid : 0),
owner_tid_(kLogLockContentions ? owner_tid : 0),
start_nano_time_(kLogLockContentions ? NanoTime() : 0) {
- if (ATRACE_ENABLED()) {
+ if (ATraceEnabled()) {
std::string msg = StringPrintf("Lock contention on %s (owner tid: %" PRIu64 ")",
mutex->GetName(), owner_tid);
- ATRACE_BEGIN(msg.c_str());
+ ATraceBegin(msg.c_str());
}
}
~ScopedContentionRecorder() {
- ATRACE_END();
+ ATraceEnd();
if (kLogLockContentions) {
uint64_t end_nano_time = NanoTime();
mutex_->RecordContention(blocked_tid_, owner_tid_, end_nano_time - start_nano_time_);
diff --git a/runtime/base/timing_logger.cc b/runtime/base/timing_logger.cc
index 0a4cddd..bd39192 100644
--- a/runtime/base/timing_logger.cc
+++ b/runtime/base/timing_logger.cc
@@ -144,12 +144,12 @@
void TimingLogger::StartTiming(const char* label) {
DCHECK(label != nullptr);
timings_.push_back(Timing(kind_, label));
- ATRACE_BEGIN(label);
+ ATraceBegin(label);
}
void TimingLogger::EndTiming() {
timings_.push_back(Timing(kind_, nullptr));
- ATRACE_END();
+ ATraceEnd();
}
uint64_t TimingLogger::GetTotalNs() const {
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 8020f86..d72003c 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -2637,7 +2637,7 @@
}
void Heap::TraceHeapSize(size_t heap_size) {
- ATRACE_INT("Heap size (KB)", heap_size / KB);
+ ATraceIntegerValue("Heap size (KB)", heap_size / KB);
}
size_t Heap::GetNativeBytes() {
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index 7240357..6abc8d7 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -280,7 +280,7 @@
// This function is inlined and just helps to not have the VLOG and ATRACE check at all the
// potential tracing points.
void Monitor::AtraceMonitorLock(Thread* self, mirror::Object* obj, bool is_wait) {
- if (UNLIKELY(VLOG_IS_ON(systrace_lock_logging) && ATRACE_ENABLED())) {
+ if (UNLIKELY(VLOG_IS_ON(systrace_lock_logging) && ATraceEnabled())) {
AtraceMonitorLockImpl(self, obj, is_wait);
}
}
@@ -338,12 +338,12 @@
(obj == nullptr ? -1 : static_cast<int32_t>(reinterpret_cast<uintptr_t>(obj))),
(filename != nullptr ? filename : "null"),
line_number);
- ATRACE_BEGIN(tmp.c_str());
+ ATraceBegin(tmp.c_str());
}
void Monitor::AtraceMonitorUnlock() {
if (UNLIKELY(VLOG_IS_ON(systrace_lock_logging))) {
- ATRACE_END();
+ ATraceEnd();
}
}
@@ -431,7 +431,7 @@
// If systrace logging is enabled, first look at the lock owner. Acquiring the monitor's
// lock and then re-acquiring the mutator lock can deadlock.
bool started_trace = false;
- if (ATRACE_ENABLED()) {
+ if (ATraceEnabled()) {
if (owner_ != nullptr) { // Did the owner_ give the lock up?
std::ostringstream oss;
std::string name;
@@ -450,7 +450,7 @@
oss << " blocking from "
<< ArtMethod::PrettyMethod(m) << "(" << (filename != nullptr ? filename : "null")
<< ":" << line_number << ")";
- ATRACE_BEGIN(oss.str().c_str());
+ ATraceBegin(oss.str().c_str());
started_trace = true;
}
}
@@ -581,7 +581,7 @@
}
}
if (started_trace) {
- ATRACE_END();
+ ATraceEnd();
}
self->SetMonitorEnterObject(nullptr);
monitor_lock_.Lock(self); // Reacquire locks in order.
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 309c04e..4828aae 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -16,10 +16,6 @@
#include "thread.h"
-#if !defined(__APPLE__)
-#include <sched.h>
-#endif
-
#include <pthread.h>
#include <signal.h>
#include <sys/resource.h>
@@ -95,6 +91,7 @@
#include "oat_quick_method_header.h"
#include "obj_ptr-inl.h"
#include "object_lock.h"
+#include "palette/palette.h"
#include "quick/quick_method_frame_info.h"
#include "quick_exception_handler.h"
#include "read_barrier-inl.h"
@@ -4233,6 +4230,7 @@
Runtime::Current()->GetThreadList()->RunCheckpoint(&closure);
}
+
void Thread::ReleaseLongJumpContextInternal() {
// Each QuickExceptionHandler gets a long jump context and uses
// it for doing the long jump, after finding catch blocks/doing deoptimization.
@@ -4246,4 +4244,18 @@
delete tlsPtr_.long_jump_context;
}
+void Thread::SetNativePriority(int new_priority) {
+ // ART tests on JVM can reach this code path, use tid = 0 as shorthand for current thread.
+ PaletteStatus status = PaletteSchedSetPriority(0, new_priority);
+ CHECK(status == PaletteStatus::kOkay || status == PaletteStatus::kCheckErrno);
+}
+
+int Thread::GetNativePriority() {
+ int priority = 0;
+ // ART tests on JVM can reach this code path, use tid = 0 as shorthand for current thread.
+ PaletteStatus status = PaletteSchedGetPriority(0, &priority);
+ CHECK(status == PaletteStatus::kOkay || status == PaletteStatus::kCheckErrno);
+ return priority;
+}
+
} // namespace art
diff --git a/runtime/thread_android.cc b/runtime/thread_android.cc
index 24864f9..f333400 100644
--- a/runtime/thread_android.cc
+++ b/runtime/thread_android.cc
@@ -16,84 +16,8 @@
#include "thread.h"
-#include <errno.h>
-#include <limits.h>
-#include <sys/resource.h>
-#include <sys/time.h>
-
-#include <processgroup/sched_policy.h>
-#include <utils/threads.h>
-
-#include "base/macros.h"
-
namespace art {
-// Conversion map for "nice" values.
-//
-// We use Android thread priority constants to be consistent with the rest
-// of the system. In some cases adjacent entries may overlap.
-//
-static const int kNiceValues[10] = {
- ANDROID_PRIORITY_LOWEST, // 1 (MIN_PRIORITY)
- ANDROID_PRIORITY_BACKGROUND + 6,
- ANDROID_PRIORITY_BACKGROUND + 3,
- ANDROID_PRIORITY_BACKGROUND,
- ANDROID_PRIORITY_NORMAL, // 5 (NORM_PRIORITY)
- ANDROID_PRIORITY_NORMAL - 2,
- ANDROID_PRIORITY_NORMAL - 4,
- ANDROID_PRIORITY_URGENT_DISPLAY + 3,
- ANDROID_PRIORITY_URGENT_DISPLAY + 2,
- ANDROID_PRIORITY_URGENT_DISPLAY // 10 (MAX_PRIORITY)
-};
-
-void Thread::SetNativePriority(int newPriority) {
- if (newPriority < 1 || newPriority > 10) {
- LOG(WARNING) << "bad priority " << newPriority;
- newPriority = 5;
- }
-
- int newNice = kNiceValues[newPriority-1];
- pid_t tid = GetTid();
-
- // TODO: b/18249098 The code below is broken. It uses getpriority() as a proxy for whether a
- // thread is already in the SP_FOREGROUND cgroup. This is not necessarily true for background
- // processes, where all threads are in the SP_BACKGROUND cgroup. This means that callers will
- // have to call setPriority twice to do what they want :
- //
- // Thread.setPriority(Thread.MIN_PRIORITY); // no-op wrt to cgroups
- // Thread.setPriority(Thread.MAX_PRIORITY); // will actually change cgroups.
- if (newNice >= ANDROID_PRIORITY_BACKGROUND) {
- set_sched_policy(tid, SP_BACKGROUND);
- } else if (getpriority(PRIO_PROCESS, tid) >= ANDROID_PRIORITY_BACKGROUND) {
- set_sched_policy(tid, SP_FOREGROUND);
- }
-
- if (setpriority(PRIO_PROCESS, tid, newNice) != 0) {
- PLOG(INFO) << *this << " setPriority(PRIO_PROCESS, " << tid << ", " << newNice << ") failed";
- }
-}
-
-int Thread::GetNativePriority() {
- errno = 0;
- int native_priority = getpriority(PRIO_PROCESS, 0);
- if (native_priority == -1 && errno != 0) {
- PLOG(WARNING) << "getpriority failed";
- return kNormThreadPriority;
- }
-
- int managed_priority = kMinThreadPriority;
- for (size_t i = 0; i < arraysize(kNiceValues); i++) {
- if (native_priority >= kNiceValues[i]) {
- break;
- }
- managed_priority++;
- }
- if (managed_priority > kMaxThreadPriority) {
- managed_priority = kMaxThreadPriority;
- }
- return managed_priority;
-}
-
void Thread::SetUpAlternateSignalStack() {
// Bionic does this for us.
}
diff --git a/runtime/thread_linux.cc b/runtime/thread_linux.cc
index d05fecf..3ed4276 100644
--- a/runtime/thread_linux.cc
+++ b/runtime/thread_linux.cc
@@ -23,14 +23,6 @@
namespace art {
-void Thread::SetNativePriority(int) {
- // Do nothing.
-}
-
-int Thread::GetNativePriority() {
- return kNormThreadPriority;
-}
-
static void SigAltStack(stack_t* new_stack, stack_t* old_stack) {
if (sigaltstack(new_stack, old_stack) == -1) {
PLOG(FATAL) << "sigaltstack failed";
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index 1b3b037..a5406ea 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -683,7 +683,7 @@
AssertThreadsAreSuspended(self, self);
}
}
- ATRACE_BEGIN((std::string("Mutator threads suspended for ") + cause).c_str());
+ ATraceBegin((std::string("Mutator threads suspended for ") + cause).c_str());
if (self != nullptr) {
VLOG(threads) << *self << " SuspendAll complete";
@@ -811,7 +811,7 @@
VLOG(threads) << "Thread[null] ResumeAll starting";
}
- ATRACE_END();
+ ATraceEnd();
ScopedTrace trace("Resuming mutator threads");
@@ -855,8 +855,8 @@
}
bool ThreadList::Resume(Thread* thread, SuspendReason reason) {
- // This assumes there was an ATRACE_BEGIN when we suspended the thread.
- ATRACE_END();
+ // This assumes there was an ATraceBegin when we suspended the thread.
+ ATraceEnd();
Thread* self = Thread::Current();
DCHECK_NE(thread, self);
@@ -987,10 +987,10 @@
// done.
if (thread->IsSuspended()) {
VLOG(threads) << "SuspendThreadByPeer thread suspended: " << *thread;
- if (ATRACE_ENABLED()) {
+ if (ATraceEnabled()) {
std::string name;
thread->GetThreadName(name);
- ATRACE_BEGIN(StringPrintf("SuspendThreadByPeer suspended %s for peer=%p", name.c_str(),
+ ATraceBegin(StringPrintf("SuspendThreadByPeer suspended %s for peer=%p", name.c_str(),
peer).c_str());
}
return thread;
@@ -1097,10 +1097,10 @@
// count, or else we've waited and it has self suspended) or is the current thread, we're
// done.
if (thread->IsSuspended()) {
- if (ATRACE_ENABLED()) {
+ if (ATraceEnabled()) {
std::string name;
thread->GetThreadName(name);
- ATRACE_BEGIN(StringPrintf("SuspendThreadByThreadId suspended %s id=%d",
+ ATraceBegin(StringPrintf("SuspendThreadByThreadId suspended %s id=%d",
name.c_str(), thread_id).c_str());
}
VLOG(threads) << "SuspendThreadByThreadId thread suspended: " << *thread;
diff --git a/tools/dexanalyze/Android.bp b/tools/dexanalyze/Android.bp
index a85bf56..a232a1b 100644
--- a/tools/dexanalyze/Android.bp
+++ b/tools/dexanalyze/Android.bp
@@ -24,11 +24,6 @@
"dexanalyze_experiments.cc",
"dexanalyze_strings.cc",
],
- target: {
- android: {
- shared_libs: ["libcutils"],
- },
- },
header_libs: [
"art_cmdlineparser_headers",
],
diff --git a/tools/tracefast-plugin/Android.bp b/tools/tracefast-plugin/Android.bp
index 1d7dd30..b7ae6c6 100644
--- a/tools/tracefast-plugin/Android.bp
+++ b/tools/tracefast-plugin/Android.bp
@@ -30,11 +30,6 @@
"libbase",
],
target: {
- android: {
- shared_libs: [
- "libcutils",
- ],
- },
darwin: {
enabled: false,
},