| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 static int nesting_; | 48 static int nesting_; |
| 49 friend class Bootstrapper; | 49 friend class Bootstrapper; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 | 52 |
| 53 // The Boostrapper is the public interface for creating a JavaScript global | 53 // The Boostrapper is the public interface for creating a JavaScript global |
| 54 // context. | 54 // context. |
| 55 class Bootstrapper { | 55 class Bootstrapper { |
| 56 public: | 56 public: |
| 57 // Requires: Heap::Setup has been called. | 57 // Requires: Heap::Setup has been called. |
| 58 static void Initialize(bool create_heap_objects); | 58 void Initialize(bool create_heap_objects); |
| 59 static void TearDown(); | 59 void TearDown(); |
| 60 | 60 |
| 61 // Creates a JavaScript Global Context with initial object graph. | 61 // Creates a JavaScript Global Context with initial object graph. |
| 62 // The returned value is a global handle casted to V8Environment*. | 62 // The returned value is a global handle casted to V8Environment*. |
| 63 static Handle<Context> CreateEnvironment( | 63 Handle<Context> CreateEnvironment( |
| 64 Handle<Object> global_object, | 64 Handle<Object> global_object, |
| 65 v8::Handle<v8::ObjectTemplate> global_template, | 65 v8::Handle<v8::ObjectTemplate> global_template, |
| 66 v8::ExtensionConfiguration* extensions); | 66 v8::ExtensionConfiguration* extensions); |
| 67 | 67 |
| 68 // Detach the environment from its outer global object. | 68 // Detach the environment from its outer global object. |
| 69 static void DetachGlobal(Handle<Context> env); | 69 void DetachGlobal(Handle<Context> env); |
| 70 | 70 |
| 71 // Reattach an outer global object to an environment. | 71 // Reattach an outer global object to an environment. |
| 72 static void ReattachGlobal(Handle<Context> env, Handle<Object> global_object); | 72 void ReattachGlobal(Handle<Context> env, Handle<Object> global_object); |
| 73 | 73 |
| 74 // Traverses the pointers for memory management. | 74 // Traverses the pointers for memory management. |
| 75 static void Iterate(ObjectVisitor* v); | 75 void Iterate(ObjectVisitor* v); |
| 76 | 76 |
| 77 // Accessor for the native scripts source code. | 77 // Accessor for the native scripts source code. |
| 78 static Handle<String> NativesSourceLookup(int index); | 78 static Handle<String> NativesSourceLookup(int index); |
| 79 | 79 |
| 80 // Tells whether bootstrapping is active. | 80 // Tells whether bootstrapping is active. |
| 81 static bool IsActive() { return BootstrapperActive::IsActive(); } | 81 static bool IsActive() { return BootstrapperActive::IsActive(); } |
| 82 | 82 |
| 83 // Support for thread preemption. | 83 // Support for thread preemption. |
| 84 static int ArchiveSpacePerThread(); | 84 int ArchiveSpacePerThread(); |
| 85 static char* ArchiveState(char* to); | 85 char* ArchiveState(char* to); |
| 86 static char* RestoreState(char* from); | 86 char* RestoreState(char* from); |
| 87 static void FreeThreadResources(); | 87 void FreeThreadResources(); |
| 88 | 88 |
| 89 // This will allocate a char array that is deleted when V8 is shut down. | 89 // This will allocate a char array that is deleted when V8 is shut down. |
| 90 // It should only be used for strictly finite allocations. | 90 // It should only be used for strictly finite allocations. |
| 91 static char* AllocateAutoDeletedArray(int bytes); | 91 static char* AllocateAutoDeletedArray(int bytes); |
| 92 | 92 |
| 93 // Used for new context creation. | 93 // Used for new context creation. |
| 94 static bool InstallExtensions(Handle<Context> global_context, | 94 bool InstallExtensions(Handle<Context> global_context, |
| 95 v8::ExtensionConfiguration* extensions); | 95 v8::ExtensionConfiguration* extensions); |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 friend class Isolate; | 98 friend class Isolate; |
| 99 Bootstrapper(); | 99 Bootstrapper(); |
| 100 | 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(Bootstrapper); | 101 DISALLOW_COPY_AND_ASSIGN(Bootstrapper); |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 | 104 |
| 105 class NativesExternalStringResource | 105 class NativesExternalStringResource |
| 106 : public v8::String::ExternalAsciiStringResource { | 106 : public v8::String::ExternalAsciiStringResource { |
| 107 public: | 107 public: |
| 108 explicit NativesExternalStringResource(const char* source); | 108 explicit NativesExternalStringResource(const char* source); |
| 109 | 109 |
| 110 const char* data() const { | 110 const char* data() const { |
| 111 return data_; | 111 return data_; |
| 112 } | 112 } |
| 113 | 113 |
| 114 size_t length() const { | 114 size_t length() const { |
| 115 return length_; | 115 return length_; |
| 116 } | 116 } |
| 117 private: | 117 private: |
| 118 const char* data_; | 118 const char* data_; |
| 119 size_t length_; | 119 size_t length_; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 }} // namespace v8::internal | 122 }} // namespace v8::internal |
| 123 | 123 |
| 124 #endif // V8_BOOTSTRAPPER_H_ | 124 #endif // V8_BOOTSTRAPPER_H_ |
| OLD | NEW |