Merge "Bump oat version again to force recompile"
diff --git a/compiler/dex/local_value_numbering.h b/compiler/dex/local_value_numbering.h
index 535b613..6d67afb 100644
--- a/compiler/dex/local_value_numbering.h
+++ b/compiler/dex/local_value_numbering.h
@@ -20,6 +20,7 @@
 #include "compiler_internals.h"
 #include "UniquePtr.h"
 #include "utils/scoped_arena_allocator.h"
+#include "utils/scoped_arena_containers.h"
 
 #define NO_VALUE 0xffff
 #define ARRAY_REF 0xfffe
@@ -75,20 +76,16 @@
   };
 
   // Key is s_reg, value is value name.
-  typedef SafeMap<uint16_t, uint16_t, std::less<uint16_t>,
-      ScopedArenaAllocatorAdapter<std::pair<uint16_t, uint16_t> > > SregValueMap;
+  typedef ScopedArenaSafeMap<uint16_t, uint16_t> SregValueMap;
   // Key is concatenation of opcode, operand1, operand2 and modifier, value is value name.
-  typedef SafeMap<uint64_t, uint16_t, std::less<uint64_t>,
-      ScopedArenaAllocatorAdapter<std::pair<uint64_t, uint16_t> > > ValueMap;
+  typedef ScopedArenaSafeMap<uint64_t, uint16_t> ValueMap;
   // Key represents a memory address, value is generation.
-  typedef SafeMap<MemoryVersionKey, uint16_t, MemoryVersionKeyComparator,
-      ScopedArenaAllocatorAdapter<std::pair<MemoryVersionKey, uint16_t> > > MemoryVersionMap;
+  typedef ScopedArenaSafeMap<MemoryVersionKey, uint16_t, MemoryVersionKeyComparator
+      > MemoryVersionMap;
   // Maps field key to field id for resolved fields.
-  typedef SafeMap<FieldReference, uint32_t, FieldReferenceComparator,
-      ScopedArenaAllocatorAdapter<std::pair<FieldReference, uint16_t> > > FieldIndexMap;
+  typedef ScopedArenaSafeMap<FieldReference, uint32_t, FieldReferenceComparator> FieldIndexMap;
   // A set of value names.
-  typedef std::set<uint16_t, std::less<uint16_t>,
-      ScopedArenaAllocatorAdapter<uint16_t> > ValueNameSet;
+  typedef ScopedArenaSet<uint16_t> ValueNameSet;
 
  public:
   static LocalValueNumbering* Create(CompilationUnit* cu) {
diff --git a/compiler/dex/mir_analysis.cc b/compiler/dex/mir_analysis.cc
index 200795e..c3b5a25 100644
--- a/compiler/dex/mir_analysis.cc
+++ b/compiler/dex/mir_analysis.cc
@@ -24,6 +24,7 @@
 #include "dex/quick/dex_file_to_method_inliner_map.h"
 #include "driver/compiler_options.h"
 #include "UniquePtr.h"
+#include "utils/scoped_arena_containers.h"
 
 namespace art {
 
@@ -1205,17 +1206,16 @@
     MethodReferenceComparator devirt_cmp;
   };
 
-  // Map invoke key (see MapEntry) to lowering info index.
-  typedef std::set<MapEntry, MapEntryComparator, ScopedArenaAllocatorAdapter<MapEntry> > InvokeMap;
-
   ScopedArenaAllocator allocator(&cu_->arena_stack);
 
   // All INVOKE instructions take 3 code units and there must also be a RETURN.
   uint32_t max_refs = (current_code_item_->insns_size_in_code_units_ - 1u) / 3u;
 
+  // Map invoke key (see MapEntry) to lowering info index and vice versa.
   // The invoke_map and sequential entries are essentially equivalent to Boost.MultiIndex's
   // multi_index_container with one ordered index and one sequential index.
-  InvokeMap invoke_map(MapEntryComparator(), allocator.Adapter());
+  ScopedArenaSet<MapEntry, MapEntryComparator> invoke_map(MapEntryComparator(),
+                                                          allocator.Adapter());
   const MapEntry** sequential_entries = reinterpret_cast<const MapEntry**>(
       allocator.Alloc(max_refs * sizeof(sequential_entries[0]), kArenaAllocMisc));
 
diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc
index 413b4e0..8e8a593 100644
--- a/compiler/dex/mir_optimization.cc
+++ b/compiler/dex/mir_optimization.cc
@@ -19,6 +19,7 @@
 #include "dataflow_iterator-inl.h"
 #include "dex/quick/dex_file_method_inliner.h"
 #include "dex/quick/dex_file_to_method_inliner_map.h"
+#include "utils/scoped_arena_containers.h"
 
 namespace art {
 
@@ -964,11 +965,9 @@
       }
     };
 
-    typedef std::set<MapEntry, MapEntryComparator, ScopedArenaAllocatorAdapter<MapEntry> >
-        ClassToIndexMap;
-
     ScopedArenaAllocator allocator(&cu_->arena_stack);
-    ClassToIndexMap class_to_index_map(MapEntryComparator(), allocator.Adapter());
+    ScopedArenaSet<MapEntry, MapEntryComparator> class_to_index_map(MapEntryComparator(),
+                                                                    allocator.Adapter());
 
     // First, find all SGET/SPUTs that may need class initialization checks, record INVOKE_STATICs.
     AllNodesIterator iter(this);
diff --git a/compiler/utils/debug_stack.h b/compiler/utils/debug_stack.h
index 2e02b43..1bb0624 100644
--- a/compiler/utils/debug_stack.h
+++ b/compiler/utils/debug_stack.h
@@ -118,7 +118,7 @@
     CheckTop();
   }
   DebugStackIndirectTopRefImpl& operator=(const DebugStackIndirectTopRefImpl& other) {
-    CHECK(ref_ == other->ref_);
+    CHECK(ref_ == other.ref_);
     CheckTop();
     return *this;
   }
diff --git a/compiler/utils/scoped_arena_allocator.h b/compiler/utils/scoped_arena_allocator.h
index d5b003c..c090062 100644
--- a/compiler/utils/scoped_arena_allocator.h
+++ b/compiler/utils/scoped_arena_allocator.h
@@ -235,8 +235,24 @@
 
   template <typename U>
   friend class ScopedArenaAllocatorAdapter;
+
+  template <typename U>
+  friend bool operator==(const ScopedArenaAllocatorAdapter<U>& lhs,
+                         const ScopedArenaAllocatorAdapter<U>& rhs);
 };
 
+template <typename T>
+inline bool operator==(const ScopedArenaAllocatorAdapter<T>& lhs,
+                       const ScopedArenaAllocatorAdapter<T>& rhs) {
+  return lhs.arena_stack_ == rhs.arena_stack_;
+}
+
+template <typename T>
+inline bool operator!=(const ScopedArenaAllocatorAdapter<T>& lhs,
+                       const ScopedArenaAllocatorAdapter<T>& rhs) {
+  return !(lhs == rhs);
+}
+
 inline ScopedArenaAllocatorAdapter<void> ScopedArenaAllocator::Adapter() {
   return ScopedArenaAllocatorAdapter<void>(this);
 }
diff --git a/compiler/utils/scoped_arena_containers.h b/compiler/utils/scoped_arena_containers.h
new file mode 100644
index 0000000..c6fefde
--- /dev/null
+++ b/compiler/utils/scoped_arena_containers.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2014 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_UTILS_SCOPED_ARENA_CONTAINERS_H_
+#define ART_COMPILER_UTILS_SCOPED_ARENA_CONTAINERS_H_
+
+#include <vector>
+#include <set>
+
+#include "utils/scoped_arena_allocator.h"
+#include "safe_map.h"
+
+namespace art {
+
+template <typename T>
+using ScopedArenaVector = std::vector<T, ScopedArenaAllocatorAdapter<T> >;
+
+template <typename T, typename Comparator = std::less<T> >
+using ScopedArenaSet = std::set<T, Comparator, ScopedArenaAllocatorAdapter<T> >;
+
+template <typename K, typename V, typename Comparator = std::less<K> >
+using ScopedArenaSafeMap =
+    SafeMap<K, V, Comparator, ScopedArenaAllocatorAdapter<std::pair<const K, V> > >;
+
+}  // namespace art
+
+#endif  // ART_COMPILER_UTILS_SCOPED_ARENA_CONTAINERS_H_
diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc
index ff2eda0..5de7026 100644
--- a/runtime/gc/collector/mark_sweep.cc
+++ b/runtime/gc/collector/mark_sweep.cc
@@ -378,7 +378,7 @@
       ++mark_sweep_->large_object_mark_;
     }
     space::LargeObjectSpace* large_object_space = mark_sweep_->GetHeap()->GetLargeObjectsSpace();
-    if (UNLIKELY(!IsAligned<kPageSize>(obj) ||
+    if (UNLIKELY(obj == nullptr || !IsAligned<kPageSize>(obj) ||
                  (kIsDebugBuild && !large_object_space->Contains(obj)))) {
       LOG(ERROR) << "Tried to mark " << obj << " not contained by any spaces";
       LOG(ERROR) << "Attempting see if it's a bad root";
diff --git a/test/Android.mk b/test/Android.mk
index 08a925c..aacd7b4 100644
--- a/test/Android.mk
+++ b/test/Android.mk
@@ -191,12 +191,13 @@
 ########################################################################
 
 TEST_ART_RUN_TEST_MAKE_TARGETS :=
+art_run_tests_dir := $(call intermediates-dir-for,PACKAGING,art-run-tests)/DATA
 
 # Helper to create individual build targets for tests.
 # Must be called with $(eval)
 # $(1): the test number
 define declare-make-art-run-test
-dmart_target := $(TARGET_OUT_DATA)/art-run-tests/$(1)/touch
+dmart_target := $(art_run_tests_dir)/art-run-tests/$(1)/touch
 $$(dmart_target): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin
 	$(hide) rm -rf $$(dir $$@) && mkdir -p $$(dir $$@)
 	$(hide) DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) $(LOCAL_PATH)/run-test --build-only --output-path $$(abspath $$(dir $$@)) $(1)
@@ -222,6 +223,9 @@
 LOCAL_MODULE_TAGS := tests
 LOCAL_MODULE := art-run-tests
 LOCAL_ADDITIONAL_DEPENDENCIES := $(TEST_ART_RUN_TEST_MAKE_TARGETS)
+# The build system use this flag to pick up files generated by declare-make-art-run-test.
+LOCAL_PICKUP_FILES := $(art_run_tests_dir)
+
 include $(BUILD_PHONY_PACKAGE)
 
 # clear temp vars