blob: f30e7940098e571ebb08d3284840c33c706b97b9 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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-inl.h"
9#include "src/snapshot/natives.h"
10
11namespace v8 {
12namespace internal {
13
14template <>
15FixedArray* NativesCollection<CORE>::GetSourceCache(Heap* heap) {
16 return heap->natives_source_cache();
17}
18
19
20template <>
21FixedArray* NativesCollection<EXPERIMENTAL>::GetSourceCache(Heap* heap) {
22 return heap->experimental_natives_source_cache();
23}
24
25
26template <>
27FixedArray* NativesCollection<EXTRAS>::GetSourceCache(Heap* heap) {
28 return heap->extra_natives_source_cache();
29}
30
31
32template <>
33FixedArray* NativesCollection<EXPERIMENTAL_EXTRAS>::GetSourceCache(Heap* heap) {
34 return heap->experimental_extra_natives_source_cache();
35}
36
37
38template <NativeType type>
39void NativesCollection<type>::UpdateSourceCache(Heap* heap) {
40 for (int i = 0; i < GetBuiltinsCount(); i++) {
41 Object* source = GetSourceCache(heap)->get(i);
42 if (!source->IsUndefined()) {
43 ExternalOneByteString::cast(source)->update_data_cache();
44 }
45 }
46}
47
48
49// Explicit template instantiations.
50template void NativesCollection<CORE>::UpdateSourceCache(Heap* heap);
51template void NativesCollection<EXPERIMENTAL>::UpdateSourceCache(Heap* heap);
52template void NativesCollection<EXTRAS>::UpdateSourceCache(Heap* heap);
53template void NativesCollection<EXPERIMENTAL_EXTRAS>::UpdateSourceCache(
54 Heap* heap);
55
56} // namespace internal
57} // namespace v8