Chromium Code Reviews| Index: src/snapshot/natives-common.cc |
| diff --git a/src/snapshot/natives-common.cc b/src/snapshot/natives-common.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b0ee9c6d8afae0ea1008147740f4f6112354b273 |
| --- /dev/null |
| +++ b/src/snapshot/natives-common.cc |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2015 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// The common functionality when building with internal or external natives. |
| + |
| +#include "src/heap/heap.h" |
| +#include "src/objects.h" |
| +#include "src/snapshot/natives.h" |
| + |
| +namespace v8 { |
| +namespace internal { |
| + |
| +template <NativeType type> |
| +FixedArray* NativesCollectionBase<type>::GetSourceCache(Heap* heap) { |
|
Michael Starzinger
2015/08/18 12:05:56
First trying to templatize NativesCollection and t
|
| + switch (type) { |
| + case CORE: |
| + return heap->natives_source_cache(); |
| + case EXPERIMENTAL: |
| + return heap->experimental_natives_source_cache(); |
| + case CODE_STUB: |
| + return heap->code_stub_natives_source_cache(); |
| + case EXTRAS: |
| + return heap->extra_natives_source_cache(); |
| + default: |
| + UNREACHABLE(); |
| + return NULL; |
| + } |
| +} |
| + |
| + |
| +template <NativeType type> |
| +void NativesCollectionBase<type>::UpdateSourceCache(Heap* heap) { |
| + FixedArray* cache = GetSourceCache(heap); |
| + for (int i = 0; i < cache->length(); i++) { |
| + Object* source = cache->get(i); |
| + if (!source->IsUndefined()) { |
| + ExternalOneByteString::cast(source)->update_data_cache(); |
| + } |
| + } |
| +} |
| + |
| + |
| +// Explicit template instantiation. |
| +template class NativesCollectionBase<CORE>; |
| +template class NativesCollectionBase<CODE_STUB>; |
| +template class NativesCollectionBase<EXPERIMENTAL>; |
| +template class NativesCollectionBase<EXTRAS>; |
| +} // namespace internal |
| +} // namespace v8 |