Merge "Refactor MemMap::MapAnonymous()."
diff --git a/adbconnection/Android.bp b/adbconnection/Android.bp
index 95fc274..5f78278 100644
--- a/adbconnection/Android.bp
+++ b/adbconnection/Android.bp
@@ -30,11 +30,6 @@
"libbase",
],
target: {
- android: {
- shared_libs: [
- "libcutils",
- ],
- },
host: {
},
darwin: {
diff --git a/adbconnection/adbconnection.cc b/adbconnection/adbconnection.cc
index ba25393..cf35914 100644
--- a/adbconnection/adbconnection.cc
+++ b/adbconnection/adbconnection.cc
@@ -24,6 +24,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/mutex.h"
+#include "base/socket_peer_is_trusted.h"
#include "jni/java_vm_ext.h"
#include "jni/jni_env_ext.h"
#include "mirror/throwable.h"
@@ -39,10 +40,6 @@
#include "poll.h"
-#ifdef ART_TARGET_ANDROID
-#include "cutils/sockets.h"
-#endif
-
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -517,11 +514,7 @@
// the debuggable flag set.
int ret = connect(sock, &control_addr_.controlAddrPlain, control_addr_len_);
if (ret == 0) {
- bool trusted = sock >= 0;
-#ifdef ART_TARGET_ANDROID
- // Needed for socket_peer_is_trusted.
- trusted = trusted && socket_peer_is_trusted(sock);
-#endif
+ bool trusted = sock >= 0 && art::SocketPeerIsTrusted(sock);
if (!trusted) {
LOG(ERROR) << "adb socket is not trusted. Aborting connection.";
if (sock >= 0 && shutdown(sock, SHUT_RDWR)) {
diff --git a/cmdline/token_range.h b/cmdline/token_range.h
index 642bb1d..e28ead9 100644
--- a/cmdline/token_range.h
+++ b/cmdline/token_range.h
@@ -325,7 +325,7 @@
string_idx += remaining;
maybe_push_wildcard_token();
- return std::unique_ptr<TokenRange>(new TokenRange(std::move(new_token_list)));
+ return std::make_unique<TokenRange>(std::move(new_token_list));
}
// Do a quick match token-by-token, and see if they match.
diff --git a/compiler/driver/simple_compiler_options_map.h b/compiler/driver/simple_compiler_options_map.h
index 3860da9..e7a51a4 100644
--- a/compiler/driver/simple_compiler_options_map.h
+++ b/compiler/driver/simple_compiler_options_map.h
@@ -50,7 +50,7 @@
static inline Parser CreateSimpleParser(bool ignore_unrecognized) {
std::unique_ptr<Parser::Builder> parser_builder =
- std::unique_ptr<Parser::Builder>(new Parser::Builder());
+ std::make_unique<Parser::Builder>();
AddCompilerOptionsArgumentParserOptions<SimpleParseArgumentMap>(*parser_builder);
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 7f94a29..dd781c2 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -36,6 +36,8 @@
#include "jit/jit_code_cache.h"
#include "mirror/class_loader.h"
#include "mirror/dex_cache.h"
+#include "mirror/object_array-alloc-inl.h"
+#include "mirror/object_array-inl.h"
#include "nodes.h"
#include "optimizing_compiler.h"
#include "reference_type_propagation.h"
diff --git a/compiler/optimizing/intrinsic_objects.cc b/compiler/optimizing/intrinsic_objects.cc
index 3c20ad6..0374b4e 100644
--- a/compiler/optimizing/intrinsic_objects.cc
+++ b/compiler/optimizing/intrinsic_objects.cc
@@ -21,6 +21,7 @@
#include "class_root.h"
#include "handle.h"
#include "obj_ptr-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
namespace art {
diff --git a/dex2oat/dex2oat_options.cc b/dex2oat/dex2oat_options.cc
index 710f14c..236c1fc 100644
--- a/dex2oat/dex2oat_options.cc
+++ b/dex2oat/dex2oat_options.cc
@@ -187,7 +187,7 @@
}
static Parser CreateArgumentParser() {
- std::unique_ptr<Builder> parser_builder = std::unique_ptr<Builder>(new Builder());
+ std::unique_ptr<Builder> parser_builder = std::make_unique<Builder>();
AddInputMappings(*parser_builder);
AddGeneratedArtifactMappings(*parser_builder);
@@ -267,7 +267,7 @@
return nullptr;
}
- return std::unique_ptr<Dex2oatArgumentMap>(new Dex2oatArgumentMap(parser.ReleaseArgumentsMap()));
+ return std::make_unique<Dex2oatArgumentMap>(parser.ReleaseArgumentsMap());
}
#pragma GCC diagnostic pop
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 898940a..770b696 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -39,6 +39,7 @@
#include "dex/dex_file_loader.h"
#include "dex2oat_environment_test.h"
#include "dex2oat_return_codes.h"
+#include "gc_root-inl.h"
#include "intern_table-inl.h"
#include "oat.h"
#include "oat_file.h"
diff --git a/dex2oat/linker/elf_writer_quick.cc b/dex2oat/linker/elf_writer_quick.cc
index 9a7f93d..9fbcca4 100644
--- a/dex2oat/linker/elf_writer_quick.cc
+++ b/dex2oat/linker/elf_writer_quick.cc
@@ -17,6 +17,7 @@
#include "elf_writer_quick.h"
#include <openssl/sha.h>
+#include <memory>
#include <unordered_map>
#include <unordered_set>
@@ -263,16 +264,15 @@
if (!debug_info.Empty() && compiler_options_.GetGenerateMiniDebugInfo()) {
// Prepare the mini-debug-info in background while we do other I/O.
Thread* self = Thread::Current();
- debug_info_task_ = std::unique_ptr<DebugInfoTask>(
- new DebugInfoTask(builder_->GetIsa(),
- compiler_options_.GetInstructionSetFeatures(),
- builder_->GetText()->GetAddress(),
- text_size_,
- builder_->GetDex()->Exists() ? builder_->GetDex()->GetAddress() : 0,
- dex_section_size_,
- debug_info));
- debug_info_thread_pool_ = std::unique_ptr<ThreadPool>(
- new ThreadPool("Mini-debug-info writer", 1));
+ debug_info_task_ = std::make_unique<DebugInfoTask>(
+ builder_->GetIsa(),
+ compiler_options_.GetInstructionSetFeatures(),
+ builder_->GetText()->GetAddress(),
+ text_size_,
+ builder_->GetDex()->Exists() ? builder_->GetDex()->GetAddress() : 0,
+ dex_section_size_,
+ debug_info);
+ debug_info_thread_pool_ = std::make_unique<ThreadPool>("Mini-debug-info writer", 1);
debug_info_thread_pool_->AddTask(self, debug_info_task_.get());
debug_info_thread_pool_->StartWorkers(self);
}
diff --git a/dex2oat/linker/image_writer.cc b/dex2oat/linker/image_writer.cc
index d43a228..4ddbf74 100644
--- a/dex2oat/linker/image_writer.cc
+++ b/dex2oat/linker/image_writer.cc
@@ -66,6 +66,7 @@
#include "mirror/method.h"
#include "mirror/object-inl.h"
#include "mirror/object-refvisitor-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/string-inl.h"
#include "oat.h"
diff --git a/dexlayout/dex_ir_builder.cc b/dexlayout/dex_ir_builder.cc
index c38e563..92e438c 100644
--- a/dexlayout/dex_ir_builder.cc
+++ b/dexlayout/dex_ir_builder.cc
@@ -17,6 +17,7 @@
*/
#include <stdint.h>
+#include <memory>
#include <vector>
#include "dex_ir_builder.h"
@@ -635,10 +636,10 @@
dex_file.GetHiddenapiClassDataAtOffset(offset);
DCHECK(hiddenapi_class_data == dex_file.GetHiddenapiClassData());
- for (size_t i = 0; i < dex_file.NumClassDefs(); ++i) {
- ClassDef* class_def = header_->ClassDefs()[i];
+ for (auto& class_def : header_->ClassDefs()) {
+ uint32_t index = class_def->GetIndex();
ClassData* class_data = class_def->GetClassData();
- const uint8_t* ptr = hiddenapi_class_data->GetFlagsPointer(i);
+ const uint8_t* ptr = hiddenapi_class_data->GetFlagsPointer(index);
std::unique_ptr<HiddenapiFlagsMap> flags = nullptr;
if (ptr != nullptr) {
@@ -660,9 +661,9 @@
CreateAndAddIndexedItem(header_->HiddenapiClassDatas(),
header_->HiddenapiClassDatas().GetOffset() +
- hiddenapi_class_data->flags_offset_[i],
- i,
- class_def,
+ hiddenapi_class_data->flags_offset_[index],
+ index,
+ class_def.get(),
std::move(flags));
}
}
@@ -741,8 +742,8 @@
uint32_t annotation_set_offset = fields[i].annotations_off_;
AnnotationSetItem* annotation_set_item =
CreateAnnotationSetItem(dex_file, field_set_item, annotation_set_offset);
- field_annotations->push_back(std::unique_ptr<FieldAnnotation>(
- new FieldAnnotation(field_id, annotation_set_item)));
+ field_annotations->push_back(std::make_unique<FieldAnnotation>(
+ field_id, annotation_set_item));
}
}
const DexFile::MethodAnnotationsItem* methods =
@@ -757,8 +758,8 @@
uint32_t annotation_set_offset = methods[i].annotations_off_;
AnnotationSetItem* annotation_set_item =
CreateAnnotationSetItem(dex_file, method_set_item, annotation_set_offset);
- method_annotations->push_back(std::unique_ptr<MethodAnnotation>(
- new MethodAnnotation(method_id, annotation_set_item)));
+ method_annotations->push_back(std::make_unique<MethodAnnotation>(
+ method_id, annotation_set_item));
}
}
const DexFile::ParameterAnnotationsItem* parameters =
@@ -1203,9 +1204,9 @@
// Decode all name=value pairs.
for (uint32_t i = 0; i < size; i++) {
const uint32_t name_index = DecodeUnsignedLeb128(data);
- elements->push_back(std::unique_ptr<AnnotationElement>(
- new AnnotationElement(header_->StringIds()[name_index],
- ReadEncodedValue(dex_file, data))));
+ elements->push_back(std::make_unique<AnnotationElement>(
+ header_->StringIds()[name_index],
+ ReadEncodedValue(dex_file, data)));
}
item->SetEncodedAnnotation(new EncodedAnnotation(header_->TypeIds()[type_idx], elements));
break;
diff --git a/dexlayout/dex_writer.cc b/dexlayout/dex_writer.cc
index 929ed40..ef6ccf9 100644
--- a/dexlayout/dex_writer.cc
+++ b/dexlayout/dex_writer.cc
@@ -468,6 +468,7 @@
}
DCHECK_EQ(header_->HiddenapiClassDatas().Size(), header_->ClassDefs().Size());
+ stream->AlignTo(SectionAlignment(DexFile::kDexTypeHiddenapiClassData));
const uint32_t start = stream->Tell();
// Compute offsets for each class def and write the header.
diff --git a/libartbase/Android.bp b/libartbase/Android.bp
index 19f1532..0c6b1a2 100644
--- a/libartbase/Android.bp
+++ b/libartbase/Android.bp
@@ -40,6 +40,7 @@
"base/safe_copy.cc",
"base/scoped_arena_allocator.cc",
"base/scoped_flock.cc",
+ "base/socket_peer_is_trusted.cc",
"base/time_utils.cc",
"base/unix_file/fd_file.cc",
"base/unix_file/random_access_file_utils.cc",
diff --git a/libartbase/base/mem_map_test.cc b/libartbase/base/mem_map_test.cc
index 0aec3a0..2d9cd59 100644
--- a/libartbase/base/mem_map_test.cc
+++ b/libartbase/base/mem_map_test.cc
@@ -21,8 +21,9 @@
#include <memory>
#include <random>
-#include "base/common_art_test.h"
+#include "common_art_test.h"
#include "common_runtime_test.h" // For TEST_DISABLED_FOR_MIPS
+#include "logging.h"
#include "memory_tool.h"
#include "unix_file/fd_file.h"
@@ -877,3 +878,30 @@
}
} // namespace art
+
+namespace {
+
+class DumpMapsOnFailListener : public testing::EmptyTestEventListener {
+ void OnTestPartResult(const testing::TestPartResult& result) override {
+ switch (result.type()) {
+ case testing::TestPartResult::kFatalFailure:
+ art::PrintFileToLog("/proc/self/maps", android::base::LogSeverity::ERROR);
+ break;
+
+ // TODO: Could consider logging on EXPECT failures.
+ case testing::TestPartResult::kNonFatalFailure:
+ case testing::TestPartResult::kSuccess:
+ break;
+ }
+ }
+};
+
+} // namespace
+
+// Inject our listener into the test runner.
+extern "C"
+__attribute__((visibility("default"))) __attribute__((used))
+void ArtTestGlobalInit() {
+ LOG(ERROR) << "Installing listener";
+ testing::UnitTest::GetInstance()->listeners().Append(new DumpMapsOnFailListener());
+}
diff --git a/libartbase/base/socket_peer_is_trusted.cc b/libartbase/base/socket_peer_is_trusted.cc
new file mode 100644
index 0000000..440054e
--- /dev/null
+++ b/libartbase/base/socket_peer_is_trusted.cc
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2018 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 "socket_peer_is_trusted.h"
+
+#include <pwd.h>
+#include <sys/socket.h>
+
+#include <android-base/logging.h>
+
+namespace art {
+
+// Returns true if the user on the other end of the socket is root or shell.
+#ifdef ART_TARGET_ANDROID
+bool SocketPeerIsTrusted(int fd) {
+ ucred cr;
+ socklen_t cr_length = sizeof(cr);
+ if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &cr_length) != 0) {
+ PLOG(ERROR) << "couldn't get socket credentials";
+ return false;
+ }
+
+ passwd* shell = getpwnam("shell");
+ if (cr.uid != 0 && cr.uid != shell->pw_uid) {
+ LOG(ERROR) << "untrusted uid " << cr.uid << " on other end of socket";
+ return false;
+ }
+
+ return true;
+}
+#else
+bool SocketPeerIsTrusted(int /* fd */) {
+ return true;
+}
+#endif
+
+} // namespace art
diff --git a/libartbase/base/socket_peer_is_trusted.h b/libartbase/base/socket_peer_is_trusted.h
new file mode 100644
index 0000000..4bbadd4
--- /dev/null
+++ b/libartbase/base/socket_peer_is_trusted.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2018 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_LIBARTBASE_BASE_SOCKET_PEER_IS_TRUSTED_H_
+#define ART_LIBARTBASE_BASE_SOCKET_PEER_IS_TRUSTED_H_
+
+namespace art {
+
+// Returns true if the user on the other end of the socket is root or shell.
+bool SocketPeerIsTrusted(int fd);
+
+} // namespace art
+
+#endif // ART_LIBARTBASE_BASE_SOCKET_PEER_IS_TRUSTED_H_
diff --git a/libdexfile/dex/class_accessor-inl.h b/libdexfile/dex/class_accessor-inl.h
index 40bca56..e9e3a98 100644
--- a/libdexfile/dex/class_accessor-inl.h
+++ b/libdexfile/dex/class_accessor-inl.h
@@ -65,7 +65,7 @@
code_off_ = DecodeUnsignedLeb128(&ptr_pos_);
if (hiddenapi_ptr_pos_ != nullptr) {
hiddenapi_flags_ = DecodeUnsignedLeb128(&hiddenapi_ptr_pos_);
- DCHECK(HiddenApiAccessFlags::AreValidFlags(hiddenapi_flags_));
+ DCHECK(hiddenapi::AreValidFlags(hiddenapi_flags_));
}
}
@@ -74,7 +74,7 @@
access_flags_ = DecodeUnsignedLeb128(&ptr_pos_);
if (hiddenapi_ptr_pos_ != nullptr) {
hiddenapi_flags_ = DecodeUnsignedLeb128(&hiddenapi_ptr_pos_);
- DCHECK(HiddenApiAccessFlags::AreValidFlags(hiddenapi_flags_));
+ DCHECK(hiddenapi::AreValidFlags(hiddenapi_flags_));
}
}
diff --git a/libdexfile/dex/dex_file_verifier.cc b/libdexfile/dex/dex_file_verifier.cc
index 43471c3..4d33cd5 100644
--- a/libdexfile/dex/dex_file_verifier.cc
+++ b/libdexfile/dex/dex_file_verifier.cc
@@ -1632,7 +1632,7 @@
failure = true;
return;
}
- if (!HiddenApiAccessFlags::AreValidFlags(decoded_flags)) {
+ if (!hiddenapi::AreValidFlags(decoded_flags)) {
ErrorStringPrintf("Hiddenapi class data flags invalid (%u) for %s %i",
decoded_flags, member_type, member.GetIndex());
failure = true;
diff --git a/libdexfile/dex/dex_instruction_iterator.h b/libdexfile/dex/dex_instruction_iterator.h
index b75a95b..6c7f42a 100644
--- a/libdexfile/dex/dex_instruction_iterator.h
+++ b/libdexfile/dex/dex_instruction_iterator.h
@@ -63,7 +63,6 @@
using value_type = std::iterator<std::forward_iterator_tag, DexInstructionPcPair>::value_type;
using difference_type = std::iterator<std::forward_iterator_tag, value_type>::difference_type;
- DexInstructionIteratorBase() = default;
explicit DexInstructionIteratorBase(const Instruction* inst, uint32_t dex_pc)
: data_(reinterpret_cast<const uint16_t*>(inst), dex_pc) {}
diff --git a/libdexfile/dex/hidden_api_access_flags.h b/libdexfile/dex/hidden_api_access_flags.h
index 837056b..fd5c865 100644
--- a/libdexfile/dex/hidden_api_access_flags.h
+++ b/libdexfile/dex/hidden_api_access_flags.h
@@ -21,8 +21,6 @@
#include "base/macros.h"
#include "dex/modifiers.h"
-namespace art {
-
/* This class is used for encoding and decoding access flags of class members
* from the boot class path. These access flags might contain additional two bits
* of information on whether the given class member should be hidden from apps
@@ -38,64 +36,65 @@
* the ApiList enum values.
*
*/
-class HiddenApiAccessFlags {
- public:
- enum ApiList {
- kWhitelist = 0,
- kLightGreylist,
- kDarkGreylist,
- kBlacklist,
- kNoList,
- };
- static ALWAYS_INLINE ApiList DecodeFromRuntime(uint32_t runtime_access_flags) {
- // This is used in the fast path, only DCHECK here.
- DCHECK_EQ(runtime_access_flags & kAccIntrinsic, 0u);
- uint32_t int_value = (runtime_access_flags & kAccHiddenApiBits) >> kAccFlagsShift;
- return static_cast<ApiList>(int_value);
- }
+namespace art {
+namespace hiddenapi {
- static ALWAYS_INLINE uint32_t EncodeForRuntime(uint32_t runtime_access_flags, ApiList value) {
- CHECK_EQ(runtime_access_flags & kAccIntrinsic, 0u);
-
- uint32_t hidden_api_flags = static_cast<uint32_t>(value) << kAccFlagsShift;
- CHECK_EQ(hidden_api_flags & ~kAccHiddenApiBits, 0u);
-
- runtime_access_flags &= ~kAccHiddenApiBits;
- return runtime_access_flags | hidden_api_flags;
- }
-
- static ALWAYS_INLINE bool AreValidFlags(uint32_t flags) {
- return flags <= static_cast<uint32_t>(kBlacklist);
- }
-
- private:
- static const int kAccFlagsShift = CTZ(kAccHiddenApiBits);
- static_assert(IsPowerOfTwo((kAccHiddenApiBits >> kAccFlagsShift) + 1),
- "kAccHiddenApiBits are not continuous");
+enum class ApiList {
+ kWhitelist = 0,
+ kLightGreylist,
+ kDarkGreylist,
+ kBlacklist,
+ kNoList,
};
-inline std::ostream& operator<<(std::ostream& os, HiddenApiAccessFlags::ApiList value) {
+static const int kAccFlagsShift = CTZ(kAccHiddenApiBits);
+static_assert(IsPowerOfTwo((kAccHiddenApiBits >> kAccFlagsShift) + 1),
+ "kAccHiddenApiBits are not continuous");
+
+inline ApiList DecodeFromRuntime(uint32_t runtime_access_flags) {
+ // This is used in the fast path, only DCHECK here.
+ DCHECK_EQ(runtime_access_flags & kAccIntrinsic, 0u);
+ uint32_t int_value = (runtime_access_flags & kAccHiddenApiBits) >> kAccFlagsShift;
+ return static_cast<ApiList>(int_value);
+}
+
+inline uint32_t EncodeForRuntime(uint32_t runtime_access_flags, ApiList value) {
+ CHECK_EQ(runtime_access_flags & kAccIntrinsic, 0u);
+
+ uint32_t hidden_api_flags = static_cast<uint32_t>(value) << kAccFlagsShift;
+ CHECK_EQ(hidden_api_flags & ~kAccHiddenApiBits, 0u);
+
+ runtime_access_flags &= ~kAccHiddenApiBits;
+ return runtime_access_flags | hidden_api_flags;
+}
+
+inline bool AreValidFlags(uint32_t flags) {
+ return flags <= static_cast<uint32_t>(ApiList::kBlacklist);
+}
+
+inline std::ostream& operator<<(std::ostream& os, ApiList value) {
switch (value) {
- case HiddenApiAccessFlags::kWhitelist:
+ case ApiList::kWhitelist:
os << "whitelist";
break;
- case HiddenApiAccessFlags::kLightGreylist:
+ case ApiList::kLightGreylist:
os << "light greylist";
break;
- case HiddenApiAccessFlags::kDarkGreylist:
+ case ApiList::kDarkGreylist:
os << "dark greylist";
break;
- case HiddenApiAccessFlags::kBlacklist:
+ case ApiList::kBlacklist:
os << "blacklist";
break;
- case HiddenApiAccessFlags::kNoList:
+ case ApiList::kNoList:
os << "no list";
break;
}
return os;
}
+} // namespace hiddenapi
} // namespace art
diff --git a/openjdkjvmti/OpenjdkJvmTi.cc b/openjdkjvmti/OpenjdkJvmTi.cc
index a2fabbf..bd5b598 100644
--- a/openjdkjvmti/OpenjdkJvmTi.cc
+++ b/openjdkjvmti/OpenjdkJvmTi.cc
@@ -29,6 +29,7 @@
* questions.
*/
+#include <memory>
#include <string>
#include <type_traits>
#include <vector>
@@ -1492,7 +1493,7 @@
capabilities(),
event_info_mutex_("jvmtiEnv_EventInfoMutex"),
last_error_mutex_("jvmtiEnv_LastErrorMutex", art::LockLevel::kGenericBottomLock) {
- object_tag_table = std::unique_ptr<ObjectTagTable>(new ObjectTagTable(event_handler, this));
+ object_tag_table = std::make_unique<ObjectTagTable>(event_handler, this);
functions = &gJvmtiInterface;
}
diff --git a/openjdkjvmti/fixed_up_dex_file.cc b/openjdkjvmti/fixed_up_dex_file.cc
index eb93fc9..41e4291 100644
--- a/openjdkjvmti/fixed_up_dex_file.cc
+++ b/openjdkjvmti/fixed_up_dex_file.cc
@@ -105,9 +105,6 @@
// this before unquickening.
art::Options options;
options.compact_dex_level_ = art::CompactDexLevel::kCompactDexLevelNone;
- // Never verify the output since hidden API flags may cause the dex file verifier to fail.
- // See b/74063493
- options.verify_output_ = false;
// Add a filter to only include the class that has the matching descriptor.
static constexpr bool kFilterByDescriptor = true;
if (kFilterByDescriptor) {
diff --git a/openjdkjvmti/ti_redefine.cc b/openjdkjvmti/ti_redefine.cc
index a610fc7..7cd1039 100644
--- a/openjdkjvmti/ti_redefine.cc
+++ b/openjdkjvmti/ti_redefine.cc
@@ -64,9 +64,12 @@
#include "jvmti_allocator.h"
#include "linear_alloc.h"
#include "mirror/array-alloc-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_ext.h"
#include "mirror/object.h"
+#include "mirror/object_array-alloc-inl.h"
+#include "mirror/object_array-inl.h"
#include "nativehelper/scoped_local_ref.h"
#include "non_debuggable_classes.h"
#include "object_lock.h"
diff --git a/openjdkjvmti/transform.cc b/openjdkjvmti/transform.cc
index 653f944..8bd10da 100644
--- a/openjdkjvmti/transform.cc
+++ b/openjdkjvmti/transform.cc
@@ -48,6 +48,7 @@
#include "events-inl.h"
#include "fault_handler.h"
#include "gc_root-inl.h"
+#include "handle_scope-inl.h"
#include "jni/jni_env_ext-inl.h"
#include "jvalue.h"
#include "jvmti.h"
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 5d99187..86ee952 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -392,7 +392,7 @@
"libbacktrace",
"liblz4",
"liblog",
- // For atrace, properties, ashmem, set_sched_policy and socket_peer_is_trusted.
+ // For atrace, properties, ashmem, set_sched_policy.
"libcutils",
// For common macros.
"libbase",
diff --git a/runtime/arch/stub_test.cc b/runtime/arch/stub_test.cc
index de19317..0cc5535 100644
--- a/runtime/arch/stub_test.cc
+++ b/runtime/arch/stub_test.cc
@@ -27,8 +27,9 @@
#include "imt_conflict_table.h"
#include "jni/jni_internal.h"
#include "linear_alloc.h"
-#include "mirror/class-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/string-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "scoped_thread_state_change-inl.h"
namespace art {
diff --git a/runtime/art_field.h b/runtime/art_field.h
index 5afd000..dc7f985 100644
--- a/runtime/art_field.h
+++ b/runtime/art_field.h
@@ -180,8 +180,8 @@
return (GetAccessFlags() & kAccVolatile) != 0;
}
- HiddenApiAccessFlags::ApiList GetHiddenApiAccessFlags() REQUIRES_SHARED(Locks::mutator_lock_) {
- return HiddenApiAccessFlags::DecodeFromRuntime(GetAccessFlags());
+ hiddenapi::ApiList GetHiddenApiAccessFlags() REQUIRES_SHARED(Locks::mutator_lock_) {
+ return hiddenapi::DecodeFromRuntime(GetAccessFlags());
}
// Returns an instance field with this offset in the given class or null if not found.
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h
index f693524..e9c17ee 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -367,7 +367,7 @@
return (GetAccessFlags() & kAccSingleImplementation) != 0;
}
-inline HiddenApiAccessFlags::ApiList ArtMethod::GetHiddenApiAccessFlags()
+inline hiddenapi::ApiList ArtMethod::GetHiddenApiAccessFlags()
REQUIRES_SHARED(Locks::mutator_lock_) {
if (UNLIKELY(IsIntrinsic())) {
switch (static_cast<Intrinsics>(GetIntrinsic())) {
@@ -407,7 +407,7 @@
// Note that the DCHECK currently won't fail if the dex methods are
// whitelisted, e.g. in the core image (b/77733081). As a result, we
// might print warnings but we won't change the semantics.
- return HiddenApiAccessFlags::kLightGreylist;
+ return hiddenapi::ApiList::kLightGreylist;
case Intrinsics::kStringNewStringFromBytes:
case Intrinsics::kStringNewStringFromChars:
case Intrinsics::kStringNewStringFromString:
@@ -417,7 +417,7 @@
case Intrinsics::kMemoryPokeIntNative:
case Intrinsics::kMemoryPokeLongNative:
case Intrinsics::kMemoryPokeShortNative:
- return HiddenApiAccessFlags::kDarkGreylist;
+ return hiddenapi::ApiList::kDarkGreylist;
case Intrinsics::kVarHandleFullFence:
case Intrinsics::kVarHandleAcquireFence:
case Intrinsics::kVarHandleReleaseFence:
@@ -460,13 +460,13 @@
// whitelisted, e.g. in the core image (b/77733081). Given that they are
// exclusively VarHandle intrinsics, they should not be used outside
// tests that do not enable hidden API checks.
- return HiddenApiAccessFlags::kBlacklist;
+ return hiddenapi::ApiList::kBlacklist;
default:
// Remaining intrinsics are public API. We DCHECK that in SetIntrinsic().
- return HiddenApiAccessFlags::kWhitelist;
+ return hiddenapi::ApiList::kWhitelist;
}
} else {
- return HiddenApiAccessFlags::DecodeFromRuntime(GetAccessFlags());
+ return hiddenapi::DecodeFromRuntime(GetAccessFlags());
}
}
@@ -492,7 +492,7 @@
bool is_default_conflict = IsDefaultConflicting();
bool is_compilable = IsCompilable();
bool must_count_locks = MustCountLocks();
- HiddenApiAccessFlags::ApiList hidden_api_flags = GetHiddenApiAccessFlags();
+ hiddenapi::ApiList hidden_api_flags = GetHiddenApiAccessFlags();
SetAccessFlags(new_value);
DCHECK_EQ(java_flags, (GetAccessFlags() & kAccJavaFlagsMask));
DCHECK_EQ(is_constructor, IsConstructor());
@@ -512,7 +512,7 @@
// these because (a) warnings on greylist do not change semantics, and
// (b) only VarHandle intrinsics are blacklisted at the moment and they
// should not be used outside tests with disabled API checks.
- if (hidden_api_flags != HiddenApiAccessFlags::kWhitelist) {
+ if (hidden_api_flags != hiddenapi::ApiList::kWhitelist) {
DCHECK_EQ(hidden_api_flags, GetHiddenApiAccessFlags()) << PrettyMethod();
}
} else {
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 4a19b10..9bf31ed 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -688,13 +688,13 @@
}
// Query the hidden API access flags of the intrinsic.
- HiddenApiAccessFlags::ApiList intrinsic_api_list = GetHiddenApiAccessFlags();
+ hiddenapi::ApiList intrinsic_api_list = GetHiddenApiAccessFlags();
// Clear intrinsic-related access flags.
ClearAccessFlags(kAccIntrinsic | kAccIntrinsicBits);
// Re-apply hidden API access flags now that the method is not an intrinsic.
- SetAccessFlags(HiddenApiAccessFlags::EncodeForRuntime(GetAccessFlags(), intrinsic_api_list));
+ SetAccessFlags(hiddenapi::EncodeForRuntime(GetAccessFlags(), intrinsic_api_list));
DCHECK_EQ(GetHiddenApiAccessFlags(), intrinsic_api_list);
}
diff --git a/runtime/art_method.h b/runtime/art_method.h
index 18ddcc0..e56f3fd 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -326,7 +326,7 @@
AddAccessFlags(kAccMustCountLocks);
}
- HiddenApiAccessFlags::ApiList GetHiddenApiAccessFlags() REQUIRES_SHARED(Locks::mutator_lock_);
+ hiddenapi::ApiList GetHiddenApiAccessFlags() REQUIRES_SHARED(Locks::mutator_lock_);
// Returns true if this method could be overridden by a default method.
bool IsOverridableByDefaultMethod() REQUIRES_SHARED(Locks::mutator_lock_);
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 032d9f3..151f7b8 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -90,6 +90,7 @@
#include "mirror/array-alloc-inl.h"
#include "mirror/array-inl.h"
#include "mirror/call_site.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class.h"
#include "mirror/class_ext.h"
@@ -105,6 +106,7 @@
#include "mirror/method_type.h"
#include "mirror/object-inl.h"
#include "mirror/object-refvisitor-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/object_reference.h"
#include "mirror/object_reference-inl.h"
@@ -3393,8 +3395,8 @@
// also set its runtime hidden API access flags.
uint32_t access_flags = field.GetAccessFlags();
if (klass->IsBootStrapClassLoaded()) {
- access_flags = HiddenApiAccessFlags::EncodeForRuntime(
- access_flags, static_cast<HiddenApiAccessFlags::ApiList>(field.GetHiddenapiFlags()));
+ access_flags = hiddenapi::EncodeForRuntime(
+ access_flags, static_cast<hiddenapi::ApiList>(field.GetHiddenapiFlags()));
}
dst->SetAccessFlags(access_flags);
}
@@ -3416,8 +3418,8 @@
// also set its runtime hidden API access flags.
uint32_t access_flags = method.GetAccessFlags();
if (klass->IsBootStrapClassLoaded()) {
- access_flags = HiddenApiAccessFlags::EncodeForRuntime(
- access_flags, static_cast<HiddenApiAccessFlags::ApiList>(method.GetHiddenapiFlags()));
+ access_flags = hiddenapi::EncodeForRuntime(
+ access_flags, static_cast<hiddenapi::ApiList>(method.GetHiddenapiFlags()));
}
if (UNLIKELY(strcmp("finalize", method_name) == 0)) {
diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc
index af71727..91636dc 100644
--- a/runtime/class_linker_test.cc
+++ b/runtime/class_linker_test.cc
@@ -46,6 +46,7 @@
#include "mirror/method_handles_lookup.h"
#include "mirror/method_type.h"
#include "mirror/object-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/proxy.h"
#include "mirror/reference.h"
diff --git a/runtime/class_table_test.cc b/runtime/class_table_test.cc
index fdf6ad1..2270662 100644
--- a/runtime/class_table_test.cc
+++ b/runtime/class_table_test.cc
@@ -24,7 +24,7 @@
#include "gc/accounting/card_table-inl.h"
#include "gc/heap.h"
#include "handle_scope-inl.h"
-#include "mirror/class-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "obj_ptr.h"
#include "scoped_thread_state_change-inl.h"
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index be39631..fcf6bb2 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -50,8 +50,10 @@
#include "interpreter/unstarted_runtime.h"
#include "jni/java_vm_ext.h"
#include "jni/jni_internal.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
+#include "mirror/object_array-alloc-inl.h"
#include "native/dalvik_system_DexFile.h"
#include "noop_compiler_callbacks.h"
#include "runtime-inl.h"
@@ -59,20 +61,6 @@
#include "thread.h"
#include "well_known_classes.h"
-int main(int argc, char **argv) {
- // Gtests can be very noisy. For example, an executable with multiple tests will trigger native
- // bridge warnings. The following line reduces the minimum log severity to ERROR and suppresses
- // everything else. In case you want to see all messages, comment out the line.
- setenv("ANDROID_LOG_TAGS", "*:e", 1);
-
- art::Locks::Init();
- art::InitLogging(argv, art::Runtime::Abort);
- art::MemMap::Init();
- LOG(INFO) << "Running main() from common_runtime_test.cc...";
- testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
namespace art {
using android::base::StringPrintf;
@@ -420,3 +408,26 @@
}
} // namespace art
+
+// Allow other test code to run global initialization/configuration before
+// gtest infra takes over.
+extern "C"
+__attribute__((visibility("default"))) __attribute__((weak))
+void ArtTestGlobalInit() {
+ LOG(ERROR) << "ArtTestGlobalInit in common_runtime_test";
+}
+
+int main(int argc, char **argv) {
+ // Gtests can be very noisy. For example, an executable with multiple tests will trigger native
+ // bridge warnings. The following line reduces the minimum log severity to ERROR and suppresses
+ // everything else. In case you want to see all messages, comment out the line.
+ setenv("ANDROID_LOG_TAGS", "*:e", 1);
+
+ art::Locks::Init();
+ art::InitLogging(argv, art::Runtime::Abort);
+ art::MemMap::Init();
+ LOG(INFO) << "Running main() from common_runtime_test.cc...";
+ testing::InitGoogleTest(&argc, argv);
+ ArtTestGlobalInit();
+ return RUN_ALL_TESTS();
+}
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index fcc5ce6..328a9bb 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -54,6 +54,7 @@
#include "jni/jni_internal.h"
#include "jvalue-inl.h"
#include "mirror/array-alloc-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class.h"
#include "mirror/class_loader.h"
diff --git a/runtime/dex/dex_file_annotations.cc b/runtime/dex/dex_file_annotations.cc
index 246cbca..1539867 100644
--- a/runtime/dex/dex_file_annotations.cc
+++ b/runtime/dex/dex_file_annotations.cc
@@ -28,8 +28,10 @@
#include "jni/jni_internal.h"
#include "jvalue-inl.h"
#include "mirror/array-alloc-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/field.h"
#include "mirror/method.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "oat_file.h"
#include "obj_ptr-inl.h"
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h
index b45bb59..0b005e0 100644
--- a/runtime/entrypoints/entrypoint_utils-inl.h
+++ b/runtime/entrypoints/entrypoint_utils-inl.h
@@ -33,6 +33,7 @@
#include "indirect_reference_table.h"
#include "jni/jni_internal.h"
#include "mirror/array-alloc-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/object-inl.h"
#include "mirror/throwable.h"
diff --git a/runtime/gc/allocation_record.cc b/runtime/gc/allocation_record.cc
index b9c1dc6..e11fa5c 100644
--- a/runtime/gc/allocation_record.cc
+++ b/runtime/gc/allocation_record.cc
@@ -24,9 +24,7 @@
#include "object_callbacks.h"
#include "stack.h"
-#ifdef ART_TARGET_ANDROID
-#include "cutils/properties.h"
-#endif
+#include <android-base/properties.h>
namespace art {
namespace gc {
@@ -45,10 +43,10 @@
#ifdef ART_TARGET_ANDROID
// Check whether there's a system property overriding the max number of records.
const char* propertyName = "dalvik.vm.allocTrackerMax";
- char allocMaxString[PROPERTY_VALUE_MAX];
- if (property_get(propertyName, allocMaxString, "") > 0) {
+ std::string allocMaxString = android::base::GetProperty(propertyName, "");
+ if (!allocMaxString.empty()) {
char* end;
- size_t value = strtoul(allocMaxString, &end, 10);
+ size_t value = strtoul(allocMaxString.c_str(), &end, 10);
if (*end != '\0') {
LOG(ERROR) << "Ignoring " << propertyName << " '" << allocMaxString
<< "' --- invalid";
@@ -61,10 +59,10 @@
}
// Check whether there's a system property overriding the number of recent records.
propertyName = "dalvik.vm.recentAllocMax";
- char recentAllocMaxString[PROPERTY_VALUE_MAX];
- if (property_get(propertyName, recentAllocMaxString, "") > 0) {
+ std::string recentAllocMaxString = android::base::GetProperty(propertyName, "");
+ if (!recentAllocMaxString.empty()) {
char* end;
- size_t value = strtoul(recentAllocMaxString, &end, 10);
+ size_t value = strtoul(recentAllocMaxString.c_str(), &end, 10);
if (*end != '\0') {
LOG(ERROR) << "Ignoring " << propertyName << " '" << recentAllocMaxString
<< "' --- invalid";
@@ -77,10 +75,10 @@
}
// Check whether there's a system property overriding the max depth of stack trace.
propertyName = "debug.allocTracker.stackDepth";
- char stackDepthString[PROPERTY_VALUE_MAX];
- if (property_get(propertyName, stackDepthString, "") > 0) {
+ std::string stackDepthString = android::base::GetProperty(propertyName, "");
+ if (!stackDepthString.empty()) {
char* end;
- size_t value = strtoul(stackDepthString, &end, 10);
+ size_t value = strtoul(stackDepthString.c_str(), &end, 10);
if (*end != '\0') {
LOG(ERROR) << "Ignoring " << propertyName << " '" << stackDepthString
<< "' --- invalid";
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index d728e7d..be1014c 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -1649,12 +1649,38 @@
inline void ConcurrentCopying::ProcessMarkStackRef(mirror::Object* to_ref) {
DCHECK(!region_space_->IsInFromSpace(to_ref));
- if (kUseBakerReadBarrier) {
- DCHECK(to_ref->GetReadBarrierState() == ReadBarrier::GrayState())
- << " " << to_ref << " " << to_ref->GetReadBarrierState()
- << " is_marked=" << IsMarked(to_ref);
- }
space::RegionSpace::RegionType rtype = region_space_->GetRegionType(to_ref);
+ auto find_space_from_ref = [this] (mirror::Object* ref)
+ REQUIRES_SHARED(Locks::mutator_lock_) -> space::Space* {
+ for (const auto& space : heap_->GetContinuousSpaces()) {
+ if (space->Contains(ref)) {
+ return space;
+ }
+ }
+ for (const auto& space : heap_->GetDiscontinuousSpaces()) {
+ if (space->Contains(ref)) {
+ return space;
+ }
+ }
+ return nullptr;
+ };
+ if (kUseBakerReadBarrier &&
+ kIsDebugBuild &&
+ to_ref->GetReadBarrierState() != ReadBarrier::GrayState()) {
+ space::Space* space = find_space_from_ref(to_ref);
+ LOG(FATAL_WITHOUT_ABORT) << " " << to_ref
+ << " " << to_ref->GetReadBarrierState()
+ << " is_marked=" << IsMarked(to_ref)
+ << " type=" << to_ref->PrettyTypeOf()
+ << " is_young_gc=" << young_gen_;
+ if (space == region_space_) {
+ LOG(FATAL) << " region_type=" << rtype;
+ } else if (space != nullptr) {
+ LOG(FATAL) << " space=" << space->GetName();
+ } else {
+ LOG(FATAL) << "no space";
+ }
+ }
bool add_to_live_bytes = false;
// Invariant: There should be no object from a newly-allocated
// region (either large or non-large) on the mark stack.
@@ -1689,10 +1715,22 @@
Scan<false>(to_ref);
}
}
- if (kUseBakerReadBarrier) {
- DCHECK(to_ref->GetReadBarrierState() == ReadBarrier::GrayState())
- << " " << to_ref << " " << to_ref->GetReadBarrierState()
- << " is_marked=" << IsMarked(to_ref);
+ if (kUseBakerReadBarrier &&
+ kIsDebugBuild &&
+ to_ref->GetReadBarrierState() != ReadBarrier::GrayState()) {
+ space::Space* space = find_space_from_ref(to_ref);
+ LOG(FATAL_WITHOUT_ABORT) << " " << to_ref
+ << " " << to_ref->GetReadBarrierState()
+ << " is_marked=" << IsMarked(to_ref)
+ << " type=" << to_ref->PrettyTypeOf()
+ << " is_young_gc=" << young_gen_;
+ if (space == region_space_) {
+ LOG(FATAL) << " region_type=" << rtype;
+ } else if (space != nullptr) {
+ LOG(FATAL) << " space=" << space->GetName();
+ } else {
+ LOG(FATAL) << "no space";
+ }
}
#ifdef USE_BAKER_OR_BROOKS_READ_BARRIER
mirror::Object* referent = nullptr;
diff --git a/runtime/gc/heap_test.cc b/runtime/gc/heap_test.cc
index 606228c..fa10150 100644
--- a/runtime/gc/heap_test.cc
+++ b/runtime/gc/heap_test.cc
@@ -21,6 +21,7 @@
#include "handle_scope-inl.h"
#include "mirror/class-inl.h"
#include "mirror/object-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "scoped_thread_state_change-inl.h"
diff --git a/runtime/gc/heap_verification_test.cc b/runtime/gc/heap_verification_test.cc
index 3754129..7835c29 100644
--- a/runtime/gc/heap_verification_test.cc
+++ b/runtime/gc/heap_verification_test.cc
@@ -21,6 +21,7 @@
#include "class_root.h"
#include "handle_scope-inl.h"
#include "mirror/object-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/string.h"
#include "runtime.h"
diff --git a/runtime/gc/reference_queue_test.cc b/runtime/gc/reference_queue_test.cc
index ce0807c..c680fb5 100644
--- a/runtime/gc/reference_queue_test.cc
+++ b/runtime/gc/reference_queue_test.cc
@@ -18,6 +18,7 @@
#include "common_runtime_test.h"
#include "handle_scope-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "reference_queue.h"
#include "scoped_thread_state_change-inl.h"
diff --git a/runtime/handle_scope_test.cc b/runtime/handle_scope_test.cc
index f888482..d72dbe6 100644
--- a/runtime/handle_scope_test.cc
+++ b/runtime/handle_scope_test.cc
@@ -22,6 +22,7 @@
#include "gtest/gtest.h"
#include "handle.h"
#include "handle_scope-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/object.h"
#include "scoped_thread_state_change-inl.h"
diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc
index 5729800..f355276 100644
--- a/runtime/hidden_api.cc
+++ b/runtime/hidden_api.cc
@@ -60,14 +60,14 @@
return os;
}
-static constexpr bool EnumsEqual(EnforcementPolicy policy, HiddenApiAccessFlags::ApiList apiList) {
+static constexpr bool EnumsEqual(EnforcementPolicy policy, hiddenapi::ApiList apiList) {
return static_cast<int>(policy) == static_cast<int>(apiList);
}
// GetMemberAction-related static_asserts.
static_assert(
- EnumsEqual(EnforcementPolicy::kDarkGreyAndBlackList, HiddenApiAccessFlags::kDarkGreylist) &&
- EnumsEqual(EnforcementPolicy::kBlacklistOnly, HiddenApiAccessFlags::kBlacklist),
+ EnumsEqual(EnforcementPolicy::kDarkGreyAndBlackList, hiddenapi::ApiList::kDarkGreylist) &&
+ EnumsEqual(EnforcementPolicy::kBlacklistOnly, hiddenapi::ApiList::kBlacklist),
"Mismatch between EnforcementPolicy and ApiList enums");
static_assert(
EnforcementPolicy::kJustWarn < EnforcementPolicy::kDarkGreyAndBlackList &&
@@ -133,8 +133,7 @@
}
}
-void MemberSignature::WarnAboutAccess(AccessMethod access_method,
- HiddenApiAccessFlags::ApiList list) {
+void MemberSignature::WarnAboutAccess(AccessMethod access_method, hiddenapi::ApiList list) {
LOG(WARNING) << "Accessing hidden " << (type_ == kField ? "field " : "method ")
<< Dumpable<MemberSignature>(*this) << " (" << list << ", " << access_method << ")";
}
@@ -200,14 +199,14 @@
static ALWAYS_INLINE void MaybeWhitelistMember(Runtime* runtime, T* member)
REQUIRES_SHARED(Locks::mutator_lock_) {
if (CanUpdateMemberAccessFlags(member) && runtime->ShouldDedupeHiddenApiWarnings()) {
- member->SetAccessFlags(HiddenApiAccessFlags::EncodeForRuntime(
- member->GetAccessFlags(), HiddenApiAccessFlags::kWhitelist));
+ member->SetAccessFlags(hiddenapi::EncodeForRuntime(
+ member->GetAccessFlags(), hiddenapi::ApiList::kWhitelist));
}
}
template<typename T>
Action GetMemberActionImpl(T* member,
- HiddenApiAccessFlags::ApiList api_list,
+ hiddenapi::ApiList api_list,
Action action,
AccessMethod access_method) {
DCHECK_NE(action, kAllow);
@@ -276,11 +275,11 @@
// Need to instantiate this.
template Action GetMemberActionImpl<ArtField>(ArtField* member,
- HiddenApiAccessFlags::ApiList api_list,
+ hiddenapi::ApiList api_list,
Action action,
AccessMethod access_method);
template Action GetMemberActionImpl<ArtMethod>(ArtMethod* member,
- HiddenApiAccessFlags::ApiList api_list,
+ hiddenapi::ApiList api_list,
Action action,
AccessMethod access_method);
} // namespace detail
diff --git a/runtime/hidden_api.h b/runtime/hidden_api.h
index c16e7f3..57f1a59 100644
--- a/runtime/hidden_api.h
+++ b/runtime/hidden_api.h
@@ -68,8 +68,8 @@
kAccessDenied = 1 << 1,
};
-inline Action GetActionFromAccessFlags(HiddenApiAccessFlags::ApiList api_list) {
- if (api_list == HiddenApiAccessFlags::kWhitelist) {
+inline Action GetActionFromAccessFlags(ApiList api_list) {
+ if (api_list == ApiList::kWhitelist) {
return kAllow;
}
@@ -85,9 +85,9 @@
}
DCHECK(policy >= EnforcementPolicy::kDarkGreyAndBlackList);
// The logic below relies on equality of values in the enums EnforcementPolicy and
- // HiddenApiAccessFlags::ApiList, and their ordering. Assertions are in hidden_api.cc.
+ // ApiList, and their ordering. Assertions are in hidden_api.cc.
if (static_cast<int>(policy) > static_cast<int>(api_list)) {
- return api_list == HiddenApiAccessFlags::kDarkGreylist
+ return api_list == ApiList::kDarkGreylist
? kAllowButWarnAndToast
: kAllowButWarn;
} else {
@@ -144,14 +144,14 @@
bool IsExempted(const std::vector<std::string>& exemptions);
- void WarnAboutAccess(AccessMethod access_method, HiddenApiAccessFlags::ApiList list);
+ void WarnAboutAccess(AccessMethod access_method, ApiList list);
void LogAccessToEventLog(AccessMethod access_method, Action action_taken);
};
template<typename T>
Action GetMemberActionImpl(T* member,
- HiddenApiAccessFlags::ApiList api_list,
+ ApiList api_list,
Action action,
AccessMethod access_method)
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -208,7 +208,7 @@
// cannot change Java semantics. We should, however, decode the access flags
// once and use it throughout this function, otherwise we may get inconsistent
// results, e.g. print whitelist warnings (b/78327881).
- HiddenApiAccessFlags::ApiList api_list = member->GetHiddenApiAccessFlags();
+ ApiList api_list = member->GetHiddenApiAccessFlags();
Action action = GetActionFromAccessFlags(member->GetHiddenApiAccessFlags());
if (action == kAllow) {
diff --git a/runtime/hidden_api_test.cc b/runtime/hidden_api_test.cc
index 4c7efe6..1727af0 100644
--- a/runtime/hidden_api_test.cc
+++ b/runtime/hidden_api_test.cc
@@ -89,39 +89,39 @@
TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) {
runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kNoChecks);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kWhitelist), hiddenapi::kAllow);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kLightGreylist), hiddenapi::kAllow);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kDarkGreylist), hiddenapi::kAllow);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kBlacklist), hiddenapi::kAllow);
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kWhitelist), hiddenapi::kAllow);
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kLightGreylist), hiddenapi::kAllow);
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kDarkGreylist), hiddenapi::kAllow);
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kBlacklist), hiddenapi::kAllow);
runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kJustWarn);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kWhitelist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kWhitelist),
hiddenapi::kAllow);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kLightGreylist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kLightGreylist),
hiddenapi::kAllowButWarn);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kDarkGreylist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kDarkGreylist),
hiddenapi::kAllowButWarn);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kBlacklist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kBlacklist),
hiddenapi::kAllowButWarn);
runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kDarkGreyAndBlackList);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kWhitelist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kWhitelist),
hiddenapi::kAllow);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kLightGreylist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kLightGreylist),
hiddenapi::kAllowButWarn);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kDarkGreylist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kDarkGreylist),
hiddenapi::kDeny);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kBlacklist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kBlacklist),
hiddenapi::kDeny);
runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kBlacklistOnly);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kWhitelist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kWhitelist),
hiddenapi::kAllow);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kLightGreylist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kLightGreylist),
hiddenapi::kAllowButWarn);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kDarkGreylist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kDarkGreylist),
hiddenapi::kAllowButWarnAndToast);
- ASSERT_EQ(GetActionFromAccessFlags(HiddenApiAccessFlags::kBlacklist),
+ ASSERT_EQ(GetActionFromAccessFlags(hiddenapi::ApiList::kBlacklist),
hiddenapi::kDeny);
}
diff --git a/runtime/indirect_reference_table_test.cc b/runtime/indirect_reference_table_test.cc
index 141feb4..c5ae4c6 100644
--- a/runtime/indirect_reference_table_test.cc
+++ b/runtime/indirect_reference_table_test.cc
@@ -20,6 +20,7 @@
#include "class_linker-inl.h"
#include "common_runtime_test.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/object-inl.h"
#include "scoped_thread_state_change-inl.h"
diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h
index b3fae25..3bd4fb5 100644
--- a/runtime/instrumentation.h
+++ b/runtime/instrumentation.h
@@ -384,15 +384,6 @@
have_exception_handled_listeners_;
}
- // Any instrumentation *other* than what is needed for Jit profiling active?
- bool NonJitProfilingActive() const REQUIRES_SHARED(Locks::mutator_lock_) {
- return have_dex_pc_listeners_ || have_method_exit_listeners_ ||
- have_field_read_listeners_ || have_field_write_listeners_ ||
- have_exception_thrown_listeners_ || have_method_unwind_listeners_ ||
- have_branch_listeners_ || have_watched_frame_pop_listeners_ ||
- have_exception_handled_listeners_;
- }
-
// Inform listeners that a method has been entered. A dex PC is provided as we may install
// listeners into executing code and get method enter events for methods already on the stack.
void MethodEnterEvent(Thread* thread, mirror::Object* this_object,
diff --git a/runtime/intern_table.cc b/runtime/intern_table.cc
index 6fbfbdd..2449121 100644
--- a/runtime/intern_table.cc
+++ b/runtime/intern_table.cc
@@ -23,6 +23,7 @@
#include "gc/space/image_space.h"
#include "gc/weak_root_state.h"
#include "gc_root-inl.h"
+#include "handle_scope-inl.h"
#include "image-inl.h"
#include "mirror/dex_cache-inl.h"
#include "mirror/object-inl.h"
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc
index b37a278..5784b9b 100644
--- a/runtime/interpreter/interpreter.cc
+++ b/runtime/interpreter/interpreter.cc
@@ -248,6 +248,14 @@
bool from_deoptimize = false) REQUIRES_SHARED(Locks::mutator_lock_) {
DCHECK(!shadow_frame.GetMethod()->IsAbstract());
DCHECK(!shadow_frame.GetMethod()->IsNative());
+
+ // Check that we are using the right interpreter.
+ if (kIsDebugBuild && self->UseMterp() != CanUseMterp()) {
+ // The flag might be currently being updated on all threads. Retry with lock.
+ MutexLock tll_mu(self, *Locks::thread_list_lock_);
+ DCHECK_EQ(self->UseMterp(), CanUseMterp());
+ }
+
if (LIKELY(!from_deoptimize)) { // Entering the method, but not via deoptimization.
if (kIsDebugBuild) {
CHECK_EQ(shadow_frame.GetDexPC(), 0u);
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index 9857249..d5902ec 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -34,6 +34,8 @@
#include "mirror/class.h"
#include "mirror/emulated_stack_frame.h"
#include "mirror/method_handle_impl-inl.h"
+#include "mirror/object_array-alloc-inl.h"
+#include "mirror/object_array-inl.h"
#include "mirror/var_handle.h"
#include "reflection-inl.h"
#include "reflection.h"
diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h
index 96588c8..9f4403e 100644
--- a/runtime/interpreter/interpreter_common.h
+++ b/runtime/interpreter/interpreter_common.h
@@ -128,10 +128,8 @@
static ALWAYS_INLINE bool UseInterpreterToInterpreterFastPath(ArtMethod* method)
REQUIRES_SHARED(Locks::mutator_lock_) {
Runtime* runtime = Runtime::Current();
- if (!runtime->IsStarted()) {
- return false;
- }
const void* quick_code = method->GetEntryPointFromQuickCompiledCode();
+ DCHECK(runtime->IsStarted());
if (!runtime->GetClassLinker()->IsQuickToInterpreterBridge(quick_code)) {
return false;
}
@@ -144,16 +142,11 @@
if (type == kStatic && !method->GetDeclaringClass()->IsInitialized()) {
return false;
}
- if (runtime->IsActiveTransaction() || runtime->GetInstrumentation()->HasMethodEntryListeners()) {
- return false;
- }
+ DCHECK(!runtime->IsActiveTransaction());
ProfilingInfo* profiling_info = method->GetProfilingInfo(kRuntimePointerSize);
if ((profiling_info != nullptr) && (profiling_info->GetSavedEntryPoint() != nullptr)) {
return false;
}
- if (runtime->GetJit() != nullptr && runtime->GetJit()->JitAtFirstUse()) {
- return false;
- }
return true;
}
@@ -171,7 +164,9 @@
JValue* result)
REQUIRES_SHARED(Locks::mutator_lock_) {
// Make sure to check for async exceptions before anything else.
- if (UNLIKELY(self->ObserveAsyncException())) {
+ if (is_mterp && self->UseMterp()) {
+ DCHECK(!self->ObserveAsyncException());
+ } else if (UNLIKELY(self->ObserveAsyncException())) {
return false;
}
const uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c();
@@ -229,7 +224,7 @@
}
}
- if (is_mterp && UseInterpreterToInterpreterFastPath<type>(called_method)) {
+ if (is_mterp && self->UseMterp() && UseInterpreterToInterpreterFastPath<type>(called_method)) {
const uint16_t number_of_inputs =
(is_range) ? inst->VRegA_3rc(inst_data) : inst->VRegA_35c(inst_data);
CodeItemDataAccessor accessor(called_method->DexInstructionData());
@@ -242,6 +237,10 @@
return false;
}
+ if (jit != nullptr) {
+ jit->AddSamples(self, called_method, 1, /* with_backedges */false);
+ }
+
// Create shadow frame on the stack.
const char* old_cause = self->StartAssertNoThreadSuspension("DoFastInvoke");
ShadowFrameAllocaUniquePtr shadow_frame_unique_ptr =
@@ -261,13 +260,9 @@
*new_shadow_frame->GetShadowRefAddr(dst) = *shadow_frame.GetShadowRefAddr(arg[i]);
}
}
+ self->PushShadowFrame(new_shadow_frame);
self->EndAssertNoThreadSuspension(old_cause);
- if (jit != nullptr) {
- jit->AddSamples(self, called_method, 1, /* with_backedges */false);
- }
-
- self->PushShadowFrame(new_shadow_frame);
DCheckStaticState(self, called_method);
while (true) {
// Mterp does not support all instrumentation/debugging.
diff --git a/runtime/interpreter/interpreter_switch_impl-inl.h b/runtime/interpreter/interpreter_switch_impl-inl.h
index 4774d69..c430de2 100644
--- a/runtime/interpreter/interpreter_switch_impl-inl.h
+++ b/runtime/interpreter/interpreter_switch_impl-inl.h
@@ -36,7 +36,7 @@
namespace interpreter {
#define CHECK_FORCE_RETURN() \
- do { \
+ { \
if (UNLIKELY(shadow_frame.GetForcePopFrame())) { \
DCHECK(PrevFrameWillRetry(self, shadow_frame)) \
<< "Pop frame forced without previous frame ready to retry instruction!"; \
@@ -53,10 +53,11 @@
ctx->result = JValue(); /* Handled in caller. */ \
return; \
} \
- } while (false)
+ } \
+ do {} while (false)
#define HANDLE_PENDING_EXCEPTION_WITH_INSTRUMENTATION(instr) \
- do { \
+ { \
DCHECK(self->IsExceptionPending()); \
self->AllowThreadSuspension(); \
CHECK_FORCE_RETURN(); \
@@ -74,13 +75,15 @@
int32_t displacement = \
static_cast<int32_t>(shadow_frame.GetDexPC()) - static_cast<int32_t>(dex_pc); \
inst = inst->RelativeAt(displacement); \
+ break; /* Stop executing this opcode and continue in the exception handler. */ \
} \
- } while (false)
+ } \
+ do {} while (false)
#define HANDLE_PENDING_EXCEPTION() HANDLE_PENDING_EXCEPTION_WITH_INSTRUMENTATION(instrumentation)
#define POSSIBLY_HANDLE_PENDING_EXCEPTION_ON_INVOKE_IMPL(_is_exception_pending, _next_function) \
- do { \
+ { \
if (UNLIKELY(shadow_frame.GetForceRetryInstruction())) { \
/* Don't need to do anything except clear the flag and exception. We leave the */ \
/* instruction the same so it will be re-executed on the next go-around. */ \
@@ -101,7 +104,8 @@
} else { \
inst = inst->_next_function(); \
} \
- } while (false)
+ } \
+ do {} while (false)
#define POSSIBLY_HANDLE_PENDING_EXCEPTION_ON_INVOKE_POLYMORPHIC(_is_exception_pending) \
POSSIBLY_HANDLE_PENDING_EXCEPTION_ON_INVOKE_IMPL(_is_exception_pending, Next_4xx)
@@ -109,7 +113,7 @@
POSSIBLY_HANDLE_PENDING_EXCEPTION_ON_INVOKE_IMPL(_is_exception_pending, Next_3xx)
#define POSSIBLY_HANDLE_PENDING_EXCEPTION(_is_exception_pending, _next_function) \
- do { \
+ { \
/* Should only be on invoke instructions. */ \
DCHECK(!shadow_frame.GetForceRetryInstruction()); \
if (UNLIKELY(_is_exception_pending)) { \
@@ -117,7 +121,8 @@
} else { \
inst = inst->_next_function(); \
} \
- } while (false)
+ } \
+ do {} while (false)
#define HANDLE_MONITOR_CHECKS() \
if (!DoMonitorCheckOnExit<do_assignability_check>(self, &shadow_frame)) { \
@@ -148,7 +153,7 @@
#define PREAMBLE() PREAMBLE_SAVE(nullptr)
#define BRANCH_INSTRUMENTATION(offset) \
- do { \
+ { \
if (UNLIKELY(instrumentation->HasBranchListeners())) { \
instrumentation->Branch(self, shadow_frame.GetMethod(), dex_pc, offset); \
} \
@@ -165,31 +170,33 @@
ctx->result = result; \
return; \
} \
- } while (false)
+ } \
+ do {} while (false)
#define HOTNESS_UPDATE() \
- do { \
+ { \
if (jit != nullptr) { \
jit->AddSamples(self, shadow_frame.GetMethod(), 1, /*with_backedges=*/ true); \
} \
- } while (false)
+ } \
+ do {} while (false)
#define HANDLE_ASYNC_EXCEPTION() \
if (UNLIKELY(self->ObserveAsyncException())) { \
HANDLE_PENDING_EXCEPTION(); \
- break; \
} \
do {} while (false)
#define HANDLE_BACKWARD_BRANCH(offset) \
- do { \
+ { \
if (IsBackwardBranch(offset)) { \
HOTNESS_UPDATE(); \
/* Record new dex pc early to have consistent suspend point at loop header. */ \
shadow_frame.SetDexPC(inst->GetDexPc(insns)); \
self->AllowThreadSuspension(); \
} \
- } while (false)
+ } \
+ do {} while (false)
// Unlike most other events the DexPcMovedEvent can be sent when there is a pending exception (if
// the next instruction is MOVE_EXCEPTION). This means it needs to be handled carefully to be able
diff --git a/runtime/interpreter/mterp/arm/arithmetic.S b/runtime/interpreter/mterp/arm/arithmetic.S
index 6413b63..7a373c7 100644
--- a/runtime/interpreter/mterp/arm/arithmetic.S
+++ b/runtime/interpreter/mterp/arm/arithmetic.S
@@ -234,7 +234,7 @@
* that specifies an instruction that performs "result = op r0/r1", where
* "result" is a 32-bit quantity in r0.
*
- * For: long-to-float, double-to-int, double-to-float
+ * For: long-to-float
*
* (This would work for long-to-int, but that instruction is actually
* an exact match for op_move.)
diff --git a/runtime/interpreter/mterp/arm/floating_point.S b/runtime/interpreter/mterp/arm/floating_point.S
index 6bf54e8..21c386e 100644
--- a/runtime/interpreter/mterp/arm/floating_point.S
+++ b/runtime/interpreter/mterp/arm/floating_point.S
@@ -19,8 +19,7 @@
FETCH_ADVANCE_INST 2 @ advance rPC, load rINST
$instr @ s2<- op
GET_INST_OPCODE ip @ extract opcode from rINST
- VREG_INDEX_TO_ADDR r9, r9 @ r9<- &vAA
- fsts s2, [r9] @ vAA<- s2
+ SET_VREG_FLOAT s2, r9, lr @ vAA<- s2
GOTO_OPCODE ip @ jump to next instruction
%def fbinop2addr(instr=""):
@@ -41,7 +40,7 @@
flds s0, [r9] @ s0<- vA
$instr @ s2<- op
GET_INST_OPCODE ip @ extract opcode from rINST
- fsts s2, [r9] @ vAA<- s2
+ fsts s2, [r9] @ vAA<- s2 No need to clear as it's 2addr
GOTO_OPCODE ip @ jump to next instruction
%def fbinopWide(instr=""):
@@ -107,8 +106,7 @@
FETCH_ADVANCE_INST 1 @ advance rPC, load rINST
$instr @ s1<- op
GET_INST_OPCODE ip @ extract opcode from rINST
- VREG_INDEX_TO_ADDR r9, r9 @ r9<- &vA
- fsts s1, [r9] @ vA<- s1
+ SET_VREG_FLOAT s1, r9, lr @ vA<- s1
GOTO_OPCODE ip @ jump to next instruction
%def funopNarrower(instr=""):
@@ -126,8 +124,7 @@
FETCH_ADVANCE_INST 1 @ advance rPC, load rINST
$instr @ s0<- op
GET_INST_OPCODE ip @ extract opcode from rINST
- VREG_INDEX_TO_ADDR r9, r9 @ r9<- &vA
- fsts s0, [r9] @ vA<- s0
+ SET_VREG_FLOAT s0, r9, lr @ vA<- s0
GOTO_OPCODE ip @ jump to next instruction
%def funopWider(instr=""):
diff --git a/runtime/interpreter/mterp/arm/main.S b/runtime/interpreter/mterp/arm/main.S
index a9cffe7..6d6b190 100644
--- a/runtime/interpreter/mterp/arm/main.S
+++ b/runtime/interpreter/mterp/arm/main.S
@@ -274,6 +274,12 @@
.macro SET_VREG_SHADOW reg, vreg
str \reg, [rREFS, \vreg, lsl #2]
.endm
+.macro SET_VREG_FLOAT reg, vreg, tmpreg
+ add \tmpreg, rFP, \vreg, lsl #2
+ fsts \reg, [\tmpreg]
+ mov \tmpreg, #0
+ str \tmpreg, [rREFS, \vreg, lsl #2]
+.endm
/*
* Clear the corresponding shadow regs for a vreg pair
diff --git a/runtime/interpreter/mterp/mterp.cc b/runtime/interpreter/mterp/mterp.cc
index 4b6f430..ba109bc 100644
--- a/runtime/interpreter/mterp/mterp.cc
+++ b/runtime/interpreter/mterp/mterp.cc
@@ -146,15 +146,18 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
const Runtime* const runtime = Runtime::Current();
return
+ runtime->IsStarted() &&
+ !runtime->IsAotCompiler() &&
!Dbg::IsDebuggerActive() &&
- !runtime->GetInstrumentation()->NonJitProfilingActive() &&
+ !runtime->GetInstrumentation()->IsActive() &&
// mterp only knows how to deal with the normal exits. It cannot handle any of the
// non-standard force-returns.
!runtime->AreNonStandardExitsEnabled() &&
// An async exception has been thrown. We need to go to the switch interpreter. MTerp doesn't
// know how to deal with these so we could end up never dealing with it if we are in an
// infinite loop.
- !runtime->AreAsyncExceptionsThrown();
+ !runtime->AreAsyncExceptionsThrown() &&
+ (runtime->GetJit() == nullptr || !runtime->GetJit()->JitAtFirstUse());
}
@@ -560,6 +563,7 @@
MutexLock tll_mu(self, *Locks::thread_list_lock_);
DCHECK_EQ(self->UseMterp(), CanUseMterp());
}
+ DCHECK(!Runtime::Current()->IsActiveTransaction());
const Instruction* inst = Instruction::At(dex_pc_ptr);
uint16_t inst_data = inst->Fetch16(0);
if (inst->Opcode(inst_data) == Instruction::MOVE_EXCEPTION) {
diff --git a/runtime/interpreter/shadow_frame.h b/runtime/interpreter/shadow_frame.h
index c0920a8..6609021 100644
--- a/runtime/interpreter/shadow_frame.h
+++ b/runtime/interpreter/shadow_frame.h
@@ -375,6 +375,17 @@
UpdateFrameFlag(enable, FrameFlags::kForceRetryInst);
}
+ void CheckConsistentVRegs() const {
+ if (kIsDebugBuild) {
+ // A shadow frame visible to GC requires the following rule: for a given vreg,
+ // its vreg reference equivalent should be the same, or null.
+ for (uint32_t i = 0; i < NumberOfVRegs(); ++i) {
+ int32_t reference_value = References()[i].AsVRegValue();
+ CHECK((GetVReg(i) == reference_value) || (reference_value == 0));
+ }
+ }
+ }
+
private:
ShadowFrame(uint32_t num_vregs, ShadowFrame* link, ArtMethod* method,
uint32_t dex_pc, bool has_reference_array)
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc
index eae3fbc..5def395 100644
--- a/runtime/interpreter/unstarted_runtime.cc
+++ b/runtime/interpreter/unstarted_runtime.cc
@@ -46,10 +46,11 @@
#include "jvalue-inl.h"
#include "mirror/array-alloc-inl.h"
#include "mirror/array-inl.h"
-#include "mirror/class.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/field-inl.h"
#include "mirror/method.h"
#include "mirror/object-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/string-inl.h"
#include "nativehelper/scoped_local_ref.h"
diff --git a/runtime/interpreter/unstarted_runtime_test.cc b/runtime/interpreter/unstarted_runtime_test.cc
index 727c5f3..a8ee23a 100644
--- a/runtime/interpreter/unstarted_runtime_test.cc
+++ b/runtime/interpreter/unstarted_runtime_test.cc
@@ -31,8 +31,10 @@
#include "handle_scope-inl.h"
#include "interpreter/interpreter_common.h"
#include "mirror/array-alloc-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class_loader.h"
#include "mirror/object-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/string-inl.h"
#include "runtime.h"
diff --git a/runtime/jdwp/jdwp_adb.cc b/runtime/jdwp/jdwp_adb.cc
index 9245f1e..d64f11f 100644
--- a/runtime/jdwp/jdwp_adb.cc
+++ b/runtime/jdwp/jdwp_adb.cc
@@ -23,13 +23,10 @@
#include "android-base/stringprintf.h"
#include "base/logging.h" // For VLOG.
+#include "base/socket_peer_is_trusted.h"
#include "jdwp/jdwp_priv.h"
#include "thread-current-inl.h"
-#ifdef ART_TARGET_ANDROID
-#include "cutils/sockets.h"
-#endif
-
/*
* The JDWP <-> ADB transport protocol is explained in detail
* in system/core/adb/jdwp_service.c. Here's a summary.
@@ -265,7 +262,7 @@
if (!ret) {
int control_sock = ControlSock();
#ifdef ART_TARGET_ANDROID
- if (control_sock < 0 || !socket_peer_is_trusted(control_sock)) {
+ if (control_sock < 0 || !art::SocketPeerIsTrusted(control_sock)) {
if (control_sock >= 0 && shutdown(control_sock, SHUT_RDWR)) {
PLOG(ERROR) << "trouble shutting down socket";
}
diff --git a/runtime/jni/jni_internal.cc b/runtime/jni/jni_internal.cc
index 52509fd..b07d2c2 100644
--- a/runtime/jni/jni_internal.cc
+++ b/runtime/jni/jni_internal.cc
@@ -45,11 +45,13 @@
#include "java_vm_ext.h"
#include "jni_env_ext.h"
#include "jvalue-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
#include "mirror/field-inl.h"
#include "mirror/method.h"
#include "mirror/object-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/string-inl.h"
#include "mirror/throwable.h"
diff --git a/runtime/method_handles_test.cc b/runtime/method_handles_test.cc
index d123754..6a7eb8c 100644
--- a/runtime/method_handles_test.cc
+++ b/runtime/method_handles_test.cc
@@ -22,6 +22,7 @@
#include "handle_scope-inl.h"
#include "jvalue-inl.h"
#include "mirror/method_type.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "reflection.h"
#include "scoped_thread_state_change-inl.h"
diff --git a/runtime/mirror/array.cc b/runtime/mirror/array.cc
index e67c713..05e397d 100644
--- a/runtime/mirror/array.cc
+++ b/runtime/mirror/array.cc
@@ -27,6 +27,7 @@
#include "gc/accounting/card_table-inl.h"
#include "handle_scope-inl.h"
#include "object-inl.h"
+#include "object_array-alloc-inl.h"
#include "object_array-inl.h"
#include "thread.h"
diff --git a/runtime/mirror/call_site.cc b/runtime/mirror/call_site.cc
index 738106c..7a23940 100644
--- a/runtime/mirror/call_site.cc
+++ b/runtime/mirror/call_site.cc
@@ -16,7 +16,7 @@
#include "call_site.h"
-#include "class-inl.h"
+#include "class-alloc-inl.h"
#include "class_root.h"
#include "obj_ptr-inl.h"
diff --git a/runtime/mirror/class-alloc-inl.h b/runtime/mirror/class-alloc-inl.h
new file mode 100644
index 0000000..d4a532e
--- /dev/null
+++ b/runtime/mirror/class-alloc-inl.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2011 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_RUNTIME_MIRROR_CLASS_ALLOC_INL_H_
+#define ART_RUNTIME_MIRROR_CLASS_ALLOC_INL_H_
+
+#include "class-inl.h"
+
+#include "gc/heap-inl.h"
+#include "object-inl.h"
+#include "runtime.h"
+
+namespace art {
+namespace mirror {
+
+inline void Class::CheckObjectAlloc() {
+ DCHECK(!IsArrayClass())
+ << PrettyClass()
+ << "A array shouldn't be allocated through this "
+ << "as it requires a pre-fence visitor that sets the class size.";
+ DCHECK(!IsClassClass())
+ << PrettyClass()
+ << "A class object shouldn't be allocated through this "
+ << "as it requires a pre-fence visitor that sets the class size.";
+ DCHECK(!IsStringClass())
+ << PrettyClass()
+ << "A string shouldn't be allocated through this "
+ << "as it requires a pre-fence visitor that sets the class size.";
+ DCHECK(IsInstantiable()) << PrettyClass();
+ // TODO: decide whether we want this check. It currently fails during bootstrap.
+ // DCHECK(!Runtime::Current()->IsStarted() || IsInitializing()) << PrettyClass();
+ DCHECK_GE(this->object_size_, sizeof(Object));
+}
+
+template<bool kIsInstrumented, bool kCheckAddFinalizer>
+inline ObjPtr<Object> Class::Alloc(Thread* self, gc::AllocatorType allocator_type) {
+ CheckObjectAlloc();
+ gc::Heap* heap = Runtime::Current()->GetHeap();
+ const bool add_finalizer = kCheckAddFinalizer && IsFinalizable();
+ if (!kCheckAddFinalizer) {
+ DCHECK(!IsFinalizable());
+ }
+ // Note that the this pointer may be invalidated after the allocation.
+ ObjPtr<Object> obj =
+ heap->AllocObjectWithAllocator<kIsInstrumented, false>(self,
+ this,
+ this->object_size_,
+ allocator_type,
+ VoidFunctor());
+ if (add_finalizer && LIKELY(obj != nullptr)) {
+ heap->AddFinalizerReference(self, &obj);
+ if (UNLIKELY(self->IsExceptionPending())) {
+ // Failed to allocate finalizer reference, it means that the whole allocation failed.
+ obj = nullptr;
+ }
+ }
+ return obj;
+}
+
+inline ObjPtr<Object> Class::AllocObject(Thread* self) {
+ return Alloc<true>(self, Runtime::Current()->GetHeap()->GetCurrentAllocator());
+}
+
+inline ObjPtr<Object> Class::AllocNonMovableObject(Thread* self) {
+ return Alloc<true>(self, Runtime::Current()->GetHeap()->GetCurrentNonMovingAllocator());
+}
+
+} // namespace mirror
+} // namespace art
+
+#endif // ART_RUNTIME_MIRROR_CLASS_ALLOC_INL_H_
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 50b1b90..9a4130d 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -30,7 +30,6 @@
#include "dex/dex_file-inl.h"
#include "dex/invoke_type.h"
#include "dex_cache.h"
-#include "gc/heap-inl.h"
#include "iftable.h"
#include "object-inl.h"
#include "object_array.h"
@@ -752,58 +751,6 @@
return size_shift;
}
-inline void Class::CheckObjectAlloc() {
- DCHECK(!IsArrayClass())
- << PrettyClass()
- << "A array shouldn't be allocated through this "
- << "as it requires a pre-fence visitor that sets the class size.";
- DCHECK(!IsClassClass())
- << PrettyClass()
- << "A class object shouldn't be allocated through this "
- << "as it requires a pre-fence visitor that sets the class size.";
- DCHECK(!IsStringClass())
- << PrettyClass()
- << "A string shouldn't be allocated through this "
- << "as it requires a pre-fence visitor that sets the class size.";
- DCHECK(IsInstantiable()) << PrettyClass();
- // TODO: decide whether we want this check. It currently fails during bootstrap.
- // DCHECK(!Runtime::Current()->IsStarted() || IsInitializing()) << PrettyClass();
- DCHECK_GE(this->object_size_, sizeof(Object));
-}
-
-template<bool kIsInstrumented, bool kCheckAddFinalizer>
-inline ObjPtr<Object> Class::Alloc(Thread* self, gc::AllocatorType allocator_type) {
- CheckObjectAlloc();
- gc::Heap* heap = Runtime::Current()->GetHeap();
- const bool add_finalizer = kCheckAddFinalizer && IsFinalizable();
- if (!kCheckAddFinalizer) {
- DCHECK(!IsFinalizable());
- }
- // Note that the this pointer may be invalidated after the allocation.
- ObjPtr<Object> obj =
- heap->AllocObjectWithAllocator<kIsInstrumented, false>(self,
- this,
- this->object_size_,
- allocator_type,
- VoidFunctor());
- if (add_finalizer && LIKELY(obj != nullptr)) {
- heap->AddFinalizerReference(self, &obj);
- if (UNLIKELY(self->IsExceptionPending())) {
- // Failed to allocate finalizer reference, it means that the whole allocation failed.
- obj = nullptr;
- }
- }
- return obj;
-}
-
-inline ObjPtr<Object> Class::AllocObject(Thread* self) {
- return Alloc<true>(self, Runtime::Current()->GetHeap()->GetCurrentAllocator());
-}
-
-inline ObjPtr<Object> Class::AllocNonMovableObject(Thread* self) {
- return Alloc<true>(self, Runtime::Current()->GetHeap()->GetCurrentNonMovingAllocator());
-}
-
inline uint32_t Class::ComputeClassSize(bool has_embedded_vtable,
uint32_t num_vtable_entries,
uint32_t num_8bit_static_fields,
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index 6a378f0..e655052 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -32,6 +32,7 @@
#include "dex/dex_file_annotations.h"
#include "dex_cache.h"
#include "gc/accounting/card_table-inl.h"
+#include "gc/heap-inl.h"
#include "handle_scope-inl.h"
#include "subtype_check.h"
#include "method.h"
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index cbe377e..74fca54 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -34,7 +34,7 @@
#include "object.h"
#include "object_array.h"
#include "read_barrier_option.h"
-#include "thread.h"
+#include "thread-current-inl.h"
namespace art {
diff --git a/runtime/mirror/class_ext.cc b/runtime/mirror/class_ext.cc
index 44bf989..6712630 100644
--- a/runtime/mirror/class_ext.cc
+++ b/runtime/mirror/class_ext.cc
@@ -20,12 +20,14 @@
#include "base/casts.h"
#include "base/enums.h"
#include "base/utils.h"
+#include "class-alloc-inl.h"
#include "class-inl.h"
#include "class_root.h"
#include "dex/dex_file-inl.h"
#include "gc/accounting/card_table-inl.h"
#include "object-inl.h"
-#include "object_array.h"
+#include "object_array-alloc-inl.h"
+#include "object_array-inl.h"
#include "stack_trace_element.h"
#include "well_known_classes.h"
diff --git a/runtime/mirror/emulated_stack_frame.cc b/runtime/mirror/emulated_stack_frame.cc
index a1c536b..001469c 100644
--- a/runtime/mirror/emulated_stack_frame.cc
+++ b/runtime/mirror/emulated_stack_frame.cc
@@ -18,11 +18,13 @@
#include "array-alloc-inl.h"
#include "array-inl.h"
-#include "class-inl.h"
+#include "class-alloc-inl.h"
#include "class_root.h"
#include "jvalue-inl.h"
#include "method_handles-inl.h"
#include "method_handles.h"
+#include "object_array-alloc-inl.h"
+#include "object_array-inl.h"
#include "reflection-inl.h"
namespace art {
diff --git a/runtime/mirror/field-inl.h b/runtime/mirror/field-inl.h
index 2e263b9..803b880 100644
--- a/runtime/mirror/field-inl.h
+++ b/runtime/mirror/field-inl.h
@@ -20,7 +20,7 @@
#include "field.h"
#include "art_field-inl.h"
-#include "class-inl.h"
+#include "class-alloc-inl.h"
#include "class_root.h"
#include "dex_cache-inl.h"
diff --git a/runtime/mirror/method.cc b/runtime/mirror/method.cc
index 910a1fc..d7a1225 100644
--- a/runtime/mirror/method.cc
+++ b/runtime/mirror/method.cc
@@ -18,7 +18,7 @@
#include "art_method.h"
#include "class_root.h"
-#include "mirror/class-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/object-inl.h"
#include "obj_ptr-inl.h"
diff --git a/runtime/mirror/method_handle_impl.cc b/runtime/mirror/method_handle_impl.cc
index 88ccbc9..e8cacd9 100644
--- a/runtime/mirror/method_handle_impl.cc
+++ b/runtime/mirror/method_handle_impl.cc
@@ -16,7 +16,7 @@
#include "method_handle_impl-inl.h"
-#include "class-inl.h"
+#include "class-alloc-inl.h"
#include "class_root.h"
namespace art {
diff --git a/runtime/mirror/method_handles_lookup.cc b/runtime/mirror/method_handles_lookup.cc
index d1e7a6d..de17c8d 100644
--- a/runtime/mirror/method_handles_lookup.cc
+++ b/runtime/mirror/method_handles_lookup.cc
@@ -16,7 +16,7 @@
#include "method_handles_lookup.h"
-#include "class-inl.h"
+#include "class-alloc-inl.h"
#include "class_root.h"
#include "dex/modifiers.h"
#include "handle_scope.h"
diff --git a/runtime/mirror/method_type.cc b/runtime/mirror/method_type.cc
index bc62ebd..6533656 100644
--- a/runtime/mirror/method_type.cc
+++ b/runtime/mirror/method_type.cc
@@ -16,9 +16,11 @@
#include "method_type.h"
-#include "class-inl.h"
+#include "class-alloc-inl.h"
#include "class_root.h"
#include "method_handles.h"
+#include "object_array-alloc-inl.h"
+#include "object_array-inl.h"
namespace art {
namespace mirror {
diff --git a/runtime/mirror/method_type_test.cc b/runtime/mirror/method_type_test.cc
index 2bdea72..a8411d9 100644
--- a/runtime/mirror/method_type_test.cc
+++ b/runtime/mirror/method_type_test.cc
@@ -25,6 +25,7 @@
#include "class_root.h"
#include "common_runtime_test.h"
#include "handle_scope-inl.h"
+#include "object_array-alloc-inl.h"
#include "object_array-inl.h"
#include "scoped_thread_state_change-inl.h"
diff --git a/runtime/mirror/object_array-alloc-inl.h b/runtime/mirror/object_array-alloc-inl.h
new file mode 100644
index 0000000..8e96d9f
--- /dev/null
+++ b/runtime/mirror/object_array-alloc-inl.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2011 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_RUNTIME_MIRROR_OBJECT_ARRAY_ALLOC_INL_H_
+#define ART_RUNTIME_MIRROR_OBJECT_ARRAY_ALLOC_INL_H_
+
+#include "object_array.h"
+
+#include "array-alloc-inl.h"
+#include "array-inl.h"
+#include "class.h"
+#include "dex/primitive.h"
+#include "gc/heap-inl.h"
+#include "handle_scope-inl.h"
+#include "obj_ptr-inl.h"
+#include "object-inl.h"
+#include "runtime.h"
+
+namespace art {
+namespace mirror {
+
+template<class T>
+inline ObjPtr<ObjectArray<T>> ObjectArray<T>::Alloc(Thread* self,
+ ObjPtr<Class> object_array_class,
+ int32_t length,
+ gc::AllocatorType allocator_type) {
+ ObjPtr<Array> array = Array::Alloc<true>(self,
+ object_array_class,
+ length,
+ ComponentSizeShiftWidth(kHeapReferenceSize),
+ allocator_type);
+ if (UNLIKELY(array == nullptr)) {
+ return nullptr;
+ }
+ DCHECK_EQ(array->GetClass()->GetComponentSizeShift(),
+ ComponentSizeShiftWidth(kHeapReferenceSize));
+ return array->AsObjectArray<T>();
+}
+
+template<class T>
+inline ObjPtr<ObjectArray<T>> ObjectArray<T>::Alloc(Thread* self,
+ ObjPtr<Class> object_array_class,
+ int32_t length) {
+ return Alloc(self,
+ object_array_class,
+ length,
+ Runtime::Current()->GetHeap()->GetCurrentAllocator());
+}
+
+template<class T>
+inline ObjPtr<ObjectArray<T>> ObjectArray<T>::CopyOf(Thread* self, int32_t new_length) {
+ DCHECK_GE(new_length, 0);
+ // We may get copied by a compacting GC.
+ StackHandleScope<1> hs(self);
+ Handle<ObjectArray<T>> h_this(hs.NewHandle(this));
+ gc::Heap* heap = Runtime::Current()->GetHeap();
+ gc::AllocatorType allocator_type = heap->IsMovableObject(this) ? heap->GetCurrentAllocator() :
+ heap->GetCurrentNonMovingAllocator();
+ ObjPtr<ObjectArray<T>> new_array = Alloc(self, GetClass(), new_length, allocator_type);
+ if (LIKELY(new_array != nullptr)) {
+ new_array->AssignableMemcpy(0, h_this.Get(), 0, std::min(h_this->GetLength(), new_length));
+ }
+ return new_array;
+}
+
+} // namespace mirror
+} // namespace art
+
+#endif // ART_RUNTIME_MIRROR_OBJECT_ARRAY_ALLOC_INL_H_
diff --git a/runtime/mirror/object_array-inl.h b/runtime/mirror/object_array-inl.h
index 4198d36..98cc4a8 100644
--- a/runtime/mirror/object_array-inl.h
+++ b/runtime/mirror/object_array-inl.h
@@ -23,49 +23,18 @@
#include "android-base/stringprintf.h"
-#include "array-alloc-inl.h"
#include "array-inl.h"
#include "base/utils.h"
#include "class.h"
-#include "gc/heap.h"
-#include "handle_scope-inl.h"
#include "obj_ptr-inl.h"
#include "object-inl.h"
#include "runtime.h"
-#include "thread.h"
+#include "thread-current-inl.h"
#include "write_barrier-inl.h"
namespace art {
namespace mirror {
-template<class T>
-inline ObjPtr<ObjectArray<T>> ObjectArray<T>::Alloc(Thread* self,
- ObjPtr<Class> object_array_class,
- int32_t length,
- gc::AllocatorType allocator_type) {
- ObjPtr<Array> array = Array::Alloc<true>(self,
- object_array_class,
- length,
- ComponentSizeShiftWidth(kHeapReferenceSize),
- allocator_type);
- if (UNLIKELY(array == nullptr)) {
- return nullptr;
- }
- DCHECK_EQ(array->GetClass()->GetComponentSizeShift(),
- ComponentSizeShiftWidth(kHeapReferenceSize));
- return array->AsObjectArray<T>();
-}
-
-template<class T>
-inline ObjPtr<ObjectArray<T>> ObjectArray<T>::Alloc(Thread* self,
- ObjPtr<Class> object_array_class,
- int32_t length) {
- return Alloc(self,
- object_array_class,
- length,
- Runtime::Current()->GetHeap()->GetCurrentAllocator());
-}
-
template<class T> template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>
inline T* ObjectArray<T>::Get(int32_t i) {
if (!CheckIsValidIndex<kVerifyFlags>(i)) {
@@ -349,22 +318,6 @@
}
template<class T>
-inline ObjPtr<ObjectArray<T>> ObjectArray<T>::CopyOf(Thread* self, int32_t new_length) {
- DCHECK_GE(new_length, 0);
- // We may get copied by a compacting GC.
- StackHandleScope<1> hs(self);
- Handle<ObjectArray<T>> h_this(hs.NewHandle(this));
- gc::Heap* heap = Runtime::Current()->GetHeap();
- gc::AllocatorType allocator_type = heap->IsMovableObject(this) ? heap->GetCurrentAllocator() :
- heap->GetCurrentNonMovingAllocator();
- ObjPtr<ObjectArray<T>> new_array = Alloc(self, GetClass(), new_length, allocator_type);
- if (LIKELY(new_array != nullptr)) {
- new_array->AssignableMemcpy(0, h_this.Get(), 0, std::min(h_this->GetLength(), new_length));
- }
- return new_array;
-}
-
-template<class T>
inline MemberOffset ObjectArray<T>::OffsetOfElement(int32_t i) {
return MemberOffset(DataOffset(kHeapReferenceSize).Int32Value() + (i * kHeapReferenceSize));
}
diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc
index 71bf033..d8c7b1d 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -26,6 +26,7 @@
#include "art_method-inl.h"
#include "asm_support.h"
#include "base/enums.h"
+#include "class-alloc-inl.h"
#include "class-inl.h"
#include "class_linker-inl.h"
#include "class_linker.h"
@@ -39,6 +40,7 @@
#include "iftable-inl.h"
#include "obj_ptr.h"
#include "object-inl.h"
+#include "object_array-alloc-inl.h"
#include "object_array-inl.h"
#include "scoped_thread_state_change-inl.h"
#include "string-inl.h"
diff --git a/runtime/mirror/stack_trace_element.cc b/runtime/mirror/stack_trace_element.cc
index 5a7575a..01f2d76 100644
--- a/runtime/mirror/stack_trace_element.cc
+++ b/runtime/mirror/stack_trace_element.cc
@@ -16,7 +16,7 @@
#include "stack_trace_element.h"
-#include "class-inl.h"
+#include "class-alloc-inl.h"
#include "class.h"
#include "class_root.h"
#include "gc/accounting/card_table-inl.h"
diff --git a/runtime/mirror/var_handle.cc b/runtime/mirror/var_handle.cc
index 4391910..085dcab 100644
--- a/runtime/mirror/var_handle.cc
+++ b/runtime/mirror/var_handle.cc
@@ -27,6 +27,7 @@
#include "jvalue-inl.h"
#include "method_handles-inl.h"
#include "method_type.h"
+#include "object_array-alloc-inl.h"
#include "obj_ptr-inl.h"
#include "well_known_classes.h"
diff --git a/runtime/mirror/var_handle_test.cc b/runtime/mirror/var_handle_test.cc
index 9df96dd..a349e34 100644
--- a/runtime/mirror/var_handle_test.cc
+++ b/runtime/mirror/var_handle_test.cc
@@ -20,6 +20,7 @@
#include <vector>
#include "art_field-inl.h"
+#include "class-alloc-inl.h"
#include "class-inl.h"
#include "class_linker-inl.h"
#include "class_loader.h"
@@ -28,6 +29,7 @@
#include "handle_scope-inl.h"
#include "jvalue-inl.h"
#include "method_type.h"
+#include "object_array-alloc-inl.h"
#include "object_array-inl.h"
#include "reflection.h"
#include "scoped_thread_state_change-inl.h"
diff --git a/runtime/monitor_test.cc b/runtime/monitor_test.cc
index 8610899..8ddd50f 100644
--- a/runtime/monitor_test.cc
+++ b/runtime/monitor_test.cc
@@ -16,6 +16,7 @@
#include "monitor.h"
+#include <memory>
#include <string>
#include "base/atomic.h"
@@ -251,8 +252,8 @@
"hello, world!"));
// Create the barrier used to synchronize.
- test->barrier_ = std::unique_ptr<Barrier>(new Barrier(2));
- test->complete_barrier_ = std::unique_ptr<Barrier>(new Barrier(3));
+ test->barrier_ = std::make_unique<Barrier>(2);
+ test->complete_barrier_ = std::make_unique<Barrier>(3);
test->completed_ = false;
// Our job: Fill the heap, then try Wait.
diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc
index f54bf87..f5c0704 100644
--- a/runtime/native/dalvik_system_ZygoteHooks.cc
+++ b/runtime/native/dalvik_system_ZygoteHooks.cc
@@ -225,7 +225,9 @@
if ((runtime_flags & DEBUG_ALWAYS_JIT) != 0) {
jit::JitOptions* jit_options = runtime->GetJITOptions();
CHECK(jit_options != nullptr);
- jit_options->SetJitAtFirstUse();
+ Runtime::Current()->DoAndMaybeSwitchInterpreter([=]() {
+ jit_options->SetJitAtFirstUse();
+ });
runtime_flags &= ~DEBUG_ALWAYS_JIT;
}
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc
index 6d94fa1..e78c245 100644
--- a/runtime/native/java_lang_Class.cc
+++ b/runtime/native/java_lang_Class.cc
@@ -30,12 +30,14 @@
#include "dex/utf.h"
#include "hidden_api.h"
#include "jni/jni_internal.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
#include "mirror/field-inl.h"
#include "mirror/method.h"
#include "mirror/method_handles_lookup.h"
#include "mirror/object-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/string-inl.h"
#include "native_util.h"
diff --git a/runtime/native/java_lang_String.cc b/runtime/native/java_lang_String.cc
index 8976058..78ec859 100644
--- a/runtime/native/java_lang_String.cc
+++ b/runtime/native/java_lang_String.cc
@@ -19,6 +19,7 @@
#include "nativehelper/jni_macros.h"
#include "common_throws.h"
+#include "handle_scope-inl.h"
#include "jni/jni_internal.h"
#include "mirror/array.h"
#include "mirror/object-inl.h"
diff --git a/runtime/native/java_lang_StringFactory.cc b/runtime/native/java_lang_StringFactory.cc
index 3978ca8..c6ad4e4 100644
--- a/runtime/native/java_lang_StringFactory.cc
+++ b/runtime/native/java_lang_StringFactory.cc
@@ -17,6 +17,7 @@
#include "java_lang_StringFactory.h"
#include "common_throws.h"
+#include "handle_scope-inl.h"
#include "jni/jni_internal.h"
#include "mirror/object-inl.h"
#include "mirror/string-inl.h"
diff --git a/runtime/native/java_lang_reflect_Array.cc b/runtime/native/java_lang_reflect_Array.cc
index 452a66d..ff94593 100644
--- a/runtime/native/java_lang_reflect_Array.cc
+++ b/runtime/native/java_lang_reflect_Array.cc
@@ -24,6 +24,7 @@
#include "handle_scope-inl.h"
#include "jni/jni_internal.h"
#include "mirror/class-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object-inl.h"
#include "native_util.h"
#include "scoped_fast_native_object_access-inl.h"
diff --git a/runtime/native/java_lang_reflect_Constructor.cc b/runtime/native/java_lang_reflect_Constructor.cc
index 4b4d6e3..337c084 100644
--- a/runtime/native/java_lang_reflect_Constructor.cc
+++ b/runtime/native/java_lang_reflect_Constructor.cc
@@ -24,8 +24,10 @@
#include "class_root.h"
#include "dex/dex_file_annotations.h"
#include "jni/jni_internal.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/method.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object-inl.h"
#include "native_util.h"
#include "reflection.h"
diff --git a/runtime/native/java_lang_reflect_Executable.cc b/runtime/native/java_lang_reflect_Executable.cc
index a10db91..ada0a64 100644
--- a/runtime/native/java_lang_reflect_Executable.cc
+++ b/runtime/native/java_lang_reflect_Executable.cc
@@ -24,9 +24,11 @@
#include "dex/dex_file_annotations.h"
#include "handle.h"
#include "jni/jni_internal.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/method.h"
#include "mirror/object-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "native_util.h"
#include "reflection.h"
diff --git a/runtime/native/java_lang_reflect_Field.cc b/runtime/native/java_lang_reflect_Field.cc
index 895b2f9..b9ac88d 100644
--- a/runtime/native/java_lang_reflect_Field.cc
+++ b/runtime/native/java_lang_reflect_Field.cc
@@ -30,6 +30,7 @@
#include "jvalue-inl.h"
#include "mirror/class-inl.h"
#include "mirror/field-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "native_util.h"
#include "reflection-inl.h"
#include "scoped_fast_native_object_access-inl.h"
diff --git a/runtime/native/java_lang_reflect_Method.cc b/runtime/native/java_lang_reflect_Method.cc
index 87fda6b..c65541d 100644
--- a/runtime/native/java_lang_reflect_Method.cc
+++ b/runtime/native/java_lang_reflect_Method.cc
@@ -27,7 +27,7 @@
#include "jni/jni_internal.h"
#include "mirror/class-inl.h"
#include "mirror/object-inl.h"
-#include "mirror/object_array-inl.h"
+#include "mirror/object_array-alloc-inl.h"
#include "native_util.h"
#include "reflection.h"
#include "scoped_fast_native_object_access-inl.h"
diff --git a/runtime/native/libcore_util_CharsetUtils.cc b/runtime/native/libcore_util_CharsetUtils.cc
index 2429804..95e0d79 100644
--- a/runtime/native/libcore_util_CharsetUtils.cc
+++ b/runtime/native/libcore_util_CharsetUtils.cc
@@ -18,6 +18,7 @@
#include <string.h>
+#include "handle_scope-inl.h"
#include "jni/jni_internal.h"
#include "mirror/string-inl.h"
#include "mirror/string.h"
diff --git a/runtime/native_stack_dump.cc b/runtime/native_stack_dump.cc
index ce295aa..10f5898 100644
--- a/runtime/native_stack_dump.cc
+++ b/runtime/native_stack_dump.cc
@@ -16,6 +16,7 @@
#include "native_stack_dump.h"
+#include <memory>
#include <ostream>
#include <stdio.h>
@@ -128,10 +129,10 @@
} else {
close(caller_to_addr2line[0]);
close(addr2line_to_caller[1]);
- return std::unique_ptr<Addr2linePipe>(new Addr2linePipe(addr2line_to_caller[0],
- caller_to_addr2line[1],
- name,
- pid));
+ return std::make_unique<Addr2linePipe>(addr2line_to_caller[0],
+ caller_to_addr2line[1],
+ name,
+ pid);
}
}
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index 2e495cc..7157928 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -16,6 +16,7 @@
#include "parsed_options.h"
+#include <memory>
#include <sstream>
#include <android-base/logging.h>
@@ -67,7 +68,7 @@
using M = RuntimeArgumentMap;
std::unique_ptr<RuntimeParser::Builder> parser_builder =
- std::unique_ptr<RuntimeParser::Builder>(new RuntimeParser::Builder());
+ std::make_unique<RuntimeParser::Builder>();
parser_builder->
Define("-Xzygote")
@@ -346,7 +347,7 @@
// TODO: Move Usage information into this DSL.
- return std::unique_ptr<RuntimeParser>(new RuntimeParser(parser_builder->Build()));
+ return std::make_unique<RuntimeParser>(parser_builder->Build());
}
#pragma GCC diagnostic pop
diff --git a/runtime/reference_table_test.cc b/runtime/reference_table_test.cc
index 3ea1714..2acb2c7 100644
--- a/runtime/reference_table_test.cc
+++ b/runtime/reference_table_test.cc
@@ -27,6 +27,7 @@
#include "handle_scope-inl.h"
#include "mirror/array-inl.h"
#include "mirror/array-alloc-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
#include "mirror/string.h"
diff --git a/runtime/reflection_test.cc b/runtime/reflection_test.cc
index 00e298e..9fab7fb 100644
--- a/runtime/reflection_test.cc
+++ b/runtime/reflection_test.cc
@@ -25,6 +25,7 @@
#include "dex/descriptors_names.h"
#include "jni/java_vm_ext.h"
#include "jni/jni_internal.h"
+#include "mirror/class-alloc-inl.h"
#include "nativehelper/scoped_local_ref.h"
#include "scoped_thread_state_change-inl.h"
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 8ac7450..c312126 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -95,6 +95,7 @@
#include "linear_alloc.h"
#include "memory_representation.h"
#include "mirror/array.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_ext.h"
#include "mirror/class_loader.h"
@@ -743,7 +744,7 @@
self->TransitionFromRunnableToSuspended(kNative);
- started_ = true;
+ DoAndMaybeSwitchInterpreter([=](){ started_ = true; });
if (!IsImageDex2OatEnabled() || !GetHeap()->HasBootImageSpace()) {
ScopedObjectAccess soa(self);
@@ -2489,7 +2490,8 @@
DCHECK(!jit_options_->UseJitCompilation());
}
std::string error_msg;
- jit_.reset(jit::Jit::Create(jit_options_.get(), &error_msg));
+ jit::Jit* jit = jit::Jit::Create(jit_options_.get(), &error_msg);
+ DoAndMaybeSwitchInterpreter([=](){ jit_.reset(jit); });
if (jit_.get() == nullptr) {
LOG(WARNING) << "Failed to create JIT " << error_msg;
return;
diff --git a/runtime/thread-inl.h b/runtime/thread-inl.h
index 91c27af..0c00fb9 100644
--- a/runtime/thread-inl.h
+++ b/runtime/thread-inl.h
@@ -385,6 +385,7 @@
}
inline ShadowFrame* Thread::PushShadowFrame(ShadowFrame* new_top_frame) {
+ new_top_frame->CheckConsistentVRegs();
return tlsPtr_.managed_stack.PushShadowFrame(new_top_frame);
}
diff --git a/runtime/thread.cc b/runtime/thread.cc
index a3de4e2..b5d214d 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -77,8 +77,9 @@
#include "java_frame_root_info.h"
#include "jni/java_vm_ext.h"
#include "jni/jni_internal.h"
-#include "mirror/class-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "mirror/class_loader.h"
+#include "mirror/object_array-alloc-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/stack_trace_element.h"
#include "monitor.h"
diff --git a/runtime/transaction_test.cc b/runtime/transaction_test.cc
index da6998b..3d9afa0 100644
--- a/runtime/transaction_test.cc
+++ b/runtime/transaction_test.cc
@@ -22,6 +22,7 @@
#include "common_runtime_test.h"
#include "dex/dex_file.h"
#include "mirror/array-alloc-inl.h"
+#include "mirror/class-alloc-inl.h"
#include "scoped_thread_state_change-inl.h"
namespace art {
diff --git a/tools/hiddenapi/hiddenapi.cc b/tools/hiddenapi/hiddenapi.cc
index 06bea1a..f61b3e8 100644
--- a/tools/hiddenapi/hiddenapi.cc
+++ b/tools/hiddenapi/hiddenapi.cc
@@ -599,9 +599,10 @@
// Append flags at the end of the data struct. This should be called
// between BeginClassDef and EndClassDef in the order of appearance of
// fields/methods in the class data stream.
- void WriteFlags(uint32_t flags) {
- EncodeUnsignedLeb128(&data_, flags);
- class_def_has_non_zero_flags_ |= (flags != 0u);
+ void WriteFlags(hiddenapi::ApiList flags) {
+ uint32_t uint_flags = static_cast<uint32_t>(flags);
+ EncodeUnsignedLeb128(&data_, uint_flags);
+ class_def_has_non_zero_flags_ |= (uint_flags != 0u);
}
// Return backing data, assuming that all flags have been written.
@@ -931,10 +932,10 @@
}
// Load dex signatures.
- std::map<std::string, HiddenApiAccessFlags::ApiList> api_list;
- OpenApiFile(light_greylist_path_, api_list, HiddenApiAccessFlags::kLightGreylist);
- OpenApiFile(dark_greylist_path_, api_list, HiddenApiAccessFlags::kDarkGreylist);
- OpenApiFile(blacklist_path_, api_list, HiddenApiAccessFlags::kBlacklist);
+ std::map<std::string, hiddenapi::ApiList> api_list;
+ OpenApiFile(light_greylist_path_, api_list, hiddenapi::ApiList::kLightGreylist);
+ OpenApiFile(dark_greylist_path_, api_list, hiddenapi::ApiList::kDarkGreylist);
+ OpenApiFile(blacklist_path_, api_list, hiddenapi::ApiList::kBlacklist);
// Iterate over input dex files and insert HiddenapiClassData sections.
for (size_t i = 0; i < boot_dex_paths_.size(); ++i) {
@@ -954,7 +955,7 @@
// TODO: Load whitelist and CHECK that entry was found.
auto it = api_list.find(boot_member.GetApiEntry());
builder.WriteFlags(
- (it == api_list.end()) ? HiddenApiAccessFlags::kWhitelist : it->second);
+ (it == api_list.end()) ? hiddenapi::ApiList::kWhitelist : it->second);
};
auto fn_field = [&](const ClassAccessor::Field& boot_field) {
fn_shared(DexMember(boot_class, boot_field));
@@ -974,8 +975,8 @@
}
void OpenApiFile(const std::string& path,
- std::map<std::string, HiddenApiAccessFlags::ApiList>& api_list,
- HiddenApiAccessFlags::ApiList membership) {
+ std::map<std::string, hiddenapi::ApiList>& api_list,
+ hiddenapi::ApiList membership) {
if (path.empty()) {
return;
}
diff --git a/tools/hiddenapi/hiddenapi_test.cc b/tools/hiddenapi/hiddenapi_test.cc
index cdf797e..0010b784 100644
--- a/tools/hiddenapi/hiddenapi_test.cc
+++ b/tools/hiddenapi/hiddenapi_test.cc
@@ -124,15 +124,15 @@
return *found;
}
- HiddenApiAccessFlags::ApiList GetFieldHiddenFlags(const char* name,
- uint32_t expected_visibility,
- const DexFile::ClassDef& class_def,
- const DexFile& dex_file) {
+ hiddenapi::ApiList GetFieldHiddenFlags(const char* name,
+ uint32_t expected_visibility,
+ const DexFile::ClassDef& class_def,
+ const DexFile& dex_file) {
ClassAccessor accessor(dex_file, class_def, /* parse hiddenapi flags */ true);
CHECK(accessor.HasClassData()) << "Class " << accessor.GetDescriptor() << " has no data";
if (!accessor.HasHiddenapiClassData()) {
- return HiddenApiAccessFlags::kWhitelist;
+ return hiddenapi::ApiList::kWhitelist;
}
for (const ClassAccessor::Field& field : accessor.GetFields()) {
@@ -141,7 +141,7 @@
const uint32_t actual_visibility = field.GetAccessFlags() & kAccVisibilityFlags;
CHECK_EQ(actual_visibility, expected_visibility)
<< "Field " << name << " in class " << accessor.GetDescriptor();
- return static_cast<HiddenApiAccessFlags::ApiList>(field.GetHiddenapiFlags());
+ return static_cast<hiddenapi::ApiList>(field.GetHiddenapiFlags());
}
}
@@ -150,16 +150,16 @@
UNREACHABLE();
}
- HiddenApiAccessFlags::ApiList GetMethodHiddenFlags(const char* name,
- uint32_t expected_visibility,
- bool expected_native,
- const DexFile::ClassDef& class_def,
- const DexFile& dex_file) {
+ hiddenapi::ApiList GetMethodHiddenFlags(const char* name,
+ uint32_t expected_visibility,
+ bool expected_native,
+ const DexFile::ClassDef& class_def,
+ const DexFile& dex_file) {
ClassAccessor accessor(dex_file, class_def, /* parse hiddenapi flags */ true);
CHECK(accessor.HasClassData()) << "Class " << accessor.GetDescriptor() << " has no data";
if (!accessor.HasHiddenapiClassData()) {
- return HiddenApiAccessFlags::kWhitelist;
+ return hiddenapi::ApiList::kWhitelist;
}
for (const ClassAccessor::Method& method : accessor.GetMethods()) {
@@ -170,7 +170,7 @@
const uint32_t actual_visibility = method.GetAccessFlags() & kAccVisibilityFlags;
CHECK_EQ(actual_visibility, expected_visibility)
<< "Method " << name << " in class " << accessor.GetDescriptor();
- return static_cast<HiddenApiAccessFlags::ApiList>(method.GetHiddenapiFlags());
+ return static_cast<hiddenapi::ApiList>(method.GetHiddenapiFlags());
}
}
@@ -179,20 +179,20 @@
UNREACHABLE();
}
- HiddenApiAccessFlags::ApiList GetIFieldHiddenFlags(const DexFile& dex_file) {
+ hiddenapi::ApiList GetIFieldHiddenFlags(const DexFile& dex_file) {
return GetFieldHiddenFlags("ifield", kAccPublic, FindClass("LMain;", dex_file), dex_file);
}
- HiddenApiAccessFlags::ApiList GetSFieldHiddenFlags(const DexFile& dex_file) {
+ hiddenapi::ApiList GetSFieldHiddenFlags(const DexFile& dex_file) {
return GetFieldHiddenFlags("sfield", kAccPrivate, FindClass("LMain;", dex_file), dex_file);
}
- HiddenApiAccessFlags::ApiList GetIMethodHiddenFlags(const DexFile& dex_file) {
+ hiddenapi::ApiList GetIMethodHiddenFlags(const DexFile& dex_file) {
return GetMethodHiddenFlags(
"imethod", 0, /* expected_native= */ false, FindClass("LMain;", dex_file), dex_file);
}
- HiddenApiAccessFlags::ApiList GetSMethodHiddenFlags(const DexFile& dex_file) {
+ hiddenapi::ApiList GetSMethodHiddenFlags(const DexFile& dex_file) {
return GetMethodHiddenFlags("smethod",
kAccPublic,
/* expected_native= */ false,
@@ -200,7 +200,7 @@
dex_file);
}
- HiddenApiAccessFlags::ApiList GetINMethodHiddenFlags(const DexFile& dex_file) {
+ hiddenapi::ApiList GetINMethodHiddenFlags(const DexFile& dex_file) {
return GetMethodHiddenFlags("inmethod",
kAccPublic,
/* expected_native= */ true,
@@ -208,7 +208,7 @@
dex_file);
}
- HiddenApiAccessFlags::ApiList GetSNMethodHiddenFlags(const DexFile& dex_file) {
+ hiddenapi::ApiList GetSNMethodHiddenFlags(const DexFile& dex_file) {
return GetMethodHiddenFlags("snmethod",
kAccProtected,
/* expected_native= */ true,
@@ -224,7 +224,7 @@
OpenStream(blacklist) << "LMain;->ifield:LBadType3;" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kWhitelist, GetIFieldHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kWhitelist, GetIFieldHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceFieldLightGreylistMatch) {
@@ -234,7 +234,7 @@
OpenStream(blacklist) << "LMain;->ifield:LBadType3;" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kLightGreylist, GetIFieldHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kLightGreylist, GetIFieldHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceFieldDarkGreylistMatch) {
@@ -244,7 +244,7 @@
OpenStream(blacklist) << "LMain;->ifield:LBadType3;" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kDarkGreylist, GetIFieldHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kDarkGreylist, GetIFieldHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceFieldBlacklistMatch) {
@@ -254,7 +254,7 @@
OpenStream(blacklist) << "LMain;->ifield:I" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kBlacklist, GetIFieldHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kBlacklist, GetIFieldHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceFieldTwoListsMatch1) {
@@ -291,7 +291,7 @@
OpenStream(blacklist) << "LMain;->sfield:LBadType3;" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kWhitelist, GetSFieldHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kWhitelist, GetSFieldHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticFieldLightGreylistMatch) {
@@ -301,7 +301,7 @@
OpenStream(blacklist) << "LMain;->sfield:LBadType3;" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kLightGreylist, GetSFieldHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kLightGreylist, GetSFieldHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticFieldDarkGreylistMatch) {
@@ -311,7 +311,7 @@
OpenStream(blacklist) << "LMain;->sfield:LBadType3;" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kDarkGreylist, GetSFieldHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kDarkGreylist, GetSFieldHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticFieldBlacklistMatch) {
@@ -321,7 +321,7 @@
OpenStream(blacklist) << "LMain;->sfield:Ljava/lang/Object;" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kBlacklist, GetSFieldHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kBlacklist, GetSFieldHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticFieldTwoListsMatch1) {
@@ -358,7 +358,7 @@
OpenStream(blacklist) << "LMain;->imethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kWhitelist, GetIMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kWhitelist, GetIMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceMethodLightGreylistMatch) {
@@ -368,7 +368,7 @@
OpenStream(blacklist) << "LMain;->imethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kLightGreylist, GetIMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kLightGreylist, GetIMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceMethodDarkGreylistMatch) {
@@ -378,7 +378,7 @@
OpenStream(blacklist) << "LMain;->imethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kDarkGreylist, GetIMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kDarkGreylist, GetIMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceMethodBlacklistMatch) {
@@ -388,7 +388,7 @@
OpenStream(blacklist) << "LMain;->imethod(J)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kBlacklist, GetIMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kBlacklist, GetIMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceMethodTwoListsMatch1) {
@@ -425,7 +425,7 @@
OpenStream(blacklist) << "LMain;->smethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kWhitelist, GetSMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kWhitelist, GetSMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticMethodLightGreylistMatch) {
@@ -435,7 +435,7 @@
OpenStream(blacklist) << "LMain;->smethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kLightGreylist, GetSMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kLightGreylist, GetSMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticMethodDarkGreylistMatch) {
@@ -445,7 +445,7 @@
OpenStream(blacklist) << "LMain;->smethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kDarkGreylist, GetSMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kDarkGreylist, GetSMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticMethodBlacklistMatch) {
@@ -455,7 +455,7 @@
OpenStream(blacklist) << "LMain;->smethod(Ljava/lang/Object;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kBlacklist, GetSMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kBlacklist, GetSMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticMethodTwoListsMatch1) {
@@ -492,7 +492,7 @@
OpenStream(blacklist) << "LMain;->inmethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kWhitelist, GetINMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kWhitelist, GetINMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceNativeMethodLightGreylistMatch) {
@@ -502,7 +502,7 @@
OpenStream(blacklist) << "LMain;->inmethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kLightGreylist, GetINMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kLightGreylist, GetINMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceNativeMethodDarkGreylistMatch) {
@@ -512,7 +512,7 @@
OpenStream(blacklist) << "LMain;->inmethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kDarkGreylist, GetINMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kDarkGreylist, GetINMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceNativeMethodBlacklistMatch) {
@@ -522,7 +522,7 @@
OpenStream(blacklist) << "LMain;->inmethod(C)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kBlacklist, GetINMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kBlacklist, GetINMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, InstanceNativeMethodTwoListsMatch1) {
@@ -559,7 +559,7 @@
OpenStream(blacklist) << "LMain;->snmethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kWhitelist, GetSNMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kWhitelist, GetSNMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticNativeMethodLightGreylistMatch) {
@@ -569,7 +569,7 @@
OpenStream(blacklist) << "LMain;->snmethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kLightGreylist, GetSNMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kLightGreylist, GetSNMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticNativeMethodDarkGreylistMatch) {
@@ -579,7 +579,7 @@
OpenStream(blacklist) << "LMain;->snmethod(LBadType3;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kDarkGreylist, GetSNMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kDarkGreylist, GetSNMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticNativeMethodBlacklistMatch) {
@@ -589,7 +589,7 @@
OpenStream(blacklist) << "LMain;->snmethod(Ljava/lang/Integer;)V" << std::endl;
auto dex_file = RunHiddenApi(light_greylist, dark_greylist, blacklist, {}, &dex);
ASSERT_NE(dex_file.get(), nullptr);
- ASSERT_EQ(HiddenApiAccessFlags::kBlacklist, GetSNMethodHiddenFlags(*dex_file));
+ ASSERT_EQ(hiddenapi::ApiList::kBlacklist, GetSNMethodHiddenFlags(*dex_file));
}
TEST_F(HiddenApiTest, StaticNativeMethodTwoListsMatch1) {
diff --git a/tools/veridex/hidden_api.h b/tools/veridex/hidden_api.h
index 68485bd..da9f058 100644
--- a/tools/veridex/hidden_api.h
+++ b/tools/veridex/hidden_api.h
@@ -43,22 +43,22 @@
FillList(whitelist, whitelist_);
}
- HiddenApiAccessFlags::ApiList GetApiList(const std::string& name) const {
+ hiddenapi::ApiList GetApiList(const std::string& name) const {
if (IsInList(name, blacklist_)) {
- return HiddenApiAccessFlags::kBlacklist;
+ return hiddenapi::ApiList::kBlacklist;
} else if (IsInList(name, dark_greylist_)) {
- return HiddenApiAccessFlags::kDarkGreylist;
+ return hiddenapi::ApiList::kDarkGreylist;
} else if (IsInList(name, light_greylist_)) {
- return HiddenApiAccessFlags::kLightGreylist;
+ return hiddenapi::ApiList::kLightGreylist;
} else if (IsInList(name, whitelist_)) {
- return HiddenApiAccessFlags::kWhitelist;
+ return hiddenapi::ApiList::kWhitelist;
} else {
- return HiddenApiAccessFlags::kNoList;
+ return hiddenapi::ApiList::kNoList;
}
}
bool IsInAnyList(const std::string& name) const {
- return GetApiList(name) != HiddenApiAccessFlags::kNoList;
+ return GetApiList(name) != hiddenapi::ApiList::kNoList;
}
static std::string GetApiMethodName(const DexFile& dex_file, uint32_t method_index);
diff --git a/tools/veridex/hidden_api_finder.cc b/tools/veridex/hidden_api_finder.cc
index a8c53b3..e24d151 100644
--- a/tools/veridex/hidden_api_finder.cc
+++ b/tools/veridex/hidden_api_finder.cc
@@ -179,8 +179,8 @@
// Dump methods from hidden APIs linked against.
for (const std::pair<const std::string,
std::vector<MethodReference>>& pair : method_locations_) {
- HiddenApiAccessFlags::ApiList api_list = hidden_api_.GetApiList(pair.first);
- stats->api_counts[api_list]++;
+ hiddenapi::ApiList api_list = hidden_api_.GetApiList(pair.first);
+ stats->api_counts[static_cast<unsigned>(api_list)]++;
os << "#" << ++stats->count << ": Linking " << api_list << " " << pair.first << " use(s):";
os << std::endl;
HiddenApiFinder::DumpReferences(os, pair.second);
@@ -190,8 +190,8 @@
// Dump fields from hidden APIs linked against.
for (const std::pair<const std::string,
std::vector<MethodReference>>& pair : field_locations_) {
- HiddenApiAccessFlags::ApiList api_list = hidden_api_.GetApiList(pair.first);
- stats->api_counts[api_list]++;
+ hiddenapi::ApiList api_list = hidden_api_.GetApiList(pair.first);
+ stats->api_counts[static_cast<unsigned>(api_list)]++;
os << "#" << ++stats->count << ": Linking " << api_list << " " << pair.first << " use(s):";
os << std::endl;
HiddenApiFinder::DumpReferences(os, pair.second);
@@ -203,9 +203,9 @@
for (const std::string& cls : classes_) {
for (const std::string& name : strings_) {
std::string full_name = cls + "->" + name;
- HiddenApiAccessFlags::ApiList api_list = hidden_api_.GetApiList(full_name);
- stats->api_counts[api_list]++;
- if (api_list != HiddenApiAccessFlags::kNoList) {
+ hiddenapi::ApiList api_list = hidden_api_.GetApiList(full_name);
+ stats->api_counts[static_cast<unsigned>(api_list)]++;
+ if (api_list != hiddenapi::ApiList::kNoList) {
stats->reflection_count++;
os << "#" << ++stats->count << ": Reflection " << api_list << " " << full_name
<< " potential use(s):";
diff --git a/tools/veridex/precise_hidden_api_finder.cc b/tools/veridex/precise_hidden_api_finder.cc
index 9e02cbf..6aef89f 100644
--- a/tools/veridex/precise_hidden_api_finder.cc
+++ b/tools/veridex/precise_hidden_api_finder.cc
@@ -91,8 +91,8 @@
std::string cls(info.cls.ToString());
std::string name(info.name.ToString());
std::string full_name = cls + "->" + name;
- HiddenApiAccessFlags::ApiList api_list = hidden_api_.GetApiList(full_name);
- if (api_list != HiddenApiAccessFlags::kNoList) {
+ hiddenapi::ApiList api_list = hidden_api_.GetApiList(full_name);
+ if (api_list != hiddenapi::ApiList::kNoList) {
named_uses[full_name].push_back(ref);
}
}
@@ -101,8 +101,8 @@
for (auto& it : named_uses) {
++stats->reflection_count;
const std::string& full_name = it.first;
- HiddenApiAccessFlags::ApiList api_list = hidden_api_.GetApiList(full_name);
- stats->api_counts[api_list]++;
+ hiddenapi::ApiList api_list = hidden_api_.GetApiList(full_name);
+ stats->api_counts[static_cast<unsigned>(api_list)]++;
os << "#" << ++stats->count << ": Reflection " << api_list << " " << full_name << " use(s):";
os << std::endl;
for (const MethodReference& ref : it.second) {
diff --git a/tools/veridex/veridex.cc b/tools/veridex/veridex.cc
index 7206c7d..179e391 100644
--- a/tools/veridex/veridex.cc
+++ b/tools/veridex/veridex.cc
@@ -271,16 +271,17 @@
const VeridexOptions& options) {
static const char* kPrefix = " ";
if (options.only_report_sdk_uses) {
- os << stats.api_counts[HiddenApiAccessFlags::kWhitelist] << " SDK API uses." << std::endl;
+ os << stats.api_counts[static_cast<unsigned>(hiddenapi::ApiList::kWhitelist)]
+ << " SDK API uses." << std::endl;
} else {
os << stats.count << " hidden API(s) used: "
<< stats.linking_count << " linked against, "
<< stats.reflection_count << " through reflection" << std::endl;
- os << kPrefix << stats.api_counts[HiddenApiAccessFlags::kBlacklist]
+ os << kPrefix << stats.api_counts[static_cast<unsigned>(hiddenapi::ApiList::kBlacklist)]
<< " in blacklist" << std::endl;
- os << kPrefix << stats.api_counts[HiddenApiAccessFlags::kDarkGreylist]
+ os << kPrefix << stats.api_counts[static_cast<unsigned>(hiddenapi::ApiList::kDarkGreylist)]
<< " in dark greylist" << std::endl;
- os << kPrefix << stats.api_counts[HiddenApiAccessFlags::kLightGreylist]
+ os << kPrefix << stats.api_counts[static_cast<unsigned>(hiddenapi::ApiList::kLightGreylist)]
<< " in light greylist" << std::endl;
}
}