ART: Use iosfwd more

Use iosfwd where an include of ostream is unnecessary. Also move
callee_save_type.h to runtime.

Bug: 119869270
Test: mmma art
Change-Id: Id8995d6f524e4c491eb6f57fdffb940cf35d291f
diff --git a/libartbase/Android.bp b/libartbase/Android.bp
index 109853c..509b072 100644
--- a/libartbase/Android.bp
+++ b/libartbase/Android.bp
@@ -24,6 +24,7 @@
         "base/arena_allocator.cc",
         "base/arena_bit_vector.cc",
         "base/bit_vector.cc",
+        "base/enums.cc",
         "base/file_magic.cc",
         "base/file_utils.cc",
         "base/hex_dump.cc",
@@ -153,7 +154,6 @@
     srcs: [
         "arch/instruction_set.h",
         "base/allocator.h",
-        "base/callee_save_type.h",
         "base/unix_file/fd_file.h",
     ],
     output_extension: "operator_out.cc",
diff --git a/libartbase/base/enums.cc b/libartbase/base/enums.cc
new file mode 100644
index 0000000..3f28232
--- /dev/null
+++ b/libartbase/base/enums.cc
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 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 "enums.h"
+
+#include <ostream>
+
+namespace art {
+
+std::ostream& operator<<(std::ostream& os, const PointerSize& rhs) {
+  switch (rhs) {
+    case PointerSize::k32: os << "k32"; break;
+    case PointerSize::k64: os << "k64"; break;
+    default: os << "PointerSize[" << static_cast<int>(rhs) << "]"; break;
+  }
+  return os;
+}
+
+}  // namespace art
diff --git a/libartbase/base/enums.h b/libartbase/base/enums.h
index ad5578f..c5fb880 100644
--- a/libartbase/base/enums.h
+++ b/libartbase/base/enums.h
@@ -18,7 +18,7 @@
 #define ART_LIBARTBASE_BASE_ENUMS_H_
 
 #include <cstddef>
-#include <ostream>
+#include <iosfwd>
 
 namespace art {
 
@@ -27,14 +27,7 @@
   k64 = 8
 };
 
-inline std::ostream& operator<<(std::ostream& os, const PointerSize& rhs) {
-  switch (rhs) {
-    case PointerSize::k32: os << "k32"; break;
-    case PointerSize::k64: os << "k64"; break;
-    default: os << "PointerSize[" << static_cast<int>(rhs) << "]"; break;
-  }
-  return os;
-}
+std::ostream& operator<<(std::ostream& os, const PointerSize& rhs);
 
 static constexpr PointerSize kRuntimePointerSize = sizeof(void*) == 8U
                                                        ? PointerSize::k64
diff --git a/libartbase/base/logging.h b/libartbase/base/logging.h
index 9ded082..484db87 100644
--- a/libartbase/base/logging.h
+++ b/libartbase/base/logging.h
@@ -17,9 +17,6 @@
 #ifndef ART_LIBARTBASE_BASE_LOGGING_H_
 #define ART_LIBARTBASE_BASE_LOGGING_H_
 
-#include <ostream>
-#include <sstream>
-
 #include "android-base/logging.h"
 #include "macros.h"
 
diff --git a/libdexfile/dex/dex_file.cc b/libdexfile/dex/dex_file.cc
index 5c100e6..d3cdf13 100644
--- a/libdexfile/dex/dex_file.cc
+++ b/libdexfile/dex/dex_file.cc
@@ -23,6 +23,7 @@
 #include <zlib.h>
 
 #include <memory>
+#include <ostream>
 #include <sstream>
 #include <type_traits>
 
diff --git a/libdexfile/dex/dex_file_types.h b/libdexfile/dex/dex_file_types.h
index d4fb3de..ecc0482 100644
--- a/libdexfile/dex/dex_file_types.h
+++ b/libdexfile/dex/dex_file_types.h
@@ -17,8 +17,9 @@
 #ifndef ART_LIBDEXFILE_DEX_DEX_FILE_TYPES_H_
 #define ART_LIBDEXFILE_DEX_DEX_FILE_TYPES_H_
 
+#include <iosfwd>
 #include <limits>
-#include <ostream>
+#include <utility>
 
 namespace art {
 namespace dex {
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 71c5b74..b89eb02 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -462,6 +462,7 @@
     cmd: "$(location generate_operator_out) art/runtime $(in) > $(out)",
     tools: ["generate_operator_out"],
     srcs: [
+        "base/callee_save_type.h",
         "base/locks.h",
         "class_loader_context.h",
         "class_status.h",
diff --git a/runtime/arch/instruction_set_features.cc b/runtime/arch/instruction_set_features.cc
index 0c45bc9..886b40a 100644
--- a/runtime/arch/instruction_set_features.cc
+++ b/runtime/arch/instruction_set_features.cc
@@ -16,6 +16,9 @@
 
 #include "instruction_set_features.h"
 
+#include <algorithm>
+#include <ostream>
+
 #include "android-base/strings.h"
 
 #include "base/casts.h"
diff --git a/runtime/arch/instruction_set_features.h b/runtime/arch/instruction_set_features.h
index c31c927..f910a41 100644
--- a/runtime/arch/instruction_set_features.h
+++ b/runtime/arch/instruction_set_features.h
@@ -17,8 +17,8 @@
 #ifndef ART_RUNTIME_ARCH_INSTRUCTION_SET_FEATURES_H_
 #define ART_RUNTIME_ARCH_INSTRUCTION_SET_FEATURES_H_
 
+#include <iosfwd>
 #include <memory>
-#include <ostream>
 #include <vector>
 
 #include "arch/instruction_set.h"
diff --git a/libartbase/base/callee_save_type.h b/runtime/base/callee_save_type.h
similarity index 89%
rename from libartbase/base/callee_save_type.h
rename to runtime/base/callee_save_type.h
index 3e44a3a..e7cc7e6 100644
--- a/libartbase/base/callee_save_type.h
+++ b/runtime/base/callee_save_type.h
@@ -14,11 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef ART_LIBARTBASE_BASE_CALLEE_SAVE_TYPE_H_
-#define ART_LIBARTBASE_BASE_CALLEE_SAVE_TYPE_H_
+#ifndef ART_RUNTIME_BASE_CALLEE_SAVE_TYPE_H_
+#define ART_RUNTIME_BASE_CALLEE_SAVE_TYPE_H_
 
-#include <cstddef>
-#include <ostream>
+#include <cstdint>
+#include <iosfwd>
 
 namespace art {
 
@@ -44,4 +44,4 @@
 
 }  // namespace art
 
-#endif  // ART_LIBARTBASE_BASE_CALLEE_SAVE_TYPE_H_
+#endif  // ART_RUNTIME_BASE_CALLEE_SAVE_TYPE_H_
diff --git a/runtime/compiler_filter.cc b/runtime/compiler_filter.cc
index bda64eb..c086490 100644
--- a/runtime/compiler_filter.cc
+++ b/runtime/compiler_filter.cc
@@ -16,6 +16,8 @@
 
 #include "compiler_filter.h"
 
+#include <ostream>
+
 #include "base/utils.h"
 
 namespace art {
diff --git a/runtime/compiler_filter.h b/runtime/compiler_filter.h
index 012ebcb..c36e40f 100644
--- a/runtime/compiler_filter.h
+++ b/runtime/compiler_filter.h
@@ -17,7 +17,7 @@
 #ifndef ART_RUNTIME_COMPILER_FILTER_H_
 #define ART_RUNTIME_COMPILER_FILTER_H_
 
-#include <ostream>
+#include <iosfwd>
 #include <string>
 #include <vector>
 
diff --git a/runtime/gc/space/malloc_space.cc b/runtime/gc/space/malloc_space.cc
index b5e6b62..474231b 100644
--- a/runtime/gc/space/malloc_space.cc
+++ b/runtime/gc/space/malloc_space.cc
@@ -16,6 +16,8 @@
 
 #include "malloc_space.h"
 
+#include <ostream>
+
 #include "android-base/stringprintf.h"
 
 #include "base/logging.h"  // For VLOG
diff --git a/runtime/gc/space/malloc_space.h b/runtime/gc/space/malloc_space.h
index 7d28516..9a90dfd 100644
--- a/runtime/gc/space/malloc_space.h
+++ b/runtime/gc/space/malloc_space.h
@@ -19,7 +19,8 @@
 
 #include "space.h"
 
-#include <ostream>
+#include <iosfwd>
+
 #include "base/memory_tool.h"
 #include "base/mutex.h"
 
diff --git a/runtime/obj_ptr-inl.h b/runtime/obj_ptr-inl.h
index b949c96..f096445 100644
--- a/runtime/obj_ptr-inl.h
+++ b/runtime/obj_ptr-inl.h
@@ -17,6 +17,8 @@
 #ifndef ART_RUNTIME_OBJ_PTR_INL_H_
 #define ART_RUNTIME_OBJ_PTR_INL_H_
 
+#include <ostream>
+
 #include "base/bit_utils.h"
 #include "obj_ptr.h"
 #include "thread-current-inl.h"
diff --git a/runtime/obj_ptr.h b/runtime/obj_ptr.h
index 73a99ab..b0f24da 100644
--- a/runtime/obj_ptr.h
+++ b/runtime/obj_ptr.h
@@ -17,7 +17,7 @@
 #ifndef ART_RUNTIME_OBJ_PTR_H_
 #define ART_RUNTIME_OBJ_PTR_H_
 
-#include <ostream>
+#include <iosfwd>
 #include <type_traits>
 
 #include "base/locks.h"  // For Locks::mutator_lock_.
diff --git a/runtime/offsets.h b/runtime/offsets.h
index d4c0dd6..6d1a8e0 100644
--- a/runtime/offsets.h
+++ b/runtime/offsets.h
@@ -17,7 +17,7 @@
 #ifndef ART_RUNTIME_OFFSETS_H_
 #define ART_RUNTIME_OFFSETS_H_
 
-#include <ostream>
+#include <iosfwd>
 
 #include "base/enums.h"
 #include "runtime_globals.h"
diff --git a/runtime/suspend_reason.h b/runtime/suspend_reason.h
index 289a1a4..af2be10 100644
--- a/runtime/suspend_reason.h
+++ b/runtime/suspend_reason.h
@@ -17,7 +17,7 @@
 #ifndef ART_RUNTIME_SUSPEND_REASON_H_
 #define ART_RUNTIME_SUSPEND_REASON_H_
 
-#include <ostream>
+#include <iosfwd>
 
 namespace art {
 
diff --git a/runtime/thread_state.h b/runtime/thread_state.h
index 8edfeec..e57a040 100644
--- a/runtime/thread_state.h
+++ b/runtime/thread_state.h
@@ -17,7 +17,7 @@
 #ifndef ART_RUNTIME_THREAD_STATE_H_
 #define ART_RUNTIME_THREAD_STATE_H_
 
-#include <ostream>
+#include <iosfwd>
 
 namespace art {