summaryrefslogtreecommitdiff
path: root/runtime/runtime.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/runtime.cc')
-rw-r--r--runtime/runtime.cc42
1 files changed, 28 insertions, 14 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index a4ed21e450..c88799cc28 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -134,9 +134,7 @@
#include "native/sun_misc_Unsafe.h"
#include "native_bridge_art_interface.h"
#include "native_stack_dump.h"
-#include "nativehelper/JniConstants.h"
-#include "nativehelper/JniConstants-priv.h"
-#include "nativehelper/ScopedLocalRef.h"
+#include "nativehelper/scoped_local_ref.h"
#include "oat_file.h"
#include "oat_file_manager.h"
#include "object_callbacks.h"
@@ -174,6 +172,11 @@ static constexpr double kLowMemoryMinLoadFactor = 0.5;
static constexpr double kLowMemoryMaxLoadFactor = 0.8;
static constexpr double kNormalMinLoadFactor = 0.4;
static constexpr double kNormalMaxLoadFactor = 0.7;
+
+// Extra added to the default heap growth multiplier. Used to adjust the GC ergonomics for the read
+// barrier config.
+static constexpr double kExtraDefaultHeapGrowthMultiplier = kUseReadBarrier ? 1.0 : 0.0;
+
Runtime* Runtime::instance_ = nullptr;
struct TraceConfig {
@@ -407,10 +410,6 @@ Runtime::~Runtime() {
// instance. We rely on a small initialization order issue in Runtime::Start() that requires
// elements of WellKnownClasses to be null, see b/65500943.
WellKnownClasses::Clear();
-
- // Ensure that libnativehelper caching is invalidated, in case a new runtime is to be brought
- // up later.
- android::ClearJniConstantsCache();
}
struct AbortState {
@@ -508,6 +507,10 @@ void Runtime::Abort(const char* msg) {
UNUSED(old_value);
#endif
+#ifdef ART_TARGET_ANDROID
+ android_set_abort_message(msg);
+#endif
+
// Ensure that we don't have multiple threads trying to abort at once,
// which would result in significantly worse diagnostics.
MutexLock mu(Thread::Current(), *Locks::abort_lock_);
@@ -1021,7 +1024,12 @@ static size_t OpenDexFiles(const std::vector<std::string>& dex_filenames,
LOG(WARNING) << "Skipping non-existent dex file '" << dex_filename << "'";
continue;
}
- if (!DexFileLoader::Open(dex_filename, dex_location, kVerifyChecksum, &error_msg, dex_files)) {
+ if (!DexFileLoader::Open(dex_filename,
+ dex_location,
+ Runtime::Current()->IsVerificationEnabled(),
+ kVerifyChecksum,
+ &error_msg,
+ dex_files)) {
LOG(WARNING) << "Failed to open .dex from file '" << dex_filename << "': " << error_msg;
++failure_count;
}
@@ -1143,6 +1151,7 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) {
zygote_max_failed_boots_ = runtime_options.GetOrDefault(Opt::ZygoteMaxFailedBoots);
experimental_flags_ = runtime_options.GetOrDefault(Opt::Experimental);
is_low_memory_mode_ = runtime_options.Exists(Opt::LowMemoryMode);
+ madvise_random_access_ = runtime_options.GetOrDefault(Opt::MadviseRandomAccess);
plugins_ = runtime_options.ReleaseOrDefault(Opt::Plugins);
agents_ = runtime_options.ReleaseOrDefault(Opt::AgentPath);
@@ -1151,13 +1160,22 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) {
// agents_.push_back(lib);
// }
+ float foreground_heap_growth_multiplier;
+ if (is_low_memory_mode_ && !runtime_options.Exists(Opt::ForegroundHeapGrowthMultiplier)) {
+ // If low memory mode, use 1.0 as the multiplier by default.
+ foreground_heap_growth_multiplier = 1.0f;
+ } else {
+ foreground_heap_growth_multiplier =
+ runtime_options.GetOrDefault(Opt::ForegroundHeapGrowthMultiplier) +
+ kExtraDefaultHeapGrowthMultiplier;
+ }
XGcOption xgc_option = runtime_options.GetOrDefault(Opt::GcOption);
heap_ = new gc::Heap(runtime_options.GetOrDefault(Opt::MemoryInitialSize),
runtime_options.GetOrDefault(Opt::HeapGrowthLimit),
runtime_options.GetOrDefault(Opt::HeapMinFree),
runtime_options.GetOrDefault(Opt::HeapMaxFree),
runtime_options.GetOrDefault(Opt::HeapTargetUtilization),
- runtime_options.GetOrDefault(Opt::ForegroundHeapGrowthMultiplier),
+ foreground_heap_growth_multiplier,
runtime_options.GetOrDefault(Opt::MemoryMaximumSize),
runtime_options.GetOrDefault(Opt::NonMovingSpaceCapacity),
runtime_options.GetOrDefault(Opt::Image),
@@ -1533,11 +1551,7 @@ void Runtime::InitNativeMethods() {
// Must be in the kNative state for calling native methods (JNI_OnLoad code).
CHECK_EQ(self->GetState(), kNative);
- // First set up JniConstants, which is used by both the runtime's built-in native
- // methods and libcore.
- JniConstants::init(env);
-
- // Then set up the native methods provided by the runtime itself.
+ // Set up the native methods provided by the runtime itself.
RegisterRuntimeNativeMethods(env);
// Initialize classes used in JNI. The initialization requires runtime native