summaryrefslogtreecommitdiff
path: root/compiler/driver/compiler_driver.h
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2016-01-20 13:33:13 -0800
committer Andreas Gampe <agampe@google.com> 2016-01-27 15:39:30 -0800
commitace0dc1dd5480ad458e622085e51583653853fb9 (patch)
treede095794b5c92933ad667bff353045458bb1c633 /compiler/driver/compiler_driver.h
parent8feb2cc26420f31e1805e57acddbb4ae303a2994 (diff)
ART: Add option to ensure deterministic compilation
To ensure reliable stable generation of a boot image, add a flag for forced determinism, trading compile time for a deterministic output. We have to run certain passes in the compiler-driver single-threaded. It is also necessary to try to make the heap layout deterministic. Switch to nonconcurrent GC, use the free-list implementation for LOS, and try to allocate the main space at a known location. This is best effort at the moment. To allow the compiler phase to be parallelized, const-strings need to be created beforehand. The identity hashcode seed needs to be pinned. Besides the Dex object we also need to null the DexFile pointer in dex caches. For classes, we need to remove the clinit thread ID. Fix oatdump alignment padding accounting. Bug: 26687569 Change-Id: Ia82120e8f715bb3691d861817b12778ac677355a
Diffstat (limited to 'compiler/driver/compiler_driver.h')
-rw-r--r--compiler/driver/compiler_driver.h76
1 files changed, 52 insertions, 24 deletions
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 6a2f7bfd4e..5e35cbb309 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -411,7 +411,7 @@ class CompilerDriver {
}
size_t GetThreadCount() const {
- return thread_count_;
+ return parallel_thread_count_;
}
bool GetDumpStats() const {
@@ -550,8 +550,9 @@ class CompilerDriver {
SHARED_REQUIRES(Locks::mutator_lock_);
private:
- void PreCompile(jobject class_loader, const std::vector<const DexFile*>& dex_files,
- ThreadPool* thread_pool, TimingLogger* timings)
+ void PreCompile(jobject class_loader,
+ const std::vector<const DexFile*>& dex_files,
+ TimingLogger* timings)
REQUIRES(!Locks::mutator_lock_, !compiled_classes_lock_);
void LoadImageClasses(TimingLogger* timings) REQUIRES(!Locks::mutator_lock_);
@@ -559,49 +560,71 @@ class CompilerDriver {
// Attempt to resolve all type, methods, fields, and strings
// referenced from code in the dex file following PathClassLoader
// ordering semantics.
- void Resolve(jobject class_loader, const std::vector<const DexFile*>& dex_files,
- ThreadPool* thread_pool, TimingLogger* timings)
+ void Resolve(jobject class_loader,
+ const std::vector<const DexFile*>& dex_files,
+ TimingLogger* timings)
REQUIRES(!Locks::mutator_lock_);
- void ResolveDexFile(jobject class_loader, const DexFile& dex_file,
+ void ResolveDexFile(jobject class_loader,
+ const DexFile& dex_file,
const std::vector<const DexFile*>& dex_files,
- ThreadPool* thread_pool, TimingLogger* timings)
+ ThreadPool* thread_pool,
+ size_t thread_count,
+ TimingLogger* timings)
REQUIRES(!Locks::mutator_lock_);
- void Verify(jobject class_loader, const std::vector<const DexFile*>& dex_files,
- ThreadPool* thread_pool, TimingLogger* timings);
- void VerifyDexFile(jobject class_loader, const DexFile& dex_file,
+ void Verify(jobject class_loader,
+ const std::vector<const DexFile*>& dex_files,
+ TimingLogger* timings);
+ void VerifyDexFile(jobject class_loader,
+ const DexFile& dex_file,
const std::vector<const DexFile*>& dex_files,
- ThreadPool* thread_pool, TimingLogger* timings)
+ ThreadPool* thread_pool,
+ size_t thread_count,
+ TimingLogger* timings)
REQUIRES(!Locks::mutator_lock_);
- void SetVerified(jobject class_loader, const std::vector<const DexFile*>& dex_files,
- ThreadPool* thread_pool, TimingLogger* timings);
- void SetVerifiedDexFile(jobject class_loader, const DexFile& dex_file,
+ void SetVerified(jobject class_loader,
+ const std::vector<const DexFile*>& dex_files,
+ TimingLogger* timings);
+ void SetVerifiedDexFile(jobject class_loader,
+ const DexFile& dex_file,
const std::vector<const DexFile*>& dex_files,
- ThreadPool* thread_pool, TimingLogger* timings)
+ ThreadPool* thread_pool,
+ size_t thread_count,
+ TimingLogger* timings)
REQUIRES(!Locks::mutator_lock_);
- void InitializeClasses(jobject class_loader, const std::vector<const DexFile*>& dex_files,
- ThreadPool* thread_pool, TimingLogger* timings)
+ void InitializeClasses(jobject class_loader,
+ const std::vector<const DexFile*>& dex_files,
+ TimingLogger* timings)
REQUIRES(!Locks::mutator_lock_, !compiled_classes_lock_);
- void InitializeClasses(jobject class_loader, const DexFile& dex_file,
+ void InitializeClasses(jobject class_loader,
+ const DexFile& dex_file,
const std::vector<const DexFile*>& dex_files,
- ThreadPool* thread_pool, TimingLogger* timings)
+ TimingLogger* timings)
REQUIRES(!Locks::mutator_lock_, !compiled_classes_lock_);
void UpdateImageClasses(TimingLogger* timings) REQUIRES(!Locks::mutator_lock_);
static void FindClinitImageClassesCallback(mirror::Object* object, void* arg)
SHARED_REQUIRES(Locks::mutator_lock_);
- void Compile(jobject class_loader, const std::vector<const DexFile*>& dex_files,
- ThreadPool* thread_pool, TimingLogger* timings);
- void CompileDexFile(jobject class_loader, const DexFile& dex_file,
+ void Compile(jobject class_loader,
+ const std::vector<const DexFile*>& dex_files,
+ TimingLogger* timings);
+ void CompileDexFile(jobject class_loader,
+ const DexFile& dex_file,
const std::vector<const DexFile*>& dex_files,
- ThreadPool* thread_pool, TimingLogger* timings)
+ ThreadPool* thread_pool,
+ size_t thread_count,
+ TimingLogger* timings)
REQUIRES(!Locks::mutator_lock_);
bool MayInlineInternal(const DexFile* inlined_from, const DexFile* inlined_into) const;
+ void InitializeThreadPools();
+ void FreeThreadPools();
+ void CheckThreadPools();
+
const CompilerOptions* const compiler_options_;
VerificationResults* const verification_results_;
DexFileToMethodInlinerMap* const method_inliner_map_;
@@ -652,7 +675,12 @@ class CompilerDriver {
bool had_hard_verifier_failure_;
- size_t thread_count_;
+ // A thread pool that can (potentially) run tasks in parallel.
+ std::unique_ptr<ThreadPool> parallel_thread_pool_;
+ size_t parallel_thread_count_;
+
+ // A thread pool that guarantees running single-threaded on the main thread.
+ std::unique_ptr<ThreadPool> single_thread_pool_;
class AOTCompilationStats;
std::unique_ptr<AOTCompilationStats> stats_;