| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 150 static StartupData* natives_blob_ = NULL; | 150 static StartupData* natives_blob_ = NULL; | 
| 151 | 151 | 
| 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<CODE_STUB>::set(NativesStore::MakeFromScriptsSource(&bytes)); |  | 
| 161     NativesHolder<EXPERIMENTAL>::set( | 160     NativesHolder<EXPERIMENTAL>::set( | 
| 162         NativesStore::MakeFromScriptsSource(&bytes)); | 161         NativesStore::MakeFromScriptsSource(&bytes)); | 
| 163     NativesHolder<EXTRAS>::set(NativesStore::MakeFromScriptsSource(&bytes)); | 162     NativesHolder<EXTRAS>::set(NativesStore::MakeFromScriptsSource(&bytes)); | 
| 164     NativesHolder<EXPERIMENTAL_EXTRAS>::set( | 163     NativesHolder<EXPERIMENTAL_EXTRAS>::set( | 
| 165         NativesStore::MakeFromScriptsSource(&bytes)); | 164         NativesStore::MakeFromScriptsSource(&bytes)); | 
| 166     DCHECK(!bytes.HasMore()); | 165     DCHECK(!bytes.HasMore()); | 
| 167   } | 166   } | 
| 168 } | 167 } | 
| 169 | 168 | 
| 170 | 169 | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 181   natives_blob_ = natives_blob; | 180   natives_blob_ = natives_blob; | 
| 182   ReadNatives(); | 181   ReadNatives(); | 
| 183 } | 182 } | 
| 184 | 183 | 
| 185 | 184 | 
| 186 /** | 185 /** | 
| 187  * Release memory allocated by SetNativesFromFile. | 186  * Release memory allocated by SetNativesFromFile. | 
| 188  */ | 187  */ | 
| 189 void DisposeNatives() { | 188 void DisposeNatives() { | 
| 190   NativesHolder<CORE>::Dispose(); | 189   NativesHolder<CORE>::Dispose(); | 
| 191   NativesHolder<CODE_STUB>::Dispose(); |  | 
| 192   NativesHolder<EXPERIMENTAL>::Dispose(); | 190   NativesHolder<EXPERIMENTAL>::Dispose(); | 
| 193   NativesHolder<EXTRAS>::Dispose(); | 191   NativesHolder<EXTRAS>::Dispose(); | 
| 194   NativesHolder<EXPERIMENTAL_EXTRAS>::Dispose(); | 192   NativesHolder<EXPERIMENTAL_EXTRAS>::Dispose(); | 
| 195 } | 193 } | 
| 196 | 194 | 
| 197 | 195 | 
| 198 // Implement NativesCollection<T> bsaed on NativesHolder + NativesStore. | 196 // Implement NativesCollection<T> bsaed on NativesHolder + NativesStore. | 
| 199 // | 197 // | 
| 200 // (The callers expect a purely static interface, since this is how the | 198 // (The callers expect a purely static interface, since this is how the | 
| 201 //  natives are usually compiled in. Since we implement them based on | 199 //  natives are usually compiled in. Since we implement them based on | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 234 | 232 | 
| 235 // Explicit template instantiations. | 233 // Explicit template instantiations. | 
| 236 #define INSTANTIATE_TEMPLATES(T)                                            \ | 234 #define INSTANTIATE_TEMPLATES(T)                                            \ | 
| 237   template int NativesCollection<T>::GetBuiltinsCount();                    \ | 235   template int NativesCollection<T>::GetBuiltinsCount();                    \ | 
| 238   template int NativesCollection<T>::GetDebuggerCount();                    \ | 236   template int NativesCollection<T>::GetDebuggerCount();                    \ | 
| 239   template int NativesCollection<T>::GetIndex(const char* name);            \ | 237   template int NativesCollection<T>::GetIndex(const char* name);            \ | 
| 240   template Vector<const char> NativesCollection<T>::GetScriptSource(int i); \ | 238   template Vector<const char> NativesCollection<T>::GetScriptSource(int i); \ | 
| 241   template Vector<const char> NativesCollection<T>::GetScriptName(int i);   \ | 239   template Vector<const char> NativesCollection<T>::GetScriptName(int i);   \ | 
| 242   template Vector<const char> NativesCollection<T>::GetScriptsSource(); | 240   template Vector<const char> NativesCollection<T>::GetScriptsSource(); | 
| 243 INSTANTIATE_TEMPLATES(CORE) | 241 INSTANTIATE_TEMPLATES(CORE) | 
| 244 INSTANTIATE_TEMPLATES(CODE_STUB) |  | 
| 245 INSTANTIATE_TEMPLATES(EXPERIMENTAL) | 242 INSTANTIATE_TEMPLATES(EXPERIMENTAL) | 
| 246 INSTANTIATE_TEMPLATES(EXTRAS) | 243 INSTANTIATE_TEMPLATES(EXTRAS) | 
| 247 INSTANTIATE_TEMPLATES(EXPERIMENTAL_EXTRAS) | 244 INSTANTIATE_TEMPLATES(EXPERIMENTAL_EXTRAS) | 
| 248 #undef INSTANTIATE_TEMPLATES | 245 #undef INSTANTIATE_TEMPLATES | 
| 249 | 246 | 
| 250 }  // namespace internal | 247 }  // namespace internal | 
| 251 }  // namespace v8 | 248 }  // namespace v8 | 
| OLD | NEW | 
|---|