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 #include "src/snapshot/natives.h" | 5 #include "src/snapshot/natives.h" |
6 | 6 |
7 #include "src/base/logging.h" | 7 #include "src/base/logging.h" |
8 #include "src/list.h" | 8 #include "src/list.h" |
9 #include "src/list-inl.h" | 9 #include "src/list-inl.h" |
10 #include "src/snapshot/snapshot-source-sink.h" | 10 #include "src/snapshot/snapshot-source-sink.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 static StartupData* natives_blob_ = NULL; | 144 static StartupData* natives_blob_ = NULL; |
145 | 145 |
146 | 146 |
147 /** | 147 /** |
148 * Read the Natives blob, as previously set by SetNativesFromFile. | 148 * Read the Natives blob, as previously set by SetNativesFromFile. |
149 */ | 149 */ |
150 void ReadNatives() { | 150 void ReadNatives() { |
151 if (natives_blob_ && NativesHolder<CORE>::empty()) { | 151 if (natives_blob_ && NativesHolder<CORE>::empty()) { |
152 SnapshotByteSource bytes(natives_blob_->data, natives_blob_->raw_size); | 152 SnapshotByteSource bytes(natives_blob_->data, natives_blob_->raw_size); |
153 NativesHolder<CORE>::set(NativesStore::MakeFromScriptsSource(&bytes)); | 153 NativesHolder<CORE>::set(NativesStore::MakeFromScriptsSource(&bytes)); |
| 154 NativesHolder<EXPERIMENTAL>::set( |
| 155 NativesStore::MakeFromScriptsSource(&bytes)); |
154 NativesHolder<EXTRAS>::set(NativesStore::MakeFromScriptsSource(&bytes)); | 156 NativesHolder<EXTRAS>::set(NativesStore::MakeFromScriptsSource(&bytes)); |
155 NativesHolder<EXPERIMENTAL_EXTRAS>::set( | 157 NativesHolder<EXPERIMENTAL_EXTRAS>::set( |
156 NativesStore::MakeFromScriptsSource(&bytes)); | 158 NativesStore::MakeFromScriptsSource(&bytes)); |
157 DCHECK(!bytes.HasMore()); | 159 DCHECK(!bytes.HasMore()); |
158 } | 160 } |
159 } | 161 } |
160 | 162 |
161 | 163 |
162 /** | 164 /** |
163 * Set the Natives (library sources) blob, as generated by js2c + the build | 165 * Set the Natives (library sources) blob, as generated by js2c + the build |
164 * system. | 166 * system. |
165 */ | 167 */ |
166 void SetNativesFromFile(StartupData* natives_blob) { | 168 void SetNativesFromFile(StartupData* natives_blob) { |
167 DCHECK(!natives_blob_); | 169 DCHECK(!natives_blob_); |
168 DCHECK(natives_blob); | 170 DCHECK(natives_blob); |
169 DCHECK(natives_blob->data); | 171 DCHECK(natives_blob->data); |
170 DCHECK(natives_blob->raw_size > 0); | 172 DCHECK(natives_blob->raw_size > 0); |
171 | 173 |
172 natives_blob_ = natives_blob; | 174 natives_blob_ = natives_blob; |
173 ReadNatives(); | 175 ReadNatives(); |
174 } | 176 } |
175 | 177 |
176 | 178 |
177 /** | 179 /** |
178 * Release memory allocated by SetNativesFromFile. | 180 * Release memory allocated by SetNativesFromFile. |
179 */ | 181 */ |
180 void DisposeNatives() { | 182 void DisposeNatives() { |
181 NativesHolder<CORE>::Dispose(); | 183 NativesHolder<CORE>::Dispose(); |
| 184 NativesHolder<EXPERIMENTAL>::Dispose(); |
182 NativesHolder<EXTRAS>::Dispose(); | 185 NativesHolder<EXTRAS>::Dispose(); |
183 NativesHolder<EXPERIMENTAL_EXTRAS>::Dispose(); | 186 NativesHolder<EXPERIMENTAL_EXTRAS>::Dispose(); |
184 } | 187 } |
185 | 188 |
186 | 189 |
187 // Implement NativesCollection<T> bsaed on NativesHolder + NativesStore. | 190 // Implement NativesCollection<T> bsaed on NativesHolder + NativesStore. |
188 // | 191 // |
189 // (The callers expect a purely static interface, since this is how the | 192 // (The callers expect a purely static interface, since this is how the |
190 // natives are usually compiled in. Since we implement them based on | 193 // natives are usually compiled in. Since we implement them based on |
191 // runtime content, we have to implement this indirection to offer | 194 // runtime content, we have to implement this indirection to offer |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 226 |
224 // Explicit template instantiations. | 227 // Explicit template instantiations. |
225 #define INSTANTIATE_TEMPLATES(T) \ | 228 #define INSTANTIATE_TEMPLATES(T) \ |
226 template int NativesCollection<T>::GetBuiltinsCount(); \ | 229 template int NativesCollection<T>::GetBuiltinsCount(); \ |
227 template int NativesCollection<T>::GetDebuggerCount(); \ | 230 template int NativesCollection<T>::GetDebuggerCount(); \ |
228 template int NativesCollection<T>::GetIndex(const char* name); \ | 231 template int NativesCollection<T>::GetIndex(const char* name); \ |
229 template Vector<const char> NativesCollection<T>::GetScriptSource(int i); \ | 232 template Vector<const char> NativesCollection<T>::GetScriptSource(int i); \ |
230 template Vector<const char> NativesCollection<T>::GetScriptName(int i); \ | 233 template Vector<const char> NativesCollection<T>::GetScriptName(int i); \ |
231 template Vector<const char> NativesCollection<T>::GetScriptsSource(); | 234 template Vector<const char> NativesCollection<T>::GetScriptsSource(); |
232 INSTANTIATE_TEMPLATES(CORE) | 235 INSTANTIATE_TEMPLATES(CORE) |
| 236 INSTANTIATE_TEMPLATES(EXPERIMENTAL) |
233 INSTANTIATE_TEMPLATES(EXTRAS) | 237 INSTANTIATE_TEMPLATES(EXTRAS) |
234 INSTANTIATE_TEMPLATES(EXPERIMENTAL_EXTRAS) | 238 INSTANTIATE_TEMPLATES(EXPERIMENTAL_EXTRAS) |
235 #undef INSTANTIATE_TEMPLATES | 239 #undef INSTANTIATE_TEMPLATES |
236 | 240 |
237 } // namespace internal | 241 } // namespace internal |
238 } // namespace v8 | 242 } // namespace v8 |
OLD | NEW |