diff options
| author | 2019-01-30 12:17:33 +0000 | |
|---|---|---|
| committer | 2019-01-30 12:17:33 +0000 | |
| commit | 5431f79cbb7aaf8de1dc7f0c7826c2d6369ce715 (patch) | |
| tree | ab11b2de94b81644f4f6d4dfa969338e9df051d6 | |
| parent | 151692615e69063e635d345b5a942355dab9da61 (diff) | |
| parent | 4b9d00aca9b025b545c9633b4605334c22fc4d2d (diff) | |
Merge "ART: introduce PALette abstraction layer"
32 files changed, 811 insertions, 176 deletions
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk index 67d85c1a57..bd306b6cd0 100644 --- a/build/Android.gtest.mk +++ b/build/Android.gtest.mk @@ -384,6 +384,7 @@ ART_TEST_MODULES := \ 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 155709aee8..8295a547af 100755 --- a/build/apex/runtests.sh +++ b/build/apex/runtests.sh @@ -147,6 +147,13 @@ function check_library { || 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 { [[ -x "$mount_point/javalib/$1" ]] || fail_check "Cannot find java library '$1' in mounted image" } @@ -173,6 +180,8 @@ function check_release_contents { 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 libopenjdkjvm.so check_library libopenjdkjvmti.so diff --git a/compiler/Android.bp b/compiler/Android.bp index 0d92b05593..0ebaa5f56c 100644 --- a/compiler/Android.bp +++ b/compiler/Android.bp @@ -182,7 +182,6 @@ art_cc_defaults { generated_sources: ["art_compiler_operator_srcs"], shared_libs: [ "libbase", - "libcutils", // for atrace. ], include_dirs: ["art/disassembler"], header_libs: [ @@ -197,7 +196,6 @@ cc_defaults { name: "libart-compiler_static_base_defaults", static_libs: [ "libbase", - "libcutils", ], } @@ -256,9 +254,10 @@ art_cc_library { }, shared_libs: [ "libart", + "libartbase", + "libartpalette", "libprofile", "libdexfile", - "libartbase", ], target: { @@ -317,10 +316,11 @@ art_cc_library { }, }, shared_libs: [ + "libartbased", "libartd", + "libartpalette", "libprofiled", "libdexfiled", - "libartbased", ], } diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp index 6a4a88ecdd..20d41b4d0a 100644 --- a/dex2oat/Android.bp +++ b/dex2oat/Android.bp @@ -64,8 +64,6 @@ art_cc_defaults { target: { android: { - // For atrace. - shared_libs: ["libcutils"], static_libs: [ "libz", ], @@ -93,11 +91,6 @@ art_cc_defaults { 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 5aa8236dd8..838510be37 100644 --- a/dexlayout/Android.bp +++ b/dexlayout/Android.bp @@ -29,16 +29,18 @@ art_cc_defaults { target: { android: { shared_libs: [ - "libdexfile", "libartbase", + "libartpalette", + "libdexfile", "libprofile", "libbase", ], }, not_windows: { shared_libs: [ - "libdexfile", "libartbase", + "libartpalette", + "libdexfile", "libprofile", "libbase", ], @@ -46,8 +48,9 @@ art_cc_defaults { windows: { cflags: ["-Wno-thread-safety"], static_libs: [ - "libdexfile", "libartbase", + "libartpalette", + "libdexfile", "libprofile", "libbase", ], diff --git a/imgdiag/Android.bp b/imgdiag/Android.bp index 972c8f7189..39720a0b86 100644 --- a/imgdiag/Android.bp +++ b/imgdiag/Android.bp @@ -31,9 +31,6 @@ cc_defaults { "libbase", ], target: { - android: { - shared_libs: ["libcutils"], - }, host: { shared_libs: ["libziparchive"], }, diff --git a/libartbase/Android.bp b/libartbase/Android.bp index 509b0728fa..1ca7011723 100644 --- a/libartbase/Android.bp +++ b/libartbase/Android.bp @@ -61,7 +61,7 @@ cc_defaults { shared_libs: [ "liblog", // For ashmem. - "libcutils", + "libartpalette", // For common macros. "libbase", ], @@ -80,7 +80,7 @@ cc_defaults { "libz", "liblog", // For ashmem. - "libcutils", + "libartpalette", // For common macros. "libbase", ], @@ -99,7 +99,7 @@ cc_defaults { "libz", "liblog", // For ashmem. - "libcutils", + "libartpalette", // For common macros. "libbase", ], @@ -128,7 +128,7 @@ cc_defaults { 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 d995dce285..30bba49f11 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 @@ class ScopedTraceNoStart { } ~ScopedTraceNoStart() { - ATRACE_END(); + ATraceEnd(); } // Message helper for the macro. Do not use directly. @@ -63,7 +82,7 @@ class ScopedTraceNoStart { ScopedTraceMessageHelper() { } ~ScopedTraceMessageHelper() { - ATRACE_BEGIN(buffer_.str().c_str()); + ATraceBegin(buffer_.str().c_str()); } std::ostream& stream() { @@ -77,7 +96,7 @@ class ScopedTraceNoStart { #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 0000000000..2fb7748483 --- /dev/null +++ b/libartpalette/Android.bp @@ -0,0 +1,130 @@ +// +// 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 targets supporting dlopen(). +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 abstraction layer on +// platforms supporting dlopen(). It primarily exists for Android. On +// Linux it is used when compiling a shared object as an additional +// check that the loading works as expected. In all other cases, it is +// just the implementation of the abstraction layer. +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"], + shared: { + srcs: ["apex/palette.cc"], + shared_libs: ["liblog"], + }, + static: { + srcs: ["system/palette_fake.cc"], + }, + version_script: "libartpalette.map.txt", + }, + linux_glibc: { + header_libs: ["libbase_headers"], + shared: { + srcs: ["apex/palette.cc"], + shared_libs: ["liblog"], + }, + static: { + srcs: ["system/palette_fake.cc"], + }, + 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, + shared: { + enabled: false, + }, + header_libs: ["libbase_headers"], + srcs: ["system/palette_fake.cc"], + }, + windows: { + enabled: true, + shared: { + enabled: false, + }, + 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 0000000000..8c170572c8 --- /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 0000000000..8bbe0eeffc --- /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 0000000000..1f58403e99 --- /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 0000000000..dc4ec52b96 --- /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 0000000000..837086e19b --- /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 0000000000..09208351cd --- /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 0000000000..1d92b7f821 --- /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) { + managed_priority = art::palette::kNormalManagedThreadPriority; + } + 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 0000000000..0961e77b2b --- /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 0000000000..b28e00d6b8 --- /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 2f56a3d105..f83f18cd2e 100644 --- a/libdexfile/Android.bp +++ b/libdexfile/Android.bp @@ -47,9 +47,8 @@ cc_defaults { shared_libs: [ // For MemMap. "libartbase", + "libartpalette", "liblog", - // For atrace. - "libcutils", // For common macros. "libbase", ], @@ -64,9 +63,8 @@ cc_defaults { "libz", // For MemMap. "libartbase", + "libartpalette", "liblog", - // For atrace. - "libcutils", // For common macros. "libbase", ], @@ -81,9 +79,8 @@ cc_defaults { "libz", // For MemMap. "libartbase", + "libartpalette", "liblog", - // For atrace. - "libcutils", // For common macros. "libbase", ], @@ -102,7 +99,6 @@ cc_defaults { name: "libdexfile_static_base_defaults", static_libs: [ "libbase", - "libcutils", "liblog", "libz", "libziparchive", diff --git a/libprofile/Android.bp b/libprofile/Android.bp index fd32c5fc04..986adce50d 100644 --- a/libprofile/Android.bp +++ b/libprofile/Android.bp @@ -25,10 +25,8 @@ cc_defaults { android: { shared_libs: [ "libartbase", + "libartpalette", "libdexfile", - "libartbase", - // For atrace. - "libcutils", "libbase", ], static_libs: [ @@ -41,10 +39,8 @@ cc_defaults { not_windows: { shared_libs: [ "libartbase", + "libartpalette", "libdexfile", - "libartbase", - // For atrace. - "libcutils", "libziparchive", "libz", "libbase", @@ -55,10 +51,8 @@ cc_defaults { cflags: ["-Wno-thread-safety"], static_libs: [ "libartbase", + "libartpalette", "libdexfile", - "libartbase", - // For atrace. - "libcutils", "libziparchive", "libz", "libbase", @@ -78,7 +72,6 @@ cc_defaults { name: "libprofile_static_base_defaults", static_libs: [ "libbase", - "libcutils", "libz", "libziparchive", ], diff --git a/oatdump/Android.bp b/oatdump/Android.bp index 45f853b06e..8849a7a28d 100644 --- a/oatdump/Android.bp +++ b/oatdump/Android.bp @@ -19,11 +19,6 @@ cc_defaults { 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: [ @@ -102,6 +97,9 @@ art_cc_binary { "libart-disassembler", "libvixl", ], + // We need this to resolve libartpalette symbols + // correctly. Multiple source libraries depend on it. + group_static_libs: true, } art_cc_binary { diff --git a/runtime/Android.bp b/runtime/Android.bp index a3081e9122..a08ba707c9 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -392,14 +392,11 @@ libart_cc_defaults { "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 @@ libart_static_cc_defaults { }, }, 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 5a52818422..7aec661c71 100644 --- a/runtime/base/mutex.cc +++ b/runtime/base/mutex.cc @@ -107,15 +107,15 @@ class ScopedContentionRecorder final : public ValueObject { 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 0a4cddd1ee..bd39192a44 100644 --- a/runtime/base/timing_logger.cc +++ b/runtime/base/timing_logger.cc @@ -144,12 +144,12 @@ void TimingLogger::Reset() { 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 8020f86419..d72003cce6 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -2637,7 +2637,7 @@ collector::GarbageCollector* Heap::Compact(space::ContinuousMemMapAllocSpace* ta } 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 7240357979..6abc8d7f8c 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -280,7 +280,7 @@ void Monitor::SetObject(mirror::Object* object) { // 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 @@ void Monitor::AtraceMonitorLockImpl(Thread* self, mirror::Object* obj, bool is_w (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 @@ void Monitor::Lock(Thread* self) { // 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 @@ void Monitor::Lock(Thread* self) { 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 @@ void Monitor::Lock(Thread* self) { } } 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 309c04e1f2..281e054a01 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 @@ void Thread::ClearAllInterpreterCaches() { 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,16 @@ void Thread::ReleaseLongJumpContextInternal() { delete tlsPtr_.long_jump_context; } +void Thread::SetNativePriority(int new_priority) { + PaletteStatus status = PaletteSchedSetPriority(GetTid(), new_priority); + CHECK(status == PaletteStatus::kOkay || status == PaletteStatus::kCheckErrno); +} + +int Thread::GetNativePriority() { + int priority = 0; + PaletteStatus status = PaletteSchedGetPriority(Thread::Current()->GetTid(), &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 24864f9542..f333400668 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 d05fecf0a9..3ed427677e 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 1b3b037df9..a5406ea66a 100644 --- a/runtime/thread_list.cc +++ b/runtime/thread_list.cc @@ -683,7 +683,7 @@ void ThreadList::SuspendAll(const char* cause, bool long_suspend) { 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 @@ void ThreadList::ResumeAll() { VLOG(threads) << "Thread[null] ResumeAll starting"; } - ATRACE_END(); + ATraceEnd(); ScopedTrace trace("Resuming mutator threads"); @@ -855,8 +855,8 @@ void ThreadList::ResumeAll() { } 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 @@ Thread* ThreadList::SuspendThreadByPeer(jobject peer, // 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 @@ Thread* ThreadList::SuspendThreadByThreadId(uint32_t thread_id, // 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 a85bf562af..a232a1b189 100644 --- a/tools/dexanalyze/Android.bp +++ b/tools/dexanalyze/Android.bp @@ -24,11 +24,6 @@ cc_defaults { "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 1d7dd302c0..b7ae6c6fef 100644 --- a/tools/tracefast-plugin/Android.bp +++ b/tools/tracefast-plugin/Android.bp @@ -30,11 +30,6 @@ cc_defaults { "libbase", ], target: { - android: { - shared_libs: [ - "libcutils", - ], - }, darwin: { enabled: false, }, |