Merge "[optimizing compiler] Support x86 hard float ABI"
diff --git a/compiler/Android.mk b/compiler/Android.mk
index 1d4f5a3..4f4d075 100644
--- a/compiler/Android.mk
+++ b/compiler/Android.mk
@@ -69,12 +69,14 @@
 	dex/post_opt_passes.cc \
 	dex/pass_driver_me_opts.cc \
 	dex/pass_driver_me_post_opt.cc \
+	dex/pass_manager.cc \
 	dex/ssa_transformation.cc \
 	dex/verified_method.cc \
 	dex/verification_results.cc \
 	dex/vreg_analysis.cc \
 	dex/quick_compiler_callbacks.cc \
 	driver/compiler_driver.cc \
+	driver/compiler_options.cc \
 	driver/dex_compilation_unit.cc \
 	jni/quick/arm/calling_convention_arm.cc \
 	jni/quick/arm64/calling_convention_arm64.cc \
@@ -99,6 +101,7 @@
 	optimizing/instruction_simplifier.cc \
 	optimizing/intrinsics.cc \
 	optimizing/intrinsics_x86_64.cc \
+	optimizing/intrinsics_arm64.cc \
 	optimizing/locations.cc \
 	optimizing/nodes.cc \
 	optimizing/optimization.cc \
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index 96f8e0c..1cd78f8 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -19,9 +19,10 @@
 #include "arch/instruction_set_features.h"
 #include "class_linker.h"
 #include "compiled_method.h"
+#include "dex/pass_manager.h"
 #include "dex/quick_compiler_callbacks.h"
-#include "dex/verification_results.h"
 #include "dex/quick/dex_file_to_method_inliner_map.h"
+#include "dex/verification_results.h"
 #include "driver/compiler_driver.h"
 #include "interpreter/interpreter.h"
 #include "mirror/art_method.h"
diff --git a/compiler/compiler.cc b/compiler/compiler.cc
index baa6688..5e8ec1e 100644
--- a/compiler/compiler.cc
+++ b/compiler/compiler.cc
@@ -17,7 +17,7 @@
 #include "compiler.h"
 
 #include "base/logging.h"
-#include "dex/quick/quick_compiler.h"
+#include "dex/quick/quick_compiler_factory.h"
 #include "driver/compiler_driver.h"
 #include "optimizing/optimizing_compiler.h"
 
diff --git a/compiler/dex/mir_graph.cc b/compiler/dex/mir_graph.cc
index db4141c..0f7d45d 100644
--- a/compiler/dex/mir_graph.cc
+++ b/compiler/dex/mir_graph.cc
@@ -30,6 +30,7 @@
 #include "dex_instruction-inl.h"
 #include "driver/compiler_driver.h"
 #include "driver/dex_compilation_unit.h"
+#include "dex/quick/quick_compiler.h"
 #include "leb128.h"
 #include "pass_driver_me_post_opt.h"
 #include "stack.h"
@@ -2432,7 +2433,10 @@
 }
 
 void MIRGraph::CalculateBasicBlockInformation() {
-  PassDriverMEPostOpt driver(cu_);
+  auto* quick_compiler = down_cast<QuickCompiler*>(cu_->compiler_driver->GetCompiler());
+  DCHECK(quick_compiler != nullptr);
+  /* Create the pass driver and launch it */
+  PassDriverMEPostOpt driver(quick_compiler->GetPostOptPassManager(), cu_);
   driver.Launch();
 }
 
diff --git a/compiler/dex/pass_driver.h b/compiler/dex/pass_driver.h
index 632df38..671bcec 100644
--- a/compiler/dex/pass_driver.h
+++ b/compiler/dex/pass_driver.h
@@ -21,19 +21,14 @@
 
 #include "base/logging.h"
 #include "pass.h"
-#include "safe_map.h"
+#include "pass_manager.h"
 
 namespace art {
 
-/**
- * @brief Helper function to create a single instance of a given Pass and can be shared across
- * the threads.
- */
-template <typename PassType>
-const Pass* GetPassInstance() {
-  static const PassType pass;
-  return &pass;
-}
+class Pass;
+class PassDataHolder;
+class PassDriver;
+class PassManager;
 
 // Empty holder for the constructor.
 class PassDriverDataHolder {
@@ -43,11 +38,11 @@
  * @class PassDriver
  * @brief PassDriver is the wrapper around all Pass instances in order to execute them
  */
-template <typename PassDriverType>
 class PassDriver {
  public:
-  explicit PassDriver() {
-    InitializePasses();
+  explicit PassDriver(const PassManager* const pass_manager) : pass_manager_(pass_manager) {
+    pass_list_ = *pass_manager_->GetDefaultPassList();
+    DCHECK(!pass_list_.empty());
   }
 
   virtual ~PassDriver() {
@@ -58,12 +53,12 @@
    */
   void InsertPass(const Pass* new_pass) {
     DCHECK(new_pass != nullptr);
-    DCHECK(new_pass->GetName() != nullptr && new_pass->GetName()[0] != 0);
+    DCHECK(new_pass->GetName() != nullptr);
+    DCHECK_NE(new_pass->GetName()[0], 0);
 
     // It is an error to override an existing pass.
     DCHECK(GetPass(new_pass->GetName()) == nullptr)
         << "Pass name " << new_pass->GetName() << " already used.";
-
     // Now add to the list.
     pass_list_.push_back(new_pass);
   }
@@ -74,7 +69,8 @@
    */
   virtual bool RunPass(const char* pass_name) {
     // Paranoid: c_unit cannot be nullptr and we need a pass name.
-    DCHECK(pass_name != nullptr && pass_name[0] != 0);
+    DCHECK(pass_name != nullptr);
+    DCHECK_NE(pass_name[0], 0);
 
     const Pass* cur_pass = GetPass(pass_name);
 
@@ -108,21 +104,6 @@
     return nullptr;
   }
 
-  static void CreateDefaultPassList(const std::string& disable_passes) {
-    // Insert each pass from g_passes into g_default_pass_list.
-    PassDriverType::g_default_pass_list.clear();
-    PassDriverType::g_default_pass_list.reserve(PassDriver<PassDriverType>::g_passes_size);
-    for (uint16_t i = 0; i < PassDriver<PassDriverType>::g_passes_size; ++i) {
-      const Pass* pass = PassDriver<PassDriverType>::g_passes[i];
-      // Check if we should disable this pass.
-      if (disable_passes.find(pass->GetName()) != std::string::npos) {
-        LOG(INFO) << "Skipping " << pass->GetName();
-      } else {
-        PassDriver<PassDriverType>::g_default_pass_list.push_back(pass);
-      }
-    }
-  }
-
   /**
    * @brief Run a pass using the Pass itself.
    * @param time_split do we want a time split request(default: false)?
@@ -130,57 +111,7 @@
    */
   virtual bool RunPass(const Pass* pass, bool time_split = false) = 0;
 
-  /**
-   * @brief Print the pass names of all the passes available.
-   */
-  static void PrintPassNames() {
-    LOG(INFO) << "Loop Passes are:";
-
-    for (const Pass* cur_pass : PassDriver<PassDriverType>::g_default_pass_list) {
-      LOG(INFO) << "\t-" << cur_pass->GetName();
-    }
-  }
-
-  /**
-   * @brief Gets the list of passes currently schedule to execute.
-   * @return pass_list_
-   */
-  std::vector<const Pass*>& GetPasses() {
-    return pass_list_;
-  }
-
-  static void SetPrintAllPasses() {
-    default_print_passes_ = true;
-  }
-
-  static void SetDumpPassList(const std::string& list) {
-    dump_pass_list_ = list;
-  }
-
-  static void SetPrintPassList(const std::string& list) {
-    print_pass_list_ = list;
-  }
-
-  /**
-   * @brief Used to set a string that contains the overridden pass options.
-   * @details An overridden pass option means that the pass uses this option
-   * instead of using its default option.
-   * @param s The string passed by user with overridden options. The string is in format
-   * Pass1Name:Pass1Option:Pass1Setting,Pass2Name:Pass2Option::Pass2Setting
-   */
-  static void SetOverriddenPassOptions(const std::string& s) {
-    overridden_pass_options_list_ = s;
-  }
-
-  void SetDefaultPasses() {
-    pass_list_ = PassDriver<PassDriverType>::g_default_pass_list;
-  }
-
  protected:
-  virtual void InitializePasses() {
-    SetDefaultPasses();
-  }
-
   /**
    * @brief Apply a patch: perform start/work/end functions.
    */
@@ -189,6 +120,7 @@
     DispatchPass(pass);
     pass->End(data);
   }
+
   /**
    * @brief Dispatch a patch.
    * Gives the ability to add logic when running the patch.
@@ -197,29 +129,11 @@
     UNUSED(pass);
   }
 
-  /** @brief List of passes: provides the order to execute the passes. */
+  /** @brief List of passes: provides the order to execute the passes.
+   *  Passes are owned by pass_manager_. */
   std::vector<const Pass*> pass_list_;
 
-  /** @brief The number of passes within g_passes.  */
-  static const uint16_t g_passes_size;
-
-  /** @brief The number of passes within g_passes.  */
-  static const Pass* const g_passes[];
-
-  /** @brief The default pass list is used to initialize pass_list_. */
-  static std::vector<const Pass*> g_default_pass_list;
-
-  /** @brief Do we, by default, want to be printing the log messages? */
-  static bool default_print_passes_;
-
-  /** @brief What are the passes we want to be printing the log messages? */
-  static std::string print_pass_list_;
-
-  /** @brief What are the passes we want to be dumping the CFG? */
-  static std::string dump_pass_list_;
-
-  /** @brief String of all options that should be overridden for selected passes */
-  static std::string overridden_pass_options_list_;
+  const PassManager* const pass_manager_;
 };
 
 }  // namespace art
diff --git a/compiler/dex/pass_driver_me.h b/compiler/dex/pass_driver_me.h
index ff7c4a4..fed92be 100644
--- a/compiler/dex/pass_driver_me.h
+++ b/compiler/dex/pass_driver_me.h
@@ -19,20 +19,25 @@
 
 #include <cstdlib>
 #include <cstring>
+
 #include "bb_optimizations.h"
 #include "dataflow_iterator.h"
 #include "dataflow_iterator-inl.h"
 #include "dex_flags.h"
 #include "pass_driver.h"
+#include "pass_manager.h"
 #include "pass_me.h"
+#include "safe_map.h"
 
 namespace art {
 
-template <typename PassDriverType>
-class PassDriverME: public PassDriver<PassDriverType> {
+class PassManager;
+class PassManagerOptions;
+
+class PassDriverME: public PassDriver {
  public:
-  explicit PassDriverME(CompilationUnit* cu)
-      : pass_me_data_holder_(), dump_cfg_folder_("/sdcard/") {
+  explicit PassDriverME(const PassManager* const pass_manager, CompilationUnit* cu)
+      : PassDriver(pass_manager), pass_me_data_holder_(), dump_cfg_folder_("/sdcard/") {
         pass_me_data_holder_.bb = nullptr;
         pass_me_data_holder_.c_unit = cu;
   }
@@ -82,7 +87,7 @@
     }
   }
 
-  bool RunPass(const Pass* pass, bool time_split) {
+  bool RunPass(const Pass* pass, bool time_split) OVERRIDE {
     // Paranoid: c_unit and pass cannot be nullptr, and the pass should have a name
     DCHECK(pass != nullptr);
     DCHECK(pass->GetName() != nullptr && pass->GetName()[0] != 0);
@@ -96,15 +101,17 @@
 
     // First, work on determining pass verbosity.
     bool old_print_pass = c_unit->print_pass;
-    c_unit->print_pass = PassDriver<PassDriverType>::default_print_passes_;
-    const char* print_pass_list = PassDriver<PassDriverType>::print_pass_list_.c_str();
-    if (print_pass_list != nullptr && strstr(print_pass_list, pass->GetName()) != nullptr) {
+    c_unit->print_pass = pass_manager_->GetOptions().GetPrintAllPasses();
+    auto* const options = &pass_manager_->GetOptions();
+    const std::string& print_pass_list = options->GetPrintPassList();
+    if (!print_pass_list.empty() && strstr(print_pass_list.c_str(), pass->GetName()) != nullptr) {
       c_unit->print_pass = true;
     }
 
-    // Next, check if there are any overridden settings for the pass that change default configuration.
+    // Next, check if there are any overridden settings for the pass that change default
+    // configuration.
     c_unit->overridden_pass_options.clear();
-    FillOverriddenPassSettings(pass->GetName(), c_unit->overridden_pass_options);
+    FillOverriddenPassSettings(options, pass->GetName(), c_unit->overridden_pass_options);
     if (c_unit->print_pass) {
       for (auto setting_it : c_unit->overridden_pass_options) {
         LOG(INFO) << "Overridden option \"" << setting_it.first << ":"
@@ -118,13 +125,12 @@
       // Applying the pass: first start, doWork, and end calls.
       this->ApplyPass(&pass_me_data_holder_, pass);
 
-      bool should_dump = ((c_unit->enable_debug & (1 << kDebugDumpCFG)) != 0);
+      bool should_dump = (c_unit->enable_debug & (1 << kDebugDumpCFG)) != 0;
 
-      const char* dump_pass_list = PassDriver<PassDriverType>::dump_pass_list_.c_str();
-
-      if (dump_pass_list != nullptr) {
-        bool found = strstr(dump_pass_list, pass->GetName());
-        should_dump = (should_dump || found);
+      const std::string& dump_pass_list = pass_manager_->GetOptions().GetDumpPassList();
+      if (!dump_pass_list.empty()) {
+        const bool found = strstr(dump_pass_list.c_str(), pass->GetName());
+        should_dump = should_dump || found;
       }
 
       if (should_dump) {
@@ -154,22 +160,23 @@
     return should_apply_pass;
   }
 
-  const char* GetDumpCFGFolder() const {
-    return dump_cfg_folder_;
-  }
-
-  static void PrintPassOptions() {
-    for (auto pass : PassDriver<PassDriverType>::g_default_pass_list) {
+  static void PrintPassOptions(PassManager* manager) {
+    for (const auto* pass : *manager->GetDefaultPassList()) {
       const PassME* me_pass = down_cast<const PassME*>(pass);
       if (me_pass->HasOptions()) {
         LOG(INFO) << "Pass options for \"" << me_pass->GetName() << "\" are:";
         SafeMap<const std::string, int> overridden_settings;
-        FillOverriddenPassSettings(me_pass->GetName(), overridden_settings);
+        FillOverriddenPassSettings(&manager->GetOptions(), me_pass->GetName(),
+                                   overridden_settings);
         me_pass->PrintPassOptions(overridden_settings);
       }
     }
   }
 
+  const char* GetDumpCFGFolder() const {
+    return dump_cfg_folder_;
+  }
+
  protected:
   /** @brief The data holder that contains data needed for the PassDriverME. */
   PassMEDataHolder pass_me_data_holder_;
@@ -198,12 +205,15 @@
     }
 
   /**
-   * @brief Fills the settings_to_fill by finding all of the applicable options in the overridden_pass_options_list_.
+   * @brief Fills the settings_to_fill by finding all of the applicable options in the
+   * overridden_pass_options_list_.
    * @param pass_name The pass name for which to fill settings.
-   * @param settings_to_fill Fills the options to contain the mapping of name of option to the new configuration.
+   * @param settings_to_fill Fills the options to contain the mapping of name of option to the new
+   * configuration.
    */
-  static void FillOverriddenPassSettings(const char* pass_name, SafeMap<const std::string, int>& settings_to_fill) {
-    const std::string& settings = PassDriver<PassDriverType>::overridden_pass_options_list_;
+  static void FillOverriddenPassSettings(const PassManagerOptions* options, const char* pass_name,
+                                         SafeMap<const std::string, int>& settings_to_fill) {
+    const std::string& settings = options->GetOverriddenPassOptions();
     const size_t settings_len = settings.size();
 
     // Before anything, check if we care about anything right now.
@@ -277,10 +287,12 @@
 
       // Get the actual setting itself. Strtol is being used to convert because it is
       // exception safe. If the input is not sane, it will set a setting of 0.
-      std::string setting_string = settings.substr(setting_pos, next_configuration_separator - setting_pos);
+      std::string setting_string =
+          settings.substr(setting_pos, next_configuration_separator - setting_pos);
       int setting = std::strtol(setting_string.c_str(), 0, 0);
 
-      std::string setting_name = settings.substr(setting_name_pos, setting_pos - setting_name_pos - 1);
+      std::string setting_name =
+          settings.substr(setting_name_pos, setting_pos - setting_name_pos - 1);
 
       settings_to_fill.Put(setting_name, setting);
 
diff --git a/compiler/dex/pass_driver_me_opts.cc b/compiler/dex/pass_driver_me_opts.cc
index c2b6b91..8c8bde6 100644
--- a/compiler/dex/pass_driver_me_opts.cc
+++ b/compiler/dex/pass_driver_me_opts.cc
@@ -21,77 +21,44 @@
 #include "bb_optimizations.h"
 #include "dataflow_iterator.h"
 #include "dataflow_iterator-inl.h"
+#include "pass_driver_me_opts.h"
+#include "pass_manager.h"
 #include "post_opt_passes.h"
 
 namespace art {
 
-/*
- * Create the pass list. These passes are immutable and are shared across the threads.
- *
- * Advantage is that there will be no race conditions here.
- * Disadvantage is the passes can't change their internal states depending on CompilationUnit:
- *   - This is not yet an issue: no current pass would require it.
- */
-// The initial list of passes to be used by the PassDriveMEOpts.
-template<>
-const Pass* const PassDriver<PassDriverMEOpts>::g_passes[] = {
-  GetPassInstance<CacheFieldLoweringInfo>(),
-  GetPassInstance<CacheMethodLoweringInfo>(),
-  GetPassInstance<CalculatePredecessors>(),
-  GetPassInstance<DFSOrders>(),
-  GetPassInstance<ClassInitCheckElimination>(),
-  GetPassInstance<SpecialMethodInliner>(),
-  GetPassInstance<NullCheckElimination>(),
-  GetPassInstance<BBCombine>(),
-  GetPassInstance<CodeLayout>(),
-  GetPassInstance<GlobalValueNumberingPass>(),
-  GetPassInstance<ConstantPropagation>(),
-  GetPassInstance<MethodUseCount>(),
-  GetPassInstance<BBOptimizations>(),
-  GetPassInstance<SuspendCheckElimination>(),
-};
-
-// The number of the passes in the initial list of Passes (g_passes).
-template<>
-uint16_t const PassDriver<PassDriverMEOpts>::g_passes_size =
-    arraysize(PassDriver<PassDriverMEOpts>::g_passes);
-
-// The default pass list is used by the PassDriverME instance of PassDriver
-// to initialize pass_list_.
-template<>
-std::vector<const Pass*> PassDriver<PassDriverMEOpts>::g_default_pass_list(
-    PassDriver<PassDriverMEOpts>::g_passes,
-    PassDriver<PassDriverMEOpts>::g_passes +
-    PassDriver<PassDriverMEOpts>::g_passes_size);
-
-// By default, do not have a dump pass list.
-template<>
-std::string PassDriver<PassDriverMEOpts>::dump_pass_list_ = std::string();
-
-// By default, do not have a print pass list.
-template<>
-std::string PassDriver<PassDriverMEOpts>::print_pass_list_ = std::string();
-
-// By default, we do not print the pass' information.
-template<>
-bool PassDriver<PassDriverMEOpts>::default_print_passes_ = false;
-
-// By default, there are no overridden pass settings.
-template<>
-std::string PassDriver<PassDriverMEOpts>::overridden_pass_options_list_ = std::string();
+void PassDriverMEOpts::SetupPasses(PassManager* pass_manager) {
+  /*
+   * Create the pass list. These passes are immutable and are shared across the threads.
+   *
+   * Advantage is that there will be no race conditions here.
+   * Disadvantage is the passes can't change their internal states depending on CompilationUnit:
+   *   - This is not yet an issue: no current pass would require it.
+   */
+  pass_manager->AddPass(new CacheFieldLoweringInfo);
+  pass_manager->AddPass(new CacheMethodLoweringInfo);
+  pass_manager->AddPass(new CalculatePredecessors);
+  pass_manager->AddPass(new DFSOrders);
+  pass_manager->AddPass(new ClassInitCheckElimination);
+  pass_manager->AddPass(new SpecialMethodInliner);
+  pass_manager->AddPass(new NullCheckElimination);
+  pass_manager->AddPass(new BBCombine);
+  pass_manager->AddPass(new CodeLayout);
+  pass_manager->AddPass(new GlobalValueNumberingPass);
+  pass_manager->AddPass(new ConstantPropagation);
+  pass_manager->AddPass(new MethodUseCount);
+  pass_manager->AddPass(new BBOptimizations);
+  pass_manager->AddPass(new SuspendCheckElimination);
+}
 
 void PassDriverMEOpts::ApplyPass(PassDataHolder* data, const Pass* pass) {
-  const PassME* pass_me = down_cast<const PassME*> (pass);
+  const PassME* const pass_me = down_cast<const PassME*>(pass);
   DCHECK(pass_me != nullptr);
-
-  PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data);
-
+  PassMEDataHolder* const pass_me_data_holder = down_cast<PassMEDataHolder*>(data);
   // Set to dirty.
   pass_me_data_holder->dirty = true;
-
   // First call the base class' version.
   PassDriver::ApplyPass(data, pass);
-
   // Now we care about flags.
   if ((pass_me->GetFlag(kOptimizationBasicBlockChange) == true) ||
       (pass_me->GetFlag(kOptimizationDefUsesChange) == true)) {
diff --git a/compiler/dex/pass_driver_me_opts.h b/compiler/dex/pass_driver_me_opts.h
index 0a5b5ae..b930d02 100644
--- a/compiler/dex/pass_driver_me_opts.h
+++ b/compiler/dex/pass_driver_me_opts.h
@@ -25,19 +25,26 @@
 struct CompilationUnit;
 class Pass;
 class PassDataHolder;
+class PassManager;
 
-class PassDriverMEOpts : public PassDriverME<PassDriverMEOpts> {
+class PassDriverMEOpts : public PassDriverME {
  public:
-  explicit PassDriverMEOpts(CompilationUnit* cu):PassDriverME<PassDriverMEOpts>(cu) {
+  explicit PassDriverMEOpts(const PassManager* const manager, CompilationUnit* cu)
+      : PassDriverME(manager, cu) {
   }
 
   ~PassDriverMEOpts() {
   }
 
   /**
+   * @brief Write and allocate corresponding passes into the pass manager.
+   */
+  static void SetupPasses(PassManager* pass_manasger);
+
+  /**
    * @brief Apply a patch: perform start/work/end functions.
    */
-  virtual void ApplyPass(PassDataHolder* data, const Pass* pass);
+  virtual void ApplyPass(PassDataHolder* data, const Pass* pass) OVERRIDE;
 };
 
 }  // namespace art
diff --git a/compiler/dex/pass_driver_me_post_opt.cc b/compiler/dex/pass_driver_me_post_opt.cc
index 5f0c65c..4e13227 100644
--- a/compiler/dex/pass_driver_me_post_opt.cc
+++ b/compiler/dex/pass_driver_me_post_opt.cc
@@ -14,63 +14,35 @@
  * limitations under the License.
  */
 
+#include "pass_driver_me_post_opt.h"
+
 #include "base/macros.h"
 #include "post_opt_passes.h"
-#include "pass_driver_me_post_opt.h"
+#include "pass_manager.h"
 
 namespace art {
 
-/*
- * Create the pass list. These passes are immutable and are shared across the threads.
- *
- * Advantage is that there will be no race conditions here.
- * Disadvantage is the passes can't change their internal states depending on CompilationUnit:
- *   - This is not yet an issue: no current pass would require it.
- */
-// The initial list of passes to be used by the PassDriveMEPostOpt.
-template<>
-const Pass* const PassDriver<PassDriverMEPostOpt>::g_passes[] = {
-    GetPassInstance<DFSOrders>(),
-    GetPassInstance<BuildDomination>(),
-    GetPassInstance<TopologicalSortOrders>(),
-    GetPassInstance<InitializeSSATransformation>(),
-    GetPassInstance<ClearPhiInstructions>(),
-    GetPassInstance<DefBlockMatrix>(),
-    GetPassInstance<CreatePhiNodes>(),
-    GetPassInstance<SSAConversion>(),
-    GetPassInstance<PhiNodeOperands>(),
-    GetPassInstance<PerformInitRegLocations>(),
-    GetPassInstance<TypeInference>(),
-    GetPassInstance<FinishSSATransformation>(),
-};
-
-// The number of the passes in the initial list of Passes (g_passes).
-template<>
-uint16_t const PassDriver<PassDriverMEPostOpt>::g_passes_size =
-    arraysize(PassDriver<PassDriverMEPostOpt>::g_passes);
-
-// The default pass list is used by the PassDriverME instance of PassDriver
-// to initialize pass_list_.
-template<>
-std::vector<const Pass*> PassDriver<PassDriverMEPostOpt>::g_default_pass_list(
-    PassDriver<PassDriverMEPostOpt>::g_passes,
-    PassDriver<PassDriverMEPostOpt>::g_passes +
-    PassDriver<PassDriverMEPostOpt>::g_passes_size);
-
-// By default, do not have a dump pass list.
-template<>
-std::string PassDriver<PassDriverMEPostOpt>::dump_pass_list_ = std::string();
-
-// By default, do not have a print pass list.
-template<>
-std::string PassDriver<PassDriverMEPostOpt>::print_pass_list_ = std::string();
-
-// By default, we do not print the pass' information.
-template<>
-bool PassDriver<PassDriverMEPostOpt>::default_print_passes_ = false;
-
-// By default, there are no overridden pass settings.
-template<>
-std::string PassDriver<PassDriverMEPostOpt>::overridden_pass_options_list_ = std::string();
+void PassDriverMEPostOpt::SetupPasses(PassManager* pass_manager) {
+  /*
+   * Create the pass list. These passes are immutable and are shared across the threads.
+   *
+   * Advantage is that there will be no race conditions here.
+   * Disadvantage is the passes can't change their internal states depending on CompilationUnit:
+   *   - This is not yet an issue: no current pass would require it.
+   */
+  // The initial list of passes to be used by the PassDriveMEPostOpt.
+  pass_manager->AddPass(new DFSOrders);
+  pass_manager->AddPass(new BuildDomination);
+  pass_manager->AddPass(new TopologicalSortOrders);
+  pass_manager->AddPass(new InitializeSSATransformation);
+  pass_manager->AddPass(new ClearPhiInstructions);
+  pass_manager->AddPass(new DefBlockMatrix);
+  pass_manager->AddPass(new CreatePhiNodes);
+  pass_manager->AddPass(new SSAConversion);
+  pass_manager->AddPass(new PhiNodeOperands);
+  pass_manager->AddPass(new PerformInitRegLocations);
+  pass_manager->AddPass(new TypeInference);
+  pass_manager->AddPass(new FinishSSATransformation);
+}
 
 }  // namespace art
diff --git a/compiler/dex/pass_driver_me_post_opt.h b/compiler/dex/pass_driver_me_post_opt.h
index 574a6ba..9e03c4e 100644
--- a/compiler/dex/pass_driver_me_post_opt.h
+++ b/compiler/dex/pass_driver_me_post_opt.h
@@ -26,13 +26,19 @@
 class Pass;
 class PassDataHolder;
 
-class PassDriverMEPostOpt : public PassDriverME<PassDriverMEPostOpt> {
+class PassDriverMEPostOpt : public PassDriverME {
  public:
-  explicit PassDriverMEPostOpt(CompilationUnit* cu) : PassDriverME<PassDriverMEPostOpt>(cu) {
+  explicit PassDriverMEPostOpt(const PassManager* const manager, CompilationUnit* cu)
+      : PassDriverME(manager, cu) {
   }
 
   ~PassDriverMEPostOpt() {
   }
+
+  /**
+   * @brief Write and allocate corresponding passes into the pass manager.
+   */
+  static void SetupPasses(PassManager* pass_manager);
 };
 
 }  // namespace art
diff --git a/compiler/dex/pass_manager.cc b/compiler/dex/pass_manager.cc
new file mode 100644
index 0000000..6d58f65
--- /dev/null
+++ b/compiler/dex/pass_manager.cc
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "pass_manager.h"
+
+#include "base/stl_util.h"
+#include "pass_me.h"
+
+namespace art {
+
+PassManager::PassManager(const PassManagerOptions& options) : options_(options) {
+}
+
+PassManager::~PassManager() {
+  STLDeleteElements(&passes_);
+}
+
+void PassManager::CreateDefaultPassList() {
+  default_pass_list_.clear();
+  // Add each pass which isn't disabled into default_pass_list_.
+  for (const auto* pass : passes_) {
+    if (options_.GetDisablePassList().find(pass->GetName()) != std::string::npos) {
+      LOG(INFO) << "Skipping disabled pass " << pass->GetName();
+    } else {
+      default_pass_list_.push_back(pass);
+    }
+  }
+}
+
+void PassManager::PrintPassNames() const {
+  LOG(INFO) << "Loop Passes are:";
+  for (const Pass* cur_pass : default_pass_list_) {
+    LOG(INFO) << "\t-" << cur_pass->GetName();
+  }
+}
+
+}  // namespace art
diff --git a/compiler/dex/pass_manager.h b/compiler/dex/pass_manager.h
new file mode 100644
index 0000000..68e488d
--- /dev/null
+++ b/compiler/dex/pass_manager.h
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_COMPILER_DEX_PASS_MANAGER_H_
+#define ART_COMPILER_DEX_PASS_MANAGER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/logging.h"
+
+namespace art {
+
+class Pass;
+
+class PassManagerOptions {
+ public:
+  PassManagerOptions()
+     : default_print_passes_(false),
+       print_pass_names_(false),
+       print_pass_options_(false) {
+  }
+  explicit PassManagerOptions(const PassManagerOptions&) = default;
+
+  void SetPrintPassNames(bool b) {
+    print_pass_names_ = b;
+  }
+
+  void SetPrintAllPasses() {
+    default_print_passes_ = true;
+  }
+  bool GetPrintAllPasses() const {
+    return default_print_passes_;
+  }
+
+  void SetDisablePassList(const std::string& list) {
+    disable_pass_list_ = list;
+  }
+  const std::string& GetDisablePassList() const {
+    return disable_pass_list_;
+  }
+
+  void SetPrintPassList(const std::string& list) {
+    print_pass_list_ = list;
+  }
+  const std::string& GetPrintPassList() const {
+    return print_pass_list_;
+  }
+
+  void SetDumpPassList(const std::string& list) {
+    dump_pass_list_ = list;
+  }
+  const std::string& GetDumpPassList() const {
+    return dump_pass_list_;
+  }
+
+  /**
+   * @brief Used to set a string that contains the overridden pass options.
+   * @details An overridden pass option means that the pass uses this option
+   * instead of using its default option.
+   * @param s The string passed by user with overridden options. The string is in format
+   * Pass1Name:Pass1Option:Pass1Setting,Pass2Name:Pass2Option::Pass2Setting
+   */
+  void SetOverriddenPassOptions(const std::string& list) {
+    overridden_pass_options_list_ = list;
+  }
+  const std::string& GetOverriddenPassOptions() const {
+    return overridden_pass_options_list_;
+  }
+
+  void SetPrintPassOptions(bool b) {
+    print_pass_options_ = b;
+  }
+  bool GetPrintPassOptions() const {
+    return print_pass_options_;
+  }
+
+ private:
+  /** @brief Do we, by default, want to be printing the log messages? */
+  bool default_print_passes_;
+
+  /** @brief What are the passes we want to be printing the log messages? */
+  std::string print_pass_list_;
+
+  /** @brief What are the passes we want to be dumping the CFG? */
+  std::string dump_pass_list_;
+
+  /** @brief String of all options that should be overridden for selected passes */
+  std::string overridden_pass_options_list_;
+
+  /** @brief String of all options that should be overridden for selected passes */
+  std::string disable_pass_list_;
+
+  /** @brief Whether or not we print all the passes when we create the pass manager */
+  bool print_pass_names_;
+
+  /** @brief Whether or not we print all the pass options when we create the pass manager */
+  bool print_pass_options_;
+};
+
+/**
+ * @class PassManager
+ * @brief Owns passes
+ */
+class PassManager {
+ public:
+  explicit PassManager(const PassManagerOptions& options);
+  virtual ~PassManager();
+  void CreateDefaultPassList();
+  void AddPass(const Pass* pass) {
+    passes_.push_back(pass);
+  }
+  /**
+   * @brief Print the pass names of all the passes available.
+   */
+  void PrintPassNames() const;
+  const std::vector<const Pass*>* GetDefaultPassList() const {
+    return &default_pass_list_;
+  }
+  const PassManagerOptions& GetOptions() const {
+    return options_;
+  }
+
+ private:
+  /** @brief The set of possible passes.  */
+  std::vector<const Pass*> passes_;
+
+  /** @brief The default pass list is used to initialize pass_list_. */
+  std::vector<const Pass*> default_pass_list_;
+
+  /** @brief Pass manager options. */
+  PassManagerOptions options_;
+
+  DISALLOW_COPY_AND_ASSIGN(PassManager);
+};
+}  // namespace art
+#endif  // ART_COMPILER_DEX_PASS_MANAGER_H_
diff --git a/compiler/dex/pass_me.h b/compiler/dex/pass_me.h
index 73e49ec..79d8f51 100644
--- a/compiler/dex/pass_me.h
+++ b/compiler/dex/pass_me.h
@@ -42,11 +42,11 @@
 
 // Data holder class.
 class PassMEDataHolder: public PassDataHolder {
-  public:
-    CompilationUnit* c_unit;
-    BasicBlock* bb;
-    void* data;               /**< @brief Any data the pass wants to use */
-    bool dirty;               /**< @brief Has the pass rendered the CFG dirty, requiring post-opt? */
+ public:
+  CompilationUnit* c_unit;
+  BasicBlock* bb;
+  void* data;               /**< @brief Any data the pass wants to use */
+  bool dirty;               /**< @brief Has the pass rendered the CFG dirty, requiring post-opt? */
 };
 
 enum DataFlowAnalysisMode {
@@ -103,8 +103,8 @@
    * @details The printing is done using LOG(INFO).
    */
   void PrintPassDefaultOptions() const {
-    for (auto option_it = default_options_.begin(); option_it != default_options_.end(); option_it++) {
-      LOG(INFO) << "\t" << option_it->first << ":" << std::dec << option_it->second;
+    for (const auto& option : default_options_) {
+      LOG(INFO) << "\t" << option.first << ":" << std::dec << option.second;
     }
   }
 
@@ -115,8 +115,9 @@
   void PrintPassOptions(SafeMap<const std::string, int>& overridden_options) const {
     // We walk through the default options only to get the pass names. We use GetPassOption to
     // also consider the overridden ones.
-    for (auto option_it = default_options_.begin(); option_it != default_options_.end(); option_it++) {
-      LOG(INFO) << "\t" << option_it->first << ":" << std::dec << GetPassOption(option_it->first, overridden_options);
+    for (const auto& option : default_options_) {
+      LOG(INFO) << "\t" << option.first << ":" << std::dec
+                << GetPassOption(option.first, overridden_options);
     }
   }
 
diff --git a/compiler/dex/quick/quick_compiler.cc b/compiler/dex/quick/quick_compiler.cc
index 3a34fcd..909077e 100644
--- a/compiler/dex/quick/quick_compiler.cc
+++ b/compiler/dex/quick/quick_compiler.cc
@@ -29,6 +29,8 @@
 #include "dex/dex_flags.h"
 #include "dex/mir_graph.h"
 #include "dex/pass_driver_me_opts.h"
+#include "dex/pass_driver_me_post_opt.h"
+#include "dex/pass_manager.h"
 #include "dex/quick/mir_to_lir.h"
 #include "driver/compiler_driver.h"
 #include "driver/compiler_options.h"
@@ -47,48 +49,6 @@
 
 namespace art {
 
-class QuickCompiler FINAL : public Compiler {
- public:
-  explicit QuickCompiler(CompilerDriver* driver) : Compiler(driver, 100) {}
-
-  void Init() OVERRIDE;
-
-  void UnInit() const OVERRIDE;
-
-  bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, CompilationUnit* cu) const
-      OVERRIDE;
-
-  CompiledMethod* Compile(const DexFile::CodeItem* code_item,
-                          uint32_t access_flags,
-                          InvokeType invoke_type,
-                          uint16_t class_def_idx,
-                          uint32_t method_idx,
-                          jobject class_loader,
-                          const DexFile& dex_file) const OVERRIDE;
-
-  CompiledMethod* JniCompile(uint32_t access_flags,
-                             uint32_t method_idx,
-                             const DexFile& dex_file) const OVERRIDE;
-
-  uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const OVERRIDE
-      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-
-  bool WriteElf(art::File* file,
-                OatWriter* oat_writer,
-                const std::vector<const art::DexFile*>& dex_files,
-                const std::string& android_root,
-                bool is_host) const
-    OVERRIDE
-    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-
-  Mir2Lir* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const;
-
-  void InitCompilationUnit(CompilationUnit& cu) const OVERRIDE;
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(QuickCompiler);
-};
-
 static_assert(0U == static_cast<size_t>(kNone),   "kNone not 0");
 static_assert(1U == static_cast<size_t>(kArm),    "kArm not 1");
 static_assert(2U == static_cast<size_t>(kArm64),  "kArm64 not 2");
@@ -730,7 +690,7 @@
   }
 
   /* Create the pass driver and launch it */
-  PassDriverMEOpts pass_driver(&cu);
+  PassDriverMEOpts pass_driver(GetPreOptPassManager(), &cu);
   pass_driver.Launch();
 
   /* For non-leaf methods check if we should skip compilation when the profiler is enabled. */
@@ -850,8 +810,34 @@
   return mir_to_lir;
 }
 
+QuickCompiler::QuickCompiler(CompilerDriver* driver) : Compiler(driver, 100) {
+  const auto& compiler_options = driver->GetCompilerOptions();
+  auto* pass_manager_options = compiler_options.GetPassManagerOptions();
+  pre_opt_pass_manager_.reset(new PassManager(*pass_manager_options));
+  CHECK(pre_opt_pass_manager_.get() != nullptr);
+  PassDriverMEOpts::SetupPasses(pre_opt_pass_manager_.get());
+  pre_opt_pass_manager_->CreateDefaultPassList();
+  if (pass_manager_options->GetPrintPassOptions()) {
+    PassDriverMEOpts::PrintPassOptions(pre_opt_pass_manager_.get());
+  }
+  // TODO: Different options for pre vs post opts?
+  post_opt_pass_manager_.reset(new PassManager(PassManagerOptions()));
+  CHECK(post_opt_pass_manager_.get() != nullptr);
+  PassDriverMEPostOpt::SetupPasses(post_opt_pass_manager_.get());
+  post_opt_pass_manager_->CreateDefaultPassList();
+  if (pass_manager_options->GetPrintPassOptions()) {
+    PassDriverMEPostOpt::PrintPassOptions(post_opt_pass_manager_.get());
+  }
+}
+
+QuickCompiler::~QuickCompiler() {
+}
 
 Compiler* CreateQuickCompiler(CompilerDriver* driver) {
+  return QuickCompiler::Create(driver);
+}
+
+Compiler* QuickCompiler::Create(CompilerDriver* driver) {
   return new QuickCompiler(driver);
 }
 
diff --git a/compiler/dex/quick/quick_compiler.h b/compiler/dex/quick/quick_compiler.h
index 10de5fb..5153a9e 100644
--- a/compiler/dex/quick/quick_compiler.h
+++ b/compiler/dex/quick/quick_compiler.h
@@ -17,12 +17,70 @@
 #ifndef ART_COMPILER_DEX_QUICK_QUICK_COMPILER_H_
 #define ART_COMPILER_DEX_QUICK_QUICK_COMPILER_H_
 
+#include "compiler.h"
+
 namespace art {
 
 class Compiler;
 class CompilerDriver;
+class Mir2Lir;
+class PassManager;
 
-Compiler* CreateQuickCompiler(CompilerDriver* driver);
+class QuickCompiler : public Compiler {
+ public:
+  virtual ~QuickCompiler();
+
+  void Init() OVERRIDE;
+
+  void UnInit() const OVERRIDE;
+
+  bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, CompilationUnit* cu) const
+      OVERRIDE;
+
+  CompiledMethod* Compile(const DexFile::CodeItem* code_item,
+                          uint32_t access_flags,
+                          InvokeType invoke_type,
+                          uint16_t class_def_idx,
+                          uint32_t method_idx,
+                          jobject class_loader,
+                          const DexFile& dex_file) const OVERRIDE;
+
+  CompiledMethod* JniCompile(uint32_t access_flags,
+                             uint32_t method_idx,
+                             const DexFile& dex_file) const OVERRIDE;
+
+  uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const OVERRIDE
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
+  bool WriteElf(art::File* file,
+                OatWriter* oat_writer,
+                const std::vector<const art::DexFile*>& dex_files,
+                const std::string& android_root,
+                bool is_host) const
+    OVERRIDE
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
+  Mir2Lir* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const;
+
+  void InitCompilationUnit(CompilationUnit& cu) const OVERRIDE;
+
+  static Compiler* Create(CompilerDriver* driver);
+
+  const PassManager* GetPreOptPassManager() const {
+    return pre_opt_pass_manager_.get();
+  }
+  const PassManager* GetPostOptPassManager() const {
+    return post_opt_pass_manager_.get();
+  }
+
+ protected:
+  explicit QuickCompiler(CompilerDriver* driver);
+
+ private:
+  std::unique_ptr<PassManager> pre_opt_pass_manager_;
+  std::unique_ptr<PassManager> post_opt_pass_manager_;
+  DISALLOW_COPY_AND_ASSIGN(QuickCompiler);
+};
 
 }  // namespace art
 
diff --git a/compiler/dex/quick/quick_compiler_factory.h b/compiler/dex/quick/quick_compiler_factory.h
new file mode 100644
index 0000000..31ee1cf
--- /dev/null
+++ b/compiler/dex/quick/quick_compiler_factory.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_COMPILER_DEX_QUICK_QUICK_COMPILER_FACTORY_H_
+#define ART_COMPILER_DEX_QUICK_QUICK_COMPILER_FACTORY_H_
+
+namespace art {
+
+class Compiler;
+class CompilerDriver;
+
+Compiler* CreateQuickCompiler(CompilerDriver* driver);
+
+}  // namespace art
+
+#endif  // ART_COMPILER_DEX_QUICK_QUICK_COMPILER_FACTORY_H_
diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc
new file mode 100644
index 0000000..09ec9a2
--- /dev/null
+++ b/compiler/driver/compiler_options.cc
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "compiler_options.h"
+
+#include "dex/pass_manager.h"
+
+namespace art {
+
+CompilerOptions::CompilerOptions()
+    : compiler_filter_(kDefaultCompilerFilter),
+      huge_method_threshold_(kDefaultHugeMethodThreshold),
+      large_method_threshold_(kDefaultLargeMethodThreshold),
+      small_method_threshold_(kDefaultSmallMethodThreshold),
+      tiny_method_threshold_(kDefaultTinyMethodThreshold),
+      num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold),
+      generate_gdb_information_(false),
+      include_patch_information_(kDefaultIncludePatchInformation),
+      top_k_profile_threshold_(kDefaultTopKProfileThreshold),
+      include_debug_symbols_(kDefaultIncludeDebugSymbols),
+      implicit_null_checks_(true),
+      implicit_so_checks_(true),
+      implicit_suspend_checks_(false),
+      compile_pic_(false),
+      verbose_methods_(nullptr),
+      pass_manager_options_(new PassManagerOptions),
+      init_failure_output_(nullptr) {
+}
+
+CompilerOptions::CompilerOptions(CompilerFilter compiler_filter,
+                                 size_t huge_method_threshold,
+                                 size_t large_method_threshold,
+                                 size_t small_method_threshold,
+                                 size_t tiny_method_threshold,
+                                 size_t num_dex_methods_threshold,
+                                 bool generate_gdb_information,
+                                 bool include_patch_information,
+                                 double top_k_profile_threshold,
+                                 bool include_debug_symbols,
+                                 bool implicit_null_checks,
+                                 bool implicit_so_checks,
+                                 bool implicit_suspend_checks,
+                                 bool compile_pic,
+                                 const std::vector<std::string>* verbose_methods,
+                                 PassManagerOptions* pass_manager_options,
+                                 std::ostream* init_failure_output
+                                 ) :  // NOLINT(whitespace/parens)
+    compiler_filter_(compiler_filter),
+    huge_method_threshold_(huge_method_threshold),
+    large_method_threshold_(large_method_threshold),
+    small_method_threshold_(small_method_threshold),
+    tiny_method_threshold_(tiny_method_threshold),
+    num_dex_methods_threshold_(num_dex_methods_threshold),
+    generate_gdb_information_(generate_gdb_information),
+    include_patch_information_(include_patch_information),
+    top_k_profile_threshold_(top_k_profile_threshold),
+    include_debug_symbols_(include_debug_symbols),
+    implicit_null_checks_(implicit_null_checks),
+    implicit_so_checks_(implicit_so_checks),
+    implicit_suspend_checks_(implicit_suspend_checks),
+    compile_pic_(compile_pic),
+    verbose_methods_(verbose_methods),
+    pass_manager_options_(pass_manager_options),
+    init_failure_output_(init_failure_output) {
+}
+
+}  // namespace art
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h
index 5466d45..122ae4b 100644
--- a/compiler/driver/compiler_options.h
+++ b/compiler/driver/compiler_options.h
@@ -26,6 +26,8 @@
 
 namespace art {
 
+class PassManagerOptions;
+
 class CompilerOptions FINAL {
  public:
   enum CompilerFilter {
@@ -53,24 +55,7 @@
   static const bool kDefaultIncludeDebugSymbols = kIsDebugBuild;
   static const bool kDefaultIncludePatchInformation = false;
 
-  CompilerOptions() :
-    compiler_filter_(kDefaultCompilerFilter),
-    huge_method_threshold_(kDefaultHugeMethodThreshold),
-    large_method_threshold_(kDefaultLargeMethodThreshold),
-    small_method_threshold_(kDefaultSmallMethodThreshold),
-    tiny_method_threshold_(kDefaultTinyMethodThreshold),
-    num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold),
-    generate_gdb_information_(false),
-    include_patch_information_(kDefaultIncludePatchInformation),
-    top_k_profile_threshold_(kDefaultTopKProfileThreshold),
-    include_debug_symbols_(kDefaultIncludeDebugSymbols),
-    implicit_null_checks_(true),
-    implicit_so_checks_(true),
-    implicit_suspend_checks_(false),
-    compile_pic_(false),
-    verbose_methods_(nullptr),
-    init_failure_output_(nullptr) {
-  }
+  CompilerOptions();
 
   CompilerOptions(CompilerFilter compiler_filter,
                   size_t huge_method_threshold,
@@ -87,25 +72,8 @@
                   bool implicit_suspend_checks,
                   bool compile_pic,
                   const std::vector<std::string>* verbose_methods,
-                  std::ostream* init_failure_output
-                  ) :  // NOLINT(whitespace/parens)
-    compiler_filter_(compiler_filter),
-    huge_method_threshold_(huge_method_threshold),
-    large_method_threshold_(large_method_threshold),
-    small_method_threshold_(small_method_threshold),
-    tiny_method_threshold_(tiny_method_threshold),
-    num_dex_methods_threshold_(num_dex_methods_threshold),
-    generate_gdb_information_(generate_gdb_information),
-    include_patch_information_(include_patch_information),
-    top_k_profile_threshold_(top_k_profile_threshold),
-    include_debug_symbols_(include_debug_symbols),
-    implicit_null_checks_(implicit_null_checks),
-    implicit_so_checks_(implicit_so_checks),
-    implicit_suspend_checks_(implicit_suspend_checks),
-    compile_pic_(compile_pic),
-    verbose_methods_(verbose_methods),
-    init_failure_output_(init_failure_output) {
-  }
+                  PassManagerOptions* pass_manager_options,
+                  std::ostream* init_failure_output);
 
   CompilerFilter GetCompilerFilter() const {
     return compiler_filter_;
@@ -210,6 +178,10 @@
     return init_failure_output_;
   }
 
+  const PassManagerOptions* GetPassManagerOptions() const {
+    return pass_manager_options_.get();
+  }
+
  private:
   CompilerFilter compiler_filter_;
   const size_t huge_method_threshold_;
@@ -230,6 +202,8 @@
   // Vector of methods to have verbose output enabled for.
   const std::vector<std::string>* const verbose_methods_;
 
+  std::unique_ptr<PassManagerOptions> pass_manager_options_;
+
   // Log initialization of initialization failures to this stream if not null.
   std::ostream* const init_failure_output_;
 
diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc
index d3d2055..46aed60 100644
--- a/compiler/oat_test.cc
+++ b/compiler/oat_test.cc
@@ -18,9 +18,10 @@
 #include "class_linker.h"
 #include "common_compiler_test.h"
 #include "compiler.h"
-#include "dex/verification_results.h"
+#include "dex/pass_manager.h"
 #include "dex/quick/dex_file_to_method_inliner_map.h"
 #include "dex/quick_compiler_callbacks.h"
+#include "dex/verification_results.h"
 #include "entrypoints/quick/quick_entrypoints.h"
 #include "mirror/art_method-inl.h"
 #include "mirror/class-inl.h"
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index 9c2facb..86567ed 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -613,9 +613,12 @@
     // Sharpening to kDirect only works if we compile PIC.
     DCHECK((optimized_invoke_type == invoke_type) || (optimized_invoke_type != kDirect)
            || compiler_driver_->GetCompilerOptions().GetCompilePic());
+    bool is_recursive =
+        (target_method.dex_method_index == outer_compilation_unit_->GetDexMethodIndex());
+    DCHECK(!is_recursive || (target_method.dex_file == outer_compilation_unit_->GetDexFile()));
     invoke = new (arena_) HInvokeStaticOrDirect(
         arena_, number_of_arguments, return_type, dex_pc, target_method.dex_method_index,
-        optimized_invoke_type);
+        is_recursive, optimized_invoke_type);
   }
 
   size_t start_index = 0;
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc
index 0fe28e8..7731a10 100644
--- a/compiler/optimizing/code_generator_arm.cc
+++ b/compiler/optimizing/code_generator_arm.cc
@@ -527,6 +527,8 @@
   bool skip_overflow_check =
       IsLeafMethod() && !FrameNeedsStackCheck(GetFrameSize(), InstructionSet::kArm);
   DCHECK(GetCompilerOptions().GetImplicitStackOverflowChecks());
+  __ Bind(&frame_entry_label_);
+
   if (!skip_overflow_check) {
     __ AddConstant(IP, SP, -static_cast<int32_t>(GetStackOverflowReservedBytes(kArm)));
     __ LoadFromOffset(kLoadWord, IP, IP, 0);
@@ -1185,18 +1187,22 @@
 
   // temp = method;
   codegen_->LoadCurrentMethod(temp);
-  // temp = temp->dex_cache_resolved_methods_;
-  __ LoadFromOffset(
-      kLoadWord, temp, temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value());
-  // temp = temp[index_in_cache]
-  __ LoadFromOffset(
-      kLoadWord, temp, temp, CodeGenerator::GetCacheOffset(invoke->GetDexMethodIndex()));
-  // LR = temp[offset_of_quick_compiled_code]
-  __ LoadFromOffset(kLoadWord, LR, temp,
-                     mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset(
-                         kArmWordSize).Int32Value());
-  // LR()
-  __ blx(LR);
+  if (!invoke->IsRecursive()) {
+    // temp = temp->dex_cache_resolved_methods_;
+    __ LoadFromOffset(
+        kLoadWord, temp, temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value());
+    // temp = temp[index_in_cache]
+    __ LoadFromOffset(
+        kLoadWord, temp, temp, CodeGenerator::GetCacheOffset(invoke->GetDexMethodIndex()));
+    // LR = temp[offset_of_quick_compiled_code]
+    __ LoadFromOffset(kLoadWord, LR, temp,
+                      mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset(
+                             kArmWordSize).Int32Value());
+    // LR()
+    __ blx(LR);
+  } else {
+    __ bl(codegen_->GetFrameEntryLabel());
+  }
 
   codegen_->RecordPcInfo(invoke, invoke->GetDexPc());
   DCHECK(!codegen_->IsLeafMethod());
diff --git a/compiler/optimizing/code_generator_arm.h b/compiler/optimizing/code_generator_arm.h
index dd69e4d..4b03dff 100644
--- a/compiler/optimizing/code_generator_arm.h
+++ b/compiler/optimizing/code_generator_arm.h
@@ -247,9 +247,12 @@
 
   void ComputeSpillMask() OVERRIDE;
 
+  Label* GetFrameEntryLabel() { return &frame_entry_label_; }
+
  private:
   // Labels for each block that will be compiled.
   GrowableArray<Label> block_labels_;
+  Label frame_entry_label_;
   LocationsBuilderARM location_builder_;
   InstructionCodeGeneratorARM instruction_visitor_;
   ParallelMoveResolverARM move_resolver_;
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc
index 1f561b7..0909424 100644
--- a/compiler/optimizing/code_generator_arm64.cc
+++ b/compiler/optimizing/code_generator_arm64.cc
@@ -16,9 +16,12 @@
 
 #include "code_generator_arm64.h"
 
+#include "common_arm64.h"
 #include "entrypoints/quick/quick_entrypoints.h"
 #include "entrypoints/quick/quick_entrypoints_enum.h"
 #include "gc/accounting/card_table.h"
+#include "intrinsics.h"
+#include "intrinsics_arm64.h"
 #include "mirror/array-inl.h"
 #include "mirror/art_method.h"
 #include "mirror/class.h"
@@ -35,175 +38,37 @@
 #error "ARM64 Codegen VIXL macro-assembler macro already defined."
 #endif
 
-
 namespace art {
 
 namespace arm64 {
 
-// TODO: Tune the use of Load-Acquire, Store-Release vs Data Memory Barriers.
-// For now we prefer the use of load-acquire, store-release over explicit memory barriers.
-static constexpr bool kUseAcquireRelease = true;
+using helpers::CPURegisterFrom;
+using helpers::DRegisterFrom;
+using helpers::FPRegisterFrom;
+using helpers::HeapOperand;
+using helpers::HeapOperandFrom;
+using helpers::InputCPURegisterAt;
+using helpers::InputFPRegisterAt;
+using helpers::InputRegisterAt;
+using helpers::InputOperandAt;
+using helpers::Int64ConstantFrom;
+using helpers::Is64BitType;
+using helpers::IsFPType;
+using helpers::IsIntegralType;
+using helpers::LocationFrom;
+using helpers::OperandFromMemOperand;
+using helpers::OutputCPURegister;
+using helpers::OutputFPRegister;
+using helpers::OutputRegister;
+using helpers::RegisterFrom;
+using helpers::StackOperandFrom;
+using helpers::VIXLRegCodeFromART;
+using helpers::WRegisterFrom;
+using helpers::XRegisterFrom;
+
 static constexpr size_t kHeapRefSize = sizeof(mirror::HeapReference<mirror::Object>);
 static constexpr int kCurrentMethodStackOffset = 0;
 
-namespace {
-
-bool IsFPType(Primitive::Type type) {
-  return type == Primitive::kPrimFloat || type == Primitive::kPrimDouble;
-}
-
-bool IsIntegralType(Primitive::Type type) {
-  switch (type) {
-    case Primitive::kPrimByte:
-    case Primitive::kPrimChar:
-    case Primitive::kPrimShort:
-    case Primitive::kPrimInt:
-    case Primitive::kPrimLong:
-      return true;
-    default:
-      return false;
-  }
-}
-
-bool Is64BitType(Primitive::Type type) {
-  return type == Primitive::kPrimLong || type == Primitive::kPrimDouble;
-}
-
-// Convenience helpers to ease conversion to and from VIXL operands.
-static_assert((SP == 31) && (WSP == 31) && (XZR == 32) && (WZR == 32),
-              "Unexpected values for register codes.");
-
-int VIXLRegCodeFromART(int code) {
-  if (code == SP) {
-    return vixl::kSPRegInternalCode;
-  }
-  if (code == XZR) {
-    return vixl::kZeroRegCode;
-  }
-  return code;
-}
-
-int ARTRegCodeFromVIXL(int code) {
-  if (code == vixl::kSPRegInternalCode) {
-    return SP;
-  }
-  if (code == vixl::kZeroRegCode) {
-    return XZR;
-  }
-  return code;
-}
-
-Register XRegisterFrom(Location location) {
-  DCHECK(location.IsRegister());
-  return Register::XRegFromCode(VIXLRegCodeFromART(location.reg()));
-}
-
-Register WRegisterFrom(Location location) {
-  DCHECK(location.IsRegister());
-  return Register::WRegFromCode(VIXLRegCodeFromART(location.reg()));
-}
-
-Register RegisterFrom(Location location, Primitive::Type type) {
-  DCHECK(type != Primitive::kPrimVoid && !IsFPType(type));
-  return type == Primitive::kPrimLong ? XRegisterFrom(location) : WRegisterFrom(location);
-}
-
-Register OutputRegister(HInstruction* instr) {
-  return RegisterFrom(instr->GetLocations()->Out(), instr->GetType());
-}
-
-Register InputRegisterAt(HInstruction* instr, int input_index) {
-  return RegisterFrom(instr->GetLocations()->InAt(input_index),
-                      instr->InputAt(input_index)->GetType());
-}
-
-FPRegister DRegisterFrom(Location location) {
-  DCHECK(location.IsFpuRegister());
-  return FPRegister::DRegFromCode(location.reg());
-}
-
-FPRegister SRegisterFrom(Location location) {
-  DCHECK(location.IsFpuRegister());
-  return FPRegister::SRegFromCode(location.reg());
-}
-
-FPRegister FPRegisterFrom(Location location, Primitive::Type type) {
-  DCHECK(IsFPType(type));
-  return type == Primitive::kPrimDouble ? DRegisterFrom(location) : SRegisterFrom(location);
-}
-
-FPRegister OutputFPRegister(HInstruction* instr) {
-  return FPRegisterFrom(instr->GetLocations()->Out(), instr->GetType());
-}
-
-FPRegister InputFPRegisterAt(HInstruction* instr, int input_index) {
-  return FPRegisterFrom(instr->GetLocations()->InAt(input_index),
-                        instr->InputAt(input_index)->GetType());
-}
-
-CPURegister CPURegisterFrom(Location location, Primitive::Type type) {
-  return IsFPType(type) ? CPURegister(FPRegisterFrom(location, type))
-                        : CPURegister(RegisterFrom(location, type));
-}
-
-CPURegister OutputCPURegister(HInstruction* instr) {
-  return IsFPType(instr->GetType()) ? static_cast<CPURegister>(OutputFPRegister(instr))
-                                    : static_cast<CPURegister>(OutputRegister(instr));
-}
-
-CPURegister InputCPURegisterAt(HInstruction* instr, int index) {
-  return IsFPType(instr->InputAt(index)->GetType())
-      ? static_cast<CPURegister>(InputFPRegisterAt(instr, index))
-      : static_cast<CPURegister>(InputRegisterAt(instr, index));
-}
-
-int64_t Int64ConstantFrom(Location location) {
-  HConstant* instr = location.GetConstant();
-  return instr->IsIntConstant() ? instr->AsIntConstant()->GetValue()
-                                : instr->AsLongConstant()->GetValue();
-}
-
-Operand OperandFrom(Location location, Primitive::Type type) {
-  if (location.IsRegister()) {
-    return Operand(RegisterFrom(location, type));
-  } else {
-    return Operand(Int64ConstantFrom(location));
-  }
-}
-
-Operand InputOperandAt(HInstruction* instr, int input_index) {
-  return OperandFrom(instr->GetLocations()->InAt(input_index),
-                     instr->InputAt(input_index)->GetType());
-}
-
-MemOperand StackOperandFrom(Location location) {
-  return MemOperand(sp, location.GetStackIndex());
-}
-
-MemOperand HeapOperand(const Register& base, size_t offset = 0) {
-  // A heap reference must be 32bit, so fit in a W register.
-  DCHECK(base.IsW());
-  return MemOperand(base.X(), offset);
-}
-
-MemOperand HeapOperand(const Register& base, Offset offset) {
-  return HeapOperand(base, offset.SizeValue());
-}
-
-MemOperand HeapOperandFrom(Location location, Offset offset) {
-  return HeapOperand(RegisterFrom(location, Primitive::kPrimNot), offset);
-}
-
-Location LocationFrom(const Register& reg) {
-  return Location::RegisterLocation(ARTRegCodeFromVIXL(reg.code()));
-}
-
-Location LocationFrom(const FPRegister& fpreg) {
-  return Location::FpuRegisterLocation(fpreg.code());
-}
-
-}  // namespace
-
 inline Condition ARM64Condition(IfCondition cond) {
   switch (cond) {
     case kCondEQ: return eq;
@@ -264,20 +129,6 @@
 #define __ down_cast<CodeGeneratorARM64*>(codegen)->GetVIXLAssembler()->
 #define QUICK_ENTRY_POINT(x) QUICK_ENTRYPOINT_OFFSET(kArm64WordSize, x).Int32Value()
 
-class SlowPathCodeARM64 : public SlowPathCode {
- public:
-  SlowPathCodeARM64() : entry_label_(), exit_label_() {}
-
-  vixl::Label* GetEntryLabel() { return &entry_label_; }
-  vixl::Label* GetExitLabel() { return &exit_label_; }
-
- private:
-  vixl::Label entry_label_;
-  vixl::Label exit_label_;
-
-  DISALLOW_COPY_AND_ASSIGN(SlowPathCodeARM64);
-};
-
 class BoundsCheckSlowPathARM64 : public SlowPathCodeARM64 {
  public:
   BoundsCheckSlowPathARM64(HBoundsCheck* instruction,
@@ -591,6 +442,8 @@
 }
 
 void CodeGeneratorARM64::GenerateFrameEntry() {
+  __ Bind(&frame_entry_label_);
+
   bool do_overflow_check = FrameNeedsStackCheck(GetFrameSize(), kArm64) || !IsLeafMethod();
   if (do_overflow_check) {
     UseScratchRegisterScope temps(GetVIXLAssembler());
@@ -602,7 +455,7 @@
   }
 
   int frame_size = GetFrameSize();
-  __ Str(w0, MemOperand(sp, -frame_size, PreIndex));
+  __ Str(kArtMethodRegister, MemOperand(sp, -frame_size, PreIndex));
   __ PokeCPURegList(GetFramePreservedRegisters(), frame_size - FrameEntrySpillSize());
 
   // Stack layout:
@@ -978,12 +831,11 @@
   Register temp_base = temps.AcquireX();
   Primitive::Type type = instruction->GetType();
 
-  DCHECK(!src.IsRegisterOffset());
   DCHECK(!src.IsPreIndex());
   DCHECK(!src.IsPostIndex());
 
   // TODO(vixl): Let the MacroAssembler handle MemOperand.
-  __ Add(temp_base, src.base(), src.offset());
+  __ Add(temp_base, src.base(), OperandFromMemOperand(src));
   MemOperand base = MemOperand(temp_base);
   switch (type) {
     case Primitive::kPrimBoolean:
@@ -1058,12 +910,12 @@
   UseScratchRegisterScope temps(GetVIXLAssembler());
   Register temp_base = temps.AcquireX();
 
-  DCHECK(!dst.IsRegisterOffset());
   DCHECK(!dst.IsPreIndex());
   DCHECK(!dst.IsPostIndex());
 
   // TODO(vixl): Let the MacroAssembler handle this.
-  __ Add(temp_base, dst.base(), dst.offset());
+  Operand op = OperandFromMemOperand(dst);
+  __ Add(temp_base, dst.base(), op);
   MemOperand base = MemOperand(temp_base);
   switch (type) {
     case Primitive::kPrimBoolean:
@@ -1956,19 +1808,37 @@
 }
 
 void LocationsBuilderARM64::VisitInvokeVirtual(HInvokeVirtual* invoke) {
+  IntrinsicLocationsBuilderARM64 intrinsic(GetGraph()->GetArena());
+  if (intrinsic.TryDispatch(invoke)) {
+    return;
+  }
+
   HandleInvoke(invoke);
 }
 
 void LocationsBuilderARM64::VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) {
+  IntrinsicLocationsBuilderARM64 intrinsic(GetGraph()->GetArena());
+  if (intrinsic.TryDispatch(invoke)) {
+    return;
+  }
+
   HandleInvoke(invoke);
 }
 
-void InstructionCodeGeneratorARM64::VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) {
-  Register temp = WRegisterFrom(invoke->GetLocations()->GetTemp(0));
-  // Make sure that ArtMethod* is passed in W0 as per the calling convention
-  DCHECK(temp.Is(w0));
+static bool TryGenerateIntrinsicCode(HInvoke* invoke, CodeGeneratorARM64* codegen) {
+  if (invoke->GetLocations()->Intrinsified()) {
+    IntrinsicCodeGeneratorARM64 intrinsic(codegen);
+    intrinsic.Dispatch(invoke);
+    return true;
+  }
+  return false;
+}
+
+void CodeGeneratorARM64::GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invoke, Register temp) {
+  // Make sure that ArtMethod* is passed in kArtMethodRegister as per the calling convention.
+  DCHECK(temp.Is(kArtMethodRegister));
   size_t index_in_cache = mirror::Array::DataOffset(kHeapRefSize).SizeValue() +
-    invoke->GetDexMethodIndex() * kHeapRefSize;
+      invoke->GetDexMethodIndex() * kHeapRefSize;
 
   // TODO: Implement all kinds of calls:
   // 1) boot -> boot
@@ -1977,23 +1847,40 @@
   //
   // Currently we implement the app -> app logic, which looks up in the resolve cache.
 
-  // temp = method;
-  codegen_->LoadCurrentMethod(temp);
-  // temp = temp->dex_cache_resolved_methods_;
-  __ Ldr(temp, HeapOperand(temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset()));
-  // temp = temp[index_in_cache];
-  __ Ldr(temp, HeapOperand(temp, index_in_cache));
-  // lr = temp->entry_point_from_quick_compiled_code_;
-  __ Ldr(lr, HeapOperand(temp, mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset(
-                          kArm64WordSize)));
-  // lr();
-  __ Blr(lr);
+  if (!invoke->IsRecursive()) {
+    // temp = method;
+    LoadCurrentMethod(temp);
+    // temp = temp->dex_cache_resolved_methods_;
+    __ Ldr(temp, HeapOperand(temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset()));
+    // temp = temp[index_in_cache];
+    __ Ldr(temp, HeapOperand(temp, index_in_cache));
+    // lr = temp->entry_point_from_quick_compiled_code_;
+    __ Ldr(lr, HeapOperand(temp, mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset(
+        kArm64WordSize)));
+    // lr();
+    __ Blr(lr);
+  } else {
+    __ Bl(&frame_entry_label_);
+  }
 
-  codegen_->RecordPcInfo(invoke, invoke->GetDexPc());
-  DCHECK(!codegen_->IsLeafMethod());
+  RecordPcInfo(invoke, invoke->GetDexPc());
+  DCHECK(!IsLeafMethod());
+}
+
+void InstructionCodeGeneratorARM64::VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) {
+  if (TryGenerateIntrinsicCode(invoke, codegen_)) {
+    return;
+  }
+
+  Register temp = WRegisterFrom(invoke->GetLocations()->GetTemp(0));
+  codegen_->GenerateStaticOrDirectCall(invoke, temp);
 }
 
 void InstructionCodeGeneratorARM64::VisitInvokeVirtual(HInvokeVirtual* invoke) {
+  if (TryGenerateIntrinsicCode(invoke, codegen_)) {
+    return;
+  }
+
   LocationSummary* locations = invoke->GetLocations();
   Location receiver = locations->InAt(0);
   Register temp = WRegisterFrom(invoke->GetLocations()->GetTemp(0));
diff --git a/compiler/optimizing/code_generator_arm64.h b/compiler/optimizing/code_generator_arm64.h
index 96013e5..9a99dcc 100644
--- a/compiler/optimizing/code_generator_arm64.h
+++ b/compiler/optimizing/code_generator_arm64.h
@@ -31,7 +31,10 @@
 namespace arm64 {
 
 class CodeGeneratorARM64;
-class SlowPathCodeARM64;
+
+// TODO: Tune the use of Load-Acquire, Store-Release vs Data Memory Barriers.
+// For now we prefer the use of load-acquire, store-release over explicit memory barriers.
+static constexpr bool kUseAcquireRelease = true;
 
 // Use a local definition to prevent copying mistakes.
 static constexpr size_t kArm64WordSize = kArm64PointerSize;
@@ -45,7 +48,8 @@
 };
 static constexpr size_t kParameterFPRegistersLength = arraysize(kParameterFPRegisters);
 
-const vixl::Register tr = vixl::x18;        // Thread Register
+const vixl::Register tr = vixl::x18;                        // Thread Register
+static const vixl::Register kArtMethodRegister = vixl::w0;  // Method register on invoke.
 
 const vixl::CPURegList vixl_reserved_core_registers(vixl::ip0, vixl::ip1);
 const vixl::CPURegList vixl_reserved_fp_registers(vixl::d31);
@@ -56,6 +60,20 @@
 
 Location ARM64ReturnLocation(Primitive::Type return_type);
 
+class SlowPathCodeARM64 : public SlowPathCode {
+ public:
+  SlowPathCodeARM64() : entry_label_(), exit_label_() {}
+
+  vixl::Label* GetEntryLabel() { return &entry_label_; }
+  vixl::Label* GetExitLabel() { return &exit_label_; }
+
+ private:
+  vixl::Label entry_label_;
+  vixl::Label exit_label_;
+
+  DISALLOW_COPY_AND_ASSIGN(SlowPathCodeARM64);
+};
+
 class InvokeDexCallingConvention : public CallingConvention<vixl::Register, vixl::FPRegister> {
  public:
   InvokeDexCallingConvention()
@@ -274,9 +292,12 @@
     return false;
   }
 
+  void GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invoke, vixl::Register temp);
+
  private:
   // Labels for each block that will be compiled.
   vixl::Label* block_labels_;
+  vixl::Label frame_entry_label_;
 
   LocationsBuilderARM64 location_builder_;
   InstructionCodeGeneratorARM64 instruction_visitor_;
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc
index df2b316..063550b 100644
--- a/compiler/optimizing/code_generator_x86.cc
+++ b/compiler/optimizing/code_generator_x86.cc
@@ -459,6 +459,7 @@
         codegen_(codegen) {}
 
 void CodeGeneratorX86::GenerateFrameEntry() {
+  __ Bind(&frame_entry_label_);
   bool skip_overflow_check =
       IsLeafMethod() && !FrameNeedsStackCheck(GetFrameSize(), InstructionSet::kX86);
   DCHECK(GetCompilerOptions().GetImplicitStackOverflowChecks());
@@ -1147,13 +1148,17 @@
 
   // temp = method;
   codegen_->LoadCurrentMethod(temp);
-  // temp = temp->dex_cache_resolved_methods_;
-  __ movl(temp, Address(temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value()));
-  // temp = temp[index_in_cache]
-  __ movl(temp, Address(temp, CodeGenerator::GetCacheOffset(invoke->GetDexMethodIndex())));
-  // (temp + offset_of_quick_compiled_code)()
-  __ call(Address(
-      temp, mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset(kX86WordSize).Int32Value()));
+  if (!invoke->IsRecursive()) {
+    // temp = temp->dex_cache_resolved_methods_;
+    __ movl(temp, Address(temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value()));
+    // temp = temp[index_in_cache]
+    __ movl(temp, Address(temp, CodeGenerator::GetCacheOffset(invoke->GetDexMethodIndex())));
+    // (temp + offset_of_quick_compiled_code)()
+    __ call(Address(
+        temp, mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset(kX86WordSize).Int32Value()));
+  } else {
+    __ call(codegen_->GetFrameEntryLabel());
+  }
 
   DCHECK(!codegen_->IsLeafMethod());
   codegen_->RecordPcInfo(invoke, invoke->GetDexPc());
diff --git a/compiler/optimizing/code_generator_x86.h b/compiler/optimizing/code_generator_x86.h
index 64a29e0..107ddaf 100644
--- a/compiler/optimizing/code_generator_x86.h
+++ b/compiler/optimizing/code_generator_x86.h
@@ -245,9 +245,12 @@
     return type == Primitive::kPrimLong;
   }
 
+  Label* GetFrameEntryLabel() { return &frame_entry_label_; }
+
  private:
   // Labels for each block that will be compiled.
   GrowableArray<Label> block_labels_;
+  Label frame_entry_label_;
   LocationsBuilderX86 location_builder_;
   InstructionCodeGeneratorX86 instruction_visitor_;
   ParallelMoveResolverX86 move_resolver_;
diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc
index 6bc28ff..90b7bda 100644
--- a/compiler/optimizing/code_generator_x86_64.cc
+++ b/compiler/optimizing/code_generator_x86_64.cc
@@ -361,13 +361,17 @@
 
   // temp = method;
   LoadCurrentMethod(temp);
-  // temp = temp->dex_cache_resolved_methods_;
-  __ movl(temp, Address(temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset().SizeValue()));
-  // temp = temp[index_in_cache]
-  __ movl(temp, Address(temp, CodeGenerator::GetCacheOffset(invoke->GetDexMethodIndex())));
-  // (temp + offset_of_quick_compiled_code)()
-  __ call(Address(temp, mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset(
-      kX86_64WordSize).SizeValue()));
+  if (!invoke->IsRecursive()) {
+    // temp = temp->dex_cache_resolved_methods_;
+    __ movl(temp, Address(temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset().SizeValue()));
+    // temp = temp[index_in_cache]
+    __ movl(temp, Address(temp, CodeGenerator::GetCacheOffset(invoke->GetDexMethodIndex())));
+    // (temp + offset_of_quick_compiled_code)()
+    __ call(Address(temp, mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset(
+        kX86_64WordSize).SizeValue()));
+  } else {
+    __ call(&frame_entry_label_);
+  }
 
   DCHECK(!IsLeafMethod());
   RecordPcInfo(invoke, invoke->GetDexPc());
@@ -472,6 +476,7 @@
 }
 
 void CodeGeneratorX86_64::GenerateFrameEntry() {
+  __ Bind(&frame_entry_label_);
   bool skip_overflow_check = IsLeafMethod()
       && !FrameNeedsStackCheck(GetFrameSize(), InstructionSet::kX86_64);
   DCHECK(GetCompilerOptions().GetImplicitStackOverflowChecks());
diff --git a/compiler/optimizing/code_generator_x86_64.h b/compiler/optimizing/code_generator_x86_64.h
index 1ac2ab7..dbdbf86 100644
--- a/compiler/optimizing/code_generator_x86_64.h
+++ b/compiler/optimizing/code_generator_x86_64.h
@@ -37,8 +37,6 @@
 static constexpr size_t kParameterCoreRegistersLength = arraysize(kParameterCoreRegisters);
 static constexpr size_t kParameterFloatRegistersLength = arraysize(kParameterFloatRegisters);
 
-static constexpr bool kCoalescedImplicitNullCheck = false;
-
 class InvokeDexCallingConvention : public CallingConvention<Register, FloatRegister> {
  public:
   InvokeDexCallingConvention() : CallingConvention(
@@ -250,6 +248,7 @@
  private:
   // Labels for each block that will be compiled.
   GrowableArray<Label> block_labels_;
+  Label frame_entry_label_;
   LocationsBuilderX86_64 location_builder_;
   InstructionCodeGeneratorX86_64 instruction_visitor_;
   ParallelMoveResolverX86_64 move_resolver_;
diff --git a/compiler/optimizing/common_arm64.h b/compiler/optimizing/common_arm64.h
new file mode 100644
index 0000000..7077f98
--- /dev/null
+++ b/compiler/optimizing/common_arm64.h
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_COMPILER_OPTIMIZING_COMMON_ARM64_H_
+#define ART_COMPILER_OPTIMIZING_COMMON_ARM64_H_
+
+#include "locations.h"
+#include "nodes.h"
+#include "utils/arm64/assembler_arm64.h"
+#include "a64/disasm-a64.h"
+#include "a64/macro-assembler-a64.h"
+
+namespace art {
+namespace arm64 {
+namespace helpers {
+
+constexpr bool IsFPType(Primitive::Type type) {
+  return type == Primitive::kPrimFloat || type == Primitive::kPrimDouble;
+}
+
+static inline bool IsIntegralType(Primitive::Type type) {
+  switch (type) {
+    case Primitive::kPrimByte:
+    case Primitive::kPrimChar:
+    case Primitive::kPrimShort:
+    case Primitive::kPrimInt:
+    case Primitive::kPrimLong:
+      return true;
+    default:
+      return false;
+  }
+}
+
+constexpr bool Is64BitType(Primitive::Type type) {
+  return type == Primitive::kPrimLong || type == Primitive::kPrimDouble;
+}
+
+// Convenience helpers to ease conversion to and from VIXL operands.
+static_assert((SP == 31) && (WSP == 31) && (XZR == 32) && (WZR == 32),
+              "Unexpected values for register codes.");
+
+static inline int VIXLRegCodeFromART(int code) {
+  if (code == SP) {
+    return vixl::kSPRegInternalCode;
+  }
+  if (code == XZR) {
+    return vixl::kZeroRegCode;
+  }
+  return code;
+}
+
+static inline int ARTRegCodeFromVIXL(int code) {
+  if (code == vixl::kSPRegInternalCode) {
+    return SP;
+  }
+  if (code == vixl::kZeroRegCode) {
+    return XZR;
+  }
+  return code;
+}
+
+static inline vixl::Register XRegisterFrom(Location location) {
+  DCHECK(location.IsRegister());
+  return vixl::Register::XRegFromCode(VIXLRegCodeFromART(location.reg()));
+}
+
+static inline vixl::Register WRegisterFrom(Location location) {
+  DCHECK(location.IsRegister());
+  return vixl::Register::WRegFromCode(VIXLRegCodeFromART(location.reg()));
+}
+
+static inline vixl::Register RegisterFrom(Location location, Primitive::Type type) {
+  DCHECK(type != Primitive::kPrimVoid && !IsFPType(type));
+  return type == Primitive::kPrimLong ? XRegisterFrom(location) : WRegisterFrom(location);
+}
+
+static inline vixl::Register OutputRegister(HInstruction* instr) {
+  return RegisterFrom(instr->GetLocations()->Out(), instr->GetType());
+}
+
+static inline vixl::Register InputRegisterAt(HInstruction* instr, int input_index) {
+  return RegisterFrom(instr->GetLocations()->InAt(input_index),
+                      instr->InputAt(input_index)->GetType());
+}
+
+static inline vixl::FPRegister DRegisterFrom(Location location) {
+  DCHECK(location.IsFpuRegister());
+  return vixl::FPRegister::DRegFromCode(location.reg());
+}
+
+static inline vixl::FPRegister SRegisterFrom(Location location) {
+  DCHECK(location.IsFpuRegister());
+  return vixl::FPRegister::SRegFromCode(location.reg());
+}
+
+static inline vixl::FPRegister FPRegisterFrom(Location location, Primitive::Type type) {
+  DCHECK(IsFPType(type));
+  return type == Primitive::kPrimDouble ? DRegisterFrom(location) : SRegisterFrom(location);
+}
+
+static inline vixl::FPRegister OutputFPRegister(HInstruction* instr) {
+  return FPRegisterFrom(instr->GetLocations()->Out(), instr->GetType());
+}
+
+static inline vixl::FPRegister InputFPRegisterAt(HInstruction* instr, int input_index) {
+  return FPRegisterFrom(instr->GetLocations()->InAt(input_index),
+                        instr->InputAt(input_index)->GetType());
+}
+
+static inline vixl::CPURegister CPURegisterFrom(Location location, Primitive::Type type) {
+  return IsFPType(type) ? vixl::CPURegister(FPRegisterFrom(location, type))
+                        : vixl::CPURegister(RegisterFrom(location, type));
+}
+
+static inline vixl::CPURegister OutputCPURegister(HInstruction* instr) {
+  return IsFPType(instr->GetType()) ? static_cast<vixl::CPURegister>(OutputFPRegister(instr))
+                                    : static_cast<vixl::CPURegister>(OutputRegister(instr));
+}
+
+static inline vixl::CPURegister InputCPURegisterAt(HInstruction* instr, int index) {
+  return IsFPType(instr->InputAt(index)->GetType())
+      ? static_cast<vixl::CPURegister>(InputFPRegisterAt(instr, index))
+      : static_cast<vixl::CPURegister>(InputRegisterAt(instr, index));
+}
+
+static inline int64_t Int64ConstantFrom(Location location) {
+  HConstant* instr = location.GetConstant();
+  return instr->IsIntConstant() ? instr->AsIntConstant()->GetValue()
+                                : instr->AsLongConstant()->GetValue();
+}
+
+static inline vixl::Operand OperandFrom(Location location, Primitive::Type type) {
+  if (location.IsRegister()) {
+    return vixl::Operand(RegisterFrom(location, type));
+  } else {
+    return vixl::Operand(Int64ConstantFrom(location));
+  }
+}
+
+static inline vixl::Operand InputOperandAt(HInstruction* instr, int input_index) {
+  return OperandFrom(instr->GetLocations()->InAt(input_index),
+                     instr->InputAt(input_index)->GetType());
+}
+
+static inline vixl::MemOperand StackOperandFrom(Location location) {
+  return vixl::MemOperand(vixl::sp, location.GetStackIndex());
+}
+
+static inline vixl::MemOperand HeapOperand(const vixl::Register& base, size_t offset = 0) {
+  // A heap reference must be 32bit, so fit in a W register.
+  DCHECK(base.IsW());
+  return vixl::MemOperand(base.X(), offset);
+}
+
+static inline vixl::MemOperand HeapOperand(const vixl::Register& base, Offset offset) {
+  return HeapOperand(base, offset.SizeValue());
+}
+
+static inline vixl::MemOperand HeapOperandFrom(Location location, Offset offset) {
+  return HeapOperand(RegisterFrom(location, Primitive::kPrimNot), offset);
+}
+
+static inline Location LocationFrom(const vixl::Register& reg) {
+  return Location::RegisterLocation(ARTRegCodeFromVIXL(reg.code()));
+}
+
+static inline Location LocationFrom(const vixl::FPRegister& fpreg) {
+  return Location::FpuRegisterLocation(fpreg.code());
+}
+
+static inline vixl::Operand OperandFromMemOperand(const vixl::MemOperand& mem_op) {
+  if (mem_op.IsImmediateOffset()) {
+    return vixl::Operand(mem_op.offset());
+  } else {
+    DCHECK(mem_op.IsRegisterOffset());
+    if (mem_op.extend() != vixl::NO_EXTEND) {
+      return vixl::Operand(mem_op.regoffset(), mem_op.extend(), mem_op.shift_amount());
+    } else if (mem_op.shift() != vixl::NO_SHIFT) {
+      return vixl::Operand(mem_op.regoffset(), mem_op.shift(), mem_op.shift_amount());
+    } else {
+      LOG(FATAL) << "Should not reach here";
+      UNREACHABLE();
+    }
+  }
+}
+
+}  // namespace helpers
+}  // namespace arm64
+}  // namespace art
+
+#endif  // ART_COMPILER_OPTIMIZING_COMMON_ARM64_H_
diff --git a/compiler/optimizing/intrinsics.cc b/compiler/optimizing/intrinsics.cc
index fe0e7f2..36cf856 100644
--- a/compiler/optimizing/intrinsics.cc
+++ b/compiler/optimizing/intrinsics.cc
@@ -47,25 +47,25 @@
   if (is_op_size) {
     switch (static_cast<OpSize>(data)) {
       case kSignedByte:
-        return Primitive::Type::kPrimByte;
+        return Primitive::kPrimByte;
       case kSignedHalf:
-        return Primitive::Type::kPrimShort;
+        return Primitive::kPrimShort;
       case k32:
-        return Primitive::Type::kPrimInt;
+        return Primitive::kPrimInt;
       case k64:
-        return Primitive::Type::kPrimLong;
+        return Primitive::kPrimLong;
       default:
         LOG(FATAL) << "Unknown/unsupported op size " << data;
         UNREACHABLE();
     }
   } else {
     if ((data & kIntrinsicFlagIsLong) != 0) {
-      return Primitive::Type::kPrimLong;
+      return Primitive::kPrimLong;
     }
     if ((data & kIntrinsicFlagIsObject) != 0) {
-      return Primitive::Type::kPrimNot;
+      return Primitive::kPrimNot;
     }
-    return Primitive::Type::kPrimInt;
+    return Primitive::kPrimInt;
   }
 }
 
@@ -82,9 +82,9 @@
     // Bit manipulations.
     case kIntrinsicReverseBits:
       switch (GetType(method.d.data, true)) {
-        case Primitive::Type::kPrimInt:
+        case Primitive::kPrimInt:
           return Intrinsics::kIntegerReverse;
-        case Primitive::Type::kPrimLong:
+        case Primitive::kPrimLong:
           return Intrinsics::kLongReverse;
         default:
           LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
@@ -93,11 +93,11 @@
       break;
     case kIntrinsicReverseBytes:
       switch (GetType(method.d.data, true)) {
-        case Primitive::Type::kPrimShort:
+        case Primitive::kPrimShort:
           return Intrinsics::kShortReverseBytes;
-        case Primitive::Type::kPrimInt:
+        case Primitive::kPrimInt:
           return Intrinsics::kIntegerReverseBytes;
-        case Primitive::Type::kPrimLong:
+        case Primitive::kPrimLong:
           return Intrinsics::kLongReverseBytes;
         default:
           LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
@@ -154,13 +154,13 @@
     // Memory.peek.
     case kIntrinsicPeek:
       switch (GetType(method.d.data, true)) {
-        case Primitive::Type::kPrimByte:
+        case Primitive::kPrimByte:
           return Intrinsics::kMemoryPeekByte;
-        case Primitive::Type::kPrimShort:
+        case Primitive::kPrimShort:
           return Intrinsics::kMemoryPeekShortNative;
-        case Primitive::Type::kPrimInt:
+        case Primitive::kPrimInt:
           return Intrinsics::kMemoryPeekIntNative;
-        case Primitive::Type::kPrimLong:
+        case Primitive::kPrimLong:
           return Intrinsics::kMemoryPeekLongNative;
         default:
           LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
@@ -171,13 +171,13 @@
     // Memory.poke.
     case kIntrinsicPoke:
       switch (GetType(method.d.data, true)) {
-        case Primitive::Type::kPrimByte:
+        case Primitive::kPrimByte:
           return Intrinsics::kMemoryPokeByte;
-        case Primitive::Type::kPrimShort:
+        case Primitive::kPrimShort:
           return Intrinsics::kMemoryPokeShortNative;
-        case Primitive::Type::kPrimInt:
+        case Primitive::kPrimInt:
           return Intrinsics::kMemoryPokeIntNative;
-        case Primitive::Type::kPrimLong:
+        case Primitive::kPrimLong:
           return Intrinsics::kMemoryPokeLongNative;
         default:
           LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
@@ -199,11 +199,11 @@
 
     case kIntrinsicCas:
       switch (GetType(method.d.data, false)) {
-        case Primitive::Type::kPrimNot:
+        case Primitive::kPrimNot:
           return Intrinsics::kUnsafeCASObject;
-        case Primitive::Type::kPrimInt:
+        case Primitive::kPrimInt:
           return Intrinsics::kUnsafeCASInt;
-        case Primitive::Type::kPrimLong:
+        case Primitive::kPrimLong:
           return Intrinsics::kUnsafeCASLong;
         default:
           LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
@@ -213,10 +213,12 @@
     case kIntrinsicUnsafeGet: {
       const bool is_volatile = (method.d.data & kIntrinsicFlagIsVolatile);
       switch (GetType(method.d.data, false)) {
-        case Primitive::Type::kPrimInt:
+        case Primitive::kPrimInt:
           return is_volatile ? Intrinsics::kUnsafeGetVolatile : Intrinsics::kUnsafeGet;
-        case Primitive::Type::kPrimLong:
+        case Primitive::kPrimLong:
           return is_volatile ? Intrinsics::kUnsafeGetLongVolatile : Intrinsics::kUnsafeGetLong;
+        case Primitive::kPrimNot:
+          return is_volatile ? Intrinsics::kUnsafeGetObjectVolatile : Intrinsics::kUnsafeGetObject;
         default:
           LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
           UNREACHABLE();
@@ -230,7 +232,7 @@
           ((method.d.data & kIntrinsicFlagIsOrdered) != 0)  ? kOrdered :
                                                               kNoSync;
       switch (GetType(method.d.data, false)) {
-        case Primitive::Type::kPrimInt:
+        case Primitive::kPrimInt:
           switch (sync) {
             case kNoSync:
               return Intrinsics::kUnsafePut;
@@ -240,7 +242,7 @@
               return Intrinsics::kUnsafePutOrdered;
           }
           break;
-        case Primitive::Type::kPrimLong:
+        case Primitive::kPrimLong:
           switch (sync) {
             case kNoSync:
               return Intrinsics::kUnsafePutLong;
@@ -250,7 +252,7 @@
               return Intrinsics::kUnsafePutLongOrdered;
           }
           break;
-        case Primitive::Type::kPrimNot:
+        case Primitive::kPrimNot:
           switch (sync) {
             case kNoSync:
               return Intrinsics::kUnsafePutObject;
diff --git a/compiler/optimizing/intrinsics_arm64.cc b/compiler/optimizing/intrinsics_arm64.cc
new file mode 100644
index 0000000..6d10544
--- /dev/null
+++ b/compiler/optimizing/intrinsics_arm64.cc
@@ -0,0 +1,1001 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "intrinsics_arm64.h"
+
+#include "code_generator_arm64.h"
+#include "common_arm64.h"
+#include "entrypoints/quick/quick_entrypoints.h"
+#include "intrinsics.h"
+#include "mirror/array-inl.h"
+#include "mirror/art_method.h"
+#include "mirror/string.h"
+#include "thread.h"
+#include "utils/arm64/assembler_arm64.h"
+#include "utils/arm64/constants_arm64.h"
+
+#include "a64/disasm-a64.h"
+#include "a64/macro-assembler-a64.h"
+
+using namespace vixl;   // NOLINT(build/namespaces)
+
+namespace art {
+
+namespace arm64 {
+
+using helpers::DRegisterFrom;
+using helpers::FPRegisterFrom;
+using helpers::HeapOperand;
+using helpers::IsIntegralType;
+using helpers::RegisterFrom;
+using helpers::SRegisterFrom;
+using helpers::WRegisterFrom;
+using helpers::XRegisterFrom;
+
+
+namespace {
+
+ALWAYS_INLINE inline MemOperand AbsoluteHeapOperandFrom(Location location, size_t offset = 0) {
+  return MemOperand(XRegisterFrom(location), offset);
+}
+
+}  // namespace
+
+vixl::MacroAssembler* IntrinsicCodeGeneratorARM64::GetVIXLAssembler() {
+  return codegen_->GetAssembler()->vixl_masm_;
+}
+
+ArenaAllocator* IntrinsicCodeGeneratorARM64::GetAllocator() {
+  return codegen_->GetGraph()->GetArena();
+}
+
+#define __ codegen->GetAssembler()->vixl_masm_->
+
+static void MoveFromReturnRegister(Location trg,
+                                   Primitive::Type type,
+                                   CodeGeneratorARM64* codegen) {
+  if (!trg.IsValid()) {
+    DCHECK(type == Primitive::kPrimVoid);
+    return;
+  }
+
+  DCHECK_NE(type, Primitive::kPrimVoid);
+
+  if (IsIntegralType(type)) {
+    Register trg_reg = RegisterFrom(trg, type);
+    Register res_reg = RegisterFrom(ARM64ReturnLocation(type), type);
+    __ Mov(trg_reg, res_reg, kDiscardForSameWReg);
+  } else {
+    FPRegister trg_reg = FPRegisterFrom(trg, type);
+    FPRegister res_reg = FPRegisterFrom(ARM64ReturnLocation(type), type);
+    __ Fmov(trg_reg, res_reg);
+  }
+}
+
+static void MoveArguments(HInvoke* invoke, ArenaAllocator* arena, CodeGeneratorARM64* codegen) {
+  if (invoke->InputCount() == 0) {
+    return;
+  }
+
+  LocationSummary* locations = invoke->GetLocations();
+  InvokeDexCallingConventionVisitor calling_convention_visitor;
+
+  // We're moving potentially two or more locations to locations that could overlap, so we need
+  // a parallel move resolver.
+  HParallelMove parallel_move(arena);
+
+  for (size_t i = 0; i < invoke->InputCount(); i++) {
+    HInstruction* input = invoke->InputAt(i);
+    Location cc_loc = calling_convention_visitor.GetNextLocation(input->GetType());
+    Location actual_loc = locations->InAt(i);
+
+    parallel_move.AddMove(actual_loc, cc_loc, nullptr);
+  }
+
+  codegen->GetMoveResolver()->EmitNativeCode(&parallel_move);
+}
+
+// Slow-path for fallback (calling the managed code to handle the intrinsic) in an intrinsified
+// call. This will copy the arguments into the positions for a regular call.
+//
+// Note: The actual parameters are required to be in the locations given by the invoke's location
+//       summary. If an intrinsic modifies those locations before a slowpath call, they must be
+//       restored!
+class IntrinsicSlowPathARM64 : public SlowPathCodeARM64 {
+ public:
+  explicit IntrinsicSlowPathARM64(HInvoke* invoke) : invoke_(invoke) { }
+
+  void EmitNativeCode(CodeGenerator* codegen_in) OVERRIDE {
+    CodeGeneratorARM64* codegen = down_cast<CodeGeneratorARM64*>(codegen_in);
+    __ Bind(GetEntryLabel());
+
+    codegen->SaveLiveRegisters(invoke_->GetLocations());
+
+    MoveArguments(invoke_, codegen->GetGraph()->GetArena(), codegen);
+
+    if (invoke_->IsInvokeStaticOrDirect()) {
+      codegen->GenerateStaticOrDirectCall(invoke_->AsInvokeStaticOrDirect(), kArtMethodRegister);
+    } else {
+      UNIMPLEMENTED(FATAL) << "Non-direct intrinsic slow-path not yet implemented";
+      UNREACHABLE();
+    }
+
+    // Copy the result back to the expected output.
+    Location out = invoke_->GetLocations()->Out();
+    if (out.IsValid()) {
+      DCHECK(out.IsRegister());  // TODO: Replace this when we support output in memory.
+      DCHECK(!invoke_->GetLocations()->GetLiveRegisters()->ContainsCoreRegister(out.reg()));
+      MoveFromReturnRegister(out, invoke_->GetType(), codegen);
+    }
+
+    codegen->RestoreLiveRegisters(invoke_->GetLocations());
+    __ B(GetExitLabel());
+  }
+
+ private:
+  // The instruction where this slow path is happening.
+  HInvoke* const invoke_;
+
+  DISALLOW_COPY_AND_ASSIGN(IntrinsicSlowPathARM64);
+};
+
+#undef __
+
+bool IntrinsicLocationsBuilderARM64::TryDispatch(HInvoke* invoke) {
+  Dispatch(invoke);
+  LocationSummary* res = invoke->GetLocations();
+  return res != nullptr && res->Intrinsified();
+}
+
+#define __ masm->
+
+static void CreateFPToIntLocations(ArenaAllocator* arena, HInvoke* invoke) {
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::RequiresFpuRegister());
+  locations->SetOut(Location::RequiresRegister());
+}
+
+static void CreateIntToFPLocations(ArenaAllocator* arena, HInvoke* invoke) {
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::RequiresRegister());
+  locations->SetOut(Location::RequiresFpuRegister());
+}
+
+static void MoveFPToInt(LocationSummary* locations, bool is64bit, vixl::MacroAssembler* masm) {
+  Location input = locations->InAt(0);
+  Location output = locations->Out();
+  __ Fmov(is64bit ? XRegisterFrom(output) : WRegisterFrom(output),
+          is64bit ? DRegisterFrom(input) : SRegisterFrom(input));
+}
+
+static void MoveIntToFP(LocationSummary* locations, bool is64bit, vixl::MacroAssembler* masm) {
+  Location input = locations->InAt(0);
+  Location output = locations->Out();
+  __ Fmov(is64bit ? DRegisterFrom(output) : SRegisterFrom(output),
+          is64bit ? XRegisterFrom(input) : WRegisterFrom(input));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitDoubleDoubleToRawLongBits(HInvoke* invoke) {
+  CreateFPToIntLocations(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitDoubleLongBitsToDouble(HInvoke* invoke) {
+  CreateIntToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitDoubleDoubleToRawLongBits(HInvoke* invoke) {
+  MoveFPToInt(invoke->GetLocations(), true, GetVIXLAssembler());
+}
+void IntrinsicCodeGeneratorARM64::VisitDoubleLongBitsToDouble(HInvoke* invoke) {
+  MoveIntToFP(invoke->GetLocations(), true, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitFloatFloatToRawIntBits(HInvoke* invoke) {
+  CreateFPToIntLocations(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitFloatIntBitsToFloat(HInvoke* invoke) {
+  CreateIntToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitFloatFloatToRawIntBits(HInvoke* invoke) {
+  MoveFPToInt(invoke->GetLocations(), false, GetVIXLAssembler());
+}
+void IntrinsicCodeGeneratorARM64::VisitFloatIntBitsToFloat(HInvoke* invoke) {
+  MoveIntToFP(invoke->GetLocations(), false, GetVIXLAssembler());
+}
+
+static void CreateIntToIntLocations(ArenaAllocator* arena, HInvoke* invoke) {
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::RequiresRegister());
+  locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
+}
+
+static void GenReverseBytes(LocationSummary* locations,
+                            Primitive::Type type,
+                            vixl::MacroAssembler* masm) {
+  Location in = locations->InAt(0);
+  Location out = locations->Out();
+
+  switch (type) {
+    case Primitive::kPrimShort:
+      __ Rev16(WRegisterFrom(out), WRegisterFrom(in));
+      __ Sxth(WRegisterFrom(out), WRegisterFrom(out));
+      break;
+    case Primitive::kPrimInt:
+    case Primitive::kPrimLong:
+      __ Rev(RegisterFrom(out, type), RegisterFrom(in, type));
+      break;
+    default:
+      LOG(FATAL) << "Unexpected size for reverse-bytes: " << type;
+      UNREACHABLE();
+  }
+}
+
+void IntrinsicLocationsBuilderARM64::VisitIntegerReverseBytes(HInvoke* invoke) {
+  CreateIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitIntegerReverseBytes(HInvoke* invoke) {
+  GenReverseBytes(invoke->GetLocations(), Primitive::kPrimInt, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitLongReverseBytes(HInvoke* invoke) {
+  CreateIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitLongReverseBytes(HInvoke* invoke) {
+  GenReverseBytes(invoke->GetLocations(), Primitive::kPrimLong, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitShortReverseBytes(HInvoke* invoke) {
+  CreateIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitShortReverseBytes(HInvoke* invoke) {
+  GenReverseBytes(invoke->GetLocations(), Primitive::kPrimShort, GetVIXLAssembler());
+}
+
+static void GenReverse(LocationSummary* locations,
+                       Primitive::Type type,
+                       vixl::MacroAssembler* masm) {
+  DCHECK(type == Primitive::kPrimInt || type == Primitive::kPrimLong);
+
+  Location in = locations->InAt(0);
+  Location out = locations->Out();
+
+  __ Rbit(RegisterFrom(out, type), RegisterFrom(in, type));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitIntegerReverse(HInvoke* invoke) {
+  CreateIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitIntegerReverse(HInvoke* invoke) {
+  GenReverse(invoke->GetLocations(), Primitive::kPrimInt, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitLongReverse(HInvoke* invoke) {
+  CreateIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitLongReverse(HInvoke* invoke) {
+  GenReverse(invoke->GetLocations(), Primitive::kPrimLong, GetVIXLAssembler());
+}
+
+static void CreateFPToFPLocations(ArenaAllocator* arena, HInvoke* invoke) {
+  // We only support FP registers here.
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::RequiresFpuRegister());
+  locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap);
+}
+
+static void MathAbsFP(LocationSummary* locations, bool is64bit, vixl::MacroAssembler* masm) {
+  Location in = locations->InAt(0);
+  Location out = locations->Out();
+
+  FPRegister in_reg = is64bit ? DRegisterFrom(in) : SRegisterFrom(in);
+  FPRegister out_reg = is64bit ? DRegisterFrom(out) : SRegisterFrom(out);
+
+  __ Fabs(out_reg, in_reg);
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathAbsDouble(HInvoke* invoke) {
+  CreateFPToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathAbsDouble(HInvoke* invoke) {
+  MathAbsFP(invoke->GetLocations(), true, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathAbsFloat(HInvoke* invoke) {
+  CreateFPToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathAbsFloat(HInvoke* invoke) {
+  MathAbsFP(invoke->GetLocations(), false, GetVIXLAssembler());
+}
+
+static void CreateIntToInt(ArenaAllocator* arena, HInvoke* invoke) {
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::RequiresRegister());
+  locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
+}
+
+static void GenAbsInteger(LocationSummary* locations,
+                          bool is64bit,
+                          vixl::MacroAssembler* masm) {
+  Location in = locations->InAt(0);
+  Location output = locations->Out();
+
+  Register in_reg = is64bit ? XRegisterFrom(in) : WRegisterFrom(in);
+  Register out_reg = is64bit ? XRegisterFrom(output) : WRegisterFrom(output);
+
+  __ Cmp(in_reg, Operand(0));
+  __ Cneg(out_reg, in_reg, lt);
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathAbsInt(HInvoke* invoke) {
+  CreateIntToInt(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathAbsInt(HInvoke* invoke) {
+  GenAbsInteger(invoke->GetLocations(), false, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathAbsLong(HInvoke* invoke) {
+  CreateIntToInt(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathAbsLong(HInvoke* invoke) {
+  GenAbsInteger(invoke->GetLocations(), true, GetVIXLAssembler());
+}
+
+static void GenMinMaxFP(LocationSummary* locations,
+                        bool is_min,
+                        bool is_double,
+                        vixl::MacroAssembler* masm) {
+  Location op1 = locations->InAt(0);
+  Location op2 = locations->InAt(1);
+  Location out = locations->Out();
+
+  FPRegister op1_reg = is_double ? DRegisterFrom(op1) : SRegisterFrom(op1);
+  FPRegister op2_reg = is_double ? DRegisterFrom(op2) : SRegisterFrom(op2);
+  FPRegister out_reg = is_double ? DRegisterFrom(out) : SRegisterFrom(out);
+  if (is_min) {
+    __ Fmin(out_reg, op1_reg, op2_reg);
+  } else {
+    __ Fmax(out_reg, op1_reg, op2_reg);
+  }
+}
+
+static void CreateFPFPToFPLocations(ArenaAllocator* arena, HInvoke* invoke) {
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::RequiresFpuRegister());
+  locations->SetInAt(1, Location::RequiresFpuRegister());
+  locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap);
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathMinDoubleDouble(HInvoke* invoke) {
+  CreateFPFPToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathMinDoubleDouble(HInvoke* invoke) {
+  GenMinMaxFP(invoke->GetLocations(), true, true, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathMinFloatFloat(HInvoke* invoke) {
+  CreateFPFPToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathMinFloatFloat(HInvoke* invoke) {
+  GenMinMaxFP(invoke->GetLocations(), true, false, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathMaxDoubleDouble(HInvoke* invoke) {
+  CreateFPFPToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathMaxDoubleDouble(HInvoke* invoke) {
+  GenMinMaxFP(invoke->GetLocations(), false, true, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathMaxFloatFloat(HInvoke* invoke) {
+  CreateFPFPToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathMaxFloatFloat(HInvoke* invoke) {
+  GenMinMaxFP(invoke->GetLocations(), false, false, GetVIXLAssembler());
+}
+
+static void GenMinMax(LocationSummary* locations,
+                      bool is_min,
+                      bool is_long,
+                      vixl::MacroAssembler* masm) {
+  Location op1 = locations->InAt(0);
+  Location op2 = locations->InAt(1);
+  Location out = locations->Out();
+
+  Register op1_reg = is_long ? XRegisterFrom(op1) : WRegisterFrom(op1);
+  Register op2_reg = is_long ? XRegisterFrom(op2) : WRegisterFrom(op2);
+  Register out_reg = is_long ? XRegisterFrom(out) : WRegisterFrom(out);
+
+  __ Cmp(op1_reg, op2_reg);
+  __ Csel(out_reg, op1_reg, op2_reg, is_min ? lt : gt);
+}
+
+static void CreateIntIntToIntLocations(ArenaAllocator* arena, HInvoke* invoke) {
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::RequiresRegister());
+  locations->SetInAt(1, Location::RequiresRegister());
+  locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathMinIntInt(HInvoke* invoke) {
+  CreateIntIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathMinIntInt(HInvoke* invoke) {
+  GenMinMax(invoke->GetLocations(), true, false, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathMinLongLong(HInvoke* invoke) {
+  CreateIntIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathMinLongLong(HInvoke* invoke) {
+  GenMinMax(invoke->GetLocations(), true, true, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathMaxIntInt(HInvoke* invoke) {
+  CreateIntIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathMaxIntInt(HInvoke* invoke) {
+  GenMinMax(invoke->GetLocations(), false, false, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathMaxLongLong(HInvoke* invoke) {
+  CreateIntIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathMaxLongLong(HInvoke* invoke) {
+  GenMinMax(invoke->GetLocations(), false, true, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathSqrt(HInvoke* invoke) {
+  CreateFPToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathSqrt(HInvoke* invoke) {
+  LocationSummary* locations = invoke->GetLocations();
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Fsqrt(DRegisterFrom(locations->Out()), DRegisterFrom(locations->InAt(0)));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathCeil(HInvoke* invoke) {
+  CreateFPToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathCeil(HInvoke* invoke) {
+  LocationSummary* locations = invoke->GetLocations();
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Frintp(DRegisterFrom(locations->Out()), DRegisterFrom(locations->InAt(0)));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathFloor(HInvoke* invoke) {
+  CreateFPToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathFloor(HInvoke* invoke) {
+  LocationSummary* locations = invoke->GetLocations();
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Frintm(DRegisterFrom(locations->Out()), DRegisterFrom(locations->InAt(0)));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathRint(HInvoke* invoke) {
+  CreateFPToFPLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathRint(HInvoke* invoke) {
+  LocationSummary* locations = invoke->GetLocations();
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Frintn(DRegisterFrom(locations->Out()), DRegisterFrom(locations->InAt(0)));
+}
+
+static void CreateFPToIntPlusTempLocations(ArenaAllocator* arena, HInvoke* invoke) {
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::RequiresFpuRegister());
+  locations->SetOut(Location::RequiresRegister());
+}
+
+static void GenMathRound(LocationSummary* locations,
+                         bool is_double,
+                         vixl::MacroAssembler* masm) {
+  FPRegister in_reg = is_double ?
+      DRegisterFrom(locations->InAt(0)) : SRegisterFrom(locations->InAt(0));
+  Register out_reg = is_double ?
+      XRegisterFrom(locations->Out()) : WRegisterFrom(locations->Out());
+  UseScratchRegisterScope temps(masm);
+  FPRegister temp1_reg = temps.AcquireSameSizeAs(in_reg);
+
+  // 0.5 can be encoded as an immediate, so use fmov.
+  if (is_double) {
+    __ Fmov(temp1_reg, static_cast<double>(0.5));
+  } else {
+    __ Fmov(temp1_reg, static_cast<float>(0.5));
+  }
+  __ Fadd(temp1_reg, in_reg, temp1_reg);
+  __ Fcvtms(out_reg, temp1_reg);
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathRoundDouble(HInvoke* invoke) {
+  CreateFPToIntPlusTempLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathRoundDouble(HInvoke* invoke) {
+  GenMathRound(invoke->GetLocations(), true, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMathRoundFloat(HInvoke* invoke) {
+  CreateFPToIntPlusTempLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMathRoundFloat(HInvoke* invoke) {
+  GenMathRound(invoke->GetLocations(), false, GetVIXLAssembler());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMemoryPeekByte(HInvoke* invoke) {
+  CreateIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMemoryPeekByte(HInvoke* invoke) {
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Ldrsb(WRegisterFrom(invoke->GetLocations()->Out()),
+          AbsoluteHeapOperandFrom(invoke->GetLocations()->InAt(0), 0));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMemoryPeekIntNative(HInvoke* invoke) {
+  CreateIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMemoryPeekIntNative(HInvoke* invoke) {
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Ldr(WRegisterFrom(invoke->GetLocations()->Out()),
+         AbsoluteHeapOperandFrom(invoke->GetLocations()->InAt(0), 0));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMemoryPeekLongNative(HInvoke* invoke) {
+  CreateIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMemoryPeekLongNative(HInvoke* invoke) {
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Ldr(XRegisterFrom(invoke->GetLocations()->Out()),
+         AbsoluteHeapOperandFrom(invoke->GetLocations()->InAt(0), 0));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMemoryPeekShortNative(HInvoke* invoke) {
+  CreateIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMemoryPeekShortNative(HInvoke* invoke) {
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Ldrsh(WRegisterFrom(invoke->GetLocations()->Out()),
+           AbsoluteHeapOperandFrom(invoke->GetLocations()->InAt(0), 0));
+}
+
+static void CreateIntIntToVoidLocations(ArenaAllocator* arena, HInvoke* invoke) {
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::RequiresRegister());
+  locations->SetInAt(1, Location::RequiresRegister());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMemoryPokeByte(HInvoke* invoke) {
+  CreateIntIntToVoidLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMemoryPokeByte(HInvoke* invoke) {
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Strb(WRegisterFrom(invoke->GetLocations()->InAt(1)),
+          AbsoluteHeapOperandFrom(invoke->GetLocations()->InAt(0), 0));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMemoryPokeIntNative(HInvoke* invoke) {
+  CreateIntIntToVoidLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMemoryPokeIntNative(HInvoke* invoke) {
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Str(WRegisterFrom(invoke->GetLocations()->InAt(1)),
+         AbsoluteHeapOperandFrom(invoke->GetLocations()->InAt(0), 0));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMemoryPokeLongNative(HInvoke* invoke) {
+  CreateIntIntToVoidLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMemoryPokeLongNative(HInvoke* invoke) {
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Str(XRegisterFrom(invoke->GetLocations()->InAt(1)),
+         AbsoluteHeapOperandFrom(invoke->GetLocations()->InAt(0), 0));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitMemoryPokeShortNative(HInvoke* invoke) {
+  CreateIntIntToVoidLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitMemoryPokeShortNative(HInvoke* invoke) {
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  __ Strh(WRegisterFrom(invoke->GetLocations()->InAt(1)),
+          AbsoluteHeapOperandFrom(invoke->GetLocations()->InAt(0), 0));
+}
+
+void IntrinsicLocationsBuilderARM64::VisitThreadCurrentThread(HInvoke* invoke) {
+  LocationSummary* locations = new (arena_) LocationSummary(invoke,
+                                                            LocationSummary::kNoCall,
+                                                            kIntrinsified);
+  locations->SetOut(Location::RequiresRegister());
+}
+
+void IntrinsicCodeGeneratorARM64::VisitThreadCurrentThread(HInvoke* invoke) {
+  codegen_->Load(Primitive::kPrimNot, WRegisterFrom(invoke->GetLocations()->Out()),
+                 MemOperand(tr, Thread::PeerOffset<8>().Int32Value()));
+}
+
+static void GenUnsafeGet(HInvoke* invoke,
+                         Primitive::Type type,
+                         bool is_volatile,
+                         CodeGeneratorARM64* codegen) {
+  LocationSummary* locations = invoke->GetLocations();
+  DCHECK((type == Primitive::kPrimInt) ||
+         (type == Primitive::kPrimLong) ||
+         (type == Primitive::kPrimNot));
+  vixl::MacroAssembler* masm = codegen->GetAssembler()->vixl_masm_;
+  Register base = WRegisterFrom(locations->InAt(1));    // Object pointer.
+  Register offset = XRegisterFrom(locations->InAt(2));  // Long offset.
+  Register trg = RegisterFrom(locations->Out(), type);
+
+  MemOperand mem_op(base.X(), offset);
+  if (is_volatile) {
+    if (kUseAcquireRelease) {
+      codegen->LoadAcquire(invoke, trg, mem_op);
+    } else {
+      codegen->Load(type, trg, mem_op);
+      __ Dmb(InnerShareable, BarrierReads);
+    }
+  } else {
+    codegen->Load(type, trg, mem_op);
+  }
+}
+
+static void CreateIntIntIntToIntLocations(ArenaAllocator* arena, HInvoke* invoke) {
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::NoLocation());        // Unused receiver.
+  locations->SetInAt(1, Location::RequiresRegister());
+  locations->SetInAt(2, Location::RequiresRegister());
+  locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
+}
+
+void IntrinsicLocationsBuilderARM64::VisitUnsafeGet(HInvoke* invoke) {
+  CreateIntIntIntToIntLocations(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafeGetVolatile(HInvoke* invoke) {
+  CreateIntIntIntToIntLocations(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafeGetLong(HInvoke* invoke) {
+  CreateIntIntIntToIntLocations(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafeGetLongVolatile(HInvoke* invoke) {
+  CreateIntIntIntToIntLocations(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafeGetObject(HInvoke* invoke) {
+  CreateIntIntIntToIntLocations(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
+  CreateIntIntIntToIntLocations(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitUnsafeGet(HInvoke* invoke) {
+  GenUnsafeGet(invoke, Primitive::kPrimInt, false, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafeGetVolatile(HInvoke* invoke) {
+  GenUnsafeGet(invoke, Primitive::kPrimInt, true, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafeGetLong(HInvoke* invoke) {
+  GenUnsafeGet(invoke, Primitive::kPrimLong, false, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafeGetLongVolatile(HInvoke* invoke) {
+  GenUnsafeGet(invoke, Primitive::kPrimLong, true, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafeGetObject(HInvoke* invoke) {
+  GenUnsafeGet(invoke, Primitive::kPrimNot, false, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
+  GenUnsafeGet(invoke, Primitive::kPrimNot, true, codegen_);
+}
+
+static void CreateIntIntIntIntToVoid(ArenaAllocator* arena, HInvoke* invoke) {
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::NoLocation());        // Unused receiver.
+  locations->SetInAt(1, Location::RequiresRegister());
+  locations->SetInAt(2, Location::RequiresRegister());
+  locations->SetInAt(3, Location::RequiresRegister());
+}
+
+void IntrinsicLocationsBuilderARM64::VisitUnsafePut(HInvoke* invoke) {
+  CreateIntIntIntIntToVoid(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafePutOrdered(HInvoke* invoke) {
+  CreateIntIntIntIntToVoid(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafePutVolatile(HInvoke* invoke) {
+  CreateIntIntIntIntToVoid(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafePutObject(HInvoke* invoke) {
+  CreateIntIntIntIntToVoid(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafePutObjectOrdered(HInvoke* invoke) {
+  CreateIntIntIntIntToVoid(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafePutObjectVolatile(HInvoke* invoke) {
+  CreateIntIntIntIntToVoid(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafePutLong(HInvoke* invoke) {
+  CreateIntIntIntIntToVoid(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafePutLongOrdered(HInvoke* invoke) {
+  CreateIntIntIntIntToVoid(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafePutLongVolatile(HInvoke* invoke) {
+  CreateIntIntIntIntToVoid(arena_, invoke);
+}
+
+static void GenUnsafePut(LocationSummary* locations,
+                         Primitive::Type type,
+                         bool is_volatile,
+                         bool is_ordered,
+                         CodeGeneratorARM64* codegen) {
+  vixl::MacroAssembler* masm = codegen->GetAssembler()->vixl_masm_;
+
+  Register base = WRegisterFrom(locations->InAt(1));    // Object pointer.
+  Register offset = XRegisterFrom(locations->InAt(2));  // Long offset.
+  Register value = RegisterFrom(locations->InAt(3), type);
+
+  MemOperand mem_op(base.X(), offset);
+
+  if (is_volatile || is_ordered) {
+    if (kUseAcquireRelease) {
+      codegen->StoreRelease(type, value, mem_op);
+    } else {
+      __ Dmb(InnerShareable, BarrierAll);
+      codegen->Store(type, value, mem_op);
+      if (is_volatile) {
+        __ Dmb(InnerShareable, BarrierReads);
+      }
+    }
+  } else {
+    codegen->Store(type, value, mem_op);
+  }
+
+  if (type == Primitive::kPrimNot) {
+    codegen->MarkGCCard(base, value);
+  }
+}
+
+void IntrinsicCodeGeneratorARM64::VisitUnsafePut(HInvoke* invoke) {
+  GenUnsafePut(invoke->GetLocations(), Primitive::kPrimInt, false, false, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafePutOrdered(HInvoke* invoke) {
+  GenUnsafePut(invoke->GetLocations(), Primitive::kPrimInt, false, true, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafePutVolatile(HInvoke* invoke) {
+  GenUnsafePut(invoke->GetLocations(), Primitive::kPrimInt, true, false, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafePutObject(HInvoke* invoke) {
+  GenUnsafePut(invoke->GetLocations(), Primitive::kPrimNot, false, false, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafePutObjectOrdered(HInvoke* invoke) {
+  GenUnsafePut(invoke->GetLocations(), Primitive::kPrimNot, false, true, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafePutObjectVolatile(HInvoke* invoke) {
+  GenUnsafePut(invoke->GetLocations(), Primitive::kPrimNot, true, false, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafePutLong(HInvoke* invoke) {
+  GenUnsafePut(invoke->GetLocations(), Primitive::kPrimLong, false, false, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafePutLongOrdered(HInvoke* invoke) {
+  GenUnsafePut(invoke->GetLocations(), Primitive::kPrimLong, false, true, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafePutLongVolatile(HInvoke* invoke) {
+  GenUnsafePut(invoke->GetLocations(), Primitive::kPrimLong, true, false, codegen_);
+}
+
+static void CreateIntIntIntIntIntToInt(ArenaAllocator* arena, HInvoke* invoke) {
+  LocationSummary* locations = new (arena) LocationSummary(invoke,
+                                                           LocationSummary::kNoCall,
+                                                           kIntrinsified);
+  locations->SetInAt(0, Location::NoLocation());        // Unused receiver.
+  locations->SetInAt(1, Location::RequiresRegister());
+  locations->SetInAt(2, Location::RequiresRegister());
+  locations->SetInAt(3, Location::RequiresRegister());
+  locations->SetInAt(4, Location::RequiresRegister());
+
+  locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
+}
+
+static void GenCas(LocationSummary* locations, Primitive::Type type, CodeGeneratorARM64* codegen) {
+  // TODO: Currently we use acquire-release load-stores in the CAS loop. One could reasonably write
+  //       a version relying on simple exclusive load-stores and barriers instead.
+  static_assert(kUseAcquireRelease, "Non-acquire-release inlined CAS not implemented, yet.");
+
+  vixl::MacroAssembler* masm = codegen->GetAssembler()->vixl_masm_;
+
+  Register out = WRegisterFrom(locations->Out());                  // Boolean result.
+
+  Register base = WRegisterFrom(locations->InAt(1));               // Object pointer.
+  Register offset = XRegisterFrom(locations->InAt(2));             // Long offset.
+  Register expected = RegisterFrom(locations->InAt(3), type);      // Expected.
+  Register value = RegisterFrom(locations->InAt(4), type);         // Value.
+
+  // This needs to be before the temp registers, as MarkGCCard also uses VIXL temps.
+  if (type == Primitive::kPrimNot) {
+    // Mark card for object assuming new value is stored.
+    codegen->MarkGCCard(base, value);
+  }
+
+  UseScratchRegisterScope temps(masm);
+  Register tmp_ptr = temps.AcquireX();                             // Pointer to actual memory.
+  Register tmp_value = temps.AcquireSameSizeAs(value);             // Value in memory.
+
+  Register tmp_32 = tmp_value.W();
+
+  __ Add(tmp_ptr, base.X(), Operand(offset));
+
+  // do {
+  //   tmp_value = [tmp_ptr] - expected;
+  // } while (tmp_value == 0 && failure([tmp_ptr] <- r_new_value));
+  // result = tmp_value != 0;
+
+  vixl::Label loop_head, exit_loop;
+  __ Bind(&loop_head);
+
+  __ Ldaxr(tmp_value, MemOperand(tmp_ptr));
+  __ Cmp(tmp_value, expected);
+  __ B(&exit_loop, ne);
+
+  __ Stlxr(tmp_32, value, MemOperand(tmp_ptr));
+  __ Cbnz(tmp_32, &loop_head);
+
+  __ Bind(&exit_loop);
+  __ Cset(out, eq);
+}
+
+void IntrinsicLocationsBuilderARM64::VisitUnsafeCASInt(HInvoke* invoke) {
+  CreateIntIntIntIntIntToInt(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafeCASLong(HInvoke* invoke) {
+  CreateIntIntIntIntIntToInt(arena_, invoke);
+}
+void IntrinsicLocationsBuilderARM64::VisitUnsafeCASObject(HInvoke* invoke) {
+  CreateIntIntIntIntIntToInt(arena_, invoke);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitUnsafeCASInt(HInvoke* invoke) {
+  GenCas(invoke->GetLocations(), Primitive::kPrimInt, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafeCASLong(HInvoke* invoke) {
+  GenCas(invoke->GetLocations(), Primitive::kPrimLong, codegen_);
+}
+void IntrinsicCodeGeneratorARM64::VisitUnsafeCASObject(HInvoke* invoke) {
+  GenCas(invoke->GetLocations(), Primitive::kPrimNot, codegen_);
+}
+
+void IntrinsicLocationsBuilderARM64::VisitStringCharAt(HInvoke* invoke) {
+  // The inputs plus one temp.
+  LocationSummary* locations = new (arena_) LocationSummary(invoke,
+                                                            LocationSummary::kCallOnSlowPath,
+                                                            kIntrinsified);
+  locations->SetInAt(0, Location::RequiresRegister());
+  locations->SetInAt(1, Location::RequiresRegister());
+  locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
+}
+
+void IntrinsicCodeGeneratorARM64::VisitStringCharAt(HInvoke* invoke) {
+  vixl::MacroAssembler* masm = GetVIXLAssembler();
+  LocationSummary* locations = invoke->GetLocations();
+
+  // Location of reference to data array
+  const MemberOffset value_offset = mirror::String::ValueOffset();
+  // Location of count
+  const MemberOffset count_offset = mirror::String::CountOffset();
+  // Starting offset within data array
+  const MemberOffset offset_offset = mirror::String::OffsetOffset();
+  // Start of char data with array_
+  const MemberOffset data_offset = mirror::Array::DataOffset(sizeof(uint16_t));
+
+  Register obj = WRegisterFrom(locations->InAt(0));  // String object pointer.
+  Register idx = WRegisterFrom(locations->InAt(1));  // Index of character.
+  Register out = WRegisterFrom(locations->Out());    // Result character.
+
+  UseScratchRegisterScope temps(masm);
+  Register temp = temps.AcquireW();
+  Register array_temp = temps.AcquireW();            // We can trade this for worse scheduling.
+
+  // TODO: Maybe we can support range check elimination. Overall, though, I think it's not worth
+  //       the cost.
+  // TODO: For simplicity, the index parameter is requested in a register, so different from Quick
+  //       we will not optimize the code for constants (which would save a register).
+
+  SlowPathCodeARM64* slow_path = new (GetAllocator()) IntrinsicSlowPathARM64(invoke);
+  codegen_->AddSlowPath(slow_path);
+
+  __ Ldr(temp, HeapOperand(obj, count_offset));          // temp = str.length.
+  codegen_->MaybeRecordImplicitNullCheck(invoke);
+  __ Cmp(idx, temp);
+  __ B(hs, slow_path->GetEntryLabel());
+
+  // Index computation.
+  __ Ldr(temp, HeapOperand(obj, offset_offset));         // temp := str.offset.
+  __ Ldr(array_temp, HeapOperand(obj, value_offset));    // array_temp := str.offset.
+  __ Add(temp, temp, idx);
+  DCHECK_EQ(data_offset.Int32Value() % 2, 0);            // We'll compensate by shifting.
+  __ Add(temp, temp, Operand(data_offset.Int32Value() / 2));
+
+  // Load the value.
+  __ Ldrh(out, MemOperand(array_temp.X(), temp, UXTW, 1));  // out := array_temp[temp].
+
+  __ Bind(slow_path->GetExitLabel());
+}
+
+// Unimplemented intrinsics.
+
+#define UNIMPLEMENTED_INTRINSIC(Name)                                                  \
+void IntrinsicLocationsBuilderARM64::Visit ## Name(HInvoke* invoke ATTRIBUTE_UNUSED) { \
+}                                                                                      \
+void IntrinsicCodeGeneratorARM64::Visit ## Name(HInvoke* invoke ATTRIBUTE_UNUSED) {    \
+}
+
+UNIMPLEMENTED_INTRINSIC(SystemArrayCopyChar)
+UNIMPLEMENTED_INTRINSIC(StringCompareTo)
+UNIMPLEMENTED_INTRINSIC(StringIsEmpty)  // Might not want to do these two anyways, inlining should
+UNIMPLEMENTED_INTRINSIC(StringLength)   // be good enough here.
+UNIMPLEMENTED_INTRINSIC(StringIndexOf)
+UNIMPLEMENTED_INTRINSIC(StringIndexOfAfter)
+UNIMPLEMENTED_INTRINSIC(ReferenceGetReferent)
+
+}  // namespace arm64
+}  // namespace art
diff --git a/compiler/optimizing/intrinsics_arm64.h b/compiler/optimizing/intrinsics_arm64.h
new file mode 100644
index 0000000..ba21889
--- /dev/null
+++ b/compiler/optimizing/intrinsics_arm64.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_COMPILER_OPTIMIZING_INTRINSICS_ARM64_H_
+#define ART_COMPILER_OPTIMIZING_INTRINSICS_ARM64_H_
+
+#include "intrinsics.h"
+
+namespace vixl {
+
+class MacroAssembler;
+
+}  // namespace vixl
+
+namespace art {
+
+class ArenaAllocator;
+class HInvokeStaticOrDirect;
+class HInvokeVirtual;
+
+namespace arm64 {
+
+class CodeGeneratorARM64;
+
+class IntrinsicLocationsBuilderARM64 FINAL : public IntrinsicVisitor {
+ public:
+  explicit IntrinsicLocationsBuilderARM64(ArenaAllocator* arena) : arena_(arena) {}
+
+  // Define visitor methods.
+
+#define OPTIMIZING_INTRINSICS(Name, IsStatic)   \
+  void Visit ## Name(HInvoke* invoke) OVERRIDE;
+#include "intrinsics_list.h"
+INTRINSICS_LIST(OPTIMIZING_INTRINSICS)
+#undef INTRINSICS_LIST
+#undef OPTIMIZING_INTRINSICS
+
+  // Check whether an invoke is an intrinsic, and if so, create a location summary. Returns whether
+  // a corresponding LocationSummary with the intrinsified_ flag set was generated and attached to
+  // the invoke.
+  bool TryDispatch(HInvoke* invoke);
+
+ private:
+  ArenaAllocator* arena_;
+
+  DISALLOW_COPY_AND_ASSIGN(IntrinsicLocationsBuilderARM64);
+};
+
+class IntrinsicCodeGeneratorARM64 FINAL : public IntrinsicVisitor {
+ public:
+  explicit IntrinsicCodeGeneratorARM64(CodeGeneratorARM64* codegen) : codegen_(codegen) {}
+
+  // Define visitor methods.
+
+#define OPTIMIZING_INTRINSICS(Name, IsStatic)   \
+  void Visit ## Name(HInvoke* invoke) OVERRIDE;
+#include "intrinsics_list.h"
+INTRINSICS_LIST(OPTIMIZING_INTRINSICS)
+#undef INTRINSICS_LIST
+#undef OPTIMIZING_INTRINSICS
+
+ private:
+  vixl::MacroAssembler* GetVIXLAssembler();
+
+  ArenaAllocator* GetAllocator();
+
+  CodeGeneratorARM64* codegen_;
+
+  DISALLOW_COPY_AND_ASSIGN(IntrinsicCodeGeneratorARM64);
+};
+
+}  // namespace arm64
+}  // namespace art
+
+#endif  // ART_COMPILER_OPTIMIZING_INTRINSICS_ARM64_H_
diff --git a/compiler/optimizing/intrinsics_list.h b/compiler/optimizing/intrinsics_list.h
index 29ca20c..9cc77c6 100644
--- a/compiler/optimizing/intrinsics_list.h
+++ b/compiler/optimizing/intrinsics_list.h
@@ -69,6 +69,8 @@
   V(UnsafeCASObject, kDirect) \
   V(UnsafeGet, kDirect) \
   V(UnsafeGetVolatile, kDirect) \
+  V(UnsafeGetObject, kDirect) \
+  V(UnsafeGetObjectVolatile, kDirect) \
   V(UnsafeGetLong, kDirect) \
   V(UnsafeGetLongVolatile, kDirect) \
   V(UnsafePut, kDirect) \
@@ -80,8 +82,7 @@
   V(UnsafePutLong, kDirect) \
   V(UnsafePutLongOrdered, kDirect) \
   V(UnsafePutLongVolatile, kDirect) \
-  \
-  V(ReferenceGetReferent, kVirtual)
+  V(ReferenceGetReferent, kDirect)
 
 #endif  // ART_COMPILER_OPTIMIZING_INTRINSICS_LIST_H_
 #undef ART_COMPILER_OPTIMIZING_INTRINSICS_LIST_H_   // #define is only for lint.
diff --git a/compiler/optimizing/intrinsics_x86_64.cc b/compiler/optimizing/intrinsics_x86_64.cc
index 2c23945..c73f092 100644
--- a/compiler/optimizing/intrinsics_x86_64.cc
+++ b/compiler/optimizing/intrinsics_x86_64.cc
@@ -30,13 +30,11 @@
 
 namespace x86_64 {
 
-static constexpr bool kIntrinsified = true;
-
 X86_64Assembler* IntrinsicCodeGeneratorX86_64::GetAssembler() {
   return reinterpret_cast<X86_64Assembler*>(codegen_->GetAssembler());
 }
 
-ArenaAllocator* IntrinsicCodeGeneratorX86_64::GetArena() {
+ArenaAllocator* IntrinsicCodeGeneratorX86_64::GetAllocator() {
   return codegen_->GetGraph()->GetArena();
 }
 
@@ -644,21 +642,18 @@
   Location temp_loc = locations->GetTemp(0);
   CpuRegister temp = temp_loc.AsRegister<CpuRegister>();
 
-  // Note: Nullcheck has been done before in a HNullCheck before the HInvokeVirtual. If/when we
-  //       move to (coalesced) implicit checks, we have to do a null check below.
-  DCHECK(!kCoalescedImplicitNullCheck);
-
   // TODO: Maybe we can support range check elimination. Overall, though, I think it's not worth
   //       the cost.
   // TODO: For simplicity, the index parameter is requested in a register, so different from Quick
   //       we will not optimize the code for constants (which would save a register).
 
-  SlowPathCodeX86_64* slow_path = new (GetArena()) IntrinsicSlowPathX86_64(invoke);
+  SlowPathCodeX86_64* slow_path = new (GetAllocator()) IntrinsicSlowPathX86_64(invoke);
   codegen_->AddSlowPath(slow_path);
 
   X86_64Assembler* assembler = GetAssembler();
 
   __ cmpl(idx, Address(obj, count_offset));
+  codegen_->MaybeRecordImplicitNullCheck(invoke);
   __ j(kAboveEqual, slow_path->GetEntryLabel());
 
   // Get the actual element.
@@ -803,18 +798,25 @@
   GetAssembler()->gs()->movl(out, Address::Absolute(Thread::PeerOffset<kX86_64WordSize>(), true));
 }
 
-static void GenUnsafeGet(LocationSummary* locations, bool is_long,
+static void GenUnsafeGet(LocationSummary* locations, Primitive::Type type,
                          bool is_volatile ATTRIBUTE_UNUSED, X86_64Assembler* assembler) {
   CpuRegister base = locations->InAt(1).AsRegister<CpuRegister>();
   CpuRegister offset = locations->InAt(2).AsRegister<CpuRegister>();
   CpuRegister trg = locations->Out().AsRegister<CpuRegister>();
 
-  if (is_long) {
-    __ movq(trg, Address(base, offset, ScaleFactor::TIMES_1, 0));
-  } else {
-    // TODO: Distinguish object. In case we move to an actual compressed heap, retrieving an object
-    //       pointer will entail an unpack operation.
-    __ movl(trg, Address(base, offset, ScaleFactor::TIMES_1, 0));
+  switch (type) {
+    case Primitive::kPrimInt:
+    case Primitive::kPrimNot:
+      __ movl(trg, Address(base, offset, ScaleFactor::TIMES_1, 0));
+      break;
+
+    case Primitive::kPrimLong:
+      __ movq(trg, Address(base, offset, ScaleFactor::TIMES_1, 0));
+      break;
+
+    default:
+      LOG(FATAL) << "Unsupported op size " << type;
+      UNREACHABLE();
   }
 }
 
@@ -822,10 +824,10 @@
   LocationSummary* locations = new (arena) LocationSummary(invoke,
                                                            LocationSummary::kNoCall,
                                                            kIntrinsified);
-  locations->SetInAt(0, Location::RequiresRegister());
+  locations->SetInAt(0, Location::NoLocation());        // Unused receiver.
   locations->SetInAt(1, Location::RequiresRegister());
   locations->SetInAt(2, Location::RequiresRegister());
-  locations->SetOut(Location::SameAsFirstInput());
+  locations->SetOut(Location::RequiresRegister());
 }
 
 void IntrinsicLocationsBuilderX86_64::VisitUnsafeGet(HInvoke* invoke) {
@@ -840,19 +842,33 @@
 void IntrinsicLocationsBuilderX86_64::VisitUnsafeGetLongVolatile(HInvoke* invoke) {
   CreateIntIntIntToIntLocations(arena_, invoke);
 }
+void IntrinsicLocationsBuilderX86_64::VisitUnsafeGetObject(HInvoke* invoke) {
+  CreateIntIntIntToIntLocations(arena_, invoke);
+}
+void IntrinsicLocationsBuilderX86_64::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
+  CreateIntIntIntToIntLocations(arena_, invoke);
+}
+
 
 void IntrinsicCodeGeneratorX86_64::VisitUnsafeGet(HInvoke* invoke) {
-  GenUnsafeGet(invoke->GetLocations(), false, false, GetAssembler());
+  GenUnsafeGet(invoke->GetLocations(), Primitive::kPrimInt, false, GetAssembler());
 }
 void IntrinsicCodeGeneratorX86_64::VisitUnsafeGetVolatile(HInvoke* invoke) {
-  GenUnsafeGet(invoke->GetLocations(), false, true, GetAssembler());
+  GenUnsafeGet(invoke->GetLocations(), Primitive::kPrimInt, true, GetAssembler());
 }
 void IntrinsicCodeGeneratorX86_64::VisitUnsafeGetLong(HInvoke* invoke) {
-  GenUnsafeGet(invoke->GetLocations(), true, false, GetAssembler());
+  GenUnsafeGet(invoke->GetLocations(), Primitive::kPrimLong, false, GetAssembler());
 }
 void IntrinsicCodeGeneratorX86_64::VisitUnsafeGetLongVolatile(HInvoke* invoke) {
-  GenUnsafeGet(invoke->GetLocations(), true, true, GetAssembler());
+  GenUnsafeGet(invoke->GetLocations(), Primitive::kPrimLong, true, GetAssembler());
 }
+void IntrinsicCodeGeneratorX86_64::VisitUnsafeGetObject(HInvoke* invoke) {
+  GenUnsafeGet(invoke->GetLocations(), Primitive::kPrimNot, false, GetAssembler());
+}
+void IntrinsicCodeGeneratorX86_64::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
+  GenUnsafeGet(invoke->GetLocations(), Primitive::kPrimNot, true, GetAssembler());
+}
+
 
 static void CreateIntIntIntIntToVoidPlusTempsLocations(ArenaAllocator* arena,
                                                        Primitive::Type type,
@@ -860,7 +876,7 @@
   LocationSummary* locations = new (arena) LocationSummary(invoke,
                                                            LocationSummary::kNoCall,
                                                            kIntrinsified);
-  locations->SetInAt(0, Location::NoLocation());
+  locations->SetInAt(0, Location::NoLocation());        // Unused receiver.
   locations->SetInAt(1, Location::RequiresRegister());
   locations->SetInAt(2, Location::RequiresRegister());
   locations->SetInAt(3, Location::RequiresRegister());
diff --git a/compiler/optimizing/intrinsics_x86_64.h b/compiler/optimizing/intrinsics_x86_64.h
index c1fa99c..dfae7fa 100644
--- a/compiler/optimizing/intrinsics_x86_64.h
+++ b/compiler/optimizing/intrinsics_x86_64.h
@@ -70,7 +70,7 @@
  private:
   X86_64Assembler* GetAssembler();
 
-  ArenaAllocator* GetArena();
+  ArenaAllocator* GetAllocator();
 
   CodeGeneratorX86_64* codegen_;
 
diff --git a/compiler/optimizing/locations.h b/compiler/optimizing/locations.h
index 6bf8f77..8b06d60 100644
--- a/compiler/optimizing/locations.h
+++ b/compiler/optimizing/locations.h
@@ -446,6 +446,8 @@
   DISALLOW_COPY_AND_ASSIGN(RegisterSet);
 };
 
+static constexpr bool kIntrinsified = true;
+
 /**
  * The code generator computes LocationSummary for each instruction so that
  * the instruction itself knows what code to generate: where to find the inputs
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 2cc021c..1a0ebe5 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -1711,9 +1711,11 @@
                         Primitive::Type return_type,
                         uint32_t dex_pc,
                         uint32_t dex_method_index,
+                        bool is_recursive,
                         InvokeType invoke_type)
       : HInvoke(arena, number_of_arguments, return_type, dex_pc, dex_method_index),
-        invoke_type_(invoke_type) {}
+        invoke_type_(invoke_type),
+        is_recursive_(is_recursive) {}
 
   bool CanDoImplicitNullCheck() const OVERRIDE {
     // We access the method via the dex cache so we can't do an implicit null check.
@@ -1722,11 +1724,13 @@
   }
 
   InvokeType GetInvokeType() const { return invoke_type_; }
+  bool IsRecursive() const { return is_recursive_; }
 
   DECLARE_INSTRUCTION(InvokeStaticOrDirect);
 
  private:
   const InvokeType invoke_type_;
+  const bool is_recursive_;
 
   DISALLOW_COPY_AND_ASSIGN(HInvokeStaticOrDirect);
 };
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index b3eb1e2..29d47e1 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -19,6 +19,7 @@
 
 #include "nodes.h"
 #include "builder.h"
+#include "compiler/dex/pass_manager.h"
 #include "dex_file.h"
 #include "dex_instruction.h"
 #include "ssa_liveness_analysis.h"
diff --git a/compiler/utils/x86/assembler_x86.cc b/compiler/utils/x86/assembler_x86.cc
index 1f0dba5..03744e4 100644
--- a/compiler/utils/x86/assembler_x86.cc
+++ b/compiler/utils/x86/assembler_x86.cc
@@ -51,7 +51,8 @@
   AssemblerBuffer::EnsureCapacity ensured(&buffer_);
   EmitUint8(0xE8);
   static const int kSize = 5;
-  EmitLabel(label, kSize);
+  // Offset by one because we already have emitted the opcode.
+  EmitLabel(label, kSize - 1);
 }
 
 
diff --git a/compiler/utils/x86_64/assembler_x86_64.cc b/compiler/utils/x86_64/assembler_x86_64.cc
index 5afa603..7e8e769 100644
--- a/compiler/utils/x86_64/assembler_x86_64.cc
+++ b/compiler/utils/x86_64/assembler_x86_64.cc
@@ -57,7 +57,8 @@
   AssemblerBuffer::EnsureCapacity ensured(&buffer_);
   EmitUint8(0xE8);
   static const int kSize = 5;
-  EmitLabel(label, kSize);
+  // Offset by one because we already have emitted the opcode.
+  EmitLabel(label, kSize - 1);
 }
 
 void X86_64Assembler::pushq(CpuRegister reg) {
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index fe3a978..e607e15 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -44,7 +44,7 @@
 #include "compiler.h"
 #include "compiler_callbacks.h"
 #include "dex_file-inl.h"
-#include "dex/pass_driver_me_opts.h"
+#include "dex/pass_manager.h"
 #include "dex/verification_results.h"
 #include "dex/quick_compiler_callbacks.h"
 #include "dex/quick/dex_file_to_method_inliner_map.h"
@@ -490,12 +490,13 @@
     // Profile file to use
     double top_k_profile_threshold = CompilerOptions::kDefaultTopKProfileThreshold;
 
-    bool print_pass_options = false;
     bool include_patch_information = CompilerOptions::kDefaultIncludePatchInformation;
     bool include_debug_symbols = kIsDebugBuild;
     bool watch_dog_enabled = true;
     bool generate_gdb_information = kIsDebugBuild;
 
+    PassManagerOptions pass_manager_options;
+
     std::string error_msg;
 
     for (int i = 0; i < argc; i++) {
@@ -685,23 +686,23 @@
       } else if (option.starts_with("--top-k-profile-threshold=")) {
         ParseDouble(option.data(), '=', 0.0, 100.0, &top_k_profile_threshold);
       } else if (option == "--print-pass-names") {
-        PassDriverMEOpts::PrintPassNames();
+        pass_manager_options.SetPrintPassNames(true);
       } else if (option.starts_with("--disable-passes=")) {
-        std::string disable_passes = option.substr(strlen("--disable-passes=")).data();
-        PassDriverMEOpts::CreateDefaultPassList(disable_passes);
+        const std::string disable_passes = option.substr(strlen("--disable-passes=")).data();
+        pass_manager_options.SetDisablePassList(disable_passes);
       } else if (option.starts_with("--print-passes=")) {
-        std::string print_passes = option.substr(strlen("--print-passes=")).data();
-        PassDriverMEOpts::SetPrintPassList(print_passes);
+        const std::string print_passes = option.substr(strlen("--print-passes=")).data();
+        pass_manager_options.SetPrintPassList(print_passes);
       } else if (option == "--print-all-passes") {
-        PassDriverMEOpts::SetPrintAllPasses();
+        pass_manager_options.SetPrintAllPasses();
       } else if (option.starts_with("--dump-cfg-passes=")) {
-        std::string dump_passes_string = option.substr(strlen("--dump-cfg-passes=")).data();
-        PassDriverMEOpts::SetDumpPassList(dump_passes_string);
+        const std::string dump_passes_string = option.substr(strlen("--dump-cfg-passes=")).data();
+        pass_manager_options.SetDumpPassList(dump_passes_string);
       } else if (option == "--print-pass-options") {
-        print_pass_options = true;
+        pass_manager_options.SetPrintPassOptions(true);
       } else if (option.starts_with("--pass-options=")) {
-        std::string options = option.substr(strlen("--pass-options=")).data();
-        PassDriverMEOpts::SetOverriddenPassOptions(options);
+        const std::string options = option.substr(strlen("--pass-options=")).data();
+        pass_manager_options.SetOverriddenPassOptions(options);
       } else if (option == "--include-patch-information") {
         include_patch_information = true;
       } else if (option == "--no-include-patch-information") {
@@ -924,10 +925,6 @@
         break;
     }
 
-    if (print_pass_options) {
-      PassDriverMEOpts::PrintPassOptions();
-    }
-
     compiler_options_.reset(new CompilerOptions(compiler_filter,
                                                 huge_method_threshold,
                                                 large_method_threshold,
@@ -945,6 +942,7 @@
                                                 verbose_methods_.empty() ?
                                                     nullptr :
                                                     &verbose_methods_,
+                                                new PassManagerOptions(pass_manager_options),
                                                 init_failure_output_.get()));
 
     // Done with usage checks, enable watchdog if requested
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 9453741..6e00cc7 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -446,7 +446,8 @@
     if (Thread::Current() != nullptr) {
       Thread::Current()->GetThreadName(name2);
     }
-    LOG(FATAL) << name1 << " " << name2;
+    LOG(FATAL) << GetName() << " level=" << level_ << " self=" << name1
+               << " Thread::Current()=" << name2;
   }
   AssertHeld(self);
   DCHECK_NE(exclusive_owner_, 0U);
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 8ab90eb..a67ebca 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -930,6 +930,16 @@
           (caller->GetDexCacheResolvedMethod(update_dex_cache_method_index) != called)) {
         caller->SetDexCacheResolvedMethod(update_dex_cache_method_index, called);
       }
+    } else if (invoke_type == kStatic) {
+      const auto called_dex_method_idx = called->GetDexMethodIndex();
+      // For static invokes, we may dispatch to the static method in the superclass but resolve
+      // using the subclass. To prevent getting slow paths on each invoke, we force set the
+      // resolved method for the super class dex method index if we are in the same dex file.
+      // b/19175856
+      if (called->GetDexFile() == called_method.dex_file &&
+          called_method.dex_method_index != called_dex_method_idx) {
+        called->GetDexCache()->SetResolvedMethod(called_dex_method_idx, called);
+      }
     }
     // Ensure that the called method's class is initialized.
     StackHandleScope<1> hs(soa.Self());
diff --git a/test/082-inline-execute/src/Main.java b/test/082-inline-execute/src/Main.java
index 5561a09..bf6c802 100644
--- a/test/082-inline-execute/src/Main.java
+++ b/test/082-inline-execute/src/Main.java
@@ -125,23 +125,25 @@
   // so we need to separate out the tests that are expected to throw exception
 
   public static void test_String_charAt() {
-    String testStr = "Now is the time";
+    String testStr = "Now is the time to test some stuff";
 
-    Assert.assertEquals('N', testStr.charAt(0));
-    Assert.assertEquals('o', testStr.charAt(1));
-    Assert.assertEquals(' ', testStr.charAt(10));
-    Assert.assertEquals('e', testStr.charAt(14));  // 14 = testStr.length()-1 as a constant.
-    Assert.assertEquals('N', test_String_charAt_inner(testStr, 0));
-    Assert.assertEquals('o', test_String_charAt_inner(testStr, 1));
-    Assert.assertEquals(' ', test_String_charAt_inner(testStr, 10));
-    Assert.assertEquals('e', test_String_charAt_inner(testStr, testStr.length()-1));
+    Assert.assertEquals(testStr.length() - 1, 33);  // 33 = testStr.length()-1 as a constant.
+    Assert.assertEquals('f', testStr.charAt(33));
 
-    test_String_charAtExc();
-    test_String_charAtExc2();
+    test_String_charAt(testStr, 'N', 'o', ' ', 'f');
+    test_String_charAt(testStr.substring(3,15), ' ', 'i', 'm', 'e');
+  }
+  public static void test_String_charAt(String testStr, char a, char b, char c, char d) {
+    Assert.assertEquals(a, testStr.charAt(0));
+    Assert.assertEquals(b, testStr.charAt(1));
+    Assert.assertEquals(c, testStr.charAt(10));
+    Assert.assertEquals(d, testStr.charAt(testStr.length()-1));
+
+    test_String_charAtExc(testStr);
+    test_String_charAtExc2(testStr);
   }
 
-  private static void test_String_charAtExc() {
-    String testStr = "Now is the time";
+  private static void test_String_charAtExc(String testStr) {
     try {
       testStr.charAt(-1);
       Assert.fail();
@@ -153,7 +155,12 @@
     } catch (StringIndexOutOfBoundsException expected) {
     }
     try {
-      testStr.charAt(15);  // 15 = "Now is the time".length()
+      if (testStr.length() == 34) {
+          testStr.charAt(34);  // 34 = "Now is the time to test some stuff".length()
+      } else {
+          Assert.assertEquals(testStr.length(), 12);  // 12 = " is the time".length()
+          testStr.charAt(12);
+      }
       Assert.fail();
     } catch (StringIndexOutOfBoundsException expected) {
     }
@@ -168,7 +175,13 @@
     } catch (StringIndexOutOfBoundsException expected) {
     }
     try {
-      test_String_charAt_inner(testStr, 15);  // 15 = "Now is the time".length()
+      if (testStr.length() == 34) {
+        // 34 = "Now is the time to test some stuff".length()
+        test_String_charAt_inner(testStr, 34);
+      } else {
+        Assert.assertEquals(testStr.length(), 12);  // 12 = " is the time".length()
+        test_String_charAt_inner(testStr, 12);
+      }
       Assert.fail();
     } catch (StringIndexOutOfBoundsException expected) {
     }
@@ -193,19 +206,27 @@
     return s.charAt(index);
   }
 
-  private static void test_String_charAtExc2() {
+  private static void test_String_charAtExc2(String testStr) {
     try {
-      test_String_charAtExc3();
+      test_String_charAtExc3(testStr);
+      Assert.fail();
+    } catch (StringIndexOutOfBoundsException expected) {
+    }
+    try {
+      test_String_charAtExc4(testStr);
       Assert.fail();
     } catch (StringIndexOutOfBoundsException expected) {
     }
   }
 
-  private static void test_String_charAtExc3() {
-    String testStr = "Now is the time";
+  private static void test_String_charAtExc3(String testStr) {
     Assert.assertEquals('N', testStr.charAt(-1));
   }
 
+  private static void test_String_charAtExc4(String testStr) {
+    Assert.assertEquals('N', testStr.charAt(100));
+  }
+
   static int start;
   private static int[] negIndex = { -100000 };
   public static void test_String_indexOf() {
diff --git a/test/133-static-invoke-super/expected.txt b/test/133-static-invoke-super/expected.txt
new file mode 100644
index 0000000..089d8e8
--- /dev/null
+++ b/test/133-static-invoke-super/expected.txt
@@ -0,0 +1,3 @@
+basis: performed 50000000 iterations
+test1: performed 50000000 iterations
+Timing is acceptable.
diff --git a/test/133-static-invoke-super/info.txt b/test/133-static-invoke-super/info.txt
new file mode 100644
index 0000000..606331b
--- /dev/null
+++ b/test/133-static-invoke-super/info.txt
@@ -0,0 +1,2 @@
+This is a performance test of invoking static methods in super class. To see the numbers, invoke
+this test with the "--timing" option.
diff --git a/test/133-static-invoke-super/run b/test/133-static-invoke-super/run
new file mode 100755
index 0000000..e27a622
--- /dev/null
+++ b/test/133-static-invoke-super/run
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# As this is a performance test we always use the non-debug build.
+exec ${RUN} "${@/#libartd.so/libart.so}"
diff --git a/test/133-static-invoke-super/src/Main.java b/test/133-static-invoke-super/src/Main.java
new file mode 100644
index 0000000..7cfd099
--- /dev/null
+++ b/test/133-static-invoke-super/src/Main.java
@@ -0,0 +1,63 @@
+
+public class Main {
+    static class SuperClass {
+      protected static int getVar(int w) {
+          return w & 0xF;
+      }
+    }
+    static class SubClass extends SuperClass {
+      final int getVarDirect(int w) {
+        return w & 0xF;
+      }
+      public void testDirect(int max) {
+        for (int i = 0; i < max; ++i) {
+          getVarDirect(max);
+        }
+      }
+      public void testStatic(int max) {
+        for (int i = 0; i < max; ++i) {
+          getVar(max);
+        }
+      }
+    }
+
+    static public void main(String[] args) throws Exception {
+        boolean timing = (args.length >= 1) && args[0].equals("--timing");
+        run(timing);
+    }
+
+    static int testBasis(int interations) {
+      (new SubClass()).testDirect(interations);
+      return interations;
+    }
+
+    static int testStatic(int interations) {
+      (new SubClass()).testStatic(interations);
+      return interations;
+    }
+
+    static public void run(boolean timing) {
+        long time0 = System.nanoTime();
+        int count1 = testBasis(50000000);
+        long time1 = System.nanoTime();
+        int count2 = testStatic(50000000);
+        long time2 = System.nanoTime();
+
+        System.out.println("basis: performed " + count1 + " iterations");
+        System.out.println("test1: performed " + count2 + " iterations");
+
+        double basisMsec = (time1 - time0) / (double) count1 / 1000000;
+        double msec1 = (time2 - time1) / (double) count2 / 1000000;
+
+        if (msec1 < basisMsec * 5) {
+            System.out.println("Timing is acceptable.");
+        } else {
+            System.out.println("Iterations are taking too long!");
+            timing = true;
+        }
+        if (timing) {
+            System.out.printf("basis time: %.3g msec\n", basisMsec);
+            System.out.printf("test1: %.3g msec per iteration\n", msec1);
+        }
+    }
+}
diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk
index b1e969d..2057cb9 100644
--- a/test/Android.run-test.mk
+++ b/test/Android.run-test.mk
@@ -166,7 +166,8 @@
 # Tests that are timing sensitive and flaky on heavily loaded systems.
 TEST_ART_TIMING_SENSITIVE_RUN_TESTS := \
   053-wait-some \
-  055-enum-performance
+  055-enum-performance \
+  133-static-invoke-super
 
  # disable timing sensitive tests on "dist" builds.
 ifdef dist_goal