OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 14 matching lines...) Expand all Loading... |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 | 28 |
29 #ifndef V8_BOOTSTRAPPER_H_ | 29 #ifndef V8_BOOTSTRAPPER_H_ |
30 #define V8_BOOTSTRAPPER_H_ | 30 #define V8_BOOTSTRAPPER_H_ |
31 | 31 |
32 namespace v8 { | 32 namespace v8 { |
33 namespace internal { | 33 namespace internal { |
34 | 34 |
| 35 |
| 36 class BootstrapperActive BASE_EMBEDDED { |
| 37 public: |
| 38 BootstrapperActive() { nesting_++; } |
| 39 ~BootstrapperActive() { nesting_--; } |
| 40 |
| 41 // Support for thread preemption. |
| 42 static int ArchiveSpacePerThread(); |
| 43 static char* ArchiveState(char* to); |
| 44 static char* RestoreState(char* from); |
| 45 |
| 46 private: |
| 47 static bool IsActive() { return nesting_ != 0; } |
| 48 static int nesting_; |
| 49 friend class Bootstrapper; |
| 50 }; |
| 51 |
| 52 |
35 // The Boostrapper is the public interface for creating a JavaScript global | 53 // The Boostrapper is the public interface for creating a JavaScript global |
36 // context. | 54 // context. |
37 class Bootstrapper : public AllStatic { | 55 class Bootstrapper : public AllStatic { |
38 public: | 56 public: |
39 // Requires: Heap::Setup has been called. | 57 // Requires: Heap::Setup has been called. |
40 static void Initialize(bool create_heap_objects); | 58 static void Initialize(bool create_heap_objects); |
41 static void TearDown(); | 59 static void TearDown(); |
42 | 60 |
43 // Creates a JavaScript Global Context with initial object graph. | 61 // Creates a JavaScript Global Context with initial object graph. |
44 // The returned value is a global handle casted to V8Environment*. | 62 // The returned value is a global handle casted to V8Environment*. |
45 static Handle<Context> CreateEnvironment( | 63 static Handle<Context> CreateEnvironment( |
46 Handle<Object> global_object, | 64 Handle<Object> global_object, |
47 v8::Handle<v8::ObjectTemplate> global_template, | 65 v8::Handle<v8::ObjectTemplate> global_template, |
48 v8::ExtensionConfiguration* extensions); | 66 v8::ExtensionConfiguration* extensions); |
49 | 67 |
50 // Detach the environment from its outer global object. | 68 // Detach the environment from its outer global object. |
51 static void DetachGlobal(Handle<Context> env); | 69 static void DetachGlobal(Handle<Context> env); |
52 | 70 |
53 // Traverses the pointers for memory management. | 71 // Traverses the pointers for memory management. |
54 static void Iterate(ObjectVisitor* v); | 72 static void Iterate(ObjectVisitor* v); |
55 | 73 |
56 // Accessors for the native scripts cache. Used in lazy loading. | 74 // Accessor for the native scripts source code. |
57 static Handle<String> NativesSourceLookup(int index); | 75 static Handle<String> NativesSourceLookup(int index); |
58 static bool NativesCacheLookup(Vector<const char> name, | |
59 Handle<SharedFunctionInfo>* handle); | |
60 static void NativesCacheAdd(Vector<const char> name, | |
61 Handle<SharedFunctionInfo> fun); | |
62 | 76 |
63 // Tells whether bootstrapping is active. | 77 // Tells whether bootstrapping is active. |
64 static bool IsActive(); | 78 static bool IsActive() { return BootstrapperActive::IsActive(); } |
65 | 79 |
66 // Encoding/decoding support for fixup flags. | 80 // Encoding/decoding support for fixup flags. |
67 class FixupFlagsUseCodeObject: public BitField<bool, 0, 1> {}; | 81 class FixupFlagsUseCodeObject: public BitField<bool, 0, 1> {}; |
68 class FixupFlagsArgumentsCount: public BitField<uint32_t, 1, 32-1> {}; | 82 class FixupFlagsArgumentsCount: public BitField<uint32_t, 1, 32-1> {}; |
69 | 83 |
70 // Support for thread preemption. | 84 // Support for thread preemption. |
71 static int ArchiveSpacePerThread(); | 85 static int ArchiveSpacePerThread(); |
72 static char* ArchiveState(char* to); | 86 static char* ArchiveState(char* to); |
73 static char* RestoreState(char* from); | 87 static char* RestoreState(char* from); |
74 static void FreeThreadResources(); | 88 static void FreeThreadResources(); |
75 | 89 |
76 // This will allocate a char array that is deleted when V8 is shut down. | 90 // This will allocate a char array that is deleted when V8 is shut down. |
77 // It should only be used for strictly finite allocations. | 91 // It should only be used for strictly finite allocations. |
78 static char* AllocateAutoDeletedArray(int bytes); | 92 static char* AllocateAutoDeletedArray(int bytes); |
| 93 |
| 94 // Used for new context creation. |
| 95 static bool InstallExtensions(Handle<Context> global_context, |
| 96 v8::ExtensionConfiguration* extensions); |
79 }; | 97 }; |
80 | 98 |
81 | 99 |
82 class NativesExternalStringResource | 100 class NativesExternalStringResource |
83 : public v8::String::ExternalAsciiStringResource { | 101 : public v8::String::ExternalAsciiStringResource { |
84 public: | 102 public: |
85 explicit NativesExternalStringResource(const char* source); | 103 explicit NativesExternalStringResource(const char* source); |
86 | 104 |
87 const char* data() const { | 105 const char* data() const { |
88 return data_; | 106 return data_; |
89 } | 107 } |
90 | 108 |
91 size_t length() const { | 109 size_t length() const { |
92 return length_; | 110 return length_; |
93 } | 111 } |
94 private: | 112 private: |
95 const char* data_; | 113 const char* data_; |
96 size_t length_; | 114 size_t length_; |
97 }; | 115 }; |
98 | 116 |
99 }} // namespace v8::internal | 117 }} // namespace v8::internal |
100 | 118 |
101 #endif // V8_BOOTSTRAPPER_H_ | 119 #endif // V8_BOOTSTRAPPER_H_ |
OLD | NEW |