Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // The common functionality when building with internal or external natives. | |
| 6 | |
| 7 #include "src/heap/heap.h" | |
| 8 #include "src/objects.h" | |
| 9 #include "src/snapshot/natives.h" | |
| 10 | |
| 11 namespace v8 { | |
| 12 namespace internal { | |
| 13 | |
| 14 template <NativeType type> | |
| 15 FixedArray* NativesCollectionBase<type>::GetSourceCache(Heap* heap) { | |
|
Michael Starzinger
2015/08/18 12:05:56
First trying to templatize NativesCollection and t
| |
| 16 switch (type) { | |
| 17 case CORE: | |
| 18 return heap->natives_source_cache(); | |
| 19 case EXPERIMENTAL: | |
| 20 return heap->experimental_natives_source_cache(); | |
| 21 case CODE_STUB: | |
| 22 return heap->code_stub_natives_source_cache(); | |
| 23 case EXTRAS: | |
| 24 return heap->extra_natives_source_cache(); | |
| 25 default: | |
| 26 UNREACHABLE(); | |
| 27 return NULL; | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 | |
| 32 template <NativeType type> | |
| 33 void NativesCollectionBase<type>::UpdateSourceCache(Heap* heap) { | |
| 34 FixedArray* cache = GetSourceCache(heap); | |
| 35 for (int i = 0; i < cache->length(); i++) { | |
| 36 Object* source = cache->get(i); | |
| 37 if (!source->IsUndefined()) { | |
| 38 ExternalOneByteString::cast(source)->update_data_cache(); | |
| 39 } | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 | |
| 44 // Explicit template instantiation. | |
| 45 template class NativesCollectionBase<CORE>; | |
| 46 template class NativesCollectionBase<CODE_STUB>; | |
| 47 template class NativesCollectionBase<EXPERIMENTAL>; | |
| 48 template class NativesCollectionBase<EXTRAS>; | |
| 49 } // namespace internal | |
| 50 } // namespace v8 | |
| OLD | NEW |