1257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch// Copyright 2011 the V8 project authors. All rights reserved. 2b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// found in the LICENSE file. 4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 5014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#ifndef V8_SNAPSHOT_NATIVES_H_ 6014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#define V8_SNAPSHOT_NATIVES_H_ 7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 8014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/objects.h" 9b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#include "src/vector.h" 10b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 11b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochnamespace v8 { class StartupData; } // Forward declaration. 12b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 { 14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace internal { 15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockenum NativeType { 17014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch CORE, 18014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch EXPERIMENTAL, 19014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch EXTRAS, 20014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch EXPERIMENTAL_EXTRAS, 21014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch D8, 22014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch TEST 23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 25f3b273f5e6ffd2f6ba1c18a27a17db41dfb113c3Ben Murdoch// Extra handling for V8_EXPORT_PRIVATE in combination with USING_V8_SHARED 26f3b273f5e6ffd2f6ba1c18a27a17db41dfb113c3Ben Murdoch// since definition of methods of classes marked as dllimport is not allowed. 27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocktemplate <NativeType type> 28f3b273f5e6ffd2f6ba1c18a27a17db41dfb113c3Ben Murdoch#ifdef USING_V8_SHARED 29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass NativesCollection { 30f3b273f5e6ffd2f6ba1c18a27a17db41dfb113c3Ben Murdoch#else 31f3b273f5e6ffd2f6ba1c18a27a17db41dfb113c3Ben Murdochclass V8_EXPORT_PRIVATE NativesCollection { 32f3b273f5e6ffd2f6ba1c18a27a17db41dfb113c3Ben Murdoch#endif // USING_V8_SHARED 33f3b273f5e6ffd2f6ba1c18a27a17db41dfb113c3Ben Murdoch 34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 35014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // The following methods are implemented in js2c-generated code: 36014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Number of built-in scripts. 38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static int GetBuiltinsCount(); 393100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu // Number of debugger implementation scripts. 403100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu static int GetDebuggerCount(); 41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 423100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu // These are used to access built-in scripts. The debugger implementation 433100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu // scripts have an index in the interval [0, GetDebuggerCount()). The 443100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu // non-debugger scripts have an index in the interval [GetDebuggerCount(), 453100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu // GetNativesCount()). 46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static int GetIndex(const char* name); 47958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier static Vector<const char> GetScriptSource(int index); 48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static Vector<const char> GetScriptName(int index); 49958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier static Vector<const char> GetScriptsSource(); 50014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 51014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // The following methods are implemented in natives-common.cc: 52014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 53014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static FixedArray* GetSourceCache(Heap* heap); 54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocktypedef NativesCollection<CORE> Natives; 57257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdochtypedef NativesCollection<EXPERIMENTAL> ExperimentalNatives; 58014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochtypedef NativesCollection<EXTRAS> ExtraNatives; 59014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochtypedef NativesCollection<EXPERIMENTAL_EXTRAS> ExperimentalExtraNatives; 60014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 62b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#ifdef V8_USE_EXTERNAL_STARTUP_DATA 63b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Used for reading the natives at runtime. Implementation in natives-empty.cc 64b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvoid SetNativesFromFile(StartupData* natives_blob); 65014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochvoid ReadNatives(); 66014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochvoid DisposeNatives(); 67b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#endif 68b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 69014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace internal 70014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace v8 71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 72014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#endif // V8_SNAPSHOT_NATIVES_H_ 73