From eb2c741c70c3ee117ff35ad682f18b90349590b8 Mon Sep 17 00:00:00 2001 From: Roland Levillain Date: Thu, 28 Jan 2016 14:37:01 +0000 Subject: [PATCH] Do not enforce deterministic compilation with read barriers. Forcing determinism of the boot image compilation (on host) does not work when read barriers are enabled, as the former switches the GC to a non-concurrent one by passing the option `-Xgc:nonconcurrent`. Also make dex2oat abort when invoked with `--force-determinism` while read barriers are enabled. Bug: 12687968 Bug: 26687569 Change-Id: I37b388fccbe4502a90def8031a898f1a40df6a9f --- dex2oat/dex2oat.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index bbed09ce1..f56fc385a 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -380,6 +380,10 @@ NO_RETURN static void Usage(const char* fmt, ...) { UsageError(" --multi-image: specify that separate oat and image files be generated for each " "input dex file."); UsageError(""); + UsageError(" --force-determinism: force the compiler to emit a deterministic output."); + UsageError(" This option is incompatible with read barriers (e.g., if dex2oat has been"); + UsageError(" built with the environment variable `ART_USE_READ_BARRIER` set to `true`)."); + UsageError(""); std::cerr << "See log for usage error information\n"; exit(EXIT_FAILURE); } @@ -924,8 +928,11 @@ class Dex2Oat FINAL { // Fill some values into the key-value store for the oat header. key_value_store_.reset(new SafeMap()); - // Automatically force determinism for the boot image in a host build. - if (!kIsTargetBuild && IsBootImage()) { + // Automatically force determinism for the boot image in a host + // build, except when read barriers are enabled, as the former + // switches the GC to a non-concurrent one by passing the + // option `-Xgc:nonconcurrent` (see below). + if (!kIsTargetBuild && IsBootImage() && !kEmitCompilerReadBarrier) { force_determinism_ = true; } compiler_options_->force_determinism_ = force_determinism_; @@ -1173,6 +1180,9 @@ class Dex2Oat FINAL { } else if (option.starts_with("--no-inline-from=")) { no_inline_from_string_ = option.substr(strlen("--no-inline-from=")).data(); } else if (option == "--force-determinism") { + if (kEmitCompilerReadBarrier) { + Usage("Cannot use --force-determinism with read barriers"); + } force_determinism_ = true; } else if (!compiler_options_->ParseCompilerOption(option, Usage)) { Usage("Unknown argument %s", option.data()); -- 2.11.0