Merge "Quick compiler - run-test bug fixes" into ics-mr1-plus-art
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 990fb62..2b20aff 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -2850,7 +2850,8 @@
       for (; j < actual_count; ++j) {
         Method* super_method = vtable->Get(j);
         super_mh.ChangeMethod(super_method);
-        if (local_mh.HasSameNameAndSignature(&super_mh)) {
+        if (local_mh.HasSameNameAndSignature(&super_mh) &&
+            klass->CanAccessMember(super_method->GetDeclaringClass(), super_method->GetAccessFlags())) {
           // Verify
           if (super_method->IsFinal()) {
             MethodHelper mh(local_method);
diff --git a/src/compiler_llvm/compilation_unit.cc b/src/compiler_llvm/compilation_unit.cc
index 8aae161..f84ebf4 100644
--- a/src/compiler_llvm/compilation_unit.cc
+++ b/src/compiler_llvm/compilation_unit.cc
@@ -221,9 +221,9 @@
 
 bool CompilationUnit::MaterializeToRawOStream(llvm::raw_ostream& out_stream) {
   // Lookup the LLVM target
-  char const* target_triple = NULL;
-  char const* target_cpu = "";
-  char const* target_attr = NULL;
+  const char* target_triple = NULL;
+  const char* target_cpu = "";
+  const char* target_attr = NULL;
 
   InstructionSet insn_set = GetInstructionSet();
   switch (insn_set) {
@@ -256,7 +256,7 @@
   }
 
   std::string errmsg;
-  llvm::Target const* target =
+  const llvm::Target* target =
     llvm::TargetRegistry::lookupTarget(target_triple, errmsg);
 
   CHECK(target != NULL) << errmsg;
@@ -278,7 +278,7 @@
   CHECK(target_machine.get() != NULL) << "Failed to create target machine";
 
   // Add target data
-  llvm::TargetData const* target_data = target_machine->getTargetData();
+  const llvm::TargetData* target_data = target_machine->getTargetData();
 
   // PassManager for code generation passes
   llvm::PassManager pm;
diff --git a/src/compiler_llvm/compiler_runtime_func_list.h b/src/compiler_llvm/compiler_runtime_func_list.h
index 2eb3de9..ffbae85 100644
--- a/src/compiler_llvm/compiler_runtime_func_list.h
+++ b/src/compiler_llvm/compiler_runtime_func_list.h
@@ -20,213 +20,205 @@
 // NOTE: COMPILER_RUNTIME_FUNC_LIST_* should be sorted!
 
 #define COMPILER_RUNTIME_FUNC_LIST_X86(V) \
-  V(__ashldi3) \
-  V(__ashrdi3) \
-  V(__divdi3) \
-  V(__fixdfdi) \
-  V(__fixsfdi) \
-  V(__fixtfdi) \
-  V(__fixtfsi) \
-  V(__fixunsdfdi) \
-  V(__fixunsdfsi) \
-  V(__fixunssfdi) \
-  V(__fixunssfsi) \
-  V(__fixunstfdi) \
-  V(__fixunstfsi) \
-  V(__fixunsxfdi) \
-  V(__fixunsxfsi) \
-  V(__fixxfdi) \
-  V(__floatdidf) \
-  V(__floatdisf) \
-  V(__floatditf) \
-  V(__floatdixf) \
-  V(__floatsitf) \
-  V(__floatundidf) \
-  V(__floatundisf) \
-  V(__floatunditf) \
-  V(__floatundixf) \
-  V(__floatunsitf) \
-  V(__lshrdi3) \
-  V(__moddi3) \
-  V(__muldi3) \
-  V(__negdi2) \
-  V(__powidf2) \
-  V(__powisf2) \
-  V(__powitf2) \
-  V(__powixf2) \
-  V(__trunctfdf2) \
-  V(__trunctfsf2) \
-  V(__udivdi3) \
-  V(__umoddi3) \
-  V(ceil) \
-  V(ceilf) \
-  V(ceill) \
-  V(copysign) \
-  V(copysignf) \
-  V(copysignl) \
-  V(cos) \
-  V(cosf) \
-  V(exp) \
-  V(exp2) \
-  V(exp2f) \
-  V(expf) \
-  V(floor) \
-  V(floorf) \
-  V(floorl) \
-  V(fma) \
-  V(fmaf) \
-  V(fmod) \
-  V(fmodf) \
-  V(log) \
-  V(log10) \
-  V(log10f) \
-  V(logf) \
-  V(memcpy) \
-  V(memmove) \
-  V(memset) \
-  V(nearbyint) \
-  V(nearbyintf) \
-  V(pow) \
-  V(powf) \
-  V(rint) \
-  V(rintf) \
-  V(sin) \
-  V(sinf) \
-  V(sqrt) \
-  V(sqrtf) \
-  V(trunc) \
-  V(truncf) \
-  V(truncl)
+  V(__ashldi3,          long long, long long, int) \
+  V(__ashrdi3,          long long, long long, int) \
+  V(__divdi3,           long long, long long, long long) \
+  V(__fixdfdi,          long long, double) \
+  V(__fixsfdi,          long long, float) \
+  V(__fixtfdi,          long long, long double) \
+  V(__fixtfsi,          int, long double) \
+  V(__fixunsdfdi,       unsigned long long, double) \
+  V(__fixunsdfsi,       unsigned int, double) \
+  V(__fixunssfdi,       unsigned long long, float) \
+  V(__fixunssfsi,       unsigned int, float) \
+  V(__fixunstfdi,       unsigned long long, long double) \
+  V(__fixunstfsi,       unsigned int, long double) \
+  V(__fixunsxfdi,       unsigned long long, long double) \
+  V(__fixunsxfsi,       unsigned int, long double) \
+  V(__fixxfdi,          long long, long double) \
+  V(__floatdidf,        double, long long) \
+  V(__floatdisf,        float, long long) \
+  V(__floatditf,        long double, long long) \
+  V(__floatdixf,        long double, long long) \
+  V(__floatsitf,        long double, int) \
+  V(__floatundidf,      double, unsigned long long) \
+  V(__floatundisf,      float, unsigned long long) \
+  V(__floatunditf,      long double, unsigned long long) \
+  V(__floatundixf,      long double, unsigned long long) \
+  V(__floatunsitf,      long double, int) \
+  V(__lshrdi3,          long long, long long, int) \
+  V(__moddi3,           long long, long long, long long) \
+  V(__muldi3,           long long, long long, long long) \
+  V(__negdi2,           long long, long long) \
+  V(__powidf2,          double, double, int) \
+  V(__powisf2,          float, float, int) \
+  V(__powitf2,          long double, long double, int) \
+  V(__powixf2,          long double, long double, int) \
+  V(__trunctfdf2,       double, long double) \
+  V(__trunctfsf2,       float, long double) \
+  V(__udivdi3,          unsigned long long, unsigned long long, unsigned long long) \
+  V(__umoddi3,          unsigned long long, unsigned long long, unsigned long long) \
+  V(ceil,               double, double) \
+  V(ceilf,              float, float) \
+  V(ceill,              long double, long double) \
+  V(copysign,           double, double, double) \
+  V(copysignf,          float, float, float) \
+  V(copysignl,          long double, long double, long double) \
+  V(cos,                double, double) \
+  V(cosf,               float, float) \
+  V(exp,                double, double) \
+  V(exp2,               double, double) \
+  V(exp2f,              float, float) \
+  V(expf,               float, float) \
+  V(floor,              double, double) \
+  V(floorf,             float, float) \
+  V(floorl,             long double, long double) \
+  V(fma,                double, double, double, double) \
+  V(fmaf,               float, float, float, float) \
+  V(fmod,               double, double, double) \
+  V(fmodf,              float, float, float) \
+  V(log,                double, double) \
+  V(log10,              double, double) \
+  V(log10f,             float, float) \
+  V(logf,               float, float) \
+  V(memcpy,             void *, void *, const void *, size_t) \
+  V(memmove,            void *, void *, const void *, size_t) \
+  V(memset,             void *, void *, int, size_t) \
+  V(nearbyint,          double, double) \
+  V(nearbyintf,         float, float) \
+  V(pow,                double, double, double) \
+  V(powf,               float, float, float) \
+  V(rint,               double, double) \
+  V(rintf,              float, float) \
+  V(sin,                double, double) \
+  V(sinf,               float, float) \
+  V(sqrt,               double, double) \
+  V(sqrtf,              float, float) \
+  V(trunc,              double, double) \
+  V(truncf,             float, float) \
+  V(truncl,             long double, long double)
 
 #define COMPILER_RUNTIME_FUNC_LIST_MIPS(V) \
-  V(__ashldi3) \
-  V(__ashrdi3) \
-  V(__divdi3) \
-  V(__fixdfdi) \
-  V(__fixsfdi) \
-  V(__fixunsdfdi) \
-  V(__fixunsdfsi) \
-  V(__fixunssfdi) \
-  V(__fixunssfsi) \
-  V(__floatdidf) \
-  V(__floatdisf) \
-  V(__floatundidf) \
-  V(__floatundisf) \
-  V(__lshrdi3) \
-  V(__moddi3) \
-  V(__muldi3) \
-  V(__negdi2) \
-  V(__powidf2) \
-  V(__powisf2) \
-  V(__udivdi3) \
-  V(__umoddi3) \
-  V(ceil) \
-  V(ceilf) \
-  V(ceill) \
-  V(copysign) \
-  V(copysignf) \
-  V(copysignl) \
-  V(cos) \
-  V(cosf) \
-  V(exp) \
-  V(exp2) \
-  V(exp2f) \
-  V(expf) \
-  V(floor) \
-  V(floorf) \
-  V(floorl) \
-  V(fma) \
-  V(fmaf) \
-  V(fmod) \
-  V(fmodf) \
-  V(log) \
-  V(log10) \
-  V(log10f) \
-  V(logf) \
-  V(memcpy) \
-  V(memmove) \
-  V(memset) \
-  V(nearbyint) \
-  V(nearbyintf) \
-  V(pow) \
-  V(powf) \
-  V(rint) \
-  V(rintf) \
-  V(sin) \
-  V(sinf) \
-  V(sqrt) \
-  V(sqrtf) \
-  V(trunc) \
-  V(truncf) \
-  V(truncl)
+  V(__ashldi3,          long long, long long, int) \
+  V(__ashrdi3,          long long, long long, int) \
+  V(__divdi3,           long long, long long, long long) \
+  V(__fixdfdi,          long long, double) \
+  V(__fixsfdi,          long long, float) \
+  V(__fixunsdfdi,       unsigned long long, double) \
+  V(__fixunsdfsi,       unsigned int, double) \
+  V(__fixunssfdi,       unsigned long long, float) \
+  V(__fixunssfsi,       unsigned int, float) \
+  V(__floatdidf,        double, long long) \
+  V(__floatdisf,        float, long long) \
+  V(__floatundidf,      double, unsigned long long) \
+  V(__floatundisf,      float, unsigned long long) \
+  V(__lshrdi3,          long long, long long, int) \
+  V(__moddi3,           long long, long long, long long) \
+  V(__muldi3,           long long, long long, long long) \
+  V(__negdi2,           long long, long long) \
+  V(__powidf2,          double, double, int) \
+  V(__powisf2,          float, float, int) \
+  V(__udivdi3,          unsigned long long, unsigned long long, unsigned long long) \
+  V(__umoddi3,          unsigned long long, unsigned long long, unsigned long long) \
+  V(ceil,               double, double) \
+  V(ceilf,              float, float) \
+  V(ceill,              long double, long double) \
+  V(copysign,           double, double, double) \
+  V(copysignf,          float, float, float) \
+  V(copysignl,          long double, long double, long double) \
+  V(cos,                double, double) \
+  V(cosf,               float, float) \
+  V(exp,                double, double) \
+  V(exp2,               double, double) \
+  V(exp2f,              float, float) \
+  V(expf,               float, float) \
+  V(floor,              double, double) \
+  V(floorf,             float, float) \
+  V(floorl,             long double, long double) \
+  V(fma,                double, double, double, double) \
+  V(fmaf,               float, float, float, float) \
+  V(fmod,               double, double, double) \
+  V(fmodf,              float, float, float) \
+  V(log,                double, double) \
+  V(log10,              double, double) \
+  V(log10f,             float, float) \
+  V(logf,               float, float) \
+  V(memcpy,             void *, void *, const void *, size_t) \
+  V(memmove,            void *, void *, const void *, size_t) \
+  V(memset,             void *, void *, int, size_t) \
+  V(nearbyint,          double, double) \
+  V(nearbyintf,         float, float) \
+  V(pow,                double, double, double) \
+  V(powf,               float, float, float) \
+  V(rint,               double, double) \
+  V(rintf,              float, float) \
+  V(sin,                double, double) \
+  V(sinf,               float, float) \
+  V(sqrt,               double, double) \
+  V(sqrtf,              float, float) \
+  V(trunc,              double, double) \
+  V(truncf,             float, float) \
+  V(truncl,             long double, long double)
 
 #define COMPILER_RUNTIME_FUNC_LIST_ARM(V) \
-  V(__aeabi_d2f) \
-  V(__aeabi_d2iz) \
-  V(__aeabi_d2lz) \
-  V(__aeabi_d2uiz) \
-  V(__aeabi_d2ulz) \
-  V(__aeabi_dadd) \
-  V(__aeabi_dcmpeq) \
-  V(__aeabi_dcmpeq) \
-  V(__aeabi_dcmpge) \
-  V(__aeabi_dcmpgt) \
-  V(__aeabi_dcmple) \
-  V(__aeabi_dcmplt) \
-  V(__aeabi_dcmpun) \
-  V(__aeabi_dcmpun) \
-  V(__aeabi_ddiv) \
-  V(__aeabi_dmul) \
-  V(__aeabi_dsub) \
-  V(__aeabi_f2d) \
-  V(__aeabi_f2iz) \
-  V(__aeabi_f2lz) \
-  V(__aeabi_f2uiz) \
-  V(__aeabi_f2ulz) \
-  V(__aeabi_fadd) \
-  V(__aeabi_fcmpeq) \
-  V(__aeabi_fcmpeq) \
-  V(__aeabi_fcmpge) \
-  V(__aeabi_fcmpgt) \
-  V(__aeabi_fcmple) \
-  V(__aeabi_fcmplt) \
-  V(__aeabi_fcmpun) \
-  V(__aeabi_fcmpun) \
-  V(__aeabi_fdiv) \
-  V(__aeabi_fmul) \
-  V(__aeabi_fsub) \
-  V(__aeabi_i2d) \
-  V(__aeabi_i2f) \
-  V(__aeabi_idiv) \
-  V(__aeabi_idiv) \
-  V(__aeabi_idiv) \
-  V(__aeabi_l2d) \
-  V(__aeabi_l2f) \
-  V(__aeabi_lasr) \
-  V(__aeabi_ldivmod) \
-  V(__aeabi_llsl) \
-  V(__aeabi_llsr) \
-  V(__aeabi_lmul) \
-  V(__aeabi_memcpy) \
-  V(__aeabi_memmove) \
-  V(__aeabi_memset) \
-  V(__aeabi_ui2d) \
-  V(__aeabi_ui2f) \
-  V(__aeabi_uidiv) \
-  V(__aeabi_uidiv) \
-  V(__aeabi_uidiv) \
-  V(__aeabi_ul2d) \
-  V(__aeabi_ul2f) \
-  V(__aeabi_uldivmod) \
-  V(__moddi3) \
-  V(__modsi3) \
-  V(__umoddi3) \
-  V(__umodsi3) \
-  V(fmod) \
-  V(fmodf) \
-  V(memcpy) \
-  V(memmove) \
-  V(memset)
+  V(__aeabi_d2f,        float, double) \
+  V(__aeabi_d2iz,       int, double) \
+  V(__aeabi_d2lz,       long long, double) \
+  V(__aeabi_d2uiz,      unsigned, double) \
+  V(__aeabi_d2ulz,      unsigned long long, double) \
+  V(__aeabi_dadd,       double, double, double) \
+  V(__aeabi_dcmpeq,     int, double, double) \
+  V(__aeabi_dcmpge,     int, double, double) \
+  V(__aeabi_dcmpgt,     int, double, double) \
+  V(__aeabi_dcmple,     int, double, double) \
+  V(__aeabi_dcmplt,     int, double, double) \
+  V(__aeabi_dcmpun,     int, double, double) \
+  V(__aeabi_ddiv,       double, double, double) \
+  V(__aeabi_dmul,       double, double, double) \
+  V(__aeabi_dsub,       double, double, double) \
+  V(__aeabi_f2d,        double, float) \
+  V(__aeabi_f2iz,       int, float) \
+  V(__aeabi_f2lz,       long long, float) \
+  V(__aeabi_f2uiz,      unsigned int, float) \
+  V(__aeabi_f2ulz,      unsigned long long, float) \
+  V(__aeabi_fadd,       float, float, float) \
+  V(__aeabi_fcmpeq,     int, float, float) \
+  V(__aeabi_fcmpge,     int, float, float) \
+  V(__aeabi_fcmpgt,     int, float, float) \
+  V(__aeabi_fcmple,     int, float, float) \
+  V(__aeabi_fcmplt,     int, float, float) \
+  V(__aeabi_fcmpun,     int, float, float) \
+  V(__aeabi_fdiv,       float, float, float) \
+  V(__aeabi_fmul,       float, float, float) \
+  V(__aeabi_fsub,       float, float, float) \
+  V(__aeabi_i2d,        double, int) \
+  V(__aeabi_i2f,        float, int) \
+  V(__aeabi_idiv,       int, int, int) \
+  V(__aeabi_l2d,        double, long long) \
+  V(__aeabi_l2f,        float, long long) \
+  V(__aeabi_lasr,       long long, long long, int) \
+  V(__aeabi_ldivmod,    /* value in regs */ void, long long, long long) \
+  V(__aeabi_llsl,       long long, long long, int) \
+  V(__aeabi_llsr,       long long, long long, int) \
+  V(__aeabi_lmul,       long long, long long, long long) \
+  V(__aeabi_memcpy,     void, void *, const void *, size_t) \
+  V(__aeabi_memmove,    void, void *, const void *, size_t) \
+  V(__aeabi_memset,     void, void *, size_t, int) /* different from stdlib */ \
+  V(__aeabi_ui2d,       double, unsigned int) \
+  V(__aeabi_ui2f,       float, unsigned int) \
+  V(__aeabi_uidiv,      unsigned int, unsigned int, unsigned int) \
+  V(__aeabi_ul2d,       double, unsigned long long) \
+  V(__aeabi_ul2f,       float, unsigned long long) \
+  V(__aeabi_uldivmod,   /* value in regs */ void, unsigned long long, unsigned long long) \
+  V(__moddi3,           long long, long long, long long) \
+  V(__modsi3,           int, int, int) \
+  V(__umoddi3,          unsigned long long, unsigned long long, unsigned long long) \
+  V(__umodsi3,          unsigned int, unsigned int, unsigned int) \
+  V(fmod,               double, double, double) \
+  V(fmodf,              float, float, float) \
+  V(memcpy,             void *, void *, const void *, size_t) \
+  V(memmove,            void *, void *, const void *, size_t) \
+  V(memset,             void *, void *, int, size_t)
 
 
 #if defined(__arm__)
diff --git a/src/compiler_llvm/jni_compiler.cc b/src/compiler_llvm/jni_compiler.cc
index f4f5be5..b96e0be 100644
--- a/src/compiler_llvm/jni_compiler.cc
+++ b/src/compiler_llvm/jni_compiler.cc
@@ -294,7 +294,7 @@
   DexFile::MethodId const& method_id = dex_file_->GetMethodId(method_idx);
 
   uint32_t shorty_size;
-  char const* shorty = dex_file_->GetMethodShorty(method_id, &shorty_size);
+  const char* shorty = dex_file_->GetMethodShorty(method_id, &shorty_size);
   CHECK_GE(shorty_size, 1u);
 
   // Get return type
diff --git a/src/compiler_llvm/jni_compiler.h b/src/compiler_llvm/jni_compiler.h
index 15a789c..15c9810 100644
--- a/src/compiler_llvm/jni_compiler.h
+++ b/src/compiler_llvm/jni_compiler.h
@@ -63,7 +63,7 @@
 
  private:
   CompilationUnit* cunit_;
-  Compiler const* compiler_;
+  const Compiler* compiler_;
 
   llvm::Module* module_;
   llvm::LLVMContext* context_;
@@ -74,9 +74,9 @@
   uint32_t access_flags_;
   uint32_t method_idx_;
   ClassLinker * class_linker_;
-  ClassLoader const* class_loader_;
-  DexCache const* dex_cache_;
-  DexFile const* dex_file_;
+  const ClassLoader* class_loader_;
+  const DexCache* dex_cache_;
+  const DexFile* dex_file_;
   Method* method_;
 
   llvm::Function* func_;
diff --git a/src/compiler_llvm/method_compiler.cc b/src/compiler_llvm/method_compiler.cc
index 13f2327..58d5c33 100644
--- a/src/compiler_llvm/method_compiler.cc
+++ b/src/compiler_llvm/method_compiler.cc
@@ -121,7 +121,7 @@
   DexFile::MethodId const& method_id = dex_file_->GetMethodId(method_idx);
 
   uint32_t shorty_size;
-  char const* shorty = dex_file_->GetMethodShorty(method_id, &shorty_size);
+  const char* shorty = dex_file_->GetMethodShorty(method_id, &shorty_size);
   CHECK_GE(shorty_size, 1u);
 
   // Get return type
@@ -324,7 +324,7 @@
   llvm::Function::arg_iterator arg_end(func_->arg_end());
 
   uint32_t shorty_size = 0;
-  char const* shorty = oat_compilation_unit_->GetShorty(&shorty_size);
+  const char* shorty = oat_compilation_unit_->GetShorty(&shorty_size);
   CHECK_GE(shorty_size, 1u);
 
   ++arg_iter; // skip method object
@@ -353,7 +353,7 @@
 void MethodCompiler::EmitInstructions() {
   uint32_t dex_pc = 0;
   while (dex_pc < code_item_->insns_size_in_code_units_) {
-    Instruction const* insn = Instruction::At(code_item_->insns_ + dex_pc);
+    const Instruction* insn = Instruction::At(code_item_->insns_ + dex_pc);
     EmitInstruction(dex_pc, insn);
     dex_pc += insn->SizeInCodeUnits();
   }
@@ -361,7 +361,7 @@
 
 
 void MethodCompiler::EmitInstruction(uint32_t dex_pc,
-                                     Instruction const* insn) {
+                                     const Instruction* insn) {
 
   // Set the IRBuilder insertion point
   irb_.SetInsertPoint(GetBasicBlock(dex_pc));
@@ -1218,7 +1218,7 @@
 
 
 void MethodCompiler::EmitInsn_Nop(uint32_t dex_pc,
-                                  Instruction const* insn) {
+                                  const Instruction* insn) {
 
   uint16_t insn_signature = code_item_->insns_[dex_pc];
 
@@ -1233,7 +1233,7 @@
 
 
 void MethodCompiler::EmitInsn_Move(uint32_t dex_pc,
-                                   Instruction const* insn,
+                                   const Instruction* insn,
                                    JType jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -1246,7 +1246,7 @@
 
 
 void MethodCompiler::EmitInsn_MoveResult(uint32_t dex_pc,
-                                         Instruction const* insn,
+                                         const Instruction* insn,
                                          JType jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -1259,7 +1259,7 @@
 
 
 void MethodCompiler::EmitInsn_MoveException(uint32_t dex_pc,
-                                            Instruction const* insn) {
+                                            const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1282,7 +1282,7 @@
 
 
 void MethodCompiler::EmitInsn_ThrowException(uint32_t dex_pc,
-                                             Instruction const* insn) {
+                                             const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1298,7 +1298,7 @@
 
 
 void MethodCompiler::EmitInsn_ThrowVerificationError(uint32_t dex_pc,
-                                                     Instruction const* insn) {
+                                                     const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1316,7 +1316,7 @@
 
 
 void MethodCompiler::EmitInsn_ReturnVoid(uint32_t dex_pc,
-                                         Instruction const* insn) {
+                                         const Instruction* insn) {
   // Pop the shadow frame
   EmitPopShadowFrame();
 
@@ -1326,7 +1326,7 @@
 
 
 void MethodCompiler::EmitInsn_Return(uint32_t dex_pc,
-                                     Instruction const* insn) {
+                                     const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1344,7 +1344,7 @@
 
 
 void MethodCompiler::EmitInsn_LoadConstant(uint32_t dex_pc,
-                                           Instruction const* insn,
+                                           const Instruction* insn,
                                            JType imm_jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -1399,7 +1399,7 @@
 
 
 void MethodCompiler::EmitInsn_LoadConstantString(uint32_t dex_pc,
-                                                 Instruction const* insn) {
+                                                 const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1533,7 +1533,7 @@
 
 
 void MethodCompiler::EmitInsn_LoadConstantClass(uint32_t dex_pc,
-                                                Instruction const* insn) {
+                                                const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1545,7 +1545,7 @@
 
 
 void MethodCompiler::EmitInsn_MonitorEnter(uint32_t dex_pc,
-                                           Instruction const* insn) {
+                                           const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1563,7 +1563,7 @@
 
 
 void MethodCompiler::EmitInsn_MonitorExit(uint32_t dex_pc,
-                                          Instruction const* insn) {
+                                          const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1585,7 +1585,7 @@
 
 
 void MethodCompiler::EmitInsn_CheckCast(uint32_t dex_pc,
-                                        Instruction const* insn) {
+                                        const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1640,7 +1640,7 @@
 
 
 void MethodCompiler::EmitInsn_InstanceOf(uint32_t dex_pc,
-                                         Instruction const* insn) {
+                                         const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1719,7 +1719,7 @@
 
 
 void MethodCompiler::EmitInsn_ArrayLength(uint32_t dex_pc,
-                                          Instruction const* insn) {
+                                          const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1736,7 +1736,7 @@
 
 
 void MethodCompiler::EmitInsn_NewInstance(uint32_t dex_pc,
-                                          Instruction const* insn) {
+                                          const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1810,7 +1810,7 @@
 
 
 void MethodCompiler::EmitInsn_NewArray(uint32_t dex_pc,
-                                       Instruction const* insn) {
+                                       const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1824,7 +1824,7 @@
 
 
 void MethodCompiler::EmitInsn_FilledNewArray(uint32_t dex_pc,
-                                             Instruction const* insn,
+                                             const Instruction* insn,
                                              bool is_range) {
 
   DecodedInstruction dec_insn(insn);
@@ -1898,7 +1898,7 @@
 
 
 void MethodCompiler::EmitInsn_FillArrayData(uint32_t dex_pc,
-                                            Instruction const* insn) {
+                                            const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1942,7 +1942,7 @@
 
 
 void MethodCompiler::EmitInsn_UnconditionalBranch(uint32_t dex_pc,
-                                                  Instruction const* insn) {
+                                                  const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1953,7 +1953,7 @@
 
 
 void MethodCompiler::EmitInsn_PackedSwitch(uint32_t dex_pc,
-                                           Instruction const* insn) {
+                                           const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -1977,7 +1977,7 @@
 
 
 void MethodCompiler::EmitInsn_SparseSwitch(uint32_t dex_pc,
-                                           Instruction const* insn) {
+                                           const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -2003,7 +2003,7 @@
 
 
 void MethodCompiler::EmitInsn_FPCompare(uint32_t dex_pc,
-                                        Instruction const* insn,
+                                        const Instruction* insn,
                                         JType fp_jty,
                                         bool gt_bias) {
 
@@ -2031,7 +2031,7 @@
 
 
 void MethodCompiler::EmitInsn_LongCompare(uint32_t dex_pc,
-                                          Instruction const* insn) {
+                                          const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -2063,7 +2063,7 @@
 
 
 void MethodCompiler::EmitInsn_BinaryConditionalBranch(uint32_t dex_pc,
-                                                      Instruction const* insn,
+                                                      const Instruction* insn,
                                                       CondBranchKind cond) {
 
   DecodedInstruction dec_insn(insn);
@@ -2127,7 +2127,7 @@
 
 
 void MethodCompiler::EmitInsn_UnaryConditionalBranch(uint32_t dex_pc,
-                                                     Instruction const* insn,
+                                                     const Instruction* insn,
                                                      CondBranchKind cond) {
 
   DecodedInstruction dec_insn(insn);
@@ -2161,10 +2161,10 @@
                     GetNextBasicBlock(dex_pc));
 }
 
-InferredRegCategoryMap const* MethodCompiler::GetInferredRegCategoryMap() {
+const InferredRegCategoryMap* MethodCompiler::GetInferredRegCategoryMap() {
   Compiler::MethodReference mref(dex_file_, method_idx_);
 
-  InferredRegCategoryMap const* map =
+  const InferredRegCategoryMap* map =
     verifier::MethodVerifier::GetInferredRegCategoryMap(mref);
 
   CHECK_NE(map, static_cast<InferredRegCategoryMap*>(NULL));
@@ -2174,13 +2174,13 @@
 
 RegCategory MethodCompiler::GetInferredRegCategory(uint32_t dex_pc,
                                                    uint16_t reg_idx) {
-  InferredRegCategoryMap const* map = GetInferredRegCategoryMap();
+  const InferredRegCategoryMap* map = GetInferredRegCategoryMap();
 
   return map->GetRegCategory(dex_pc, reg_idx);
 }
 
 bool MethodCompiler::IsRegCanBeObject(uint16_t reg_idx) {
-  InferredRegCategoryMap const* map = GetInferredRegCategoryMap();
+  const InferredRegCategoryMap* map = GetInferredRegCategoryMap();
 
   return map->IsRegCanBeObject(reg_idx);
 }
@@ -2282,7 +2282,7 @@
 
 
 void MethodCompiler::EmitInsn_AGet(uint32_t dex_pc,
-                                   Instruction const* insn,
+                                   const Instruction* insn,
                                    JType elem_jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -2303,7 +2303,7 @@
 
 
 void MethodCompiler::EmitInsn_APut(uint32_t dex_pc,
-                                   Instruction const* insn,
+                                   const Instruction* insn,
                                    JType elem_jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -2334,7 +2334,7 @@
 
 
 void MethodCompiler::EmitInsn_IGet(uint32_t dex_pc,
-                                   Instruction const* insn,
+                                   const Instruction* insn,
                                    JType field_jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -2400,7 +2400,7 @@
 
 
 void MethodCompiler::EmitInsn_IPut(uint32_t dex_pc,
-                                   Instruction const* insn,
+                                   const Instruction* insn,
                                    JType field_jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -2524,7 +2524,7 @@
 
 
 void MethodCompiler::EmitInsn_SGet(uint32_t dex_pc,
-                                   Instruction const* insn,
+                                   const Instruction* insn,
                                    JType field_jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -2603,7 +2603,7 @@
 
 
 void MethodCompiler::EmitInsn_SPut(uint32_t dex_pc,
-                                   Instruction const* insn,
+                                   const Instruction* insn,
                                    JType field_jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -2695,7 +2695,7 @@
     dex_file_->GetMethodId(callee_method_idx);
 
   uint32_t shorty_size;
-  char const* shorty = dex_file_->GetMethodShorty(method_id, &shorty_size);
+  const char* shorty = dex_file_->GetMethodShorty(method_id, &shorty_size);
   CHECK_GE(shorty_size, 1u);
 
   // Load argument values according to the shorty (without "this")
@@ -2728,7 +2728,7 @@
 
 
 void MethodCompiler::EmitInsn_Invoke(uint32_t dex_pc,
-                                     Instruction const* insn,
+                                     const Instruction* insn,
                                      InvokeType invoke_type,
                                      InvokeArgFmt arg_fmt) {
   DecodedInstruction dec_insn(insn);
@@ -2965,7 +2965,7 @@
 
 
 void MethodCompiler::EmitInsn_Neg(uint32_t dex_pc,
-                                  Instruction const* insn,
+                                  const Instruction* insn,
                                   JType op_jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -2981,7 +2981,7 @@
 
 
 void MethodCompiler::EmitInsn_Not(uint32_t dex_pc,
-                                  Instruction const* insn,
+                                  const Instruction* insn,
                                   JType op_jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -2999,7 +2999,7 @@
 
 
 void MethodCompiler::EmitInsn_SExt(uint32_t dex_pc,
-                                   Instruction const* insn) {
+                                   const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -3012,7 +3012,7 @@
 
 
 void MethodCompiler::EmitInsn_Trunc(uint32_t dex_pc,
-                                    Instruction const* insn) {
+                                    const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -3025,7 +3025,7 @@
 
 
 void MethodCompiler::EmitInsn_TruncAndSExt(uint32_t dex_pc,
-                                           Instruction const* insn,
+                                           const Instruction* insn,
                                            unsigned N) {
 
   DecodedInstruction dec_insn(insn);
@@ -3044,7 +3044,7 @@
 
 
 void MethodCompiler::EmitInsn_TruncAndZExt(uint32_t dex_pc,
-                                           Instruction const* insn,
+                                           const Instruction* insn,
                                            unsigned N) {
 
   DecodedInstruction dec_insn(insn);
@@ -3063,7 +3063,7 @@
 
 
 void MethodCompiler::EmitInsn_FNeg(uint32_t dex_pc,
-                                   Instruction const* insn,
+                                   const Instruction* insn,
                                    JType op_jty) {
 
   DecodedInstruction dec_insn(insn);
@@ -3079,7 +3079,7 @@
 
 
 void MethodCompiler::EmitInsn_IntToFP(uint32_t dex_pc,
-                                      Instruction const* insn,
+                                      const Instruction* insn,
                                       JType src_jty,
                                       JType dest_jty) {
 
@@ -3098,7 +3098,7 @@
 
 
 void MethodCompiler::EmitInsn_FPToInt(uint32_t dex_pc,
-                                      Instruction const* insn,
+                                      const Instruction* insn,
                                       JType src_jty,
                                       JType dest_jty,
                                       runtime_support::RuntimeId runtime_func_id) {
@@ -3117,7 +3117,7 @@
 
 
 void MethodCompiler::EmitInsn_FExt(uint32_t dex_pc,
-                                   Instruction const* insn) {
+                                   const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -3130,7 +3130,7 @@
 
 
 void MethodCompiler::EmitInsn_FTrunc(uint32_t dex_pc,
-                                     Instruction const* insn) {
+                                     const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -3143,7 +3143,7 @@
 
 
 void MethodCompiler::EmitInsn_IntArithm(uint32_t dex_pc,
-                                        Instruction const* insn,
+                                        const Instruction* insn,
                                         IntArithmKind arithm,
                                         JType op_jty,
                                         bool is_2addr) {
@@ -3174,7 +3174,7 @@
 
 
 void MethodCompiler::EmitInsn_IntArithmImmediate(uint32_t dex_pc,
-                                                 Instruction const* insn,
+                                                 const Instruction* insn,
                                                  IntArithmKind arithm) {
 
   DecodedInstruction dec_insn(insn);
@@ -3292,7 +3292,7 @@
 
 
 void MethodCompiler::EmitInsn_IntShiftArithm(uint32_t dex_pc,
-                                             Instruction const* insn,
+                                             const Instruction* insn,
                                              IntShiftArithmKind arithm,
                                              JType op_jty,
                                              bool is_2addr) {
@@ -3326,7 +3326,7 @@
 
 void MethodCompiler::
 EmitInsn_IntShiftArithmImmediate(uint32_t dex_pc,
-                                 Instruction const* insn,
+                                 const Instruction* insn,
                                  IntShiftArithmKind arithm) {
 
   DecodedInstruction dec_insn(insn);
@@ -3378,7 +3378,7 @@
 
 
 void MethodCompiler::EmitInsn_RSubImmediate(uint32_t dex_pc,
-                                            Instruction const* insn) {
+                                            const Instruction* insn) {
 
   DecodedInstruction dec_insn(insn);
 
@@ -3392,7 +3392,7 @@
 
 
 void MethodCompiler::EmitInsn_FPArithm(uint32_t dex_pc,
-                                       Instruction const* insn,
+                                       const Instruction* insn,
                                        FPArithmKind arithm,
                                        JType op_jty,
                                        bool is_2addr) {
@@ -3586,7 +3586,7 @@
 
 void MethodCompiler::EmitGuard_ExceptionLandingPad(uint32_t dex_pc, bool can_skip_unwind) {
   llvm::BasicBlock* lpad = GetLandingPadBasicBlock(dex_pc);
-  Instruction const* insn = Instruction::At(code_item_->insns_ + dex_pc);
+  const Instruction* insn = Instruction::At(code_item_->insns_ + dex_pc);
   if (lpad == NULL && can_skip_unwind &&
       IsInstructionDirectToReturn(dex_pc + insn->SizeInCodeUnits())) {
     return;
@@ -3617,7 +3617,7 @@
 
 
 llvm::BasicBlock* MethodCompiler::
-CreateBasicBlockWithDexPC(uint32_t dex_pc, char const* postfix) {
+CreateBasicBlockWithDexPC(uint32_t dex_pc, const char* postfix) {
   std::string name;
 
 #if !defined(NDEBUG)
@@ -3648,7 +3648,7 @@
 
 llvm::BasicBlock*
 MethodCompiler::GetNextBasicBlock(uint32_t dex_pc) {
-  Instruction const* insn = Instruction::At(code_item_->insns_ + dex_pc);
+  const Instruction* insn = Instruction::At(code_item_->insns_ + dex_pc);
   return GetBasicBlock(dex_pc + insn->SizeInCodeUnits());
 }
 
@@ -3664,7 +3664,7 @@
   while (min <= max) {
     int32_t mid = min + (max - min) / 2;
 
-    DexFile::TryItem const* ti = DexFile::GetTryItems(*code_item_, mid);
+    const DexFile::TryItem* ti = DexFile::GetTryItems(*code_item_, mid);
     uint32_t start = ti->start_addr_;
     uint32_t end = start + ti->insn_count_;
 
@@ -3700,7 +3700,7 @@
   }
 
   // Get try item from code item
-  DexFile::TryItem const* ti = DexFile::GetTryItems(*code_item_, ti_offset);
+  const DexFile::TryItem* ti = DexFile::GetTryItems(*code_item_, ti_offset);
 
   std::string lpadname;
 
@@ -4106,7 +4106,7 @@
       return false;
     }
 
-    Instruction const* insn = Instruction::At(code_item_->insns_ + dex_pc);
+    const Instruction* insn = Instruction::At(code_item_->insns_ + dex_pc);
 
     if (insn->IsReturn()) {
       return true;
@@ -4157,7 +4157,7 @@
   std::vector<bool>& set_to_another_object = method_info_.set_to_another_object;
   set_to_another_object.resize(code_item_->registers_size_, false);
 
-  Instruction const* insn;
+  const Instruction* insn;
   for (uint32_t dex_pc = 0;
        dex_pc < code_item_->insns_size_in_code_units_;
        dex_pc += insn->SizeInCodeUnits()) {
diff --git a/src/compiler_llvm/method_compiler.h b/src/compiler_llvm/method_compiler.h
index 41c43f0..dbdcb52 100644
--- a/src/compiler_llvm/method_compiler.h
+++ b/src/compiler_llvm/method_compiler.h
@@ -94,7 +94,7 @@
   void EmitPrologueAllocShadowFrame();
   void EmitPrologueAssignArgRegister();
   void EmitInstructions();
-  void EmitInstruction(uint32_t dex_pc, Instruction const* insn);
+  void EmitInstruction(uint32_t dex_pc, const Instruction* insn);
 
   enum CondBranchKind {
     kCondBranch_EQ,
@@ -135,7 +135,7 @@
     kArgRange,
   };
 
-#define GEN_INSN_ARGS uint32_t dex_pc, Instruction const* insn
+#define GEN_INSN_ARGS uint32_t dex_pc, const Instruction* insn
 
   // NOP, PAYLOAD (unreachable) instructions
   void EmitInsn_Nop(GEN_INSN_ARGS);
@@ -364,7 +364,7 @@
 
   RegCategory GetInferredRegCategory(uint32_t dex_pc, uint16_t reg);
 
-  InferredRegCategoryMap const* GetInferredRegCategoryMap();
+  const InferredRegCategoryMap* GetInferredRegCategoryMap();
 
   bool IsRegCanBeObject(uint16_t reg_idx);
 
@@ -375,7 +375,7 @@
   llvm::BasicBlock* GetNextBasicBlock(uint32_t dex_pc);
 
   llvm::BasicBlock* CreateBasicBlockWithDexPC(uint32_t dex_pc,
-                                              char const* postfix = NULL);
+                                              const char* postfix = NULL);
 
   int32_t GetTryItemOffset(uint32_t dex_pc);
 
@@ -442,11 +442,11 @@
   Compiler* compiler_;
 
   ClassLinker* class_linker_;
-  ClassLoader const* class_loader_;
+  const ClassLoader* class_loader_;
 
-  DexFile const* dex_file_;
+  const DexFile* dex_file_;
   DexCache* dex_cache_;
-  DexFile::CodeItem const* code_item_;
+  const DexFile::CodeItem* code_item_;
 
   OatCompilationUnit* oat_compilation_unit_;
 
diff --git a/src/compiler_llvm/procedure_linkage_table.cc b/src/compiler_llvm/procedure_linkage_table.cc
index 8e03605..cb4a9ed 100644
--- a/src/compiler_llvm/procedure_linkage_table.cc
+++ b/src/compiler_llvm/procedure_linkage_table.cc
@@ -42,19 +42,19 @@
   };
 
   const char* const compiler_runtime_func_name_list_arm[] = {
-#define DEFINE_ENTRY(NAME) #NAME,
+#define DEFINE_ENTRY(NAME, RETURN_TYPE, ...) #NAME,
     COMPILER_RUNTIME_FUNC_LIST_ARM(DEFINE_ENTRY)
 #undef DEFINE_ENTRY
   };
 
   const char* const compiler_runtime_func_name_list_mips[] = {
-#define DEFINE_ENTRY(NAME) #NAME,
+#define DEFINE_ENTRY(NAME, RETURN_TYPE, ...) #NAME,
     COMPILER_RUNTIME_FUNC_LIST_MIPS(DEFINE_ENTRY)
 #undef DEFINE_ENTRY
   };
 
   const char* const compiler_runtime_func_name_list_x86[] = {
-#define DEFINE_ENTRY(NAME) #NAME,
+#define DEFINE_ENTRY(NAME, RETURN_TYPE, ...) #NAME,
     COMPILER_RUNTIME_FUNC_LIST_X86(DEFINE_ENTRY)
 #undef DEFINE_ENTRY
   };
diff --git a/src/compiler_llvm/runtime_support_llvm.cc b/src/compiler_llvm/runtime_support_llvm.cc
index fce4a38..bf3c9ba 100644
--- a/src/compiler_llvm/runtime_support_llvm.cc
+++ b/src/compiler_llvm/runtime_support_llvm.cc
@@ -34,8 +34,10 @@
 #include "well_known_classes.h"
 
 #include <algorithm>
-#include <cstdarg>
+#include <math.h>
+#include <stdarg.h>
 #include <stdint.h>
+#include <stdlib.h>
 
 #include "asm_support.h"
 
@@ -605,21 +607,22 @@
 // Runtime Support Function Lookup Callback
 //----------------------------------------------------------------------------
 
-#define EXTERNAL_LINKAGE(NAME) \
-extern "C" void NAME(...);
+#define EXTERNAL_LINKAGE(NAME, RETURN_TYPE, ...) \
+extern "C" RETURN_TYPE NAME(__VA_ARGS__);
 COMPILER_RUNTIME_FUNC_LIST_NATIVE(EXTERNAL_LINKAGE)
 #undef EXTERNAL_LINKAGE
 
-static void* art_find_compiler_runtime_func(char const* name) {
+static void* art_find_compiler_runtime_func(const char* name) {
 // TODO: If target support some math func, use the target's version. (e.g. art_d2i -> __aeabi_d2iz)
   static const char* const names[] = {
-#define DEFINE_ENTRY(NAME) #NAME ,
+#define DEFINE_ENTRY(NAME, RETURN_TYPE, ...) #NAME ,
     COMPILER_RUNTIME_FUNC_LIST_NATIVE(DEFINE_ENTRY)
 #undef DEFINE_ENTRY
   };
 
   static void* const funcs[] = {
-#define DEFINE_ENTRY(NAME) reinterpret_cast<void*>(NAME) ,
+#define DEFINE_ENTRY(NAME, RETURN_TYPE, ...) \
+    reinterpret_cast<void*>(static_cast<RETURN_TYPE (*)(__VA_ARGS__)>(NAME)) ,
     COMPILER_RUNTIME_FUNC_LIST_NATIVE(DEFINE_ENTRY)
 #undef DEFINE_ENTRY
   };
@@ -786,9 +789,9 @@
   va_end(ap);
 }
 
-void* art_find_runtime_support_func(void* context, char const* name) {
+void* art_find_runtime_support_func(void* context, const char* name) {
   struct func_entry_t {
-    char const* name;
+    const char* name;
     size_t name_len;
     void* addr;
   };
diff --git a/src/compiler_llvm/runtime_support_llvm.h b/src/compiler_llvm/runtime_support_llvm.h
index dabd88f..c900717 100644
--- a/src/compiler_llvm/runtime_support_llvm.h
+++ b/src/compiler_llvm/runtime_support_llvm.h
@@ -61,7 +61,7 @@
 // Runtime Support Function Lookup Callback
 //----------------------------------------------------------------------------
 
-void* art_find_runtime_support_func(void* context, char const* name);
+void* art_find_runtime_support_func(void* context, const char* name);
 
 }  // namespace art
 
diff --git a/src/compiler_llvm/stub_compiler.cc b/src/compiler_llvm/stub_compiler.cc
index 7539532..d14dd62 100644
--- a/src/compiler_llvm/stub_compiler.cc
+++ b/src/compiler_llvm/stub_compiler.cc
@@ -47,7 +47,7 @@
 
 
 CompiledInvokeStub* StubCompiler::CreateInvokeStub(bool is_static,
-                                                   char const* shorty) {
+                                                   const char* shorty) {
   CHECK(shorty != NULL);
   size_t shorty_size = strlen(shorty);
 
@@ -174,7 +174,7 @@
 }
 
 
-CompiledInvokeStub* StubCompiler::CreateProxyStub(char const* shorty) {
+CompiledInvokeStub* StubCompiler::CreateProxyStub(const char* shorty) {
   CHECK(shorty != NULL);
   size_t shorty_size = strlen(shorty);
 
diff --git a/src/compiler_llvm/stub_compiler.h b/src/compiler_llvm/stub_compiler.h
index 0ed6261..9139acc 100644
--- a/src/compiler_llvm/stub_compiler.h
+++ b/src/compiler_llvm/stub_compiler.h
@@ -41,12 +41,12 @@
  public:
   StubCompiler(CompilationUnit* cunit, Compiler& compiler);
 
-  CompiledInvokeStub* CreateInvokeStub(bool is_static, char const* shorty);
-  CompiledInvokeStub* CreateProxyStub(char const* shorty);
+  CompiledInvokeStub* CreateInvokeStub(bool is_static, const char* shorty);
+  CompiledInvokeStub* CreateProxyStub(const char* shorty);
 
  private:
   CompilationUnit* cunit_;
-  Compiler const* compiler_;
+  const Compiler* compiler_;
   llvm::Module* module_;
   llvm::LLVMContext* context_;
   IRBuilder& irb_;
diff --git a/src/heap.h b/src/heap.h
index b91868c..75362ce 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -254,7 +254,6 @@
   void RequestConcurrentGC();
 
   void RecordAllocationLocked(AllocSpace* space, const Object* object);
-  void RecordImageAllocations(Space* space);
 
   // TODO: can we teach GCC to understand the weird locking in here?
   void CollectGarbageInternal(bool concurrent, bool clear_soft_references) NO_THREAD_SAFETY_ANALYSIS;
diff --git a/src/mark_stack.h b/src/mark_stack.h
index 7d4114e..59e12d0 100644
--- a/src/mark_stack.h
+++ b/src/mark_stack.h
@@ -67,7 +67,7 @@
   const Object* const* limit_;
 
   // Pointer to the top of the mark stack.
-  Object const**  ptr_;
+  const Object**  ptr_;
 
   DISALLOW_COPY_AND_ASSIGN(MarkStack);
 };
diff --git a/src/native/java_lang_Class.cc b/src/native/java_lang_Class.cc
index ecab777..bc1d0de 100644
--- a/src/native/java_lang_Class.cc
+++ b/src/native/java_lang_Class.cc
@@ -354,35 +354,6 @@
   return lhs->IsAssignableFrom(rhs) ? JNI_TRUE : JNI_FALSE;
 }
 
-// Validate method/field access.
-static bool CheckMemberAccess(const Class* access_from, Class* access_to, uint32_t member_flags) {
-  // quick accept for public access */
-  if (member_flags & kAccPublic) {
-    return true;
-  }
-
-  // quick accept for access from same class
-  if (access_from == access_to) {
-    return true;
-  }
-
-  // quick reject for private access from another class
-  if (member_flags & kAccPrivate) {
-    return false;
-  }
-
-  // Semi-quick test for protected access from a sub-class, which may or
-  // may not be in the same package.
-  if (member_flags & kAccProtected) {
-    if (access_from->IsSubClass(access_to)) {
-        return true;
-    }
-  }
-
-  // Allow protected and private access from other classes in the same
-  return access_from->IsInSamePackage(access_to);
-}
-
 static jobject Class_newInstanceImpl(JNIEnv* env, jobject javaThis) {
   ScopedJniThreadState ts(env);
   Class* c = DecodeClass(ts, javaThis);
@@ -424,7 +395,7 @@
         PrettyDescriptor(caller_ch.GetDescriptor()).c_str());
     return NULL;
   }
-  if (!CheckMemberAccess(caller_class, init->GetDeclaringClass(), init->GetAccessFlags())) {
+  if (!caller_class->CanAccessMember(init->GetDeclaringClass(), init->GetAccessFlags())) {
     ts.Self()->ThrowNewExceptionF("Ljava/lang/IllegalAccessException;",
         "%s is not accessible from class %s",
         PrettyMethod(init).c_str(),
diff --git a/test/083-compiler-regressions/expected.txt b/test/083-compiler-regressions/expected.txt
index abfd60f..e2846dd 100644
--- a/test/083-compiler-regressions/expected.txt
+++ b/test/083-compiler-regressions/expected.txt
@@ -9,3 +9,5 @@
 wideGetterSetterTest passes
 wideIdentityTest passes
 returnConstantTest passes
+longDivTest passes
+longModTest passes
diff --git a/test/083-compiler-regressions/src/Main.java b/test/083-compiler-regressions/src/Main.java
index f3e84cc..4d6aca3 100644
--- a/test/083-compiler-regressions/src/Main.java
+++ b/test/083-compiler-regressions/src/Main.java
@@ -40,6 +40,8 @@
         wideGetterSetterTest();
         wideIdentityTest();
         returnConstantTest();
+        ZeroTests.longDivTest();
+        ZeroTests.longModTest();
     }
 
     public static void returnConstantTest() {
diff --git a/test/083-compiler-regressions/src/ZeroTests.java b/test/083-compiler-regressions/src/ZeroTests.java
new file mode 100644
index 0000000..bd1a281
--- /dev/null
+++ b/test/083-compiler-regressions/src/ZeroTests.java
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+/**
+ * Tests long division by zero for both / and %.
+ */
+public class ZeroTests {
+    public static void longDivTest() throws Exception {
+      longTest("longDivTest", true);
+    }
+
+    public static void longModTest() throws Exception {
+      longTest("longModTest", false);
+    }
+
+    private static void longTest(String name, boolean divide) throws Exception {
+      try {
+        if (divide) {
+          longDiv(1, 0);
+        } else {
+          longMod(1, 0);
+        }
+        throw new AssertionError(name + " failed to throw");
+      } catch (ArithmeticException expected) {
+        System.out.println(name + " passes");
+      }
+    }
+
+    private static long longDiv(long lhs, long rhs) {
+      return lhs / rhs;
+    }
+
+    private static long longMod(long lhs, long rhs) {
+      return lhs % rhs;
+    }
+}
diff --git a/test/300-package-override/expected.txt b/test/300-package-override/expected.txt
new file mode 100644
index 0000000..b0aad4d
--- /dev/null
+++ b/test/300-package-override/expected.txt
@@ -0,0 +1 @@
+passed
diff --git a/test/300-package-override/info.txt b/test/300-package-override/info.txt
new file mode 100644
index 0000000..0ed59eb
--- /dev/null
+++ b/test/300-package-override/info.txt
@@ -0,0 +1,2 @@
+Tests a dalvik bug where we'd allow subclasses to override package-protected
+methods.
\ No newline at end of file
diff --git a/test/300-package-override/src/Main.java b/test/300-package-override/src/Main.java
new file mode 100644
index 0000000..ad7eaaf
--- /dev/null
+++ b/test/300-package-override/src/Main.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+public class Main {
+  public static void main(String args[]) throws Exception {
+    p1.BaseClass c = new p2.DerivedClass();
+    c.run();
+  }
+}
diff --git a/test/300-package-override/src/p1/BaseClass.java b/test/300-package-override/src/p1/BaseClass.java
new file mode 100644
index 0000000..1c048ac
--- /dev/null
+++ b/test/300-package-override/src/p1/BaseClass.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+package p1;
+
+public class BaseClass {
+  public void run() { foo(); }
+  void foo() { System.out.println("passed"); } // It should not be possible to override this.
+}
diff --git a/test/300-package-override/src/p2/DerivedClass.java b/test/300-package-override/src/p2/DerivedClass.java
new file mode 100644
index 0000000..860f50c
--- /dev/null
+++ b/test/300-package-override/src/p2/DerivedClass.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+package p2;
+
+public class DerivedClass extends p1.BaseClass {
+  void foo() { System.out.println("DerivedClass overrode package-private method!"); } // This should not override BaseClass.foo.
+}