Ensure getConstString uses slow path for non-image compilation

Change-Id: If7f0eeb277e1ddc9028c90d4b8fab1621f1ea77e
diff --git a/src/class_linker.cc b/src/class_linker.cc
index b495e3e..9a7cd16 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -2402,8 +2402,7 @@
   const DexFile::StringId& string_id = dex_file.GetStringId(string_idx);
   int32_t utf16_length = dex_file.GetStringLength(string_id);
   const char* utf8_data = dex_file.GetStringData(string_id);
-  // TODO: remote the const_cast below
-  String* string = const_cast<String*>(intern_table_->InternStrong(utf16_length, utf8_data));
+  String* string = intern_table_->InternStrong(utf16_length, utf8_data);
   dex_cache->SetResolvedString(string_idx, string);
   return string;
 }
diff --git a/src/compiler/CompilerIR.h b/src/compiler/CompilerIR.h
index 8dcf56b..dac63cf 100644
--- a/src/compiler/CompilerIR.h
+++ b/src/compiler/CompilerIR.h
@@ -186,7 +186,8 @@
     int numInsts;
     int numBlocks;
     GrowableList blockList;
-    const Method *method;
+    const Compiler* compiler;
+    const Method* method;
     LIR* firstLIRInsn;
     LIR* lastLIRInsn;
     LIR* literalList;                   // Constants
diff --git a/src/compiler/Frontend.cc b/src/compiler/Frontend.cc
index d0c92f6..33dbba4 100644
--- a/src/compiler/Frontend.cc
+++ b/src/compiler/Frontend.cc
@@ -711,6 +711,7 @@
     oatInit(compiler);
 
     memset(&cUnit, 0, sizeof(cUnit));
+    cUnit.compiler = &compiler;
     cUnit.method = method;
     cUnit.instructionSet = (OatInstructionSetType)insnSet;
     cUnit.insns = code_item->insns_;
diff --git a/src/compiler/codegen/arm/Thumb2/Gen.cc b/src/compiler/codegen/arm/Thumb2/Gen.cc
index 094d10c..d88960f 100644
--- a/src/compiler/codegen/arm/Thumb2/Gen.cc
+++ b/src/compiler/codegen/arm/Thumb2/Gen.cc
@@ -651,7 +651,7 @@
     /* NOTE: Most strings should be available at compile time */
     const art::String* str = cUnit->method->GetDexCacheStrings()->
         Get(mir->dalvikInsn.vB);
-    if (SLOW_STRING_PATH || (str == NULL)) {
+    if (SLOW_STRING_PATH || (str == NULL) || !cUnit->compiler->IsImage()) {
         oatFlushAllRegs(cUnit);
         oatLockCallTemps(cUnit); // Using explicit registers
         loadCurrMethodDirect(cUnit, r2);
diff --git a/src/dex_file.cc b/src/dex_file.cc
index 474d742..7c49644 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -360,7 +360,7 @@
 
 DexFile::~DexFile() {
   if (dex_object_ != NULL) {
-    UNIMPLEMENTED(WARNING) << "leaked a global reference to an com.android.dex.Dex instance";
+    UNIMPLEMENTED(WARNING) << "leaked a global reference to an com.android.dex.Dex instance in " << location_;
   }
 }