c923a0f353bb1bc6dc59f7f5e4e80a16e86172a5
[platform/upstream/v8.git] / src / snapshot / natives.h
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
3 // found in the LICENSE file.
4
5 #ifndef V8_SNAPSHOT_NATIVES_H_
6 #define V8_SNAPSHOT_NATIVES_H_
7
8 #include "src/objects.h"
9 #include "src/vector.h"
10
11 namespace v8 { class StartupData; }  // Forward declaration.
12
13 namespace v8 {
14 namespace internal {
15
16 enum NativeType {
17   CORE,
18   CODE_STUB,
19   EXPERIMENTAL,
20   EXTRAS,
21   EXPERIMENTAL_EXTRAS,
22   D8,
23   TEST
24 };
25
26 template <NativeType type>
27 class NativesCollection {
28  public:
29   // The following methods are implemented in js2c-generated code:
30
31   // Number of built-in scripts.
32   static int GetBuiltinsCount();
33   // Number of debugger implementation scripts.
34   static int GetDebuggerCount();
35
36   // These are used to access built-in scripts.  The debugger implementation
37   // scripts have an index in the interval [0, GetDebuggerCount()).  The
38   // non-debugger scripts have an index in the interval [GetDebuggerCount(),
39   // GetNativesCount()).
40   static int GetIndex(const char* name);
41   static Vector<const char> GetScriptSource(int index);
42   static Vector<const char> GetScriptName(int index);
43   static Vector<const char> GetScriptsSource();
44
45   // The following methods are implemented in natives-common.cc:
46
47   static FixedArray* GetSourceCache(Heap* heap);
48   static void UpdateSourceCache(Heap* heap);
49 };
50
51 typedef NativesCollection<CORE> Natives;
52 typedef NativesCollection<CODE_STUB> CodeStubNatives;
53 typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives;
54 typedef NativesCollection<EXTRAS> ExtraNatives;
55 typedef NativesCollection<EXPERIMENTAL_EXTRAS> ExperimentalExtraNatives;
56
57
58 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
59 // Used for reading the natives at runtime. Implementation in natives-empty.cc
60 void SetNativesFromFile(StartupData* natives_blob);
61 void ReadNatives();
62 void DisposeNatives();
63 #endif
64
65 } }  // namespace v8::internal
66
67 #endif  // V8_SNAPSHOT_NATIVES_H_