Remove inline header includes from natives.h header.
authormstarzinger <mstarzinger@chromium.org>
Tue, 18 Aug 2015 14:31:26 +0000 (07:31 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 18 Aug 2015 14:31:34 +0000 (14:31 +0000)
R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/1303463002

Cr-Commit-Position: refs/heads/master@{#30222}

BUILD.gn
src/snapshot/natives-common.cc [new file with mode: 0644]
src/snapshot/natives-external.cc
src/snapshot/natives.h
tools/gyp/v8.gyp

index 903e6a5..9bb19f0 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1139,6 +1139,7 @@ source_set("v8_base") {
     "src/simulator.h",
     "src/small-pointer-list.h",
     "src/snapshot/natives.h",
+    "src/snapshot/natives-common.cc",
     "src/snapshot/serialize.cc",
     "src/snapshot/serialize.h",
     "src/snapshot/snapshot-common.cc",
diff --git a/src/snapshot/natives-common.cc b/src/snapshot/natives-common.cc
new file mode 100644 (file)
index 0000000..080cd49
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// The common functionality when building with internal or external natives.
+
+#include "src/heap/heap.h"
+#include "src/objects-inl.h"
+#include "src/snapshot/natives.h"
+
+namespace v8 {
+namespace internal {
+
+template <>
+FixedArray* NativesCollection<CORE>::GetSourceCache(Heap* heap) {
+  return heap->natives_source_cache();
+}
+
+
+template <>
+FixedArray* NativesCollection<EXPERIMENTAL>::GetSourceCache(Heap* heap) {
+  return heap->experimental_natives_source_cache();
+}
+
+
+template <>
+FixedArray* NativesCollection<EXTRAS>::GetSourceCache(Heap* heap) {
+  return heap->extra_natives_source_cache();
+}
+
+
+template <>
+FixedArray* NativesCollection<CODE_STUB>::GetSourceCache(Heap* heap) {
+  return heap->code_stub_natives_source_cache();
+}
+
+
+template <NativeType type>
+void NativesCollection<type>::UpdateSourceCache(Heap* heap) {
+  for (int i = 0; i < GetBuiltinsCount(); i++) {
+    Object* source = GetSourceCache(heap)->get(i);
+    if (!source->IsUndefined()) {
+      ExternalOneByteString::cast(source)->update_data_cache();
+    }
+  }
+}
+
+
+// Explicit template instantiations.
+template void NativesCollection<CORE>::UpdateSourceCache(Heap* heap);
+template void NativesCollection<CODE_STUB>::UpdateSourceCache(Heap* heap);
+template void NativesCollection<EXPERIMENTAL>::UpdateSourceCache(Heap* heap);
+template void NativesCollection<EXTRAS>::UpdateSourceCache(Heap* heap);
+
+}  // namespace internal
+}  // namespace v8
index 94fc2c1..e0df27f 100644 (file)
@@ -229,11 +229,19 @@ Vector<const char> NativesCollection<type>::GetScriptsSource() {
 }
 
 
-// The compiler can't 'see' all uses of the static methods and hence
-// my choice to elide them. This we'll explicitly instantiate these.
-template class NativesCollection<CORE>;
-template class NativesCollection<CODE_STUB>;
-template class NativesCollection<EXPERIMENTAL>;
-template class NativesCollection<EXTRAS>;
+// Explicit template instantiations.
+#define INSTANTIATE_TEMPLATES(T)                                            \
+  template int NativesCollection<T>::GetBuiltinsCount();                    \
+  template int NativesCollection<T>::GetDebuggerCount();                    \
+  template int NativesCollection<T>::GetIndex(const char* name);            \
+  template Vector<const char> NativesCollection<T>::GetScriptSource(int i); \
+  template Vector<const char> NativesCollection<T>::GetScriptName(int i);   \
+  template Vector<const char> NativesCollection<T>::GetScriptsSource();
+INSTANTIATE_TEMPLATES(CORE)
+INSTANTIATE_TEMPLATES(CODE_STUB)
+INSTANTIATE_TEMPLATES(EXPERIMENTAL)
+INSTANTIATE_TEMPLATES(EXTRAS)
+#undef INSTANTIATE_TEMPLATES
+
 }  // namespace internal
 }  // namespace v8
index 8c24bd2..1efaf7e 100644 (file)
@@ -5,10 +5,7 @@
 #ifndef V8_SNAPSHOT_NATIVES_H_
 #define V8_SNAPSHOT_NATIVES_H_
 
-#include "src/heap/heap.h"
-#include "src/heap/heap-inl.h"
 #include "src/objects.h"
-#include "src/objects-inl.h"
 #include "src/vector.h"
 
 namespace v8 { class StartupData; }  // Forward declaration.
@@ -37,9 +34,9 @@ class NativesCollection {
   static Vector<const char> GetScriptName(int index);
   static Vector<const char> GetScriptsSource();
 
-  // The following methods are implemented below:
+  // The following methods are implemented in natives-common.cc:
 
-  inline static FixedArray* GetSourceCache(Heap* heap);
+  static FixedArray* GetSourceCache(Heap* heap);
   static void UpdateSourceCache(Heap* heap);
 };
 
@@ -49,40 +46,6 @@ typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives;
 typedef NativesCollection<EXTRAS> ExtraNatives;
 
 
-template <>
-inline FixedArray* Natives::GetSourceCache(Heap* heap) {
-  return heap->natives_source_cache();
-}
-
-
-template <>
-inline FixedArray* ExperimentalNatives::GetSourceCache(Heap* heap) {
-  return heap->experimental_natives_source_cache();
-}
-
-
-template <>
-inline FixedArray* ExtraNatives::GetSourceCache(Heap* heap) {
-  return heap->extra_natives_source_cache();
-}
-
-
-template <>
-inline FixedArray* CodeStubNatives::GetSourceCache(Heap* heap) {
-  return heap->code_stub_natives_source_cache();
-}
-
-template <NativeType type>
-void NativesCollection<type>::UpdateSourceCache(Heap* heap) {
-  for (int i = 0; i < GetBuiltinsCount(); i++) {
-    Object* source = GetSourceCache(heap)->get(i);
-    if (!source->IsUndefined()) {
-      ExternalOneByteString::cast(source)->update_data_cache();
-    }
-  }
-}
-
-
 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
 // Used for reading the natives at runtime. Implementation in natives-empty.cc
 void SetNativesFromFile(StartupData* natives_blob);
index 2a2e495..6b9b131 100644 (file)
         '../../src/simulator.h',
         '../../src/small-pointer-list.h',
         '../../src/snapshot/natives.h',
+        '../../src/snapshot/natives-common.cc',
         '../../src/snapshot/serialize.cc',
         '../../src/snapshot/serialize.h',
         '../../src/snapshot/snapshot.h',