From 0681767fcd0d78aafc6f15a65a04ac893bdcb5c1 Mon Sep 17 00:00:00 2001 From: William Chen Date: Mon, 22 Feb 2021 09:08:10 -0800 Subject: [PATCH 1/3] Update typeSizeTable during cg lowering if new type created for C/C++ --- src/mapleall/maple_be/include/be/becommon.h | 3 + src/mapleall/maple_be/src/be/becommon.cpp | 9 ++ src/mapleall/maple_be/src/be/lower.cpp | 1 + .../art/libartbase/arch/instruction_set.cc | 17 +++- .../art/libartbase/arch/instruction_set.h | 27 ++++-- .../art/libartbase/base/arena_allocator.h | 1 + .../art/libartbase/base/bit_vector.h | 2 +- .../art/libartbase/base/file_magic.cc | 2 +- .../art/libartbase/base/file_utils.cc | 4 +- .../art/libartbase/base/hiddenapi_stubs.h | 17 ++-- .../art/libartbase/base/logging.cc | 1 + .../art/libartbase/base/memfd.cc | 1 + .../art/libartbase/base/os_linux.cc | 3 +- .../art/libartbase/base/safe_copy.cc | 6 +- .../art/libartbase/base/scoped_flock.cc | 1 + .../art/libartbase/base/string_view_cpp20.h | 8 +- .../art/libartbase/base/unix_file/fd_file.cc | 1 + .../art/libartbase/base/utils.cc | 93 ------------------- .../art/libartbase/base/utils.h | 11 ++- .../art/libartpalette/system/palette_fake.cc | 4 +- .../art/libdexfile/dex/compact_dex_file.cc | 2 + .../art/libdexfile/dex/compact_offset_table.h | 4 +- .../art/libdexfile/dex/descriptors_names.cc | 2 + .../art/libdexfile/dex/dex_file-inl.h | 9 +- .../art/libdexfile/dex/dex_file.cc | 2 +- .../art/libdexfile/dex/dex_file.h | 6 +- .../art/libdexfile/dex/dex_file_loader.h | 1 + .../art/libdexfile/dex/dex_file_verifier.cc | 2 +- .../art/libdexfile/dex/signature-inl.h | 6 +- .../art/libdexfile/dex/signature.cc | 6 +- .../art/libdexfile/dex/signature.h | 4 +- .../art/libdexfile/dex/standard_dex_file.cc | 2 + .../include/art_api/dex_file_support.h | 8 +- .../aosp_10.0.0_r35/system/core/base/cmsg.cpp | 6 +- .../core/base/include/android-base/logging.h | 6 +- .../core/base/include/android-base/strings.h | 15 +-- .../system/core/base/logging.cpp | 7 +- .../system/core/base/mapped_file.cpp | 2 +- .../system/core/base/strings.cpp | 14 +-- .../cutils/android_filesystem_config.h | 33 +++++++ .../system/core/include/cutils/fs.h | 8 ++ .../system/core/include/cutils/trace.h | 3 +- .../system/core/include/log/log_id.h | 2 + .../private/android_filesystem_config.h | 33 +++++++ .../system/core/include/utils/Flattenable.h | 7 +- .../system/core/include/utils/String8.h | 3 + .../system/core/liblog/include/log/log_id.h | 2 + .../core/liblog/include_vndk/log/log_id.h | 2 + .../system/core/liblog/liblog.map.txt | 1 + .../core/libutils/include/utils/Flattenable.h | 7 +- .../core/libutils/include/utils/String8.h | 3 + .../system/core/libziparchive/zip_archive.cc | 5 +- .../core/libziparchive/zip_archive_private.h | 2 +- .../system/core/libziparchive/zip_writer.cc | 2 +- 54 files changed, 235 insertions(+), 194 deletions(-) diff --git a/src/mapleall/maple_be/include/be/becommon.h b/src/mapleall/maple_be/include/be/becommon.h index 3179894ace..89092fc5db 100644 --- a/src/mapleall/maple_be/include/be/becommon.h +++ b/src/mapleall/maple_be/include/be/becommon.h @@ -142,6 +142,9 @@ class BECommon { } } + /* Global type table might be updated during lowering for C/C++. */ + void FinalizeTypeTable(); + uint32 GetFieldIdxIncrement(const MIRType &ty) const { if (ty.GetKind() == kTypeClass) { /* number of fields + 2 */ diff --git a/src/mapleall/maple_be/src/be/becommon.cpp b/src/mapleall/maple_be/src/be/becommon.cpp index ba35b57fc3..0badc30dc5 100644 --- a/src/mapleall/maple_be/src/be/becommon.cpp +++ b/src/mapleall/maple_be/src/be/becommon.cpp @@ -635,6 +635,15 @@ MIRType *BECommon::BeGetOrCreateFunctionType(TyIdx tyIdx, const std::vector GetSizeOfTypeSizeTable())) { + for (uint32 i = GetSizeOfTypeSizeTable(); i < GlobalTables::GetTypeTable().GetTypeTableSize(); ++i) { + MIRType *ty = GlobalTables::GetTypeTable().GetTypeFromTyIdx(i); + AddAndComputeSizeAlign(*ty); + } + } +} + BaseNode *BECommon::GetAddressOfNode(const BaseNode &node) { switch (node.GetOpCode()) { case OP_dread: { diff --git a/src/mapleall/maple_be/src/be/lower.cpp b/src/mapleall/maple_be/src/be/lower.cpp index 2aa8bf469c..cdb1b1fcc8 100644 --- a/src/mapleall/maple_be/src/be/lower.cpp +++ b/src/mapleall/maple_be/src/be/lower.cpp @@ -2846,6 +2846,7 @@ void CGLowerer::LowerFunc(MIRFunction &func) { CHECK_FATAL(origBody != nullptr, "origBody should not be nullptr"); BlockNode *newBody = LowerBlock(*origBody); + beCommon.FinalizeTypeTable(); func.SetBody(newBody); if (needBranchCleanup) { CleanupBranches(func); diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/arch/instruction_set.cc b/third_party/aosp_10.0.0_r35/art/libartbase/arch/instruction_set.cc index 8d4fbf4422..0ca55a7213 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/arch/instruction_set.cc +++ b/third_party/aosp_10.0.0_r35/art/libartbase/arch/instruction_set.cc @@ -19,6 +19,7 @@ #include "android-base/logging.h" #include "base/bit_utils.h" #include "base/globals.h" +#include namespace art { @@ -115,11 +116,23 @@ static_assert(IsAligned(kMips64StackOverflowReservedBytes), static_assert(IsAligned(kX86StackOverflowReservedBytes), "X86 gap not page aligned"); static_assert(IsAligned(kX86_64StackOverflowReservedBytes), "X86_64 gap not page aligned"); - +/* +cflags += [ + "-DART_STACK_OVERFLOW_GAP_arm=8192", + "-DART_STACK_OVERFLOW_GAP_arm64=8192", + "-DART_STACK_OVERFLOW_GAP_mips=16384", + "-DART_STACK_OVERFLOW_GAP_mips64=16384", + "-DART_STACK_OVERFLOW_GAP_x86=16384", + "-DART_STACK_OVERFLOW_GAP_x86_64=20480", + "-DART_FRAME_SIZE_LIMIT=7400", + ] + */ +/* #if !defined(ART_FRAME_SIZE_LIMIT) #error "ART frame size limit missing" #endif - +*/ +const uint32_t ART_FRAME_SIZE_LIMIT = 7400; // TODO: Should we require an extra page (RoundUp(SIZE) + kPageSize)? static_assert(ART_FRAME_SIZE_LIMIT < kArmStackOverflowReservedBytes, "Frame size limit too large"); static_assert(ART_FRAME_SIZE_LIMIT < kArm64StackOverflowReservedBytes, diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/arch/instruction_set.h b/third_party/aosp_10.0.0_r35/art/libartbase/arch/instruction_set.h index 7e071bd9e2..f4fe567af5 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/arch/instruction_set.h +++ b/third_party/aosp_10.0.0_r35/art/libartbase/arch/instruction_set.h @@ -227,19 +227,30 @@ constexpr size_t GetBytesPerFprSpillLocation(InstructionSet isa) { } namespace instruction_set_details { - +/* +cflags += [ + "-DART_STACK_OVERFLOW_GAP_arm=8192", + "-DART_STACK_OVERFLOW_GAP_arm64=8192", + "-DART_STACK_OVERFLOW_GAP_mips=16384", + "-DART_STACK_OVERFLOW_GAP_mips64=16384", + "-DART_STACK_OVERFLOW_GAP_x86=16384", + "-DART_STACK_OVERFLOW_GAP_x86_64=20480", + "-DART_FRAME_SIZE_LIMIT=7400", + ] + */ + /* #if !defined(ART_STACK_OVERFLOW_GAP_arm) || !defined(ART_STACK_OVERFLOW_GAP_arm64) || \ !defined(ART_STACK_OVERFLOW_GAP_mips) || !defined(ART_STACK_OVERFLOW_GAP_mips64) || \ !defined(ART_STACK_OVERFLOW_GAP_x86) || !defined(ART_STACK_OVERFLOW_GAP_x86_64) #error "Missing defines for stack overflow gap" #endif - -static constexpr size_t kArmStackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_arm; -static constexpr size_t kArm64StackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_arm64; -static constexpr size_t kMipsStackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_mips; -static constexpr size_t kMips64StackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_mips64; -static constexpr size_t kX86StackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_x86; -static constexpr size_t kX86_64StackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_x86_64; +*/ +static constexpr size_t kArmStackOverflowReservedBytes = 8192; +static constexpr size_t kArm64StackOverflowReservedBytes = 8192; +static constexpr size_t kMipsStackOverflowReservedBytes = 16384; +static constexpr size_t kMips64StackOverflowReservedBytes = 16384; +static constexpr size_t kX86StackOverflowReservedBytes = 16384; +static constexpr size_t kX86_64StackOverflowReservedBytes = 20480; NO_RETURN void GetStackOverflowReservedBytesFailure(const char* error_msg); diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/arena_allocator.h b/third_party/aosp_10.0.0_r35/art/libartbase/base/arena_allocator.h index a9ccae1b07..6b6b8fc109 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/arena_allocator.h +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/arena_allocator.h @@ -25,6 +25,7 @@ #include "dchecked_vector.h" #include "macros.h" #include "memory_tool.h" +#include namespace art { diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/bit_vector.h b/third_party/aosp_10.0.0_r35/art/libartbase/base/bit_vector.h index a930f4e556..6f7a9de623 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/bit_vector.h +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/bit_vector.h @@ -19,7 +19,7 @@ #include #include - +#include #include "bit_utils.h" #include "globals.h" diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/file_magic.cc b/third_party/aosp_10.0.0_r35/art/libartbase/base/file_magic.cc index 1471c59b73..90e0b76396 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/file_magic.cc +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/file_magic.cc @@ -19,7 +19,7 @@ #include #include #include - +#include #include #include diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/file_utils.cc b/third_party/aosp_10.0.0_r35/art/libartbase/base/file_utils.cc index 1216ab0662..a8760b6679 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/file_utils.cc +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/file_utils.cc @@ -40,7 +40,7 @@ #include - +#include #include "android-base/stringprintf.h" #include "android-base/strings.h" @@ -401,7 +401,7 @@ bool RuntimeModuleRootDistinctFromAndroidRoot() { &error_msg); return (android_root != nullptr) && (runtime_root != nullptr) - && (std::string_view(android_root) != std::string_view(runtime_root)); + && (StringView(android_root) != StringView(runtime_root)); } int DupCloexec(int fd) { diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/hiddenapi_stubs.h b/third_party/aosp_10.0.0_r35/art/libartbase/base/hiddenapi_stubs.h index 94ef95c267..361d4d5d69 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/hiddenapi_stubs.h +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/hiddenapi_stubs.h @@ -18,11 +18,16 @@ #define ART_LIBARTBASE_BASE_HIDDENAPI_STUBS_H_ #include -#include +#include "string_view_format.h" namespace art { namespace hiddenapi { +const std::string kPublicApiStr = "public-api"; +const std::string kSystemApiStr = "system-api"; +const std::string kTestApiStr = "test-api"; +const std::string kCorePlatformApiStr = "core-platform-api"; + class ApiStubs { public: enum class Kind { @@ -32,7 +37,7 @@ class ApiStubs { kCorePlatformApi, }; - static const std::string_view ToString(Kind api) { + static std::string ToString(Kind api) { switch (api) { case Kind::kPublicApi: return kPublicApiStr; @@ -45,16 +50,10 @@ class ApiStubs { } } - static bool IsStubsFlag(const std::string_view& api_flag_name) { + static bool IsStubsFlag(const std::string& api_flag_name) { return api_flag_name == kPublicApiStr || api_flag_name == kSystemApiStr || api_flag_name == kTestApiStr || api_flag_name == kCorePlatformApiStr; } - - private: - static constexpr std::string_view kPublicApiStr{"public-api"}; - static constexpr std::string_view kSystemApiStr{"system-api"}; - static constexpr std::string_view kTestApiStr{"test-api"}; - static constexpr std::string_view kCorePlatformApiStr{"core-platform-api"}; }; } // namespace hiddenapi diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/logging.cc b/third_party/aosp_10.0.0_r35/art/libartbase/base/logging.cc index a66a7e3635..ba025666d4 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/logging.cc +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/logging.cc @@ -23,6 +23,7 @@ #include "aborting.h" #include "os.h" #include "unix_file/fd_file.h" +#include // Headers for LogMessage::LogLine. #ifdef ART_TARGET_ANDROID diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/memfd.cc b/third_party/aosp_10.0.0_r35/art/libartbase/base/memfd.cc index 780be328af..ebb35f92bc 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/memfd.cc +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/memfd.cc @@ -25,6 +25,7 @@ #endif #include "macros.h" +#include // When building for linux host, glibc in prebuilts does not include memfd_create system call // number. As a temporary testing measure, we add the definition here. diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/os_linux.cc b/third_party/aosp_10.0.0_r35/art/libartbase/base/os_linux.cc index b25e5e85b3..a00779eb48 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/os_linux.cc +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/os_linux.cc @@ -62,8 +62,7 @@ File* OS::OpenFileWithFlags(const char* name, int flags, bool auto_flush) { CHECK(name != nullptr); bool read_only = ((flags & O_ACCMODE) == O_RDONLY); bool check_usage = !read_only && auto_flush; - std::unique_ptr file( - new File(name, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, check_usage)); + std::unique_ptr file(new File(name, flags, 0666, check_usage)); if (!file->IsOpened()) { return nullptr; } diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/safe_copy.cc b/third_party/aosp_10.0.0_r35/art/libartbase/base/safe_copy.cc index ad75aa7b28..951cb42b02 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/safe_copy.cc +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/safe_copy.cc @@ -56,10 +56,10 @@ ssize_t SafeCopy(void *dst, const void *src, size_t len) { } src_iovs[iovecs_used].iov_base = const_cast(cur); - if (!IsAlignedParam(cur, PAGE_SIZE)) { - src_iovs[iovecs_used].iov_len = AlignUp(cur, PAGE_SIZE) - cur; + if (!IsAlignedParam(cur, sysconf(_SC_PAGE_SIZE))) { + src_iovs[iovecs_used].iov_len = AlignUp(cur, sysconf(_SC_PAGE_SIZE)) - cur; } else { - src_iovs[iovecs_used].iov_len = PAGE_SIZE; + src_iovs[iovecs_used].iov_len = sysconf(_SC_PAGE_SIZE); } src_iovs[iovecs_used].iov_len = std::min(src_iovs[iovecs_used].iov_len, len); diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/scoped_flock.cc b/third_party/aosp_10.0.0_r35/art/libartbase/base/scoped_flock.cc index b16a45aaec..e70208d77c 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/scoped_flock.cc +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/scoped_flock.cc @@ -24,6 +24,7 @@ #include "file_utils.h" #include "unix_file/fd_file.h" +#include namespace art { diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/string_view_cpp20.h b/third_party/aosp_10.0.0_r35/art/libartbase/base/string_view_cpp20.h index 2c11a2f2b8..5ef3137c40 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/string_view_cpp20.h +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/string_view_cpp20.h @@ -17,21 +17,21 @@ #ifndef ART_LIBARTBASE_BASE_STRING_VIEW_CPP20_H_ #define ART_LIBARTBASE_BASE_STRING_VIEW_CPP20_H_ -#include +#include "string_view_format.h" namespace art { -// Replacement functions for std::string_view::starts_with(), ends_with() +// Replacement functions for StringView::starts_with(), ends_with() // which shall be available in C++20. #if __cplusplus >= 202000L #error "When upgrading to C++20, remove this error and file a bug to remove this workaround." #endif -inline bool StartsWith(std::string_view sv, std::string_view prefix) { +inline bool StartsWith(StringView sv, StringView prefix) { return sv.substr(0u, prefix.size()) == prefix; } -inline bool EndsWith(std::string_view sv, std::string_view suffix) { +inline bool EndsWith(StringView sv, StringView suffix) { return sv.size() >= suffix.size() && sv.substr(sv.size() - suffix.size()) == suffix; } diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/unix_file/fd_file.cc b/third_party/aosp_10.0.0_r35/art/libartbase/base/unix_file/fd_file.cc index 8831b9c6b7..d8127a9553 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/unix_file/fd_file.cc +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/unix_file/fd_file.cc @@ -20,6 +20,7 @@ #include #include #include +#include #if defined(__BIONIC__) #include diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/utils.cc b/third_party/aosp_10.0.0_r35/art/libartbase/base/utils.cc index 5af80f4396..30423a47a7 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/utils.cc +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/utils.cc @@ -29,7 +29,6 @@ #include "android-base/stringprintf.h" #include "android-base/strings.h" -#include "bit_utils.h" #include "os.h" #if defined(__APPLE__) @@ -63,98 +62,6 @@ namespace art { using android::base::ReadFileToString; using android::base::StringPrintf; -#if defined(__arm__) - -namespace { - -// Bitmap of caches to flush for cacheflush(2). Must be zero for ARM. -static constexpr int kCacheFlushFlags = 0x0; - -// Number of retry attempts when flushing cache ranges. -static constexpr size_t kMaxFlushAttempts = 4; - -int CacheFlush(uintptr_t start, uintptr_t limit) { - // The signature of cacheflush(2) seems to vary by source. On ARM the system call wrapper - // (bionic/SYSCALLS.TXT) has the form: int cacheflush(long start, long end, long flags); - int r = cacheflush(start, limit, kCacheFlushFlags); - if (r == -1) { - CHECK_NE(errno, EINVAL); - } - return r; -} - -bool TouchAndFlushCacheLinesWithinPage(uintptr_t start, uintptr_t limit, size_t attempts) { - CHECK_LT(start, limit); - CHECK_EQ(RoundDown(start, kPageSize), RoundDown(limit - 1, kPageSize)) << "range spans pages"; - // Declare a volatile variable so the compiler does not elide reads from the page being touched. - volatile uint8_t v = 0; - for (size_t i = 0; i < attempts; ++i) { - // Touch page to maximize chance page is resident. - v = *reinterpret_cast(start); - - if (LIKELY(CacheFlush(start, limit) == 0)) { - return true; - } - } - return false; -} - -} // namespace - -bool FlushCpuCaches(void* begin, void* end) { - // This method is specialized for ARM as the generic implementation below uses the - // __builtin___clear_cache() intrinsic which is declared as void. On ARMv7 flushing the CPU - // caches is a privileged operation. The Linux kernel allows these operations to fail when they - // trigger a fault (e.g. page not resident). We use a wrapper for the ARM specific cacheflush() - // system call to detect the failure and potential erroneous state of the data and instruction - // caches. - // - // The Android bug for this is b/132205399 and there's a similar discussion on - // https://reviews.llvm.org/D37788. This is primarily an issue for the dual view JIT where the - // pages where code is executed are only ever RX and never RWX. When attempting to invalidate - // instruction cache lines in the RX mapping after writing fresh code in the RW mapping, the - // page may not be resident (due to memory pressure), and this means that a fault is raised in - // the midst of a cacheflush() call and the instruction cache lines are not invalidated and so - // have stale code. - // - // Other architectures fair better for reasons such as: - // - // (1) stronger coherence between the data and instruction caches. - // - // (2) fault handling that allows flushing/invalidation to continue after - // a missing page has been faulted in. - - // In the common case, this flush of the complete range succeeds. - uintptr_t start = reinterpret_cast(begin); - const uintptr_t limit = reinterpret_cast(end); - if (LIKELY(CacheFlush(start, limit) == 0)) { - return true; - } - - // A rare failure has occurred implying that part of the range (begin, end] has been swapped - // out. Retry flushing but this time grouping cache-line flushes on individual pages and - // touching each page before flushing. - uintptr_t next_page = RoundUp(start + 1, kPageSize); - while (start < limit) { - uintptr_t boundary = std::min(next_page, limit); - if (!TouchAndFlushCacheLinesWithinPage(start, boundary, kMaxFlushAttempts)) { - return false; - } - start = boundary; - next_page += kPageSize; - } - return true; -} - -#else - -bool FlushCpuCaches(void* begin, void* end) { - __builtin___clear_cache(reinterpret_cast(begin), reinterpret_cast(end)); - return true; -} - -#endif - pid_t GetTid() { #if defined(__APPLE__) uint64_t owner; diff --git a/third_party/aosp_10.0.0_r35/art/libartbase/base/utils.h b/third_party/aosp_10.0.0_r35/art/libartbase/base/utils.h index f434cb40db..9284950c1a 100644 --- a/third_party/aosp_10.0.0_r35/art/libartbase/base/utils.h +++ b/third_party/aosp_10.0.0_r35/art/libartbase/base/utils.h @@ -113,8 +113,15 @@ static T GetRandomNumber(T min, T max) { // Sleep forever and never come back. NO_RETURN void SleepForever(); -// Flush CPU caches. Returns true on success, false if flush failed. -WARN_UNUSED bool FlushCpuCaches(void* begin, void* end); +inline void FlushDataCache(void* begin, void* end) { + __builtin___clear_cache(reinterpret_cast(begin), reinterpret_cast(end)); +} + +inline void FlushInstructionCache(void* begin, void* end) { + // Same as FlushInstructionCache for lack of other builtin. __builtin___clear_cache + // flushes both caches. + __builtin___clear_cache(reinterpret_cast(begin), reinterpret_cast(end)); +} template constexpr PointerSize ConvertToPointerSize(T any) { diff --git a/third_party/aosp_10.0.0_r35/art/libartpalette/system/palette_fake.cc b/third_party/aosp_10.0.0_r35/art/libartpalette/system/palette_fake.cc index 4cc00d0419..1edd1423e7 100644 --- a/third_party/aosp_10.0.0_r35/art/libartpalette/system/palette_fake.cc +++ b/third_party/aosp_10.0.0_r35/art/libartpalette/system/palette_fake.cc @@ -21,7 +21,7 @@ #include #include // For ATTRIBUTE_UNUSED - +#include "string_view_format.h" #include "palette_system.h" enum PaletteStatus PaletteGetVersion(int32_t* version) { @@ -54,7 +54,7 @@ enum PaletteStatus PaletteSchedGetPriority(int32_t tid, } enum PaletteStatus PaletteWriteCrashThreadStacks(/*in*/ const char* stacks, size_t stacks_len) { - LOG(INFO) << std::string_view(stacks, stacks_len); + LOG(INFO) << StringView(stacks, stacks_len); return PaletteStatus::kOkay; } diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/compact_dex_file.cc b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/compact_dex_file.cc index a5044aad7e..24cef30a11 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/compact_dex_file.cc +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/compact_dex_file.cc @@ -19,6 +19,8 @@ #include "base/leb128.h" #include "code_item_accessors-inl.h" #include "dex_file-inl.h" +#include +#include namespace art { diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/compact_offset_table.h b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/compact_offset_table.h index ec759e200d..e651363f3b 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/compact_offset_table.h +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/compact_offset_table.h @@ -28,7 +28,7 @@ class CompactOffsetTable { public: // This value is coupled with the leb chunk bitmask. That logic must also be adjusted when the // integer is modified. - static constexpr size_t kElementsPerIndex = 16; + static constexpr std::size_t kElementsPerIndex = 16; // Leb block format: // [uint16_t] 16 bit mask for what indexes actually have a non zero offset for the chunk. @@ -61,7 +61,7 @@ class CompactOffsetTable { uint32_t* out_table_offset); // 32 bit aligned for the offset table. - static constexpr size_t kAlignment = sizeof(uint32_t); + static constexpr std::size_t kAlignment = sizeof(uint32_t); }; } // namespace art diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/descriptors_names.cc b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/descriptors_names.cc index 1e8eb3349b..1fa5fd1fc8 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/descriptors_names.cc +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/descriptors_names.cc @@ -21,6 +21,8 @@ #include "base/macros.h" #include "dex/utf-inl.h" +#include +#include namespace art { diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file-inl.h b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file-inl.h index 0c3f949b91..3b794805c7 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file-inl.h +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file-inl.h @@ -28,14 +28,15 @@ #include "dex_instruction_iterator.h" #include "invoke_type.h" #include "standard_dex_file.h" +#include "string_view_format.h" namespace art { -inline std::string_view StringViewFromUtf16Length(const char* utf8_data, size_t utf16_length) { +inline StringView StringViewFromUtf16Length(const char* utf8_data, size_t utf16_length) { size_t utf8_length = LIKELY(utf8_data[utf16_length] == 0) // Is ASCII? ? utf16_length : utf16_length + strlen(utf8_data + utf16_length); - return std::string_view(utf8_data, utf8_length); + return StringView(utf8_data, utf8_length); } inline int32_t DexFile::GetStringLength(const dex::StringId& string_id) const { @@ -71,10 +72,10 @@ inline const char* DexFile::StringDataByIdx(dex::StringIndex idx) const { return StringDataAndUtf16LengthByIdx(idx, &unicode_length); } -inline std::string_view DexFile::StringViewByIdx(dex::StringIndex idx) const { +inline StringView DexFile::StringViewByIdx(dex::StringIndex idx) const { uint32_t unicode_length; const char* data = StringDataAndUtf16LengthByIdx(idx, &unicode_length); - return data != nullptr ? StringViewFromUtf16Length(data, unicode_length) : std::string_view(""); + return data != nullptr ? StringViewFromUtf16Length(data, unicode_length) : StringView(""); } inline const char* DexFile::StringByTypeIdx(dex::TypeIndex idx, uint32_t* unicode_length) const { diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file.cc b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file.cc index 7db4de0223..de96e55132 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file.cc +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file.cc @@ -400,7 +400,7 @@ const ProtoId* DexFile::FindProtoId(dex::TypeIndex return_type_idx, } // Given a signature place the type ids into the given vector -bool DexFile::CreateTypeList(std::string_view signature, +bool DexFile::CreateTypeList(StringView signature, dex::TypeIndex* return_type_idx, std::vector* param_type_idxs) const { if (signature[0] != '(') { diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file.h b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file.h index b892d82426..cf99b65c92 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file.h +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file.h @@ -19,7 +19,7 @@ #include #include -#include +#include "string_view_format.h" #include #include @@ -262,7 +262,7 @@ class DexFile { const char* StringDataAndUtf16LengthByIdx(dex::StringIndex idx, uint32_t* utf16_length) const; const char* StringDataByIdx(dex::StringIndex idx) const; - std::string_view StringViewByIdx(dex::StringIndex idx) const; + StringView StringViewByIdx(dex::StringIndex idx) const; // Looks up a string id for a given modified utf8 string. const dex::StringId* FindStringId(const char* string) const; @@ -480,7 +480,7 @@ class DexFile { } // Given a signature place the type ids into the given vector, returns true on success - bool CreateTypeList(std::string_view signature, + bool CreateTypeList(StringView signature, dex::TypeIndex* return_type_idx, std::vector* param_type_idxs) const; diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file_loader.h b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file_loader.h index 49e177fce6..23315ad5c0 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file_loader.h +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file_loader.h @@ -19,6 +19,7 @@ #include #include +#include #include #include diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file_verifier.cc b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file_verifier.cc index 86a28e5a3e..7e59e3e590 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file_verifier.cc +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/dex_file_verifier.cc @@ -17,7 +17,7 @@ #include "dex_file_verifier.h" #include - +#include #include #include "android-base/stringprintf.h" diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature-inl.h b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature-inl.h index 12ad1b303f..c6dbe90d0b 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature-inl.h +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature-inl.h @@ -36,13 +36,13 @@ inline bool Signature::operator==(const Signature& rhs) const { uint32_t lhs_shorty_len; // For a shorty utf16 length == mutf8 length. const char* lhs_shorty_data = dex_file_->StringDataAndUtf16LengthByIdx(proto_id_->shorty_idx_, &lhs_shorty_len); - std::string_view lhs_shorty(lhs_shorty_data, lhs_shorty_len); + StringView lhs_shorty(lhs_shorty_data, lhs_shorty_len); { uint32_t rhs_shorty_len; const char* rhs_shorty_data = rhs.dex_file_->StringDataAndUtf16LengthByIdx(rhs.proto_id_->shorty_idx_, &rhs_shorty_len); - std::string_view rhs_shorty(rhs_shorty_data, rhs_shorty_len); + StringView rhs_shorty(rhs_shorty_data, rhs_shorty_len); if (lhs_shorty != rhs_shorty) { return false; // Shorty mismatch. } @@ -56,7 +56,7 @@ inline bool Signature::operator==(const Signature& rhs) const { return false; // Return type mismatch. } } - if (lhs_shorty.find('L', 1) != std::string_view::npos) { + if (lhs_shorty.find('L', 1) != StringView::npos) { const dex::TypeList* params = dex_file_->GetProtoParameters(*proto_id_); const dex::TypeList* rhs_params = rhs.dex_file_->GetProtoParameters(*rhs.proto_id_); // We found a reference parameter in the matching shorty, so both lists must be non-empty. diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature.cc b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature.cc index ac004286f2..b7456fd9cb 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature.cc +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature.cc @@ -57,11 +57,11 @@ bool Signature::IsVoid() const { return strcmp(return_type, "V") == 0; } -bool Signature::operator==(std::string_view rhs) const { +bool Signature::operator==(StringView rhs) const { if (dex_file_ == nullptr) { return false; } - std::string_view tail(rhs); + StringView tail(rhs); if (!StartsWith(tail, "(")) { return false; // Invalid signature } @@ -69,7 +69,7 @@ bool Signature::operator==(std::string_view rhs) const { const TypeList* params = dex_file_->GetProtoParameters(*proto_id_); if (params != nullptr) { for (uint32_t i = 0; i < params->Size(); ++i) { - std::string_view param(dex_file_->StringByTypeIdx(params->GetTypeItem(i).type_idx_)); + StringView param(dex_file_->StringByTypeIdx(params->GetTypeItem(i).type_idx_)); if (!StartsWith(tail, param)) { return false; } diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature.h b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature.h index 3fbb543d38..26d0a5c9da 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature.h +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/signature.h @@ -19,7 +19,7 @@ #include #include -#include +#include "string_view_format.h" #include @@ -49,7 +49,7 @@ class Signature : public ValueObject { return !(*this == rhs); } - bool operator==(std::string_view rhs) const; + bool operator==(StringView rhs) const; private: Signature(const DexFile* dex, const dex::ProtoId& proto) : dex_file_(dex), proto_id_(&proto) { diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/standard_dex_file.cc b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/standard_dex_file.cc index 8bac44e02e..ac9d548a6e 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/dex/standard_dex_file.cc +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/dex/standard_dex_file.cc @@ -20,6 +20,8 @@ #include "base/leb128.h" #include "code_item_accessors-inl.h" #include "dex_file-inl.h" +#include +#include namespace art { diff --git a/third_party/aosp_10.0.0_r35/art/libdexfile/external/include/art_api/dex_file_support.h b/third_party/aosp_10.0.0_r35/art/libdexfile/external/include/art_api/dex_file_support.h index a98ff0e294..be1fa6e51e 100644 --- a/third_party/aosp_10.0.0_r35/art/libdexfile/external/include/art_api/dex_file_support.h +++ b/third_party/aosp_10.0.0_r35/art/libdexfile/external/include/art_api/dex_file_support.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include "string_view_format.h" #include #include @@ -46,7 +46,7 @@ class DexString final { } explicit DexString(const char* str = "") : ext_string_(MakeExtDexFileString(str, std::strlen(str))) {} - explicit DexString(std::string_view str) + explicit DexString(StringView str) : ext_string_(MakeExtDexFileString(str.data(), str.size())) {} ~DexString() { g_ExtDexFileFreeString(ext_string_); } @@ -68,10 +68,10 @@ class DexString final { } size_t length() const { return size(); } - operator std::string_view() const { + operator StringView() const { size_t len; const char* chars = g_ExtDexFileGetString(ext_string_, &len); - return std::string_view(chars, len); + return StringView(chars, len); } private: diff --git a/third_party/aosp_10.0.0_r35/system/core/base/cmsg.cpp b/third_party/aosp_10.0.0_r35/system/core/base/cmsg.cpp index 42866f8f2b..47c28efd62 100644 --- a/third_party/aosp_10.0.0_r35/system/core/base/cmsg.cpp +++ b/third_party/aosp_10.0.0_r35/system/core/base/cmsg.cpp @@ -21,7 +21,7 @@ #include #include #include - +#include #include #include @@ -33,7 +33,7 @@ ssize_t SendFileDescriptorVector(int sockfd, const void* data, size_t len, const std::vector& fds) { size_t cmsg_space = CMSG_SPACE(sizeof(int) * fds.size()); size_t cmsg_len = CMSG_LEN(sizeof(int) * fds.size()); - if (cmsg_space >= PAGE_SIZE) { + if (cmsg_space >= sysconf(_SC_PAGE_SIZE)) { errno = ENOMEM; return -1; } @@ -75,7 +75,7 @@ ssize_t ReceiveFileDescriptorVector(int sockfd, void* data, size_t len, size_t m fds->clear(); size_t cmsg_space = CMSG_SPACE(sizeof(int) * max_fds); - if (cmsg_space >= PAGE_SIZE) { + if (cmsg_space >= sysconf(_SC_PAGE_SIZE)) { errno = ENOMEM; return -1; } diff --git a/third_party/aosp_10.0.0_r35/system/core/base/include/android-base/logging.h b/third_party/aosp_10.0.0_r35/system/core/base/include/android-base/logging.h index f94cc258e9..87337aec90 100644 --- a/third_party/aosp_10.0.0_r35/system/core/base/include/android-base/logging.h +++ b/third_party/aosp_10.0.0_r35/system/core/base/include/android-base/logging.h @@ -81,7 +81,7 @@ namespace base { enum LogSeverity { VERBOSE, - DEBUG, + DEBUG_S, INFO, WARNING, ERROR, @@ -181,7 +181,7 @@ class ErrnoRestorer { // Note: DO NOT USE DIRECTLY. This is an implementation detail. #define SEVERITY_LAMBDA(severity) ([&]() { \ using ::android::base::VERBOSE; \ - using ::android::base::DEBUG; \ + using ::android::base::DEBUG_S; \ using ::android::base::INFO; \ using ::android::base::WARNING; \ using ::android::base::ERROR; \ @@ -248,7 +248,7 @@ struct LogAbortAfterFullExpr { // Logs a message to logcat with the specified log ID on Android otherwise to // stderr. If the severity is FATAL it also causes an abort. // Use an expression here so we can support the << operator following the macro, -// like "LOG(DEBUG) << xxx;". +// like "LOG(DEBUG_S) << xxx;". #define LOG_TO(dest, severity) LOGGING_PREAMBLE(severity) && LOG_STREAM_TO(dest, severity) // A variant of LOG that also logs the current errno value. To be used when diff --git a/third_party/aosp_10.0.0_r35/system/core/base/include/android-base/strings.h b/third_party/aosp_10.0.0_r35/system/core/base/include/android-base/strings.h index 8e9716f9fe..8feb308c56 100644 --- a/third_party/aosp_10.0.0_r35/system/core/base/include/android-base/strings.h +++ b/third_party/aosp_10.0.0_r35/system/core/base/include/android-base/strings.h @@ -19,6 +19,7 @@ #include #include #include +#include "string_view_format.h" namespace android { namespace base { @@ -56,17 +57,17 @@ extern template std::string Join(const std::vector&, const std::str extern template std::string Join(const std::vector&, const std::string&); // Tests whether 's' starts with 'prefix'. -bool StartsWith(std::string_view s, std::string_view prefix); -bool StartsWith(std::string_view s, char prefix); -bool StartsWithIgnoreCase(std::string_view s, std::string_view prefix); +bool StartsWith(StringView s, StringView prefix); +bool StartsWith(StringView s, char prefix); +bool StartsWithIgnoreCase(StringView s, StringView prefix); // Tests whether 's' ends with 'suffix'. -bool EndsWith(std::string_view s, std::string_view suffix); -bool EndsWith(std::string_view s, char suffix); -bool EndsWithIgnoreCase(std::string_view s, std::string_view suffix); +bool EndsWith(StringView s, StringView suffix); +bool EndsWith(StringView s, char suffix); +bool EndsWithIgnoreCase(StringView s, StringView suffix); // Tests whether 'lhs' equals 'rhs', ignoring case. -bool EqualsIgnoreCase(std::string_view lhs, std::string_view rhs); +bool EqualsIgnoreCase(StringView lhs, StringView rhs); } // namespace base } // namespace android diff --git a/third_party/aosp_10.0.0_r35/system/core/base/logging.cpp b/third_party/aosp_10.0.0_r35/system/core/base/logging.cpp index f89168c0fc..4f0d37b2d3 100644 --- a/third_party/aosp_10.0.0_r35/system/core/base/logging.cpp +++ b/third_party/aosp_10.0.0_r35/system/core/base/logging.cpp @@ -16,10 +16,11 @@ #if defined(_WIN32) #include +#include "android-base/threads.h" #endif #include "android-base/logging.h" - +#include #include #include #include @@ -167,7 +168,7 @@ void KernelLogger(android::base::LogId, android::base::LogSeverity severity, static constexpr int kLogSeverityToKernelLogLevel[] = { [android::base::VERBOSE] = 7, // KERN_DEBUG (there is no verbose kernel log // level) - [android::base::DEBUG] = 7, // KERN_DEBUG + [android::base::DEBUG_S] = 7, // KERN_DEBUG_S [android::base::INFO] = 6, // KERN_INFO [android::base::WARNING] = 4, // KERN_WARNING [android::base::ERROR] = 3, // KERN_ERROR @@ -310,7 +311,7 @@ void InitLogging(char* argv[], LogFunction&& logger, AbortFunction&& aborter) { gMinimumLogSeverity = VERBOSE; continue; case 'd': - gMinimumLogSeverity = DEBUG; + gMinimumLogSeverity = DEBUG_S; continue; case 'i': gMinimumLogSeverity = INFO; diff --git a/third_party/aosp_10.0.0_r35/system/core/base/mapped_file.cpp b/third_party/aosp_10.0.0_r35/system/core/base/mapped_file.cpp index d26e8ba915..7c65dc3c5b 100644 --- a/third_party/aosp_10.0.0_r35/system/core/base/mapped_file.cpp +++ b/third_party/aosp_10.0.0_r35/system/core/base/mapped_file.cpp @@ -76,7 +76,7 @@ MappedFile::~MappedFile() { if (base_ != nullptr) UnmapViewOfFile(base_); if (handle_ != nullptr) CloseHandle(handle_); #else - if (base_ != nullptr) munmap(base_, size_ + offset_); + if (base_ != nullptr) munmap(base_, size_); #endif base_ = nullptr; diff --git a/third_party/aosp_10.0.0_r35/system/core/base/strings.cpp b/third_party/aosp_10.0.0_r35/system/core/base/strings.cpp index bb3167ef0a..284d4db5f1 100644 --- a/third_party/aosp_10.0.0_r35/system/core/base/strings.cpp +++ b/third_party/aosp_10.0.0_r35/system/core/base/strings.cpp @@ -87,32 +87,32 @@ template std::string Join(const std::vector&, char); template std::string Join(const std::vector&, const std::string&); template std::string Join(const std::vector&, const std::string&); -bool StartsWith(std::string_view s, std::string_view prefix) { +bool StartsWith(StringView s, StringView prefix) { return s.substr(0, prefix.size()) == prefix; } -bool StartsWith(std::string_view s, char prefix) { +bool StartsWith(StringView s, char prefix) { return !s.empty() && s.front() == prefix; } -bool StartsWithIgnoreCase(std::string_view s, std::string_view prefix) { +bool StartsWithIgnoreCase(StringView s, StringView prefix) { return s.size() >= prefix.size() && strncasecmp(s.data(), prefix.data(), prefix.size()) == 0; } -bool EndsWith(std::string_view s, std::string_view suffix) { +bool EndsWith(StringView s, StringView suffix) { return s.size() >= suffix.size() && s.substr(s.size() - suffix.size(), suffix.size()) == suffix; } -bool EndsWith(std::string_view s, char suffix) { +bool EndsWith(StringView s, char suffix) { return !s.empty() && s.back() == suffix; } -bool EndsWithIgnoreCase(std::string_view s, std::string_view suffix) { +bool EndsWithIgnoreCase(StringView s, StringView suffix) { return s.size() >= suffix.size() && strncasecmp(s.data() + (s.size() - suffix.size()), suffix.data(), suffix.size()) == 0; } -bool EqualsIgnoreCase(std::string_view lhs, std::string_view rhs) { +bool EqualsIgnoreCase(StringView lhs, StringView rhs) { return lhs.size() == rhs.size() && strncasecmp(lhs.data(), rhs.data(), lhs.size()) == 0; } diff --git a/third_party/aosp_10.0.0_r35/system/core/include/cutils/android_filesystem_config.h b/third_party/aosp_10.0.0_r35/system/core/include/cutils/android_filesystem_config.h index 63c3793fd9..9a13e03825 100644 --- a/third_party/aosp_10.0.0_r35/system/core/include/cutils/android_filesystem_config.h +++ b/third_party/aosp_10.0.0_r35/system/core/include/cutils/android_filesystem_config.h @@ -144,6 +144,7 @@ /* The range 2900-2999 is reserved for OEM, and must never be * used here */ #define AID_OEM_RESERVED_START 2900 +#define AID_HDB 2901 /* access hdbservice */ #define AID_OEM_RESERVED_END 2999 /* The 3000 series are intended for use as supplemental group id's only. @@ -161,6 +162,38 @@ /* The range 5000-5999 is also reserved for OEM, and must never be used here. */ #define AID_OEM_RESERVED_2_START 5000 + +/* Huawei Extend AID */ +/* + * 1. ALL huawei extend AID should add VENDOR prefix,e.g. AID_VENDOR_XXXX + * 2. If the added AID was used in vendor partition only, Add it to config.fs + * vendor/huawei/chipset_common/config/common/config.fs + * 3. Huawei AID range: + * AID used in system partition: 5501-5900 + * AID used in vendor partiton only: 5900-5999 + * 4. wiki: http://3ms.huawei.com/hi/group/2844405/wiki_5160709.html?for_statistic_from=creation_group_wiki +*/ + +#define AID_VENDOR_HDB 5501 /* access hdbservice*/ + +#define AID_VENDOR_DSM 5502 /* dsm access */ + +#define AID_VENDOR_HWHFD 5503 /* Huawei kernel hot fix daemon */ + +#define AID_VENDOR_SKYTONE 5504 /* access skytone */ + +#define AID_VENDOR_ACT_RCS 5505 /* access device actr */ + +#define AID_VENDOR_ODMF 5506 /* access AI model files */ + +#define AID_VENDOR_INSTALLER 5507 /* access installer files */ + +#define AID_VENDOR_HBS 5508 /* access hbs data */ + +#define AID_DSM 5509 /* dsm access */ + +#define AID_VENDOR_FACEID 5510 /* acess faceid */ + #define AID_OEM_RESERVED_2_END 5999 #define AID_EVERYBODY 9997 /* shared between all apps in the same profile */ diff --git a/third_party/aosp_10.0.0_r35/system/core/include/cutils/fs.h b/third_party/aosp_10.0.0_r35/system/core/include/cutils/fs.h index a34ce86022..0d5916117b 100644 --- a/third_party/aosp_10.0.0_r35/system/core/include/cutils/fs.h +++ b/third_party/aosp_10.0.0_r35/system/core/include/cutils/fs.h @@ -45,6 +45,14 @@ extern "C" { */ extern int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid); +/* DTS2016051401335 AR000485VM FixUid l00214442 20160514 begin */ +/* + * Ensure that directory exists with given mode and owners. If it exists + * with a different mode or owners, they are fixed to match the given values recursively. + */ +extern int fs_prepare_dir_fixup_recursive(const char* path, mode_t mode, uid_t uid, gid_t gid, int allow_fixup); +/* DTS2016051401335 AR000485VM FixUid l00214442 20160514 end */ + /* * Ensure that directory exists with given mode and owners. If it exists * with different owners, they are not fixed and -1 is returned. diff --git a/third_party/aosp_10.0.0_r35/system/core/include/cutils/trace.h b/third_party/aosp_10.0.0_r35/system/core/include/cutils/trace.h index 79b4b355b9..195f678e89 100644 --- a/third_party/aosp_10.0.0_r35/system/core/include/cutils/trace.h +++ b/third_party/aosp_10.0.0_r35/system/core/include/cutils/trace.h @@ -18,7 +18,6 @@ #define _LIBS_CUTILS_TRACE_H #include -#include #include #include #include @@ -88,7 +87,7 @@ __BEGIN_DECLS #elif ATRACE_TAG > ATRACE_TAG_VALID_MASK #error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h #endif - +using namespace std; /** * Opens the trace file for writing and reads the property for initial tags. * The atrace.tags.enableflags property sets the tags to trace. diff --git a/third_party/aosp_10.0.0_r35/system/core/include/log/log_id.h b/third_party/aosp_10.0.0_r35/system/core/include/log/log_id.h index c052a503c0..70ebd1f384 100644 --- a/third_party/aosp_10.0.0_r35/system/core/include/log/log_id.h +++ b/third_party/aosp_10.0.0_r35/system/core/include/log/log_id.h @@ -58,6 +58,8 @@ int __android_log_buf_print(int bufID, int prio, const char* tag, log_id_t android_name_to_log_id(const char* logName); const char* android_log_id_to_name(log_id_t log_id); +int __hwlog_setparam(int paramid, const char *val); + #ifdef __cplusplus } #endif diff --git a/third_party/aosp_10.0.0_r35/system/core/include/private/android_filesystem_config.h b/third_party/aosp_10.0.0_r35/system/core/include/private/android_filesystem_config.h index 63c3793fd9..9a13e03825 100644 --- a/third_party/aosp_10.0.0_r35/system/core/include/private/android_filesystem_config.h +++ b/third_party/aosp_10.0.0_r35/system/core/include/private/android_filesystem_config.h @@ -144,6 +144,7 @@ /* The range 2900-2999 is reserved for OEM, and must never be * used here */ #define AID_OEM_RESERVED_START 2900 +#define AID_HDB 2901 /* access hdbservice */ #define AID_OEM_RESERVED_END 2999 /* The 3000 series are intended for use as supplemental group id's only. @@ -161,6 +162,38 @@ /* The range 5000-5999 is also reserved for OEM, and must never be used here. */ #define AID_OEM_RESERVED_2_START 5000 + +/* Huawei Extend AID */ +/* + * 1. ALL huawei extend AID should add VENDOR prefix,e.g. AID_VENDOR_XXXX + * 2. If the added AID was used in vendor partition only, Add it to config.fs + * vendor/huawei/chipset_common/config/common/config.fs + * 3. Huawei AID range: + * AID used in system partition: 5501-5900 + * AID used in vendor partiton only: 5900-5999 + * 4. wiki: http://3ms.huawei.com/hi/group/2844405/wiki_5160709.html?for_statistic_from=creation_group_wiki +*/ + +#define AID_VENDOR_HDB 5501 /* access hdbservice*/ + +#define AID_VENDOR_DSM 5502 /* dsm access */ + +#define AID_VENDOR_HWHFD 5503 /* Huawei kernel hot fix daemon */ + +#define AID_VENDOR_SKYTONE 5504 /* access skytone */ + +#define AID_VENDOR_ACT_RCS 5505 /* access device actr */ + +#define AID_VENDOR_ODMF 5506 /* access AI model files */ + +#define AID_VENDOR_INSTALLER 5507 /* access installer files */ + +#define AID_VENDOR_HBS 5508 /* access hbs data */ + +#define AID_DSM 5509 /* dsm access */ + +#define AID_VENDOR_FACEID 5510 /* acess faceid */ + #define AID_OEM_RESERVED_2_END 5999 #define AID_EVERYBODY 9997 /* shared between all apps in the same profile */ diff --git a/third_party/aosp_10.0.0_r35/system/core/include/utils/Flattenable.h b/third_party/aosp_10.0.0_r35/system/core/include/utils/Flattenable.h index 2c4b8075d2..9d006023d5 100644 --- a/third_party/aosp_10.0.0_r35/system/core/include/utils/Flattenable.h +++ b/third_party/aosp_10.0.0_r35/system/core/include/utils/Flattenable.h @@ -47,12 +47,7 @@ public: template static size_t align(void*& buffer) { - static_assert(!(N & (N - 1)), "Can only align to a power of 2."); - void* b = buffer; - buffer = reinterpret_cast((uintptr_t(buffer) + (N-1)) & ~(N-1)); - size_t delta = size_t(uintptr_t(buffer) - uintptr_t(b)); - memset(b, 0, delta); - return delta; + return align( const_cast(buffer) ); } static void advance(void*& buffer, size_t& size, size_t offset) { diff --git a/third_party/aosp_10.0.0_r35/system/core/include/utils/String8.h b/third_party/aosp_10.0.0_r35/system/core/include/utils/String8.h index c8f584e306..9043686bce 100644 --- a/third_party/aosp_10.0.0_r35/system/core/include/utils/String8.h +++ b/third_party/aosp_10.0.0_r35/system/core/include/utils/String8.h @@ -58,6 +58,9 @@ public: explicit String8(const char16_t* o, size_t numChars); explicit String8(const char32_t* o); explicit String8(const char32_t* o, size_t numChars); + //fix bug of sogou input method + explicit String8(unsigned short const* o); + //fix bug of sogou input method ~String8(); static inline const String8 empty(); diff --git a/third_party/aosp_10.0.0_r35/system/core/liblog/include/log/log_id.h b/third_party/aosp_10.0.0_r35/system/core/liblog/include/log/log_id.h index c052a503c0..70ebd1f384 100644 --- a/third_party/aosp_10.0.0_r35/system/core/liblog/include/log/log_id.h +++ b/third_party/aosp_10.0.0_r35/system/core/liblog/include/log/log_id.h @@ -58,6 +58,8 @@ int __android_log_buf_print(int bufID, int prio, const char* tag, log_id_t android_name_to_log_id(const char* logName); const char* android_log_id_to_name(log_id_t log_id); +int __hwlog_setparam(int paramid, const char *val); + #ifdef __cplusplus } #endif diff --git a/third_party/aosp_10.0.0_r35/system/core/liblog/include_vndk/log/log_id.h b/third_party/aosp_10.0.0_r35/system/core/liblog/include_vndk/log/log_id.h index c052a503c0..70ebd1f384 100644 --- a/third_party/aosp_10.0.0_r35/system/core/liblog/include_vndk/log/log_id.h +++ b/third_party/aosp_10.0.0_r35/system/core/liblog/include_vndk/log/log_id.h @@ -58,6 +58,8 @@ int __android_log_buf_print(int bufID, int prio, const char* tag, log_id_t android_name_to_log_id(const char* logName); const char* android_log_id_to_name(log_id_t log_id); +int __hwlog_setparam(int paramid, const char *val); + #ifdef __cplusplus } #endif diff --git a/third_party/aosp_10.0.0_r35/system/core/liblog/liblog.map.txt b/third_party/aosp_10.0.0_r35/system/core/liblog/liblog.map.txt index ce4c53c82f..170c26ad6b 100644 --- a/third_party/aosp_10.0.0_r35/system/core/liblog/liblog.map.txt +++ b/third_party/aosp_10.0.0_r35/system/core/liblog/liblog.map.txt @@ -63,6 +63,7 @@ LIBLOG_Q { __android_log_security; # apex android_log_reset; #vndk android_log_parser_reset; #vndk + __hwlog_setparam; }; LIBLOG_PRIVATE { diff --git a/third_party/aosp_10.0.0_r35/system/core/libutils/include/utils/Flattenable.h b/third_party/aosp_10.0.0_r35/system/core/libutils/include/utils/Flattenable.h index 2c4b8075d2..9d006023d5 100644 --- a/third_party/aosp_10.0.0_r35/system/core/libutils/include/utils/Flattenable.h +++ b/third_party/aosp_10.0.0_r35/system/core/libutils/include/utils/Flattenable.h @@ -47,12 +47,7 @@ public: template static size_t align(void*& buffer) { - static_assert(!(N & (N - 1)), "Can only align to a power of 2."); - void* b = buffer; - buffer = reinterpret_cast((uintptr_t(buffer) + (N-1)) & ~(N-1)); - size_t delta = size_t(uintptr_t(buffer) - uintptr_t(b)); - memset(b, 0, delta); - return delta; + return align( const_cast(buffer) ); } static void advance(void*& buffer, size_t& size, size_t offset) { diff --git a/third_party/aosp_10.0.0_r35/system/core/libutils/include/utils/String8.h b/third_party/aosp_10.0.0_r35/system/core/libutils/include/utils/String8.h index c8f584e306..9043686bce 100644 --- a/third_party/aosp_10.0.0_r35/system/core/libutils/include/utils/String8.h +++ b/third_party/aosp_10.0.0_r35/system/core/libutils/include/utils/String8.h @@ -58,6 +58,9 @@ public: explicit String8(const char16_t* o, size_t numChars); explicit String8(const char32_t* o); explicit String8(const char32_t* o, size_t numChars); + //fix bug of sogou input method + explicit String8(unsigned short const* o); + //fix bug of sogou input method ~String8(); static inline const String8 empty(); diff --git a/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_archive.cc b/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_archive.cc index 0710d0addb..402fb201bd 100644 --- a/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_archive.cc +++ b/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_archive.cc @@ -33,6 +33,7 @@ #include #include +#include "string_view_format.h" #if defined(__APPLE__) #define lseek64 lseek @@ -103,8 +104,8 @@ static uint32_t RoundUpPower2(uint32_t val) { static uint32_t ComputeHash(const ZipString& name) { #if !defined(_WIN32) - return std::hash{}( - std::string_view(reinterpret_cast(name.name), name.name_length)); + return std::hash{}( + StringView(reinterpret_cast(name.name), name.name_length)); #else // Remove this code path once the windows compiler knows how to compile the above statement. uint32_t hash = 0; diff --git a/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_archive_private.h b/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_archive_private.h index 330a02a072..a5f7a3a907 100644 --- a/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_archive_private.h +++ b/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_archive_private.h @@ -138,7 +138,7 @@ class CentralDirectory { /** * More space efficient string representation of strings in an mmaped zipped file than - * std::string_view or ZipString. Using ZipString as an entry in the ZipArchive hashtable wastes + * StringView or ZipString. Using ZipString as an entry in the ZipArchive hashtable wastes * space. ZipString stores a pointer to a string (on 64 bit, 8 bytes) and the length to read from * that pointer, 2 bytes. Because of alignment, the structure consumes 16 bytes, wasting 6 bytes. * ZipStringOffset stores a 4 byte offset from a fixed location in the memory mapped file instead diff --git a/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_writer.cc b/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_writer.cc index 0df0fa5387..98b0a734db 100644 --- a/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_writer.cc +++ b/third_party/aosp_10.0.0_r35/system/core/libziparchive/zip_writer.cc @@ -358,7 +358,7 @@ int32_t ZipWriter::CompressBytes(FileEntry* file, const void* data, size_t len) CHECK(z_stream_->avail_out != 0); // Prepare the input. - z_stream_->next_in = reinterpret_cast(data); + z_stream_->next_in = (unsigned char *)(data); z_stream_->avail_in = len; while (z_stream_->avail_in > 0) { -- Gitee From 202c3f4c268e8a29bb698243900af77f9c88e6bd Mon Sep 17 00:00:00 2001 From: William Chen Date: Mon, 22 Feb 2021 09:42:46 -0800 Subject: [PATCH 2/3] C empty struct has size 0 --- src/mapleall/maple_be/src/be/becommon.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mapleall/maple_be/src/be/becommon.cpp b/src/mapleall/maple_be/src/be/becommon.cpp index 0badc30dc5..8e8f56bc8d 100644 --- a/src/mapleall/maple_be/src/be/becommon.cpp +++ b/src/mapleall/maple_be/src/be/becommon.cpp @@ -117,7 +117,12 @@ void BECommon::ComputeStructTypeSizesAligns(MIRType &ty, const TyIdx &tyIdx) { SetStructFieldCount(structType.GetTypeIndex(), fields.size()); if (fields.size() == 0 && mirModule.IsCModule()) { SetTypeAlign(tyIdx.GetIdx(), 1); - SetTypeSize(tyIdx.GetIdx(), 1); + if (structType.IsCPlusPlus()) { + SetTypeSize(tyIdx.GetIdx(), 1); + } else { + /* empty struct is not supported in C, but gcc allows for it as size 0 */ + SetTypeSize(tyIdx.GetIdx(), 0); + } return; } for (size_t j = 0; j < fields.size(); ++j) { -- Gitee From cbc23f9c965f18d1fd3412df18a2786ebe54a71f Mon Sep 17 00:00:00 2001 From: William Chen Date: Mon, 22 Feb 2021 14:03:57 -0800 Subject: [PATCH 3/3] Fix imm opnd of SelectCopyMemOpnd for 32 and 64 bit -1 --- src/mapleall/maple_be/include/cg/operand.h | 4 ++++ src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mapleall/maple_be/include/cg/operand.h b/src/mapleall/maple_be/include/cg/operand.h index 56e9e2b806..5c9e47337f 100644 --- a/src/mapleall/maple_be/include/cg/operand.h +++ b/src/mapleall/maple_be/include/cg/operand.h @@ -424,6 +424,10 @@ class ImmOperand : public Operand { return value == -1; } + bool IsAllOnes32bit() const { + return value == 0x0ffffffffLL; + } + bool operator<(const ImmOperand &iOpnd) const { return value < iOpnd.value || (value == iOpnd.value && isSigned < iOpnd.isSigned) || (value == iOpnd.value && isSigned == iOpnd.isSigned && size < iOpnd.GetSize()); diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp index 4385425271..717aee4dd6 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -428,10 +428,10 @@ void AArch64CGFunc::SelectCopyMemOpnd(Operand &dest, PrimType dtype, uint32 dsiz } Insn *insn = nullptr; uint32 ssize = src.GetSize(); - if (!IsPrimitiveFloat(stype)) { + if (IsPrimitiveFloat(stype)) { + CHECK_FATAL(dsize == ssize, "dsize %u expect equals ssize %u", dtype, ssize); insn = &GetCG()->BuildInstruction(PickLdInsn(ssize, stype), dest, src); } else { - CHECK_FATAL(dsize == ssize, "dsize %u expect equals ssize %u", dtype, ssize); insn = &GetCG()->BuildInstruction(PickLdInsn(ssize, stype), dest, src); } @@ -2896,7 +2896,7 @@ void AArch64CGFunc::SelectRelationOperator(RelationOperator operatorCode, Operan } else if ((operatorCode == kIOR) || (operatorCode == kEOR)) { SelectCopy(resOpnd, primType, opnd0, primType); } - } else if (immOpnd->IsAllOnes()) { + } else if ((is64Bits && immOpnd->IsAllOnes()) || (!is64Bits && immOpnd->IsAllOnes32bit())) { if (operatorCode == kAND) { SelectCopy(resOpnd, primType, opnd0, primType); } else if (operatorCode == kIOR) { -- Gitee