Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: src/snapshot/natives.h

Issue 1292533005: Remove heap-inl.h include from natives.h. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix again. argh templates. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_SNAPSHOT_NATIVES_H_ 5 #ifndef V8_SNAPSHOT_NATIVES_H_
6 #define V8_SNAPSHOT_NATIVES_H_ 6 #define V8_SNAPSHOT_NATIVES_H_
7 7
8 #include "src/heap/heap.h" 8 #include "src/heap/heap.h"
9 #include "src/heap/heap-inl.h" 9 #include "src/heap/heap-inl.h"
Michael Starzinger 2015/08/18 12:05:56 Please also actually remove the includes.
10 #include "src/objects.h" 10 #include "src/objects.h"
11 #include "src/objects-inl.h" 11 #include "src/objects-inl.h"
12 #include "src/vector.h" 12 #include "src/vector.h"
13 13
14 namespace v8 { class StartupData; } // Forward declaration. 14 namespace v8 { class StartupData; } // Forward declaration.
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace internal {
18 18
19 enum NativeType { CORE, CODE_STUB, EXPERIMENTAL, EXTRAS, D8, TEST }; 19 enum NativeType { CORE, CODE_STUB, EXPERIMENTAL, EXTRAS, D8, TEST };
20 20
21
21 template <NativeType type> 22 template <NativeType type>
22 class NativesCollection { 23 class NativesCollectionBase {
24 public:
25 static FixedArray* GetSourceCache(Heap* heap);
26 static void UpdateSourceCache(Heap* heap);
27 };
28
29
30 template <NativeType type>
31 class NativesCollection : public NativesCollectionBase<type> {
23 public: 32 public:
24 // The following methods are implemented in js2c-generated code: 33 // The following methods are implemented in js2c-generated code:
25 34
26 // Number of built-in scripts. 35 // Number of built-in scripts.
27 static int GetBuiltinsCount(); 36 static int GetBuiltinsCount();
28 // Number of debugger implementation scripts. 37 // Number of debugger implementation scripts.
29 static int GetDebuggerCount(); 38 static int GetDebuggerCount();
30 39
31 // These are used to access built-in scripts. The debugger implementation 40 // These are used to access built-in scripts. The debugger implementation
32 // scripts have an index in the interval [0, GetDebuggerCount()). The 41 // scripts have an index in the interval [0, GetDebuggerCount()). The
33 // non-debugger scripts have an index in the interval [GetDebuggerCount(), 42 // non-debugger scripts have an index in the interval [GetDebuggerCount(),
34 // GetNativesCount()). 43 // GetNativesCount()).
35 static int GetIndex(const char* name); 44 static int GetIndex(const char* name);
36 static Vector<const char> GetScriptSource(int index); 45 static Vector<const char> GetScriptSource(int index);
37 static Vector<const char> GetScriptName(int index); 46 static Vector<const char> GetScriptName(int index);
38 static Vector<const char> GetScriptsSource(); 47 static Vector<const char> GetScriptsSource();
39
40 // The following methods are implemented below:
41
42 inline static FixedArray* GetSourceCache(Heap* heap);
43 static void UpdateSourceCache(Heap* heap);
44 }; 48 };
45 49
46 typedef NativesCollection<CORE> Natives; 50 typedef NativesCollection<CORE> Natives;
47 typedef NativesCollection<CODE_STUB> CodeStubNatives; 51 typedef NativesCollection<CODE_STUB> CodeStubNatives;
48 typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives; 52 typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives;
49 typedef NativesCollection<EXTRAS> ExtraNatives; 53 typedef NativesCollection<EXTRAS> ExtraNatives;
50 54
51 55
52 template <>
53 inline FixedArray* Natives::GetSourceCache(Heap* heap) {
54 return heap->natives_source_cache();
55 }
56
57
58 template <>
59 inline FixedArray* ExperimentalNatives::GetSourceCache(Heap* heap) {
60 return heap->experimental_natives_source_cache();
61 }
62
63
64 template <>
65 inline FixedArray* ExtraNatives::GetSourceCache(Heap* heap) {
66 return heap->extra_natives_source_cache();
67 }
68
69
70 template <>
71 inline FixedArray* CodeStubNatives::GetSourceCache(Heap* heap) {
72 return heap->code_stub_natives_source_cache();
73 }
74
75 template <NativeType type>
76 void NativesCollection<type>::UpdateSourceCache(Heap* heap) {
77 for (int i = 0; i < GetBuiltinsCount(); i++) {
78 Object* source = GetSourceCache(heap)->get(i);
79 if (!source->IsUndefined()) {
80 ExternalOneByteString::cast(source)->update_data_cache();
81 }
82 }
83 }
84
85
86 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 56 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
87 // Used for reading the natives at runtime. Implementation in natives-empty.cc 57 // Used for reading the natives at runtime. Implementation in natives-empty.cc
88 void SetNativesFromFile(StartupData* natives_blob); 58 void SetNativesFromFile(StartupData* natives_blob);
89 void ReadNatives(); 59 void ReadNatives();
90 void DisposeNatives(); 60 void DisposeNatives();
91 #endif 61 #endif
92 62
93 } } // namespace v8::internal 63 } } // namespace v8::internal
94 64
95 #endif // V8_SNAPSHOT_NATIVES_H_ 65 #endif // V8_SNAPSHOT_NATIVES_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/snapshot/natives-common.cc » ('j') | src/snapshot/natives-common.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698