Fix implicit check option handling for non-cross-compiles
This fixes an issue where the compiler was not being told to
generate implicit checks but the runtime was expecting them.
Bug: 15747876
Change-Id: I65e7475bac245c44d5094eb666d67bc1af327ab1
diff --git a/build/Android.oat.mk b/build/Android.oat.mk
index fbb7eb3..c67a815 100644
--- a/build/Android.oat.mk
+++ b/build/Android.oat.mk
@@ -42,6 +42,11 @@
$(HOST_CORE_OAT_OUT): $(HOST_CORE_IMG_OUT)
+IMPLICIT_CHECKS_arm := null,stack
+IMPLICIT_CHECKS_arm64 := none
+IMPLICIT_CHECKS_x86 := none
+IMPLICIT_CHECKS_x86_64 := none
+IMPLICIT_CHECKS_mips := none
define create-oat-target-targets
$$($(1)TARGET_CORE_IMG_OUT): $$($(1)TARGET_CORE_DEX_FILES) $$(DEX2OATD_DEPENDENCY)
@echo "target dex2oat: $$@ ($$?)"
@@ -49,6 +54,7 @@
$$(hide) $$(DEX2OATD) --runtime-arg -Xms16m --runtime-arg -Xmx16m --image-classes=$$(PRELOADED_CLASSES) $$(addprefix \
--dex-file=,$$(TARGET_CORE_DEX_FILES)) $$(addprefix --dex-location=,$$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$$($(1)TARGET_CORE_OAT_OUT) \
--oat-location=$$($(1)TARGET_CORE_OAT) --image=$$($(1)TARGET_CORE_IMG_OUT) --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) \
+ --implicit-checks=$(IMPLICIT_CHECKS_$($(1)TARGET_ARCH)) \
--instruction-set=$$($(1)TARGET_ARCH) --instruction-set-features=$$(TARGET_INSTRUCTION_SET_FEATURES) --android-root=$$(PRODUCT_OUT)/system
# This "renaming" eases declaration in art/Android.mk
@@ -58,7 +64,7 @@
endef
ifdef TARGET_2ND_ARCH
-$(eval $(call create-oat-target-targets,2ND_))
+ $(eval $(call create-oat-target-targets,2ND_))
endif
$(eval $(call create-oat-target-targets,))
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 5f3cd92..38051ea 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -748,6 +748,7 @@
bool* explicit_so_checks, bool* explicit_suspend_checks) {
switch (isa) {
case kArm:
+ case kThumb2:
break; // All checks implemented, leave as is.
default: // No checks implemented, reset all to explicit checks.
@@ -1039,8 +1040,8 @@
} else {
Usage("--implicit-checks passed non-recognized value %s", val.c_str());
}
- has_explicit_checks_options = true;
}
+ has_explicit_checks_options = true;
} else {
Usage("Unknown argument %s", option.data());
}
@@ -1170,6 +1171,7 @@
CheckExplicitCheckOptions(instruction_set, &explicit_null_checks, &explicit_so_checks,
&explicit_suspend_checks);
+ LOG(INFO) << "init compiler options for explicit null: " << explicit_null_checks;
CompilerOptions compiler_options(compiler_filter,
huge_method_threshold,
large_method_threshold,
@@ -1256,7 +1258,17 @@
// TODO: Not sure whether it's a good idea to allow anything else but the runtime option in
// this case at all, as we'll have to throw away produced code for a mismatch.
if (!has_explicit_checks_options) {
- if (instruction_set == kRuntimeISA) {
+ bool cross_compiling = true;
+ switch (kRuntimeISA) {
+ case kArm:
+ case kThumb2:
+ cross_compiling = instruction_set != kArm && instruction_set != kThumb2;
+ break;
+ default:
+ cross_compiling = instruction_set != kRuntimeISA;
+ break;
+ }
+ if (!cross_compiling) {
Runtime* runtime = Runtime::Current();
compiler_options.SetExplicitNullChecks(runtime->ExplicitNullChecks());
compiler_options.SetExplicitStackOverflowChecks(runtime->ExplicitStackOverflowChecks());