| 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 // (OneByteString*, JSFunction*), mapping names of native code files | 14 // (OneByteString*, 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 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(bit_cast<Object**, FixedArray**>(&cache_)); | 27 v->VisitPointer(bit_cast<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 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 static v8::Extension* free_buffer_extension_; | 119 static v8::Extension* free_buffer_extension_; |
| 120 static v8::Extension* gc_extension_; | 120 static v8::Extension* gc_extension_; |
| 121 static v8::Extension* externalize_string_extension_; | 121 static v8::Extension* externalize_string_extension_; |
| 122 static v8::Extension* statistics_extension_; | 122 static v8::Extension* statistics_extension_; |
| 123 static v8::Extension* trigger_failure_extension_; | 123 static v8::Extension* trigger_failure_extension_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(Bootstrapper); | 125 DISALLOW_COPY_AND_ASSIGN(Bootstrapper); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 | 128 |
| 129 class BootstrapperActive FINAL BASE_EMBEDDED { | 129 class BootstrapperActive final BASE_EMBEDDED { |
| 130 public: | 130 public: |
| 131 explicit BootstrapperActive(Bootstrapper* bootstrapper) | 131 explicit BootstrapperActive(Bootstrapper* bootstrapper) |
| 132 : bootstrapper_(bootstrapper) { | 132 : bootstrapper_(bootstrapper) { |
| 133 ++bootstrapper_->nesting_; | 133 ++bootstrapper_->nesting_; |
| 134 } | 134 } |
| 135 | 135 |
| 136 ~BootstrapperActive() { | 136 ~BootstrapperActive() { |
| 137 --bootstrapper_->nesting_; | 137 --bootstrapper_->nesting_; |
| 138 } | 138 } |
| 139 | 139 |
| 140 private: | 140 private: |
| 141 Bootstrapper* bootstrapper_; | 141 Bootstrapper* bootstrapper_; |
| 142 | 142 |
| 143 DISALLOW_COPY_AND_ASSIGN(BootstrapperActive); | 143 DISALLOW_COPY_AND_ASSIGN(BootstrapperActive); |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 | 146 |
| 147 class NativesExternalStringResource FINAL | 147 class NativesExternalStringResource final |
| 148 : public v8::String::ExternalOneByteStringResource { | 148 : public v8::String::ExternalOneByteStringResource { |
| 149 public: | 149 public: |
| 150 NativesExternalStringResource(const char* source, size_t length) | 150 NativesExternalStringResource(const char* source, size_t length) |
| 151 : data_(source), length_(length) {} | 151 : data_(source), length_(length) {} |
| 152 const char* data() const OVERRIDE { return data_; } | 152 const char* data() const override { return data_; } |
| 153 size_t length() const OVERRIDE { return length_; } | 153 size_t length() const override { return length_; } |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 const char* data_; | 156 const char* data_; |
| 157 size_t length_; | 157 size_t length_; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 }} // namespace v8::internal | 160 }} // namespace v8::internal |
| 161 | 161 |
| 162 #endif // V8_BOOTSTRAPPER_H_ | 162 #endif // V8_BOOTSTRAPPER_H_ |
| OLD | NEW |