Add support for -Xverify:none mode.
This mode skips all verification and compilation.
Public bug: https://code.google.com/p/android/issues/detail?id=67664
Change-Id: Idd00ab8e9e46d129c02988b063c41a507e07bf5b
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 19cc23c..6c5406e 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -569,6 +569,10 @@
Runtime::Current()->AddCurrentRuntimeFeaturesAsDex2OatArguments(&argv);
+ if (!Runtime::Current()->IsVerificationEnabled()) {
+ argv.push_back("--compiler-filter=verify-none");
+ }
+
if (!kIsTargetBuild) {
argv.push_back("--host");
}
@@ -2533,6 +2537,12 @@
klass->SetStatus(mirror::Class::kStatusVerifyingAtRuntime, self);
}
+ // Skip verification if disabled.
+ if (!Runtime::Current()->IsVerificationEnabled()) {
+ klass->SetStatus(mirror::Class::kStatusVerified, self);
+ return;
+ }
+
// Verify super class.
SirtRef<mirror::Class> super(self, klass->GetSuperClass());
if (super.get() != NULL) {
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index e2086f1..08a674f 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -196,6 +196,8 @@
profile_backoff_coefficient_ = 2.0;
profile_clock_source_ = kDefaultProfilerClockSource;
+ verify_ = true;
+
// Default to explicit checks. Switch off with -implicit-checks:.
// or setprop dalvik.vm.implicit_checks check1,check2,...
#ifdef HAVE_ANDROID_OS
@@ -569,6 +571,16 @@
return false;
}
image_compiler_options_.push_back(options[i].first);
+ } else if (StartsWith(option, "-Xverify:")) {
+ std::string verify_mode = option.substr(strlen("-Xverify:"));
+ if (verify_mode == "none") {
+ verify_ = false;
+ } else if (verify_mode == "remote" || verify_mode == "all") {
+ verify_ = true;
+ } else {
+ Usage("Unknown -Xverify option %s", verify_mode.c_str());
+ return false;
+ }
} else if (StartsWith(option, "-ea:") ||
StartsWith(option, "-da:") ||
StartsWith(option, "-enableassertions:") ||
@@ -578,7 +590,6 @@
(option == "-dsa") ||
(option == "-enablesystemassertions") ||
(option == "-disablesystemassertions") ||
- StartsWith(option, "-Xverify:") ||
(option == "-Xrs") ||
StartsWith(option, "-Xint:") ||
StartsWith(option, "-Xdexopt:") ||
diff --git a/runtime/parsed_options.h b/runtime/parsed_options.h
index d6516a8..416bc78 100644
--- a/runtime/parsed_options.h
+++ b/runtime/parsed_options.h
@@ -80,6 +80,7 @@
uint32_t profile_interval_us_;
double profile_backoff_coefficient_;
ProfilerClockSource profile_clock_source_;
+ bool verify_;
static constexpr uint32_t kExplicitNullCheck = 1;
static constexpr uint32_t kExplicitSuspendCheck = 2;
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index b0a6584..1b3c996 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -132,7 +132,8 @@
preinitialization_transaction_(nullptr),
null_pointer_handler_(nullptr),
suspend_handler_(nullptr),
- stack_overflow_handler_(nullptr) {
+ stack_overflow_handler_(nullptr),
+ verify_(false) {
for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) {
callee_save_methods_[i] = nullptr;
}
@@ -521,6 +522,7 @@
thread_list_ = new ThreadList;
intern_table_ = new InternTable;
+ verify_ = options->verify_;
if (options->interpreter_only_) {
GetInstrumentation()->ForceInterpretOnly();
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 176b71c..7b3e04c 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -421,6 +421,10 @@
return stack_overflow_handler_ == nullptr;
}
+ bool IsVerificationEnabled() const {
+ return verify_;
+ }
+
bool RunningOnValgrind() const {
return running_on_valgrind_;
}
@@ -563,6 +567,9 @@
SuspensionHandler* suspend_handler_;
StackOverflowHandler* stack_overflow_handler_;
+ // If false, verification is disabled. True by default.
+ bool verify_;
+
DISALLOW_COPY_AND_ASSIGN(Runtime);
};