diff options
| author | 2016-04-01 17:33:31 -0700 | |
|---|---|---|
| committer | 2016-04-04 11:36:13 -0700 | |
| commit | 085a072b209ac24ab4cb6b565a1570b485ec2fa3 (patch) | |
| tree | 4dcbb7c502d72bfb4b29fa0ad4c14f7e6e77d7ab /compiler/driver/compiler_driver.cc | |
| parent | 7d9a5b0fbceef5806f059060d47533b9e699ec28 (diff) | |
Mark array classes as verification attempted
We now initialize all array classes in the compiler driver. This in
turn will ensure they are marked verified in the image. This
prevents dirty pages in the image since we would otherwise set the
flags in the zygote.
On BusinessCard:
Reduces shared dirty from 636k -> 432k for boot.art, and dirty pages
from 183 to 132.
(cherry picked from commit 3b674098bef6eaf7d3fb731878293ef715fe1080)
Change-Id: If3093e4e3242e4ee3ea120abe5be7db028290260
Diffstat (limited to 'compiler/driver/compiler_driver.cc')
| -rw-r--r-- | compiler/driver/compiler_driver.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index d29d528c27..be149af82a 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -2486,6 +2486,20 @@ void CompilerDriver::InitializeClasses(jobject jni_class_loader, context.ForAll(0, dex_file.NumClassDefs(), &visitor, init_thread_count); } +class InitializeArrayClassVisitor : public ClassVisitor { + public: + virtual bool operator()(mirror::Class* klass) OVERRIDE SHARED_REQUIRES(Locks::mutator_lock_) { + if (klass->IsArrayClass()) { + StackHandleScope<1> hs(Thread::Current()); + Runtime::Current()->GetClassLinker()->EnsureInitialized(hs.Self(), + hs.NewHandle(klass), + true, + true); + } + return true; + } +}; + void CompilerDriver::InitializeClasses(jobject class_loader, const std::vector<const DexFile*>& dex_files, TimingLogger* timings) { @@ -2494,6 +2508,14 @@ void CompilerDriver::InitializeClasses(jobject class_loader, CHECK(dex_file != nullptr); InitializeClasses(class_loader, *dex_file, dex_files, timings); } + { + // Make sure that we call EnsureIntiailized on all the array classes to call + // SetVerificationAttempted so that the access flags are set. If we do not do this they get + // changed at runtime resulting in more dirty image pages. + ScopedObjectAccess soa(Thread::Current()); + InitializeArrayClassVisitor visitor; + Runtime::Current()->GetClassLinker()->VisitClasses(&visitor); + } if (IsBootImage()) { // Prune garbage objects created during aborted transactions. Runtime::Current()->GetHeap()->CollectGarbage(true); |