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 #include "src/snapshot/natives.h" |
9 | 10 |
10 namespace v8 { | 11 namespace v8 { |
11 namespace internal { | 12 namespace internal { |
12 | 13 |
13 // A SourceCodeCache uses a FixedArray to store pairs of | 14 // A SourceCodeCache uses a FixedArray to store pairs of |
14 // (OneByteString*, JSFunction*), mapping names of native code files | 15 // (OneByteString*, JSFunction*), mapping names of native code files |
15 // (runtime.js, etc.) to precompiled functions. Instead of mapping | 16 // (runtime.js, etc.) to precompiled functions. Instead of mapping |
16 // names to functions it might make sense to let the JS2C tool | 17 // names to functions it might make sense to let the JS2C tool |
17 // generate an index for each native JS file. | 18 // generate an index for each native JS file. |
18 class SourceCodeCache final BASE_EMBEDDED { | 19 class SourceCodeCache final BASE_EMBEDDED { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 MaybeHandle<JSGlobalProxy> maybe_global_proxy, | 90 MaybeHandle<JSGlobalProxy> maybe_global_proxy, |
90 v8::Local<v8::ObjectTemplate> global_object_template); | 91 v8::Local<v8::ObjectTemplate> global_object_template); |
91 | 92 |
92 // Detach the environment from its outer global object. | 93 // Detach the environment from its outer global object. |
93 void DetachGlobal(Handle<Context> env); | 94 void DetachGlobal(Handle<Context> env); |
94 | 95 |
95 // Traverses the pointers for memory management. | 96 // Traverses the pointers for memory management. |
96 void Iterate(ObjectVisitor* v); | 97 void Iterate(ObjectVisitor* v); |
97 | 98 |
98 // Accessor for the native scripts source code. | 99 // Accessor for the native scripts source code. |
99 template <class Source> | 100 Handle<String> GetNativeSource(NativeType type, int index); |
100 Handle<String> SourceLookup(int index); | |
101 | 101 |
102 // Tells whether bootstrapping is active. | 102 // Tells whether bootstrapping is active. |
103 bool IsActive() const { return nesting_ != 0; } | 103 bool IsActive() const { return nesting_ != 0; } |
104 | 104 |
105 // Support for thread preemption. | 105 // Support for thread preemption. |
106 static int ArchiveSpacePerThread(); | 106 static int ArchiveSpacePerThread(); |
107 char* ArchiveState(char* to); | 107 char* ArchiveState(char* to); |
108 char* RestoreState(char* from); | 108 char* RestoreState(char* from); |
109 void FreeThreadResources(); | 109 void FreeThreadResources(); |
110 | 110 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 ~BootstrapperActive() { | 156 ~BootstrapperActive() { |
157 --bootstrapper_->nesting_; | 157 --bootstrapper_->nesting_; |
158 } | 158 } |
159 | 159 |
160 private: | 160 private: |
161 Bootstrapper* bootstrapper_; | 161 Bootstrapper* bootstrapper_; |
162 | 162 |
163 DISALLOW_COPY_AND_ASSIGN(BootstrapperActive); | 163 DISALLOW_COPY_AND_ASSIGN(BootstrapperActive); |
164 }; | 164 }; |
165 | 165 |
166 | |
167 class NativesExternalStringResource final | |
168 : public v8::String::ExternalOneByteStringResource { | |
169 public: | |
170 NativesExternalStringResource(const char* source, size_t length) | |
171 : data_(source), length_(length) {} | |
172 const char* data() const override { return data_; } | |
173 size_t length() const override { return length_; } | |
174 | |
175 private: | |
176 const char* data_; | |
177 size_t length_; | |
178 }; | |
179 | |
180 } // namespace internal | 166 } // namespace internal |
181 } // namespace v8 | 167 } // namespace v8 |
182 | 168 |
183 #endif // V8_BOOTSTRAPPER_H_ | 169 #endif // V8_BOOTSTRAPPER_H_ |
OLD | NEW |