Home | History | Annotate | Download | only in dex
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ART_COMPILER_DEX_QUICK_COMPILER_CALLBACKS_H_
     18 #define ART_COMPILER_DEX_QUICK_COMPILER_CALLBACKS_H_
     19 
     20 #include "compiler_callbacks.h"
     21 #include "verifier/verifier_deps.h"
     22 
     23 namespace art {
     24 
     25 class CompilerDriver;
     26 class DexFile;
     27 class VerificationResults;
     28 
     29 class QuickCompilerCallbacks FINAL : public CompilerCallbacks {
     30  public:
     31   explicit QuickCompilerCallbacks(CompilerCallbacks::CallbackMode mode)
     32       : CompilerCallbacks(mode), dex_files_(nullptr) {}
     33 
     34   ~QuickCompilerCallbacks() { }
     35 
     36   void MethodVerified(verifier::MethodVerifier* verifier)
     37       REQUIRES_SHARED(Locks::mutator_lock_) OVERRIDE;
     38 
     39   void ClassRejected(ClassReference ref) OVERRIDE;
     40 
     41   // We are running in an environment where we can call patchoat safely so we should.
     42   bool IsRelocationPossible() OVERRIDE {
     43     return true;
     44   }
     45 
     46   verifier::VerifierDeps* GetVerifierDeps() const OVERRIDE {
     47     return verifier_deps_.get();
     48   }
     49 
     50   void SetVerifierDeps(verifier::VerifierDeps* deps) OVERRIDE {
     51     verifier_deps_.reset(deps);
     52   }
     53 
     54   void SetVerificationResults(VerificationResults* verification_results) {
     55     verification_results_ = verification_results;
     56   }
     57 
     58   ClassStatus GetPreviousClassState(ClassReference ref) OVERRIDE;
     59 
     60   void SetDoesClassUnloading(bool does_class_unloading, CompilerDriver* compiler_driver)
     61       OVERRIDE {
     62     does_class_unloading_ = does_class_unloading;
     63     compiler_driver_ = compiler_driver;
     64     DCHECK(!does_class_unloading || compiler_driver_ != nullptr);
     65   }
     66 
     67   void UpdateClassState(ClassReference ref, ClassStatus state) OVERRIDE;
     68 
     69   bool CanUseOatStatusForVerification(mirror::Class* klass) OVERRIDE
     70       REQUIRES_SHARED(Locks::mutator_lock_);
     71 
     72   void SetDexFiles(const std::vector<const DexFile*>* dex_files) {
     73     dex_files_ = dex_files;
     74   }
     75 
     76  private:
     77   VerificationResults* verification_results_ = nullptr;
     78   bool does_class_unloading_ = false;
     79   CompilerDriver* compiler_driver_ = nullptr;
     80   std::unique_ptr<verifier::VerifierDeps> verifier_deps_;
     81   const std::vector<const DexFile*>* dex_files_;
     82 };
     83 
     84 }  // namespace art
     85 
     86 #endif  // ART_COMPILER_DEX_QUICK_COMPILER_CALLBACKS_H_
     87