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

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

Issue 1289603002: Put V8 extras into the snapshot (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comment 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"
9 #include "src/heap/heap-inl.h"
10 #include "src/objects.h"
11 #include "src/objects-inl.h"
8 #include "src/vector.h" 12 #include "src/vector.h"
9 13
10 namespace v8 { class StartupData; } // Forward declaration. 14 namespace v8 { class StartupData; } // Forward declaration.
11 15
12 namespace v8 { 16 namespace v8 {
13 namespace internal { 17 namespace internal {
14 18
15 enum NativeType { CORE, CODE_STUB, EXPERIMENTAL, EXTRAS, D8, TEST }; 19 enum NativeType { CORE, CODE_STUB, EXPERIMENTAL, EXTRAS, D8, TEST };
16 20
17 template <NativeType type> 21 template <NativeType type>
18 class NativesCollection { 22 class NativesCollection {
19 public: 23 public:
24 // The following methods are implemented in js2c-generated code:
25
20 // Number of built-in scripts. 26 // Number of built-in scripts.
21 static int GetBuiltinsCount(); 27 static int GetBuiltinsCount();
22 // Number of debugger implementation scripts. 28 // Number of debugger implementation scripts.
23 static int GetDebuggerCount(); 29 static int GetDebuggerCount();
24 30
25 // These are used to access built-in scripts. The debugger implementation 31 // These are used to access built-in scripts. The debugger implementation
26 // scripts have an index in the interval [0, GetDebuggerCount()). The 32 // scripts have an index in the interval [0, GetDebuggerCount()). The
27 // non-debugger scripts have an index in the interval [GetDebuggerCount(), 33 // non-debugger scripts have an index in the interval [GetDebuggerCount(),
28 // GetNativesCount()). 34 // GetNativesCount()).
29 static int GetIndex(const char* name); 35 static int GetIndex(const char* name);
30 static Vector<const char> GetScriptSource(int index); 36 static Vector<const char> GetScriptSource(int index);
31 static Vector<const char> GetScriptName(int index); 37 static Vector<const char> GetScriptName(int index);
32 static Vector<const char> GetScriptsSource(); 38 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);
33 }; 44 };
34 45
35 typedef NativesCollection<CORE> Natives; 46 typedef NativesCollection<CORE> Natives;
36 typedef NativesCollection<CODE_STUB> CodeStubNatives; 47 typedef NativesCollection<CODE_STUB> CodeStubNatives;
37 typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives; 48 typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives;
38 typedef NativesCollection<EXTRAS> ExtraNatives; 49 typedef NativesCollection<EXTRAS> ExtraNatives;
39 50
51
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
40 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 86 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
41 // Used for reading the natives at runtime. Implementation in natives-empty.cc 87 // Used for reading the natives at runtime. Implementation in natives-empty.cc
42 void SetNativesFromFile(StartupData* natives_blob); 88 void SetNativesFromFile(StartupData* natives_blob);
43 void ReadNatives(); 89 void ReadNatives();
44 void DisposeNatives(); 90 void DisposeNatives();
45 #endif 91 #endif
46 92
47 } } // namespace v8::internal 93 } } // namespace v8::internal
48 94
49 #endif // V8_SNAPSHOT_NATIVES_H_ 95 #endif // V8_SNAPSHOT_NATIVES_H_
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/snapshot/serialize.h » ('j') | src/snapshot/serialize.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698