Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 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 | EXPERIMENTAL, |
| 19 | EXTRAS, |
| 20 | EXPERIMENTAL_EXTRAS, |
| 21 | D8, |
| 22 | TEST |
| 23 | }; |
| 24 | |
| 25 | template <NativeType type> |
| 26 | class NativesCollection { |
| 27 | public: |
| 28 | // The following methods are implemented in js2c-generated code: |
| 29 | |
| 30 | // Number of built-in scripts. |
| 31 | static int GetBuiltinsCount(); |
| 32 | // Number of debugger implementation scripts. |
| 33 | static int GetDebuggerCount(); |
| 34 | |
| 35 | // These are used to access built-in scripts. The debugger implementation |
| 36 | // scripts have an index in the interval [0, GetDebuggerCount()). The |
| 37 | // non-debugger scripts have an index in the interval [GetDebuggerCount(), |
| 38 | // GetNativesCount()). |
| 39 | static int GetIndex(const char* name); |
| 40 | static Vector<const char> GetScriptSource(int index); |
| 41 | static Vector<const char> GetScriptName(int index); |
| 42 | static Vector<const char> GetScriptsSource(); |
| 43 | |
| 44 | // The following methods are implemented in natives-common.cc: |
| 45 | |
| 46 | static FixedArray* GetSourceCache(Heap* heap); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | typedef NativesCollection<CORE> Natives; |
| 50 | typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives; |
| 51 | typedef NativesCollection<EXTRAS> ExtraNatives; |
| 52 | typedef NativesCollection<EXPERIMENTAL_EXTRAS> ExperimentalExtraNatives; |
| 53 | |
| 54 | |
| 55 | #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 56 | // Used for reading the natives at runtime. Implementation in natives-empty.cc |
| 57 | void SetNativesFromFile(StartupData* natives_blob); |
| 58 | void ReadNatives(); |
| 59 | void DisposeNatives(); |
| 60 | #endif |
| 61 | |
| 62 | } // namespace internal |
| 63 | } // namespace v8 |
| 64 | |
| 65 | #endif // V8_SNAPSHOT_NATIVES_H_ |