| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_BOOTSTRAPPER_H_ | 5 #ifndef V8_BOOTSTRAPPER_H_ |
| 6 #define V8_BOOTSTRAPPER_H_ | 6 #define V8_BOOTSTRAPPER_H_ |
| 7 | 7 |
| 8 #include "src/factory.h" | 8 #include "src/factory.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 | 12 |
| 13 // A SourceCodeCache uses a FixedArray to store pairs of | 13 // A SourceCodeCache uses a FixedArray to store pairs of |
| 14 // (AsciiString*, JSFunction*), mapping names of native code files | 14 // (AsciiString*, JSFunction*), mapping names of native code files |
| 15 // (runtime.js, etc.) to precompiled functions. Instead of mapping | 15 // (runtime.js, etc.) to precompiled functions. Instead of mapping |
| 16 // names to functions it might make sense to let the JS2C tool | 16 // names to functions it might make sense to let the JS2C tool |
| 17 // generate an index for each native JS file. | 17 // generate an index for each native JS file. |
| 18 class SourceCodeCache V8_FINAL BASE_EMBEDDED { | 18 class SourceCodeCache FINAL BASE_EMBEDDED { |
| 19 public: | 19 public: |
| 20 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { } | 20 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { } |
| 21 | 21 |
| 22 void Initialize(Isolate* isolate, bool create_heap_objects) { | 22 void Initialize(Isolate* isolate, bool create_heap_objects) { |
| 23 cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL; | 23 cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL; |
| 24 } | 24 } |
| 25 | 25 |
| 26 void Iterate(ObjectVisitor* v) { | 26 void Iterate(ObjectVisitor* v) { |
| 27 v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_)); | 27 v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_)); |
| 28 } | 28 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 Script::Type type_; | 59 Script::Type type_; |
| 60 FixedArray* cache_; | 60 FixedArray* cache_; |
| 61 DISALLOW_COPY_AND_ASSIGN(SourceCodeCache); | 61 DISALLOW_COPY_AND_ASSIGN(SourceCodeCache); |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 | 64 |
| 65 // The Boostrapper is the public interface for creating a JavaScript global | 65 // The Boostrapper is the public interface for creating a JavaScript global |
| 66 // context. | 66 // context. |
| 67 class Bootstrapper V8_FINAL { | 67 class Bootstrapper FINAL { |
| 68 public: | 68 public: |
| 69 static void InitializeOncePerProcess(); | 69 static void InitializeOncePerProcess(); |
| 70 static void TearDownExtensions(); | 70 static void TearDownExtensions(); |
| 71 | 71 |
| 72 // Requires: Heap::SetUp has been called. | 72 // Requires: Heap::SetUp has been called. |
| 73 void Initialize(bool create_heap_objects); | 73 void Initialize(bool create_heap_objects); |
| 74 void TearDown(); | 74 void TearDown(); |
| 75 | 75 |
| 76 // Creates a JavaScript Global Context with initial object graph. | 76 // Creates a JavaScript Global Context with initial object graph. |
| 77 // The returned value is a global handle casted to V8Environment*. | 77 // The returned value is a global handle casted to V8Environment*. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 static v8::Extension* free_buffer_extension_; | 127 static v8::Extension* free_buffer_extension_; |
| 128 static v8::Extension* gc_extension_; | 128 static v8::Extension* gc_extension_; |
| 129 static v8::Extension* externalize_string_extension_; | 129 static v8::Extension* externalize_string_extension_; |
| 130 static v8::Extension* statistics_extension_; | 130 static v8::Extension* statistics_extension_; |
| 131 static v8::Extension* trigger_failure_extension_; | 131 static v8::Extension* trigger_failure_extension_; |
| 132 | 132 |
| 133 DISALLOW_COPY_AND_ASSIGN(Bootstrapper); | 133 DISALLOW_COPY_AND_ASSIGN(Bootstrapper); |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 | 136 |
| 137 class BootstrapperActive V8_FINAL BASE_EMBEDDED { | 137 class BootstrapperActive FINAL BASE_EMBEDDED { |
| 138 public: | 138 public: |
| 139 explicit BootstrapperActive(Bootstrapper* bootstrapper) | 139 explicit BootstrapperActive(Bootstrapper* bootstrapper) |
| 140 : bootstrapper_(bootstrapper) { | 140 : bootstrapper_(bootstrapper) { |
| 141 ++bootstrapper_->nesting_; | 141 ++bootstrapper_->nesting_; |
| 142 } | 142 } |
| 143 | 143 |
| 144 ~BootstrapperActive() { | 144 ~BootstrapperActive() { |
| 145 --bootstrapper_->nesting_; | 145 --bootstrapper_->nesting_; |
| 146 } | 146 } |
| 147 | 147 |
| 148 private: | 148 private: |
| 149 Bootstrapper* bootstrapper_; | 149 Bootstrapper* bootstrapper_; |
| 150 | 150 |
| 151 DISALLOW_COPY_AND_ASSIGN(BootstrapperActive); | 151 DISALLOW_COPY_AND_ASSIGN(BootstrapperActive); |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 | 154 |
| 155 class NativesExternalStringResource V8_FINAL | 155 class NativesExternalStringResource FINAL |
| 156 : public v8::String::ExternalAsciiStringResource { | 156 : public v8::String::ExternalAsciiStringResource { |
| 157 public: | 157 public: |
| 158 NativesExternalStringResource(Bootstrapper* bootstrapper, | 158 NativesExternalStringResource(Bootstrapper* bootstrapper, |
| 159 const char* source, | 159 const char* source, |
| 160 size_t length); | 160 size_t length); |
| 161 virtual const char* data() const V8_OVERRIDE { return data_; } | 161 virtual const char* data() const OVERRIDE { return data_; } |
| 162 virtual size_t length() const V8_OVERRIDE { return length_; } | 162 virtual size_t length() const OVERRIDE { return length_; } |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 const char* data_; | 165 const char* data_; |
| 166 size_t length_; | 166 size_t length_; |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 }} // namespace v8::internal | 169 }} // namespace v8::internal |
| 170 | 170 |
| 171 #endif // V8_BOOTSTRAPPER_H_ | 171 #endif // V8_BOOTSTRAPPER_H_ |
| OLD | NEW |