summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/Android.bp1
-rw-r--r--runtime/arch/arm/callee_save_frame_arm.h2
-rw-r--r--runtime/arch/arm/fault_handler_arm.cc3
-rw-r--r--runtime/arch/arm64/callee_save_frame_arm64.h2
-rw-r--r--runtime/arch/arm64/fault_handler_arm64.cc3
-rw-r--r--runtime/arch/instruction_set_features.cc3
-rw-r--r--runtime/arch/instruction_set_features.h2
-rw-r--r--runtime/arch/mips/callee_save_frame_mips.h2
-rw-r--r--runtime/arch/mips/fault_handler_mips.cc3
-rw-r--r--runtime/arch/mips/registers_mips.h3
-rw-r--r--runtime/arch/mips64/callee_save_frame_mips64.h2
-rw-r--r--runtime/arch/mips64/fault_handler_mips64.cc3
-rw-r--r--runtime/arch/mips64/registers_mips64.h3
-rw-r--r--runtime/arch/x86/callee_save_frame_x86.h2
-rw-r--r--runtime/arch/x86/fault_handler_x86.cc3
-rw-r--r--runtime/arch/x86/registers_x86.h3
-rw-r--r--runtime/arch/x86_64/callee_save_frame_x86_64.h2
-rw-r--r--runtime/arch/x86_64/registers_x86_64.h3
-rw-r--r--runtime/base/callee_save_type.h47
-rw-r--r--runtime/base/mutex.h2
-rw-r--r--runtime/class_linker.cc12
-rw-r--r--runtime/class_linker.h6
-rw-r--r--runtime/common_runtime_test.h2
-rw-r--r--runtime/compiler_filter.cc2
-rw-r--r--runtime/compiler_filter.h2
-rw-r--r--runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc12
-rw-r--r--runtime/fault_handler.h2
-rw-r--r--runtime/gc/accounting/bitmap.h2
-rw-r--r--runtime/gc/accounting/card_table.h2
-rw-r--r--runtime/gc/accounting/mod_union_table.h2
-rw-r--r--runtime/gc/accounting/read_barrier_table.h2
-rw-r--r--runtime/gc/accounting/remembered_set.h2
-rw-r--r--runtime/gc/accounting/space_bitmap.h2
-rw-r--r--runtime/gc/accounting/space_bitmap_test.cc2
-rw-r--r--runtime/gc/allocator/dlmalloc.cc2
-rw-r--r--runtime/gc/allocator/rosalloc.h2
-rw-r--r--runtime/gc/gc_cause.cc2
-rw-r--r--runtime/gc/heap.cc18
-rw-r--r--runtime/gc/heap.h21
-rw-r--r--runtime/gc/reference_processor.h2
-rw-r--r--runtime/gc/reference_queue.h2
-rw-r--r--runtime/gc/space/image_space.cc1
-rw-r--r--runtime/gc/space/image_space.h2
-rw-r--r--runtime/gc/space/image_space_fs.h2
-rw-r--r--runtime/gc/space/malloc_space.cc2
-rw-r--r--runtime/gc/space/malloc_space.h3
-rw-r--r--runtime/gc/space/space.h2
-rw-r--r--runtime/gc/space/space_test.h2
-rw-r--r--runtime/gc/task_processor.h2
-rw-r--r--runtime/handle_scope-inl.h10
-rw-r--r--runtime/handle_scope.h51
-rw-r--r--runtime/handle_wrapper.h65
-rw-r--r--runtime/hidden_api.cc4
-rw-r--r--runtime/hidden_api.h5
-rw-r--r--runtime/hidden_api_test.cc7
-rw-r--r--runtime/hprof/hprof.cc2
-rw-r--r--runtime/image.h2
-rw-r--r--runtime/jdwp_provider.h2
-rw-r--r--runtime/mirror/class-inl.h13
-rw-r--r--runtime/mirror/class.h14
-rw-r--r--runtime/mirror/dex_cache.cc2
-rw-r--r--runtime/mirror/object.h2
-rw-r--r--runtime/mirror/object_reference.h2
-rw-r--r--runtime/mirror/string-alloc-inl.h2
-rw-r--r--runtime/mirror/string-inl.h2
-rw-r--r--runtime/mirror/string.h2
-rw-r--r--runtime/oat.cc1
-rw-r--r--runtime/oat.h2
-rw-r--r--runtime/obj_ptr-inl.h2
-rw-r--r--runtime/obj_ptr.h4
-rw-r--r--runtime/offsets.h4
-rw-r--r--runtime/parsed_options.h2
-rw-r--r--runtime/quick_exception_handler.cc5
-rw-r--r--runtime/reflection.cc1
-rw-r--r--runtime/runtime.h2
-rw-r--r--runtime/runtime_globals.h82
-rw-r--r--runtime/suspend_reason.h2
-rw-r--r--runtime/thread-inl.h21
-rw-r--r--runtime/thread.h24
-rw-r--r--runtime/thread_state.h2
-rw-r--r--runtime/trace.h2
-rw-r--r--runtime/utils/dex_cache_arrays_layout-inl.h2
-rw-r--r--runtime/verifier/method_verifier.cc28
-rw-r--r--runtime/verify_object.cc2
84 files changed, 389 insertions, 197 deletions
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 71c5b74363..b89eb02ff0 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -462,6 +462,7 @@ gensrcs {
cmd: "$(location generate_operator_out) art/runtime $(in) > $(out)",
tools: ["generate_operator_out"],
srcs: [
+ "base/callee_save_type.h",
"base/locks.h",
"class_loader_context.h",
"class_status.h",
diff --git a/runtime/arch/arm/callee_save_frame_arm.h b/runtime/arch/arm/callee_save_frame_arm.h
index 11eefb9283..72ba3b7f66 100644
--- a/runtime/arch/arm/callee_save_frame_arm.h
+++ b/runtime/arch/arm/callee_save_frame_arm.h
@@ -21,9 +21,9 @@
#include "base/bit_utils.h"
#include "base/callee_save_type.h"
#include "base/enums.h"
-#include "base/globals.h"
#include "quick/quick_method_frame_info.h"
#include "registers_arm.h"
+#include "runtime_globals.h"
namespace art {
namespace arm {
diff --git a/runtime/arch/arm/fault_handler_arm.cc b/runtime/arch/arm/fault_handler_arm.cc
index bb33a273b8..e186cd3992 100644
--- a/runtime/arch/arm/fault_handler_arm.cc
+++ b/runtime/arch/arm/fault_handler_arm.cc
@@ -18,12 +18,13 @@
#include <sys/ucontext.h>
+#include "arch/instruction_set.h"
#include "art_method.h"
#include "base/enums.h"
-#include "base/globals.h"
#include "base/hex_dump.h"
#include "base/logging.h" // For VLOG.
#include "base/macros.h"
+#include "runtime_globals.h"
#include "thread-current-inl.h"
//
diff --git a/runtime/arch/arm64/callee_save_frame_arm64.h b/runtime/arch/arm64/callee_save_frame_arm64.h
index a5aea2a573..d3609f1d96 100644
--- a/runtime/arch/arm64/callee_save_frame_arm64.h
+++ b/runtime/arch/arm64/callee_save_frame_arm64.h
@@ -21,9 +21,9 @@
#include "base/bit_utils.h"
#include "base/callee_save_type.h"
#include "base/enums.h"
-#include "base/globals.h"
#include "quick/quick_method_frame_info.h"
#include "registers_arm64.h"
+#include "runtime_globals.h"
namespace art {
namespace arm64 {
diff --git a/runtime/arch/arm64/fault_handler_arm64.cc b/runtime/arch/arm64/fault_handler_arm64.cc
index e8b4627f86..751c05b7e9 100644
--- a/runtime/arch/arm64/fault_handler_arm64.cc
+++ b/runtime/arch/arm64/fault_handler_arm64.cc
@@ -18,13 +18,14 @@
#include <sys/ucontext.h>
+#include "arch/instruction_set.h"
#include "art_method.h"
#include "base/enums.h"
-#include "base/globals.h"
#include "base/hex_dump.h"
#include "base/logging.h" // For VLOG.
#include "base/macros.h"
#include "registers_arm64.h"
+#include "runtime_globals.h"
#include "thread-current-inl.h"
extern "C" void art_quick_throw_stack_overflow();
diff --git a/runtime/arch/instruction_set_features.cc b/runtime/arch/instruction_set_features.cc
index 0c45bc9197..886b40af30 100644
--- a/runtime/arch/instruction_set_features.cc
+++ b/runtime/arch/instruction_set_features.cc
@@ -16,6 +16,9 @@
#include "instruction_set_features.h"
+#include <algorithm>
+#include <ostream>
+
#include "android-base/strings.h"
#include "base/casts.h"
diff --git a/runtime/arch/instruction_set_features.h b/runtime/arch/instruction_set_features.h
index c31c927668..f910a4183d 100644
--- a/runtime/arch/instruction_set_features.h
+++ b/runtime/arch/instruction_set_features.h
@@ -17,8 +17,8 @@
#ifndef ART_RUNTIME_ARCH_INSTRUCTION_SET_FEATURES_H_
#define ART_RUNTIME_ARCH_INSTRUCTION_SET_FEATURES_H_
+#include <iosfwd>
#include <memory>
-#include <ostream>
#include <vector>
#include "arch/instruction_set.h"
diff --git a/runtime/arch/mips/callee_save_frame_mips.h b/runtime/arch/mips/callee_save_frame_mips.h
index 6e88d08432..84ce2093b7 100644
--- a/runtime/arch/mips/callee_save_frame_mips.h
+++ b/runtime/arch/mips/callee_save_frame_mips.h
@@ -21,9 +21,9 @@
#include "base/bit_utils.h"
#include "base/callee_save_type.h"
#include "base/enums.h"
-#include "base/globals.h"
#include "quick/quick_method_frame_info.h"
#include "registers_mips.h"
+#include "runtime_globals.h"
namespace art {
namespace mips {
diff --git a/runtime/arch/mips/fault_handler_mips.cc b/runtime/arch/mips/fault_handler_mips.cc
index 7c8ac288c3..0354f0c7a6 100644
--- a/runtime/arch/mips/fault_handler_mips.cc
+++ b/runtime/arch/mips/fault_handler_mips.cc
@@ -17,14 +17,15 @@
#include <sys/ucontext.h>
#include "fault_handler.h"
+#include "arch/instruction_set.h"
#include "arch/mips/callee_save_frame_mips.h"
#include "art_method.h"
#include "base/callee_save_type.h"
-#include "base/globals.h"
#include "base/hex_dump.h"
#include "base/logging.h" // For VLOG.
#include "base/macros.h"
#include "registers_mips.h"
+#include "runtime_globals.h"
#include "thread-current-inl.h"
extern "C" void art_quick_throw_stack_overflow();
diff --git a/runtime/arch/mips/registers_mips.h b/runtime/arch/mips/registers_mips.h
index 34f2f9684d..4900e413e0 100644
--- a/runtime/arch/mips/registers_mips.h
+++ b/runtime/arch/mips/registers_mips.h
@@ -19,9 +19,6 @@
#include <iosfwd>
-#include <android-base/logging.h>
-
-#include "base/globals.h"
#include "base/macros.h"
namespace art {
diff --git a/runtime/arch/mips64/callee_save_frame_mips64.h b/runtime/arch/mips64/callee_save_frame_mips64.h
index 59529a0c7b..64d6becdcd 100644
--- a/runtime/arch/mips64/callee_save_frame_mips64.h
+++ b/runtime/arch/mips64/callee_save_frame_mips64.h
@@ -21,9 +21,9 @@
#include "base/bit_utils.h"
#include "base/callee_save_type.h"
#include "base/enums.h"
-#include "base/globals.h"
#include "quick/quick_method_frame_info.h"
#include "registers_mips64.h"
+#include "runtime_globals.h"
namespace art {
namespace mips64 {
diff --git a/runtime/arch/mips64/fault_handler_mips64.cc b/runtime/arch/mips64/fault_handler_mips64.cc
index 85f3528ec4..6255235a21 100644
--- a/runtime/arch/mips64/fault_handler_mips64.cc
+++ b/runtime/arch/mips64/fault_handler_mips64.cc
@@ -18,14 +18,15 @@
#include <sys/ucontext.h>
+#include "arch/instruction_set.h"
#include "arch/mips64/callee_save_frame_mips64.h"
#include "art_method.h"
#include "base/callee_save_type.h"
-#include "base/globals.h"
#include "base/hex_dump.h"
#include "base/logging.h" // For VLOG.
#include "base/macros.h"
#include "registers_mips64.h"
+#include "runtime_globals.h"
#include "thread-current-inl.h"
extern "C" void art_quick_throw_stack_overflow();
diff --git a/runtime/arch/mips64/registers_mips64.h b/runtime/arch/mips64/registers_mips64.h
index a3fa2ac426..1c22c0761b 100644
--- a/runtime/arch/mips64/registers_mips64.h
+++ b/runtime/arch/mips64/registers_mips64.h
@@ -19,9 +19,6 @@
#include <iosfwd>
-#include <android-base/logging.h>
-
-#include "base/globals.h"
#include "base/macros.h"
namespace art {
diff --git a/runtime/arch/x86/callee_save_frame_x86.h b/runtime/arch/x86/callee_save_frame_x86.h
index f336f43aa3..2edcade6f0 100644
--- a/runtime/arch/x86/callee_save_frame_x86.h
+++ b/runtime/arch/x86/callee_save_frame_x86.h
@@ -21,9 +21,9 @@
#include "base/bit_utils.h"
#include "base/callee_save_type.h"
#include "base/enums.h"
-#include "base/globals.h"
#include "quick/quick_method_frame_info.h"
#include "registers_x86.h"
+#include "runtime_globals.h"
namespace art {
namespace x86 {
diff --git a/runtime/arch/x86/fault_handler_x86.cc b/runtime/arch/x86/fault_handler_x86.cc
index 8b243342f9..26312fb0ca 100644
--- a/runtime/arch/x86/fault_handler_x86.cc
+++ b/runtime/arch/x86/fault_handler_x86.cc
@@ -18,13 +18,14 @@
#include <sys/ucontext.h>
+#include "arch/instruction_set.h"
#include "art_method.h"
#include "base/enums.h"
-#include "base/globals.h"
#include "base/hex_dump.h"
#include "base/logging.h" // For VLOG.
#include "base/macros.h"
#include "base/safe_copy.h"
+#include "runtime_globals.h"
#include "thread-current-inl.h"
#if defined(__APPLE__)
diff --git a/runtime/arch/x86/registers_x86.h b/runtime/arch/x86/registers_x86.h
index d3b959fc53..ff6c18f6b0 100644
--- a/runtime/arch/x86/registers_x86.h
+++ b/runtime/arch/x86/registers_x86.h
@@ -19,9 +19,6 @@
#include <iosfwd>
-#include <android-base/logging.h>
-
-#include "base/globals.h"
#include "base/macros.h"
namespace art {
diff --git a/runtime/arch/x86_64/callee_save_frame_x86_64.h b/runtime/arch/x86_64/callee_save_frame_x86_64.h
index 228a902d38..d4f2da7978 100644
--- a/runtime/arch/x86_64/callee_save_frame_x86_64.h
+++ b/runtime/arch/x86_64/callee_save_frame_x86_64.h
@@ -21,9 +21,9 @@
#include "base/bit_utils.h"
#include "base/callee_save_type.h"
#include "base/enums.h"
-#include "base/globals.h"
#include "quick/quick_method_frame_info.h"
#include "registers_x86_64.h"
+#include "runtime_globals.h"
namespace art {
namespace x86_64 {
diff --git a/runtime/arch/x86_64/registers_x86_64.h b/runtime/arch/x86_64/registers_x86_64.h
index 66aea705d2..248c82b694 100644
--- a/runtime/arch/x86_64/registers_x86_64.h
+++ b/runtime/arch/x86_64/registers_x86_64.h
@@ -19,9 +19,6 @@
#include <iosfwd>
-#include <android-base/logging.h>
-
-#include "base/globals.h"
#include "base/macros.h"
namespace art {
diff --git a/runtime/base/callee_save_type.h b/runtime/base/callee_save_type.h
new file mode 100644
index 0000000000..e7cc7e6092
--- /dev/null
+++ b/runtime/base/callee_save_type.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2017 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_BASE_CALLEE_SAVE_TYPE_H_
+#define ART_RUNTIME_BASE_CALLEE_SAVE_TYPE_H_
+
+#include <cstdint>
+#include <iosfwd>
+
+namespace art {
+
+// Returns a special method that describes all callee saves being spilled to the stack.
+enum class CalleeSaveType : uint32_t {
+ kSaveAllCalleeSaves, // All callee-save registers.
+ kSaveRefsOnly, // Only those callee-save registers that can hold references.
+ kSaveRefsAndArgs, // References (see above) and arguments (usually caller-save registers).
+ kSaveEverything, // All registers, including both callee-save and caller-save.
+ kSaveEverythingForClinit, // Special kSaveEverything for clinit.
+ kSaveEverythingForSuspendCheck, // Special kSaveEverything for suspend check.
+ kLastCalleeSaveType // Value used for iteration.
+};
+std::ostream& operator<<(std::ostream& os, const CalleeSaveType& rhs);
+
+static inline constexpr CalleeSaveType GetCanonicalCalleeSaveType(CalleeSaveType type) {
+ if (type == CalleeSaveType::kSaveEverythingForClinit ||
+ type == CalleeSaveType::kSaveEverythingForSuspendCheck) {
+ return CalleeSaveType::kSaveEverything;
+ }
+ return type;
+}
+
+} // namespace art
+
+#endif // ART_RUNTIME_BASE_CALLEE_SAVE_TYPE_H_
diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h
index 41a47af500..aaa1ee6d6f 100644
--- a/runtime/base/mutex.h
+++ b/runtime/base/mutex.h
@@ -28,7 +28,7 @@
#include "base/aborting.h"
#include "base/atomic.h"
-#include "base/globals.h"
+#include "runtime_globals.h"
#include "base/macros.h"
#include "locks.h"
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 5d1f20c6cd..d29a6b7577 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -229,7 +229,9 @@ static void EnsureSkipAccessChecksMethods(Handle<mirror::Class> klass, PointerSi
}
}
-void ClassLinker::ThrowEarlierClassFailure(ObjPtr<mirror::Class> c, bool wrap_in_no_class_def) {
+void ClassLinker::ThrowEarlierClassFailure(ObjPtr<mirror::Class> c,
+ bool wrap_in_no_class_def,
+ bool log) {
// The class failed to initialize on a previous attempt, so we want to throw
// a NoClassDefFoundError (v2 2.17.5). The exception to this rule is if we
// failed in verification, in which case v2 5.4.1 says we need to re-throw
@@ -245,8 +247,10 @@ void ClassLinker::ThrowEarlierClassFailure(ObjPtr<mirror::Class> c, bool wrap_in
extra = verify_error->AsThrowable()->Dump();
}
}
- LOG(INFO) << "Rejecting re-init on previously-failed class " << c->PrettyClass()
- << ": " << extra;
+ if (log) {
+ LOG(INFO) << "Rejecting re-init on previously-failed class " << c->PrettyClass()
+ << ": " << extra;
+ }
}
CHECK(c->IsErroneous()) << c->PrettyClass() << " " << c->GetStatus();
@@ -5044,7 +5048,7 @@ bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass,
// Was the class already found to be erroneous? Done under the lock to match the JLS.
if (klass->IsErroneous()) {
- ThrowEarlierClassFailure(klass.Get(), true);
+ ThrowEarlierClassFailure(klass.Get(), true, /* log= */ true);
VlogClassInitializationFailure(klass);
return false;
}
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index b9ac9caf0c..4f4cb4b942 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -17,6 +17,7 @@
#ifndef ART_RUNTIME_CLASS_LINKER_H_
#define ART_RUNTIME_CLASS_LINKER_H_
+#include <list>
#include <set>
#include <string>
#include <unordered_map>
@@ -89,6 +90,7 @@ template<class T> class ObjectLock;
class Runtime;
class ScopedObjectAccessAlreadyRunnable;
template<size_t kNumReferences> class PACKED(4) StackHandleScope;
+class Thread;
enum VisitRootFlags : uint8_t;
@@ -685,7 +687,9 @@ class ClassLinker {
// Throw the class initialization failure recorded when first trying to initialize the given
// class.
- void ThrowEarlierClassFailure(ObjPtr<mirror::Class> c, bool wrap_in_no_class_def = false)
+ void ThrowEarlierClassFailure(ObjPtr<mirror::Class> c,
+ bool wrap_in_no_class_def = false,
+ bool log = false)
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Locks::dex_lock_);
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index 29b7813881..d7f6127ccb 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -26,7 +26,6 @@
#include "arch/instruction_set.h"
#include "base/common_art_test.h"
-#include "base/globals.h"
#include "base/locks.h"
#include "base/os.h"
#include "base/unix_file/fd_file.h"
@@ -34,6 +33,7 @@
#include "dex/compact_dex_level.h"
// TODO: Add inl file and avoid including inl.
#include "obj_ptr-inl.h"
+#include "runtime_globals.h"
#include "scoped_thread_state_change-inl.h"
namespace art {
diff --git a/runtime/compiler_filter.cc b/runtime/compiler_filter.cc
index bda64ebf25..c0864901cf 100644
--- a/runtime/compiler_filter.cc
+++ b/runtime/compiler_filter.cc
@@ -16,6 +16,8 @@
#include "compiler_filter.h"
+#include <ostream>
+
#include "base/utils.h"
namespace art {
diff --git a/runtime/compiler_filter.h b/runtime/compiler_filter.h
index 012ebcbe1c..c36e40fc0a 100644
--- a/runtime/compiler_filter.h
+++ b/runtime/compiler_filter.h
@@ -17,7 +17,7 @@
#ifndef ART_RUNTIME_COMPILER_FILTER_H_
#define ART_RUNTIME_COMPILER_FILTER_H_
-#include <ostream>
+#include <iosfwd>
#include <string>
#include <vector>
diff --git a/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc b/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc
index 2431bce059..d06dbcb12a 100644
--- a/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc
@@ -16,7 +16,6 @@
#include "base/logging.h" // For VLOG_IS_ON.
#include "base/mutex.h"
-#include "base/systrace.h"
#include "callee_save_frame.h"
#include "interpreter/interpreter.h"
#include "obj_ptr-inl.h" // TODO: Find the other include that isn't complete, and clean this up.
@@ -41,13 +40,10 @@ NO_RETURN static void artDeoptimizeImpl(Thread* self, DeoptimizationKind kind, b
self->AssertHasDeoptimizationContext();
QuickExceptionHandler exception_handler(self, true);
- {
- ScopedTrace trace(std::string("Deoptimization ") + GetDeoptimizationKindName(kind));
- if (single_frame) {
- exception_handler.DeoptimizeSingleFrame(kind);
- } else {
- exception_handler.DeoptimizeStack();
- }
+ if (single_frame) {
+ exception_handler.DeoptimizeSingleFrame(kind);
+ } else {
+ exception_handler.DeoptimizeStack();
}
uintptr_t return_pc = exception_handler.UpdateInstrumentationStack();
if (exception_handler.IsFullFragmentDone()) {
diff --git a/runtime/fault_handler.h b/runtime/fault_handler.h
index d3be51f509..f6cf2d77d7 100644
--- a/runtime/fault_handler.h
+++ b/runtime/fault_handler.h
@@ -23,8 +23,8 @@
#include <vector>
-#include "base/globals.h" // For CanDoImplicitNullCheckOn.
#include "base/locks.h" // For annotalysis.
+#include "runtime_globals.h" // For CanDoImplicitNullCheckOn.
namespace art {
diff --git a/runtime/gc/accounting/bitmap.h b/runtime/gc/accounting/bitmap.h
index bdc686e419..68f2d049d0 100644
--- a/runtime/gc/accounting/bitmap.h
+++ b/runtime/gc/accounting/bitmap.h
@@ -23,9 +23,9 @@
#include <set>
#include <vector>
-#include "base/globals.h"
#include "base/locks.h"
#include "base/mem_map.h"
+#include "runtime_globals.h"
namespace art {
diff --git a/runtime/gc/accounting/card_table.h b/runtime/gc/accounting/card_table.h
index c99ed4bcf5..30c438614b 100644
--- a/runtime/gc/accounting/card_table.h
+++ b/runtime/gc/accounting/card_table.h
@@ -19,9 +19,9 @@
#include <memory>
-#include "base/globals.h"
#include "base/locks.h"
#include "base/mem_map.h"
+#include "runtime_globals.h"
namespace art {
diff --git a/runtime/gc/accounting/mod_union_table.h b/runtime/gc/accounting/mod_union_table.h
index 8c471bc6c2..011e95c442 100644
--- a/runtime/gc/accounting/mod_union_table.h
+++ b/runtime/gc/accounting/mod_union_table.h
@@ -18,12 +18,12 @@
#define ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_H_
#include "base/allocator.h"
-#include "base/globals.h"
#include "base/safe_map.h"
#include "base/tracking_safe_map.h"
#include "bitmap.h"
#include "card_table.h"
#include "mirror/object_reference.h"
+#include "runtime_globals.h"
#include <set>
#include <vector>
diff --git a/runtime/gc/accounting/read_barrier_table.h b/runtime/gc/accounting/read_barrier_table.h
index 2e42f8da5b..44cdb5e02e 100644
--- a/runtime/gc/accounting/read_barrier_table.h
+++ b/runtime/gc/accounting/read_barrier_table.h
@@ -20,10 +20,10 @@
#include <sys/mman.h> // For the PROT_* and MAP_* constants.
#include "base/bit_utils.h"
-#include "base/globals.h"
#include "base/locks.h"
#include "base/mem_map.h"
#include "gc/space/space.h"
+#include "runtime_globals.h"
namespace art {
namespace gc {
diff --git a/runtime/gc/accounting/remembered_set.h b/runtime/gc/accounting/remembered_set.h
index 469074fe50..3525667534 100644
--- a/runtime/gc/accounting/remembered_set.h
+++ b/runtime/gc/accounting/remembered_set.h
@@ -18,9 +18,9 @@
#define ART_RUNTIME_GC_ACCOUNTING_REMEMBERED_SET_H_
#include "base/allocator.h"
-#include "base/globals.h"
#include "base/locks.h"
#include "base/safe_map.h"
+#include "runtime_globals.h"
#include <set>
#include <vector>
diff --git a/runtime/gc/accounting/space_bitmap.h b/runtime/gc/accounting/space_bitmap.h
index 8561f06f3a..6ca254a670 100644
--- a/runtime/gc/accounting/space_bitmap.h
+++ b/runtime/gc/accounting/space_bitmap.h
@@ -23,9 +23,9 @@
#include <set>
#include <vector>
-#include "base/globals.h"
#include "base/locks.h"
#include "base/mem_map.h"
+#include "runtime_globals.h"
namespace art {
diff --git a/runtime/gc/accounting/space_bitmap_test.cc b/runtime/gc/accounting/space_bitmap_test.cc
index 22529b83c2..9f355e3adb 100644
--- a/runtime/gc/accounting/space_bitmap_test.cc
+++ b/runtime/gc/accounting/space_bitmap_test.cc
@@ -19,9 +19,9 @@
#include <stdint.h>
#include <memory>
-#include "base/globals.h"
#include "base/mutex.h"
#include "common_runtime_test.h"
+#include "runtime_globals.h"
#include "space_bitmap-inl.h"
namespace art {
diff --git a/runtime/gc/allocator/dlmalloc.cc b/runtime/gc/allocator/dlmalloc.cc
index 11ad8a84bf..79d4fbfb5a 100644
--- a/runtime/gc/allocator/dlmalloc.cc
+++ b/runtime/gc/allocator/dlmalloc.cc
@@ -60,8 +60,8 @@ static void art_heap_usage_error(const char* function, void* p) {
#include <sys/mman.h>
-#include "base/globals.h"
#include "base/utils.h"
+#include "runtime_globals.h"
extern "C" void DlmallocMadviseCallback(void* start, void* end, size_t used_bytes, void* arg) {
// Is this chunk in use?
diff --git a/runtime/gc/allocator/rosalloc.h b/runtime/gc/allocator/rosalloc.h
index bf26aea71a..090629583c 100644
--- a/runtime/gc/allocator/rosalloc.h
+++ b/runtime/gc/allocator/rosalloc.h
@@ -30,9 +30,9 @@
#include "base/allocator.h"
#include "base/bit_utils.h"
-#include "base/globals.h"
#include "base/mem_map.h"
#include "base/mutex.h"
+#include "runtime_globals.h"
#include "thread.h"
namespace art {
diff --git a/runtime/gc/gc_cause.cc b/runtime/gc/gc_cause.cc
index ee7ac7dae0..8b4bac2f8d 100644
--- a/runtime/gc/gc_cause.cc
+++ b/runtime/gc/gc_cause.cc
@@ -18,8 +18,8 @@
#include <android-base/logging.h>
-#include "base/globals.h"
#include "base/macros.h"
+#include "runtime_globals.h"
#include <ostream>
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 8d19cd0efe..d699da0d16 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -3798,7 +3798,7 @@ void Heap::ConcurrentGC(Thread* self, GcCause cause, bool force_full) {
if (!Runtime::Current()->IsShuttingDown(self)) {
// Wait for any GCs currently running to finish.
if (WaitForGcToComplete(cause, self) == collector::kGcTypeNone) {
- // If the we can't run the GC type we wanted to run, find the next appropriate one and try
+ // If we can't run the GC type we wanted to run, find the next appropriate one and try
// that instead. E.g. can't do partial, so do full instead.
collector::GcType next_gc_type = next_gc_type_;
// If forcing full and next gc type is sticky, override with a non-sticky type.
@@ -3977,8 +3977,13 @@ static constexpr size_t kNewNativeDiscountFactor = 2;
// If weighted java + native memory use exceeds our target by kStopForNativeFactor, and
// newly allocated memory exceeds kHugeNativeAlloc, we wait for GC to complete to avoid
// running out of memory.
-static constexpr float kStopForNativeFactor = 2.0;
-static constexpr size_t kHugeNativeAllocs = 200*1024*1024;
+static constexpr float kStopForNativeFactor = 4.0;
+// TODO: Allow this to be tuned. We want this much smaller for some apps, like Calculator.
+// But making it too small can cause jank in apps like launcher that intentionally allocate
+// large amounts of memory in rapid succession. (b/122099093)
+// For now, we punt, and use a value that should be easily large enough to disable this in all
+// questionable setting, but that is clearly too large to be effective for small memory devices.
+static constexpr size_t kHugeNativeAllocs = 1 * GB;
// Return the ratio of the weighted native + java allocated bytes to its target value.
// A return value > 1.0 means we should collect. Significantly larger values mean we're falling
@@ -3998,8 +4003,9 @@ inline float Heap::NativeMemoryOverTarget(size_t current_native_bytes) {
size_t new_native_bytes = UnsignedDifference(current_native_bytes, old_native_bytes);
size_t weighted_native_bytes = new_native_bytes / kNewNativeDiscountFactor
+ old_native_bytes / kOldNativeDiscountFactor;
- size_t adj_start_bytes = concurrent_start_bytes_
- + NativeAllocationGcWatermark() / kNewNativeDiscountFactor;
+ size_t add_bytes_allowed = static_cast<size_t>(
+ NativeAllocationGcWatermark() * HeapGrowthMultiplier());
+ size_t adj_start_bytes = concurrent_start_bytes_ + add_bytes_allowed / kNewNativeDiscountFactor;
return static_cast<float>(GetBytesAllocated() + weighted_native_bytes)
/ static_cast<float>(adj_start_bytes);
}
@@ -4017,7 +4023,7 @@ inline void Heap::CheckConcurrentGCForNative(Thread* self) {
if (VLOG_IS_ON(heap) || VLOG_IS_ON(startup)) {
LOG(INFO) << "Stopping for native allocation, urgency: " << gc_urgency;
}
- WaitForGcToComplete(kGcCauseForAlloc, self);
+ WaitForGcToComplete(kGcCauseForNativeAlloc, self);
}
} else {
CollectGarbageInternal(NonStickyGcType(), kGcCauseForNativeAlloc, false);
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 6696cc1f06..341f16ad20 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -25,9 +25,7 @@
#include <android-base/logging.h>
#include "allocator_type.h"
-#include "arch/instruction_set.h"
#include "base/atomic.h"
-#include "base/globals.h"
#include "base/macros.h"
#include "base/mutex.h"
#include "base/runtime_debug.h"
@@ -43,11 +41,13 @@
#include "offsets.h"
#include "process_state.h"
#include "read_barrier_config.h"
+#include "runtime_globals.h"
#include "verify_object.h"
namespace art {
class ConditionVariable;
+enum class InstructionSet;
class IsMarkedVisitor;
class Mutex;
class RootVisitor;
@@ -157,7 +157,12 @@ class Heap {
// Client should call NotifyNativeAllocation every kNotifyNativeInterval allocations.
// Should be chosen so that time_to_call_mallinfo / kNotifyNativeInterval is on the same order
// as object allocation time. time_to_call_mallinfo seems to be on the order of 1 usec.
+#ifdef __ANDROID__
static constexpr uint32_t kNotifyNativeInterval = 32;
+#else
+ // Some host mallinfo() implementations are slow. And memory is less scarce.
+ static constexpr uint32_t kNotifyNativeInterval = 128;
+#endif
// RegisterNativeAllocation checks immediately whether GC is needed if size exceeds the
// following. kCheckImmediatelyThreshold * kNotifyNativeInterval should be small enough to
@@ -1140,15 +1145,9 @@ class Heap {
// collect. We collect when a weighted sum of Java memory plus native memory exceeds
// the similarly weighted sum of the Java heap size target and this value.
ALWAYS_INLINE size_t NativeAllocationGcWatermark() const {
- // It probably makes most sense to use a constant multiple of target_footprint_ .
- // This is a good indication of the live data size, together with the
- // intended space-time trade-off, as expressed by SetTargetHeapUtilization.
- // For a fixed target utilization, the amount of GC effort per native
- // allocated byte remains roughly constant as the Java heap size changes.
- // But we previously triggered on max_free_ native allocation which is often much
- // smaller. To avoid unexpected growth, we partially keep that limit in place for now.
- // TODO: Consider HeapGrowthMultiplier(). Maybe.
- return std::min(target_footprint_.load(std::memory_order_relaxed), 2 * max_free_);
+ // We keep the traditional limit of max_free_ in place for small heaps,
+ // but allow it to be adjusted upward for large heaps to limit GC overhead.
+ return target_footprint_.load(std::memory_order_relaxed) / 8 + max_free_;
}
ALWAYS_INLINE void IncrementNumberOfBytesFreedRevoke(size_t freed_bytes_revoke);
diff --git a/runtime/gc/reference_processor.h b/runtime/gc/reference_processor.h
index 17b546ac5e..c1c9a3c833 100644
--- a/runtime/gc/reference_processor.h
+++ b/runtime/gc/reference_processor.h
@@ -17,10 +17,10 @@
#ifndef ART_RUNTIME_GC_REFERENCE_PROCESSOR_H_
#define ART_RUNTIME_GC_REFERENCE_PROCESSOR_H_
-#include "base/globals.h"
#include "base/locks.h"
#include "jni.h"
#include "reference_queue.h"
+#include "runtime_globals.h"
namespace art {
diff --git a/runtime/gc/reference_queue.h b/runtime/gc/reference_queue.h
index 53518cc1c1..90f0be773f 100644
--- a/runtime/gc/reference_queue.h
+++ b/runtime/gc/reference_queue.h
@@ -22,12 +22,12 @@
#include <vector>
#include "base/atomic.h"
-#include "base/globals.h"
#include "base/locks.h"
#include "base/timing_logger.h"
#include "jni.h"
#include "obj_ptr.h"
#include "offsets.h"
+#include "runtime_globals.h"
#include "thread_pool.h"
namespace art {
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 64fd3cd0c8..5ad5f522ec 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -25,6 +25,7 @@
#include "android-base/stringprintf.h"
#include "android-base/strings.h"
+#include "arch/instruction_set.h"
#include "art_field-inl.h"
#include "art_method-inl.h"
#include "base/array_ref.h"
diff --git a/runtime/gc/space/image_space.h b/runtime/gc/space/image_space.h
index 14e364a44c..42ac3e2790 100644
--- a/runtime/gc/space/image_space.h
+++ b/runtime/gc/space/image_space.h
@@ -17,7 +17,6 @@
#ifndef ART_RUNTIME_GC_SPACE_IMAGE_SPACE_H_
#define ART_RUNTIME_GC_SPACE_IMAGE_SPACE_H_
-#include "arch/instruction_set.h"
#include "gc/accounting/space_bitmap.h"
#include "image.h"
#include "space.h"
@@ -26,6 +25,7 @@ namespace art {
template <typename T> class ArrayRef;
class DexFile;
+enum class InstructionSet;
class OatFile;
namespace gc {
diff --git a/runtime/gc/space/image_space_fs.h b/runtime/gc/space/image_space_fs.h
index 14deb6f001..262c6e01e3 100644
--- a/runtime/gc/space/image_space_fs.h
+++ b/runtime/gc/space/image_space_fs.h
@@ -23,13 +23,13 @@
#include "android-base/stringprintf.h"
#include "base/file_utils.h"
-#include "base/globals.h"
#include "base/logging.h" // For VLOG.
#include "base/macros.h"
#include "base/os.h"
#include "base/unix_file/fd_file.h"
#include "base/utils.h"
#include "runtime.h"
+#include "runtime_globals.h"
namespace art {
namespace gc {
diff --git a/runtime/gc/space/malloc_space.cc b/runtime/gc/space/malloc_space.cc
index b5e6b62bcd..474231bb40 100644
--- a/runtime/gc/space/malloc_space.cc
+++ b/runtime/gc/space/malloc_space.cc
@@ -16,6 +16,8 @@
#include "malloc_space.h"
+#include <ostream>
+
#include "android-base/stringprintf.h"
#include "base/logging.h" // For VLOG
diff --git a/runtime/gc/space/malloc_space.h b/runtime/gc/space/malloc_space.h
index 7d28516961..9a90dfd2ac 100644
--- a/runtime/gc/space/malloc_space.h
+++ b/runtime/gc/space/malloc_space.h
@@ -19,7 +19,8 @@
#include "space.h"
-#include <ostream>
+#include <iosfwd>
+
#include "base/memory_tool.h"
#include "base/mutex.h"
diff --git a/runtime/gc/space/space.h b/runtime/gc/space/space.h
index dd5451bf2e..903263f26a 100644
--- a/runtime/gc/space/space.h
+++ b/runtime/gc/space/space.h
@@ -21,12 +21,12 @@
#include <string>
#include "base/atomic.h"
-#include "base/globals.h"
#include "base/locks.h"
#include "base/macros.h"
#include "base/mem_map.h"
#include "gc/accounting/space_bitmap.h"
#include "gc/collector/object_byte_pair.h"
+#include "runtime_globals.h"
namespace art {
namespace mirror {
diff --git a/runtime/gc/space/space_test.h b/runtime/gc/space/space_test.h
index 1b111e3496..7fbd0b5887 100644
--- a/runtime/gc/space/space_test.h
+++ b/runtime/gc/space/space_test.h
@@ -20,13 +20,13 @@
#include <stdint.h>
#include <memory>
-#include "base/globals.h"
#include "common_runtime_test.h"
#include "handle_scope-inl.h"
#include "mirror/array-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
#include "mirror/object-inl.h"
+#include "runtime_globals.h"
#include "scoped_thread_state_change-inl.h"
#include "thread_list.h"
#include "zygote_space.h"
diff --git a/runtime/gc/task_processor.h b/runtime/gc/task_processor.h
index 6db3c37689..86e36ab6d6 100644
--- a/runtime/gc/task_processor.h
+++ b/runtime/gc/task_processor.h
@@ -20,8 +20,8 @@
#include <memory>
#include <set>
-#include "base/globals.h"
#include "base/mutex.h"
+#include "runtime_globals.h"
#include "thread_pool.h"
namespace art {
diff --git a/runtime/handle_scope-inl.h b/runtime/handle_scope-inl.h
index f61c700a36..765ed7d53b 100644
--- a/runtime/handle_scope-inl.h
+++ b/runtime/handle_scope-inl.h
@@ -21,6 +21,7 @@
#include "base/mutex.h"
#include "handle.h"
+#include "handle_wrapper.h"
#include "obj_ptr-inl.h"
#include "thread-current-inl.h"
#include "verify_object.h"
@@ -106,6 +107,15 @@ inline bool HandleScope::Contains(StackReference<mirror::Object>* handle_scope_e
handle_scope_entry <= &GetReferences()[number_of_references_ - 1];
}
+template <typename Visitor>
+inline void HandleScope::VisitRoots(Visitor& visitor) {
+ for (size_t i = 0, count = NumberOfReferences(); i < count; ++i) {
+ // GetReference returns a pointer to the stack reference within the handle scope. If this
+ // needs to be updated, it will be done by the root visitor.
+ visitor.VisitRootIfNonNull(GetHandle(i).GetReference());
+ }
+}
+
template<size_t kNumReferences> template<class T>
inline MutableHandle<T> FixedSizeHandleScope<kNumReferences>::NewHandle(T* object) {
SetReference(pos_, object);
diff --git a/runtime/handle_scope.h b/runtime/handle_scope.h
index 1a1c92f9c5..dae8e29ef0 100644
--- a/runtime/handle_scope.h
+++ b/runtime/handle_scope.h
@@ -24,13 +24,16 @@
#include "base/enums.h"
#include "base/locks.h"
#include "base/macros.h"
-#include "handle.h"
#include "stack_reference.h"
#include "verify_object.h"
namespace art {
+template<class T> class Handle;
class HandleScope;
+template<class T> class HandleWrapper;
+template<class T> class HandleWrapperObjPtr;
+template<class T> class MutableHandle;
template<class MirrorType> class ObjPtr;
class Thread;
class VariableSizedHandleScope;
@@ -144,13 +147,7 @@ class PACKED(4) HandleScope : public BaseHandleScope {
}
template <typename Visitor>
- void VisitRoots(Visitor& visitor) REQUIRES_SHARED(Locks::mutator_lock_) {
- for (size_t i = 0, count = NumberOfReferences(); i < count; ++i) {
- // GetReference returns a pointer to the stack reference within the handle scope. If this
- // needs to be updated, it will be done by the root visitor.
- visitor.VisitRootIfNonNull(GetHandle(i).GetReference());
- }
- }
+ ALWAYS_INLINE void VisitRoots(Visitor& visitor) REQUIRES_SHARED(Locks::mutator_lock_);
protected:
// Return backing storage used for references.
@@ -172,44 +169,6 @@ class PACKED(4) HandleScope : public BaseHandleScope {
DISALLOW_COPY_AND_ASSIGN(HandleScope);
};
-// A wrapper which wraps around Object** and restores the pointer in the destructor.
-// TODO: Delete
-template<class T>
-class HandleWrapper : public MutableHandle<T> {
- public:
- HandleWrapper(T** obj, const MutableHandle<T>& handle)
- : MutableHandle<T>(handle), obj_(obj) {
- }
-
- HandleWrapper(const HandleWrapper&) = default;
-
- ~HandleWrapper() {
- *obj_ = MutableHandle<T>::Get();
- }
-
- private:
- T** const obj_;
-};
-
-
-// A wrapper which wraps around ObjPtr<Object>* and restores the pointer in the destructor.
-// TODO: Add more functionality.
-template<class T>
-class HandleWrapperObjPtr : public MutableHandle<T> {
- public:
- HandleWrapperObjPtr(ObjPtr<T>* obj, const MutableHandle<T>& handle)
- : MutableHandle<T>(handle), obj_(obj) {}
-
- HandleWrapperObjPtr(const HandleWrapperObjPtr&) = default;
-
- ~HandleWrapperObjPtr() {
- *obj_ = ObjPtr<T>(MutableHandle<T>::Get());
- }
-
- private:
- ObjPtr<T>* const obj_;
-};
-
// Fixed size handle scope that is not necessarily linked in the thread.
template<size_t kNumReferences>
class PACKED(4) FixedSizeHandleScope : public HandleScope {
diff --git a/runtime/handle_wrapper.h b/runtime/handle_wrapper.h
new file mode 100644
index 0000000000..01252c724d
--- /dev/null
+++ b/runtime/handle_wrapper.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2014 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_HANDLE_WRAPPER_H_
+#define ART_RUNTIME_HANDLE_WRAPPER_H_
+
+#include "handle.h"
+#include "obj_ptr.h"
+
+namespace art {
+
+// A wrapper which wraps around Object** and restores the pointer in the destructor.
+// TODO: Delete
+template<class T>
+class HandleWrapper : public MutableHandle<T> {
+ public:
+ HandleWrapper(T** obj, const MutableHandle<T>& handle)
+ : MutableHandle<T>(handle), obj_(obj) {
+ }
+
+ HandleWrapper(const HandleWrapper&) = default;
+
+ ~HandleWrapper() {
+ *obj_ = MutableHandle<T>::Get();
+ }
+
+ private:
+ T** const obj_;
+};
+
+
+// A wrapper which wraps around ObjPtr<Object>* and restores the pointer in the destructor.
+// TODO: Add more functionality.
+template<class T>
+class HandleWrapperObjPtr : public MutableHandle<T> {
+ public:
+ HandleWrapperObjPtr(ObjPtr<T>* obj, const MutableHandle<T>& handle)
+ : MutableHandle<T>(handle), obj_(obj) {}
+
+ HandleWrapperObjPtr(const HandleWrapperObjPtr&) = default;
+
+ ~HandleWrapperObjPtr() {
+ *obj_ = ObjPtr<T>(MutableHandle<T>::Get());
+ }
+
+ private:
+ ObjPtr<T>* const obj_;
+};
+
+} // namespace art
+
+#endif // ART_RUNTIME_HANDLE_WRAPPER_H_
diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc
index c146daa809..2d3493d60e 100644
--- a/runtime/hidden_api.cc
+++ b/runtime/hidden_api.cc
@@ -361,9 +361,11 @@ bool ShouldDenyAccessToMemberImpl(T* member,
hiddenapi::ApiList api_list,
AccessMethod access_method) {
DCHECK(member != nullptr);
-
Runtime* runtime = Runtime::Current();
+
EnforcementPolicy policy = runtime->GetHiddenApiEnforcementPolicy();
+ DCHECK(policy != EnforcementPolicy::kDisabled)
+ << "Should never enter this function when access checks are completely disabled";
const bool deny_access =
(policy == EnforcementPolicy::kEnabled) &&
diff --git a/runtime/hidden_api.h b/runtime/hidden_api.h
index a0eeae2950..1a5e010a7d 100644
--- a/runtime/hidden_api.h
+++ b/runtime/hidden_api.h
@@ -311,6 +311,11 @@ inline bool ShouldDenyAccessToMember(T* member,
return false;
}
+ // Exit early if access checks are completely disabled.
+ if (Runtime::Current()->GetHiddenApiEnforcementPolicy() == EnforcementPolicy::kDisabled) {
+ return false;
+ }
+
// Check if caller is exempted from access checks.
// This can be *very* expensive. Save it for last.
if (fn_get_access_context().IsTrusted()) {
diff --git a/runtime/hidden_api_test.cc b/runtime/hidden_api_test.cc
index 595f0779e2..1f83c052eb 100644
--- a/runtime/hidden_api_test.cc
+++ b/runtime/hidden_api_test.cc
@@ -100,13 +100,6 @@ class HiddenApiTest : public CommonRuntimeTest {
TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) {
ScopedObjectAccess soa(self_);
- runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kDisabled);
- ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false);
- ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false);
- ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxP()), false);
- ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxO()), false);
- ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blacklist()), false);
-
runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kJustWarn);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false);
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index 3abe4c529a..34f645b54c 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -42,7 +42,6 @@
#include "art_method-inl.h"
#include "base/array_ref.h"
#include "base/file_utils.h"
-#include "base/globals.h"
#include "base/macros.h"
#include "base/mutex.h"
#include "base/os.h"
@@ -66,6 +65,7 @@
#include "mirror/class-inl.h"
#include "mirror/class.h"
#include "mirror/object-refvisitor-inl.h"
+#include "runtime_globals.h"
#include "scoped_thread_state_change-inl.h"
#include "thread_list.h"
diff --git a/runtime/image.h b/runtime/image.h
index 140f50412c..657828708f 100644
--- a/runtime/image.h
+++ b/runtime/image.h
@@ -20,9 +20,9 @@
#include <string.h>
#include "base/enums.h"
-#include "base/globals.h"
#include "base/iteration_range.h"
#include "mirror/object.h"
+#include "runtime_globals.h"
namespace art {
diff --git a/runtime/jdwp_provider.h b/runtime/jdwp_provider.h
index 9579513939..29fbc3f998 100644
--- a/runtime/jdwp_provider.h
+++ b/runtime/jdwp_provider.h
@@ -19,7 +19,7 @@
#include <ios>
-#include "base/globals.h"
+#include "runtime_globals.h"
namespace art {
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 40c7d30707..fe498133fe 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -39,6 +39,7 @@
#include "runtime.h"
#include "string.h"
#include "subtype_check.h"
+#include "thread-current-inl.h"
namespace art {
namespace mirror {
@@ -1117,6 +1118,18 @@ inline void Class::SetClassLoader(ObjPtr<ClassLoader> new_class_loader) {
}
}
+inline void Class::SetRecursivelyInitialized() {
+ DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId());
+ uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
+ SetAccessFlags(flags | kAccRecursivelyInitialized);
+}
+
+inline void Class::SetHasDefaultMethods() {
+ DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId());
+ uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
+ SetAccessFlags(flags | kAccHasDefaultMethod);
+}
+
} // namespace mirror
} // namespace art
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index f7a41f7f56..d35d526dab 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -30,7 +30,6 @@
#include "object.h"
#include "object_array.h"
#include "read_barrier_option.h"
-#include "thread-current-inl.h"
namespace art {
@@ -52,6 +51,7 @@ template<typename T> class ArraySlice;
class Signature;
class StringPiece;
template<size_t kNumReferences> class PACKED(4) StackHandleScope;
+class Thread;
namespace mirror {
@@ -223,17 +223,9 @@ class MANAGED Class final : public Object {
SetAccessFlags(flags | kAccSkipHiddenapiChecks);
}
- ALWAYS_INLINE void SetRecursivelyInitialized() REQUIRES_SHARED(Locks::mutator_lock_) {
- DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId());
- uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
- SetAccessFlags(flags | kAccRecursivelyInitialized);
- }
+ ALWAYS_INLINE void SetRecursivelyInitialized() REQUIRES_SHARED(Locks::mutator_lock_);
- ALWAYS_INLINE void SetHasDefaultMethods() REQUIRES_SHARED(Locks::mutator_lock_) {
- DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId());
- uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
- SetAccessFlags(flags | kAccHasDefaultMethod);
- }
+ ALWAYS_INLINE void SetHasDefaultMethods() REQUIRES_SHARED(Locks::mutator_lock_);
ALWAYS_INLINE void SetFinalizable() REQUIRES_SHARED(Locks::mutator_lock_) {
uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
diff --git a/runtime/mirror/dex_cache.cc b/runtime/mirror/dex_cache.cc
index 8d2b838cb2..7e79ebe070 100644
--- a/runtime/mirror/dex_cache.cc
+++ b/runtime/mirror/dex_cache.cc
@@ -17,7 +17,6 @@
#include "dex_cache-inl.h"
#include "art_method-inl.h"
-#include "base/globals.h"
#include "class_linker.h"
#include "gc/accounting/card_table-inl.h"
#include "gc/heap.h"
@@ -27,6 +26,7 @@
#include "object.h"
#include "object_array-inl.h"
#include "runtime.h"
+#include "runtime_globals.h"
#include "string.h"
#include "thread.h"
#include "utils/dex_cache_arrays_layout-inl.h"
diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h
index bca7511489..ba222f6695 100644
--- a/runtime/mirror/object.h
+++ b/runtime/mirror/object.h
@@ -20,13 +20,13 @@
#include "base/atomic.h"
#include "base/casts.h"
#include "base/enums.h"
-#include "base/globals.h"
#include "dex/primitive.h"
#include "obj_ptr.h"
#include "object_reference.h"
#include "offsets.h"
#include "read_barrier_config.h"
#include "read_barrier_option.h"
+#include "runtime_globals.h"
#include "verify_object.h"
namespace art {
diff --git a/runtime/mirror/object_reference.h b/runtime/mirror/object_reference.h
index 8636928620..e19e1656ee 100644
--- a/runtime/mirror/object_reference.h
+++ b/runtime/mirror/object_reference.h
@@ -18,10 +18,10 @@
#define ART_RUNTIME_MIRROR_OBJECT_REFERENCE_H_
#include "base/atomic.h"
-#include "base/globals.h"
#include "base/locks.h" // For Locks::mutator_lock_.
#include "heap_poisoning.h"
#include "obj_ptr.h"
+#include "runtime_globals.h"
namespace art {
namespace mirror {
diff --git a/runtime/mirror/string-alloc-inl.h b/runtime/mirror/string-alloc-inl.h
index c31eccff7c..4c4e2af3e7 100644
--- a/runtime/mirror/string-alloc-inl.h
+++ b/runtime/mirror/string-alloc-inl.h
@@ -22,11 +22,11 @@
#include "array.h"
#include "base/bit_utils.h"
-#include "base/globals.h"
#include "class.h"
#include "class_root.h"
#include "gc/heap-inl.h"
#include "runtime.h"
+#include "runtime_globals.h"
#include "thread.h"
namespace art {
diff --git a/runtime/mirror/string-inl.h b/runtime/mirror/string-inl.h
index e11906a85a..f04a8aaa38 100644
--- a/runtime/mirror/string-inl.h
+++ b/runtime/mirror/string-inl.h
@@ -20,10 +20,10 @@
#include "android-base/stringprintf.h"
-#include "base/globals.h"
#include "class-inl.h"
#include "common_throws.h"
#include "dex/utf.h"
+#include "runtime_globals.h"
namespace art {
namespace mirror {
diff --git a/runtime/mirror/string.h b/runtime/mirror/string.h
index b32db08605..c367957bc3 100644
--- a/runtime/mirror/string.h
+++ b/runtime/mirror/string.h
@@ -18,10 +18,10 @@
#define ART_RUNTIME_MIRROR_STRING_H_
#include "base/bit_utils.h"
-#include "base/globals.h"
#include "gc/allocator_type.h"
#include "class.h"
#include "object.h"
+#include "runtime_globals.h"
namespace art {
diff --git a/runtime/oat.cc b/runtime/oat.cc
index d7c968f9d1..c6a963a54f 100644
--- a/runtime/oat.cc
+++ b/runtime/oat.cc
@@ -20,6 +20,7 @@
#include "android-base/stringprintf.h"
+#include "arch/instruction_set.h"
#include "arch/instruction_set_features.h"
#include "base/bit_utils.h"
#include "base/strlcpy.h"
diff --git a/runtime/oat.h b/runtime/oat.h
index ded148914f..88238d96ec 100644
--- a/runtime/oat.h
+++ b/runtime/oat.h
@@ -19,13 +19,13 @@
#include <vector>
-#include "arch/instruction_set.h"
#include "base/macros.h"
#include "base/safe_map.h"
#include "compiler_filter.h"
namespace art {
+enum class InstructionSet;
class InstructionSetFeatures;
class PACKED(4) OatHeader {
diff --git a/runtime/obj_ptr-inl.h b/runtime/obj_ptr-inl.h
index b949c96dd2..f096445913 100644
--- a/runtime/obj_ptr-inl.h
+++ b/runtime/obj_ptr-inl.h
@@ -17,6 +17,8 @@
#ifndef ART_RUNTIME_OBJ_PTR_INL_H_
#define ART_RUNTIME_OBJ_PTR_INL_H_
+#include <ostream>
+
#include "base/bit_utils.h"
#include "obj_ptr.h"
#include "thread-current-inl.h"
diff --git a/runtime/obj_ptr.h b/runtime/obj_ptr.h
index 9e2ee295c7..b0f24dabc8 100644
--- a/runtime/obj_ptr.h
+++ b/runtime/obj_ptr.h
@@ -17,12 +17,12 @@
#ifndef ART_RUNTIME_OBJ_PTR_H_
#define ART_RUNTIME_OBJ_PTR_H_
-#include <ostream>
+#include <iosfwd>
#include <type_traits>
-#include "base/globals.h"
#include "base/locks.h" // For Locks::mutator_lock_.
#include "base/macros.h"
+#include "runtime_globals.h"
// Always inline ObjPtr methods even in debug builds.
#define OBJPTR_INLINE __attribute__ ((always_inline))
diff --git a/runtime/offsets.h b/runtime/offsets.h
index 372b821809..6d1a8e0ed6 100644
--- a/runtime/offsets.h
+++ b/runtime/offsets.h
@@ -17,10 +17,10 @@
#ifndef ART_RUNTIME_OFFSETS_H_
#define ART_RUNTIME_OFFSETS_H_
-#include <ostream>
+#include <iosfwd>
#include "base/enums.h"
-#include "base/globals.h"
+#include "runtime_globals.h"
namespace art {
diff --git a/runtime/parsed_options.h b/runtime/parsed_options.h
index 8c77d39f7b..095d66e62c 100644
--- a/runtime/parsed_options.h
+++ b/runtime/parsed_options.h
@@ -23,10 +23,10 @@
#include <jni.h>
#include "arch/instruction_set.h"
-#include "base/globals.h"
#include "gc/collector_type.h"
#include "gc/space/large_object_space.h"
// #include "jit/profile_saver_options.h"
+#include "runtime_globals.h"
#include "runtime_options.h"
namespace art {
diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc
index 0d570c39ae..3bc718b058 100644
--- a/runtime/quick_exception_handler.cc
+++ b/runtime/quick_exception_handler.cc
@@ -20,6 +20,7 @@
#include "art_method-inl.h"
#include "base/enums.h"
#include "base/logging.h" // For VLOG_IS_ON.
+#include "base/systrace.h"
#include "dex/dex_file_types.h"
#include "dex/dex_instruction.h"
#include "entrypoints/entrypoint_utils.h"
@@ -592,6 +593,10 @@ void QuickExceptionHandler::DeoptimizeSingleFrame(DeoptimizationKind kind) {
// Compiled code made an explicit deoptimization.
ArtMethod* deopt_method = visitor.GetSingleFrameDeoptMethod();
+ SCOPED_TRACE << "Deoptimizing "
+ << deopt_method->PrettyMethod()
+ << ": " << GetDeoptimizationKindName(kind);
+
DCHECK(deopt_method != nullptr);
if (VLOG_IS_ON(deopt) || kDebugExceptionDelivery) {
LOG(INFO) << "Single-frame deopting: "
diff --git a/runtime/reflection.cc b/runtime/reflection.cc
index dfd7e64a08..dbf40f6a8a 100644
--- a/runtime/reflection.cc
+++ b/runtime/reflection.cc
@@ -33,6 +33,7 @@
#include "nth_caller_visitor.h"
#include "scoped_thread_state_change-inl.h"
#include "stack_reference.h"
+#include "thread-inl.h"
#include "well_known_classes.h"
namespace art {
diff --git a/runtime/runtime.h b/runtime/runtime.h
index a2d519de57..a249c9fb9c 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -27,7 +27,6 @@
#include <memory>
#include <vector>
-#include "arch/instruction_set.h"
#include "base/locks.h"
#include "base/macros.h"
#include "base/mem_map.h"
@@ -84,6 +83,7 @@ enum class CalleeSaveType: uint32_t;
class ClassLinker;
class CompilerCallbacks;
class DexFile;
+enum class InstructionSet;
class InternTable;
class IsMarkedVisitor;
class JavaVMExt;
diff --git a/runtime/runtime_globals.h b/runtime/runtime_globals.h
new file mode 100644
index 0000000000..793291a008
--- /dev/null
+++ b/runtime/runtime_globals.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_RUNTIME_GLOBALS_H_
+#define ART_RUNTIME_RUNTIME_GLOBALS_H_
+
+#include "base/globals.h"
+
+namespace art {
+
+// Size of Dex virtual registers.
+static constexpr size_t kVRegSize = 4;
+
+// Returns whether the given memory offset can be used for generating
+// an implicit null check.
+static inline bool CanDoImplicitNullCheckOn(uintptr_t offset) {
+ return offset < kPageSize;
+}
+
+// Required object alignment
+static constexpr size_t kObjectAlignmentShift = 3;
+static constexpr size_t kObjectAlignment = 1u << kObjectAlignmentShift;
+static constexpr size_t kLargeObjectAlignment = kPageSize;
+
+// Garbage collector constants.
+static constexpr bool kMovingCollector = true;
+static constexpr bool kMarkCompactSupport = false && kMovingCollector;
+// True if we allow moving classes.
+static constexpr bool kMovingClasses = !kMarkCompactSupport;
+// If true, enable generational collection when using the Concurrent Copying
+// (CC) collector, i.e. use sticky-bit CC for minor collections and (full) CC
+// for major collections.
+//
+// Generational CC collection is currently only compatible with Baker read
+// barriers.
+#if defined(ART_USE_GENERATIONAL_CC) && defined(ART_READ_BARRIER_TYPE_IS_BAKER)
+static constexpr bool kEnableGenerationalConcurrentCopyingCollection = true;
+#else
+static constexpr bool kEnableGenerationalConcurrentCopyingCollection = false;
+#endif
+
+// If true, enable the tlab allocator by default.
+#ifdef ART_USE_TLAB
+static constexpr bool kUseTlab = true;
+#else
+static constexpr bool kUseTlab = false;
+#endif
+
+// Kinds of tracing clocks.
+enum class TraceClockSource {
+ kThreadCpu,
+ kWall,
+ kDual, // Both wall and thread CPU clocks.
+};
+
+#if defined(__linux__)
+static constexpr TraceClockSource kDefaultTraceClockSource = TraceClockSource::kDual;
+#else
+static constexpr TraceClockSource kDefaultTraceClockSource = TraceClockSource::kWall;
+#endif
+
+static constexpr bool kDefaultMustRelocate = true;
+
+// Size of a heap reference.
+static constexpr size_t kHeapReferenceSize = sizeof(uint32_t);
+
+} // namespace art
+
+#endif // ART_RUNTIME_RUNTIME_GLOBALS_H_
diff --git a/runtime/suspend_reason.h b/runtime/suspend_reason.h
index 289a1a4fb3..af2be10dfd 100644
--- a/runtime/suspend_reason.h
+++ b/runtime/suspend_reason.h
@@ -17,7 +17,7 @@
#ifndef ART_RUNTIME_SUSPEND_REASON_H_
#define ART_RUNTIME_SUSPEND_REASON_H_
-#include <ostream>
+#include <iosfwd>
namespace art {
diff --git a/runtime/thread-inl.h b/runtime/thread-inl.h
index 0c00fb93ac..00f882e3e0 100644
--- a/runtime/thread-inl.h
+++ b/runtime/thread-inl.h
@@ -19,6 +19,7 @@
#include "thread.h"
+#include "arch/instruction_set.h"
#include "base/aborting.h"
#include "base/casts.h"
#include "base/mutex-inl.h"
@@ -393,6 +394,26 @@ inline ShadowFrame* Thread::PopShadowFrame() {
return tlsPtr_.managed_stack.PopShadowFrame();
}
+inline uint8_t* Thread::GetStackEndForInterpreter(bool implicit_overflow_check) const {
+ uint8_t* end = tlsPtr_.stack_end + (implicit_overflow_check
+ ? GetStackOverflowReservedBytes(kRuntimeISA)
+ : 0);
+ if (kIsDebugBuild) {
+ // In a debuggable build, but especially under ASAN, the access-checks interpreter has a
+ // potentially humongous stack size. We don't want to take too much of the stack regularly,
+ // so do not increase the regular reserved size (for compiled code etc) and only report the
+ // virtually smaller stack to the interpreter here.
+ end += GetStackOverflowReservedBytes(kRuntimeISA);
+ }
+ return end;
+}
+
+inline void Thread::ResetDefaultStackEnd() {
+ // Our stacks grow down, so we want stack_end_ to be near there, but reserving enough room
+ // to throw a StackOverflowError.
+ tlsPtr_.stack_end = tlsPtr_.stack_begin + GetStackOverflowReservedBytes(kRuntimeISA);
+}
+
} // namespace art
#endif // ART_RUNTIME_THREAD_INL_H_
diff --git a/runtime/thread.h b/runtime/thread.h
index ad69ecfacc..592013bd03 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -26,13 +26,12 @@
#include <string>
#include "arch/context.h"
-#include "arch/instruction_set.h"
#include "base/atomic.h"
#include "base/enums.h"
-#include "base/globals.h"
#include "base/locks.h"
#include "base/macros.h"
#include "base/safe_map.h"
+#include "base/value_object.h"
#include "entrypoints/jni/jni_entrypoints.h"
#include "entrypoints/quick/quick_entrypoints.h"
#include "handle_scope.h"
@@ -41,6 +40,7 @@
#include "managed_stack.h"
#include "offsets.h"
#include "read_barrier_config.h"
+#include "runtime_globals.h"
#include "runtime_stats.h"
#include "suspend_reason.h"
#include "thread_state.h"
@@ -819,19 +819,7 @@ class Thread {
return tlsPtr_.stack_size - (tlsPtr_.stack_end - tlsPtr_.stack_begin);
}
- uint8_t* GetStackEndForInterpreter(bool implicit_overflow_check) const {
- uint8_t* end = tlsPtr_.stack_end + (implicit_overflow_check
- ? GetStackOverflowReservedBytes(kRuntimeISA)
- : 0);
- if (kIsDebugBuild) {
- // In a debuggable build, but especially under ASAN, the access-checks interpreter has a
- // potentially humongous stack size. We don't want to take too much of the stack regularly,
- // so do not increase the regular reserved size (for compiled code etc) and only report the
- // virtually smaller stack to the interpreter here.
- end += GetStackOverflowReservedBytes(kRuntimeISA);
- }
- return end;
- }
+ ALWAYS_INLINE uint8_t* GetStackEndForInterpreter(bool implicit_overflow_check) const;
uint8_t* GetStackEnd() const {
return tlsPtr_.stack_end;
@@ -841,11 +829,7 @@ class Thread {
void SetStackEndForStackOverflow() REQUIRES_SHARED(Locks::mutator_lock_);
// Set the stack end to that to be used during regular execution
- void ResetDefaultStackEnd() {
- // Our stacks grow down, so we want stack_end_ to be near there, but reserving enough room
- // to throw a StackOverflowError.
- tlsPtr_.stack_end = tlsPtr_.stack_begin + GetStackOverflowReservedBytes(kRuntimeISA);
- }
+ ALWAYS_INLINE void ResetDefaultStackEnd();
bool IsHandlingStackOverflow() const {
return tlsPtr_.stack_end == tlsPtr_.stack_begin;
diff --git a/runtime/thread_state.h b/runtime/thread_state.h
index 8edfeecbdd..e57a040cb1 100644
--- a/runtime/thread_state.h
+++ b/runtime/thread_state.h
@@ -17,7 +17,7 @@
#ifndef ART_RUNTIME_THREAD_STATE_H_
#define ART_RUNTIME_THREAD_STATE_H_
-#include <ostream>
+#include <iosfwd>
namespace art {
diff --git a/runtime/trace.h b/runtime/trace.h
index 582f756ca9..567f6edb22 100644
--- a/runtime/trace.h
+++ b/runtime/trace.h
@@ -27,12 +27,12 @@
#include <vector>
#include "base/atomic.h"
-#include "base/globals.h"
#include "base/locks.h"
#include "base/macros.h"
#include "base/os.h"
#include "base/safe_map.h"
#include "instrumentation.h"
+#include "runtime_globals.h"
namespace unix_file {
class FdFile;
diff --git a/runtime/utils/dex_cache_arrays_layout-inl.h b/runtime/utils/dex_cache_arrays_layout-inl.h
index c0ea6be5a3..3512efe080 100644
--- a/runtime/utils/dex_cache_arrays_layout-inl.h
+++ b/runtime/utils/dex_cache_arrays_layout-inl.h
@@ -22,10 +22,10 @@
#include <android-base/logging.h>
#include "base/bit_utils.h"
-#include "base/globals.h"
#include "dex/primitive.h"
#include "gc_root.h"
#include "mirror/dex_cache.h"
+#include "runtime_globals.h"
namespace art {
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 167982124c..91eba2149b 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -2654,6 +2654,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
// See if instance-of was preceded by a move-object operation, common due to the small
// register encoding space of instance-of, and propagate type information to the source
// of the move-object.
+ // Note: this is only valid if the move source was not clobbered.
uint32_t move_idx = instance_of_idx - 1;
while (0 != move_idx && !GetInstructionFlags(move_idx).IsOpcode()) {
move_idx--;
@@ -2663,28 +2664,25 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
work_insn_idx_)) {
break;
}
+ auto maybe_update_fn = [&instance_of_inst, update_line, this, &cast_type](
+ uint16_t move_src,
+ uint16_t move_trg)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ if (move_trg == instance_of_inst.VRegB_22c() &&
+ move_src != instance_of_inst.VRegA_22c()) {
+ update_line->SetRegisterType<LockOp::kKeep>(this, move_src, cast_type);
+ }
+ };
const Instruction& move_inst = code_item_accessor_.InstructionAt(move_idx);
switch (move_inst.Opcode()) {
case Instruction::MOVE_OBJECT:
- if (move_inst.VRegA_12x() == instance_of_inst.VRegB_22c()) {
- update_line->SetRegisterType<LockOp::kKeep>(this,
- move_inst.VRegB_12x(),
- cast_type);
- }
+ maybe_update_fn(move_inst.VRegB_12x(), move_inst.VRegA_12x());
break;
case Instruction::MOVE_OBJECT_FROM16:
- if (move_inst.VRegA_22x() == instance_of_inst.VRegB_22c()) {
- update_line->SetRegisterType<LockOp::kKeep>(this,
- move_inst.VRegB_22x(),
- cast_type);
- }
+ maybe_update_fn(move_inst.VRegB_22x(), move_inst.VRegA_22x());
break;
case Instruction::MOVE_OBJECT_16:
- if (move_inst.VRegA_32x() == instance_of_inst.VRegB_22c()) {
- update_line->SetRegisterType<LockOp::kKeep>(this,
- move_inst.VRegB_32x(),
- cast_type);
- }
+ maybe_update_fn(move_inst.VRegB_32x(), move_inst.VRegA_32x());
break;
default:
break;
diff --git a/runtime/verify_object.cc b/runtime/verify_object.cc
index 70ca13f913..2b8c7da76b 100644
--- a/runtime/verify_object.cc
+++ b/runtime/verify_object.cc
@@ -17,11 +17,11 @@
#include "verify_object-inl.h"
#include "base/bit_utils.h"
-#include "base/globals.h"
#include "gc/heap.h"
#include "mirror/object-inl.h"
#include "obj_ptr-inl.h"
#include "runtime.h"
+#include "runtime_globals.h"
namespace art {