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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 /** | 153 /** |
154 * Read the Natives blob, as previously set by SetNativesFromFile. | 154 * Read the Natives blob, as previously set by SetNativesFromFile. |
155 */ | 155 */ |
156 void ReadNatives() { | 156 void ReadNatives() { |
157 if (natives_blob_ && NativesHolder<CORE>::empty()) { | 157 if (natives_blob_ && NativesHolder<CORE>::empty()) { |
158 SnapshotByteSource bytes(natives_blob_->data, natives_blob_->raw_size); | 158 SnapshotByteSource bytes(natives_blob_->data, natives_blob_->raw_size); |
159 NativesHolder<CORE>::set(NativesStore::MakeFromScriptsSource(&bytes)); | 159 NativesHolder<CORE>::set(NativesStore::MakeFromScriptsSource(&bytes)); |
160 NativesHolder<EXPERIMENTAL>::set( | 160 NativesHolder<EXPERIMENTAL>::set( |
161 NativesStore::MakeFromScriptsSource(&bytes)); | 161 NativesStore::MakeFromScriptsSource(&bytes)); |
| 162 NativesHolder<EXTRAS>::set(NativesStore::MakeFromScriptsSource(&bytes)); |
162 DCHECK(!bytes.HasMore()); | 163 DCHECK(!bytes.HasMore()); |
163 } | 164 } |
164 } | 165 } |
165 | 166 |
166 | 167 |
167 /** | 168 /** |
168 * Set the Natives (library sources) blob, as generated by js2c + the build | 169 * Set the Natives (library sources) blob, as generated by js2c + the build |
169 * system. | 170 * system. |
170 */ | 171 */ |
171 void SetNativesFromFile(StartupData* natives_blob) { | 172 void SetNativesFromFile(StartupData* natives_blob) { |
172 DCHECK(!natives_blob_); | 173 DCHECK(!natives_blob_); |
173 DCHECK(natives_blob); | 174 DCHECK(natives_blob); |
174 DCHECK(natives_blob->data); | 175 DCHECK(natives_blob->data); |
175 DCHECK(natives_blob->raw_size > 0); | 176 DCHECK(natives_blob->raw_size > 0); |
176 | 177 |
177 natives_blob_ = natives_blob; | 178 natives_blob_ = natives_blob; |
178 ReadNatives(); | 179 ReadNatives(); |
179 } | 180 } |
180 | 181 |
181 | 182 |
182 /** | 183 /** |
183 * Release memory allocated by SetNativesFromFile. | 184 * Release memory allocated by SetNativesFromFile. |
184 */ | 185 */ |
185 void DisposeNatives() { | 186 void DisposeNatives() { |
186 NativesHolder<CORE>::Dispose(); | 187 NativesHolder<CORE>::Dispose(); |
187 NativesHolder<EXPERIMENTAL>::Dispose(); | 188 NativesHolder<EXPERIMENTAL>::Dispose(); |
| 189 NativesHolder<EXTRAS>::Dispose(); |
188 } | 190 } |
189 | 191 |
190 | 192 |
191 // Implement NativesCollection<T> bsaed on NativesHolder + NativesStore. | 193 // Implement NativesCollection<T> bsaed on NativesHolder + NativesStore. |
192 // | 194 // |
193 // (The callers expect a purely static interface, since this is how the | 195 // (The callers expect a purely static interface, since this is how the |
194 // natives are usually compiled in. Since we implement them based on | 196 // natives are usually compiled in. Since we implement them based on |
195 // runtime content, we have to implement this indirection to offer | 197 // runtime content, we have to implement this indirection to offer |
196 // a static interface.) | 198 // a static interface.) |
197 template<NativeType type> | 199 template<NativeType type> |
(...skipping 24 matching lines...) Expand all Loading... |
222 template <NativeType type> | 224 template <NativeType type> |
223 Vector<const char> NativesCollection<type>::GetScriptsSource() { | 225 Vector<const char> NativesCollection<type>::GetScriptsSource() { |
224 return NativesHolder<type>::get()->GetScriptsSource(); | 226 return NativesHolder<type>::get()->GetScriptsSource(); |
225 } | 227 } |
226 | 228 |
227 | 229 |
228 // The compiler can't 'see' all uses of the static methods and hence | 230 // The compiler can't 'see' all uses of the static methods and hence |
229 // my choice to elide them. This we'll explicitly instantiate these. | 231 // my choice to elide them. This we'll explicitly instantiate these. |
230 template class NativesCollection<CORE>; | 232 template class NativesCollection<CORE>; |
231 template class NativesCollection<EXPERIMENTAL>; | 233 template class NativesCollection<EXPERIMENTAL>; |
| 234 template class NativesCollection<EXTRAS>; |
232 | 235 |
233 } // namespace v8::internal | 236 } // namespace v8::internal |
234 } // namespace v8 | 237 } // namespace v8 |
OLD | NEW |