V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
roots.cc
1 // Copyright 2018 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 #include "src/roots.h"
6 
7 #include "src/elements-kind.h"
8 #include "src/visitors.h"
9 
10 namespace v8 {
11 namespace internal {
12 
13 const char* RootsTable::root_names_[RootsTable::kEntriesCount] = {
14 #define ROOT_NAME(type, name, CamelName) #name,
15  ROOT_LIST(ROOT_NAME)
16 #undef ROOT_NAME
17 };
18 
19 // static
20 RootIndex RootsTable::RootIndexForFixedTypedArray(
21  ExternalArrayType array_type) {
22  switch (array_type) {
23 #define ARRAY_TYPE_TO_ROOT_INDEX(Type, type, TYPE, ctype) \
24  case kExternal##Type##Array: \
25  return RootIndex::kFixed##Type##ArrayMap;
26 
27  TYPED_ARRAYS(ARRAY_TYPE_TO_ROOT_INDEX)
28 #undef ARRAY_TYPE_TO_ROOT_INDEX
29  }
30  UNREACHABLE();
31 }
32 
33 // static
34 RootIndex RootsTable::RootIndexForFixedTypedArray(ElementsKind elements_kind) {
35  switch (elements_kind) {
36 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype) \
37  case TYPE##_ELEMENTS: \
38  return RootIndex::kFixed##Type##ArrayMap;
39  TYPED_ARRAYS(TYPED_ARRAY_CASE)
40  default:
41  UNREACHABLE();
42 #undef TYPED_ARRAY_CASE
43  }
44 }
45 
46 // static
47 RootIndex RootsTable::RootIndexForEmptyFixedTypedArray(
48  ElementsKind elements_kind) {
49  switch (elements_kind) {
50 #define ELEMENT_KIND_TO_ROOT_INDEX(Type, type, TYPE, ctype) \
51  case TYPE##_ELEMENTS: \
52  return RootIndex::kEmptyFixed##Type##Array;
53 
54  TYPED_ARRAYS(ELEMENT_KIND_TO_ROOT_INDEX)
55 #undef ELEMENT_KIND_TO_ROOT_INDEX
56  default:
57  UNREACHABLE();
58  }
59 }
60 
61 void ReadOnlyRoots::Iterate(RootVisitor* visitor) {
62  visitor->VisitRootPointers(Root::kReadOnlyRootList, nullptr,
63  roots_table_.read_only_roots_begin(),
64  roots_table_.read_only_roots_end());
65  visitor->Synchronize(VisitorSynchronization::kReadOnlyRootList);
66 }
67 
68 } // namespace internal
69 } // namespace v8
Definition: libplatform.h:13