summaryrefslogtreecommitdiff
path: root/compiler/optimizing/optimizing_compiler.cc
diff options
context:
space:
mode:
authorRoland Levillain <rpl@google.com>2016-11-01 14:48:47 +0000
committerRoland Levillain <rpl@google.com>2016-11-01 14:48:47 +0000
commitb0103ca545c285f07e30ba5fd1cc007332fef66b (patch)
treeb9adcb3e16c9e9bc2de17571b3f03b6fd583ca61 /compiler/optimizing/optimizing_compiler.cc
parentb9b8cab87a275fad382fefbddd18daf495a58772 (diff)
Flush the CFG visualizer output after writing to it.
This fixes test failures exposed by the ART Buildbot in 608-checker-unresolved-lse (AOT) on the hammerhead-ndebug configuration. The test used to fail because the CFG file dumped by second invocation of dex2oat on device would be truncated (at the beginning of the disassembly section of the second compiled Dex file's contents) because of dex2oat's fast exit. Interestingly enough, this is the only case where this failure has been observed, which seems to be due to a combination of: - targeting (32-bit) ARM; - using a secondary Dex file (used to create an unresolved access for that test); - compiling that secondary Dex file with dex2oat (ndebug mode) instead of dex2oatd; - supporting multithread CFG graph dumping (by having the write-to-file operation in a critical section) since https://android-review.googlesource.com/#/c/296224/. Test: art/test/run-test -O --debuggable 608-checker-unresolved-lse Change-Id: Ifc1a23a3708b8645fd36c148312074bb9fe00cfc
Diffstat (limited to 'compiler/optimizing/optimizing_compiler.cc')
-rw-r--r--compiler/optimizing/optimizing_compiler.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 8c769270b1..19fd6f95c3 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -170,6 +170,15 @@ class PassObserver : public ValueObject {
if (visualizer_enabled_) {
MutexLock mu(Thread::Current(), visualizer_dump_mutex_);
*visualizer_output_ << visualizer_oss_.str();
+ // The destructor of `visualizer_output_` is normally
+ // responsible for flushing (and closing) the stream, but it
+ // won't be invoked during fast exits in non-debug mode -- see
+ // art::Dex2Oat::~Dex2Oat, which explicitly abandons some
+ // objects (such as the compiler driver) in non-debug mode, to
+ // avoid the cost of destructing them. Therefore we explicitly
+ // flush the stream here to prevent truncated CFG visualizer
+ // files.
+ visualizer_output_->flush();
}
}