v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
objects-visiting.cc
Go to the documentation of this file.
1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #include "v8.h"
29 
30 #include "ic-inl.h"
31 #include "objects-visiting.h"
32 
33 namespace v8 {
34 namespace internal {
35 
36 
37 static inline bool IsShortcutCandidate(int type) {
38  return ((type & kShortcutTypeMask) == kShortcutTypeTag);
39 }
40 
41 
43  int instance_type,
44  int instance_size) {
45  if (instance_type < FIRST_NONSTRING_TYPE) {
46  switch (instance_type & kStringRepresentationMask) {
47  case kSeqStringTag:
48  if ((instance_type & kStringEncodingMask) == kOneByteStringTag) {
49  return kVisitSeqOneByteString;
50  } else {
51  return kVisitSeqTwoByteString;
52  }
53 
54  case kConsStringTag:
55  if (IsShortcutCandidate(instance_type)) {
56  return kVisitShortcutCandidate;
57  } else {
58  return kVisitConsString;
59  }
60 
61  case kSlicedStringTag:
62  return kVisitSlicedString;
63 
64  case kExternalStringTag:
66  kVisitDataObjectGeneric,
67  instance_size);
68  }
69  UNREACHABLE();
70  }
71 
72  switch (instance_type) {
73  case BYTE_ARRAY_TYPE:
74  return kVisitByteArray;
75 
76  case FREE_SPACE_TYPE:
77  return kVisitFreeSpace;
78 
79  case FIXED_ARRAY_TYPE:
80  return kVisitFixedArray;
81 
83  return kVisitFixedDoubleArray;
84 
86  return kVisitConstantPoolArray;
87 
88  case ODDBALL_TYPE:
89  return kVisitOddball;
90 
91  case MAP_TYPE:
92  return kVisitMap;
93 
94  case CODE_TYPE:
95  return kVisitCode;
96 
97  case CELL_TYPE:
98  return kVisitCell;
99 
100  case PROPERTY_CELL_TYPE:
101  return kVisitPropertyCell;
102 
103  case JS_SET_TYPE:
105  kVisitStructGeneric,
106  JSSet::kSize);
107 
108  case JS_MAP_TYPE:
110  kVisitStructGeneric,
111  JSMap::kSize);
112 
113  case JS_WEAK_MAP_TYPE:
114  return kVisitJSWeakMap;
115 
116  case JS_WEAK_SET_TYPE:
117  return kVisitJSWeakSet;
118 
119  case JS_REGEXP_TYPE:
120  return kVisitJSRegExp;
121 
123  return kVisitSharedFunctionInfo;
124 
125  case JS_PROXY_TYPE:
127  kVisitStructGeneric,
129 
132  kVisitStructGeneric,
134 
135  case FOREIGN_TYPE:
137  kVisitDataObjectGeneric,
139 
140  case SYMBOL_TYPE:
141  return kVisitSymbol;
142 
143  case FILLER_TYPE:
144  return kVisitDataObjectGeneric;
145 
147  return kVisitJSArrayBuffer;
148 
149  case JS_TYPED_ARRAY_TYPE:
150  return kVisitJSTypedArray;
151 
152  case JS_DATA_VIEW_TYPE:
153  return kVisitJSDataView;
154 
155  case JS_OBJECT_TYPE:
158  case JS_MODULE_TYPE:
159  case JS_VALUE_TYPE:
160  case JS_DATE_TYPE:
161  case JS_ARRAY_TYPE:
167  kVisitJSObjectGeneric,
168  instance_size);
169 
170  case JS_FUNCTION_TYPE:
171  return kVisitJSFunction;
172 
173  case HEAP_NUMBER_TYPE:
174 #define EXTERNAL_ARRAY_CASE(Type, type, TYPE, ctype, size) \
175  case EXTERNAL_##TYPE##_ARRAY_TYPE:
176 
179  kVisitDataObjectGeneric,
180  instance_size);
181 #undef EXTERNAL_ARRAY_CASE
182 
191  return kVisitFixedTypedArray;
192 
194  return kVisitFixedFloat64Array;
195 
196 #define MAKE_STRUCT_CASE(NAME, Name, name) \
197  case NAME##_TYPE:
199 #undef MAKE_STRUCT_CASE
200  if (instance_type == ALLOCATION_SITE_TYPE) {
201  return kVisitAllocationSite;
202  }
203 
205  kVisitStructGeneric,
206  instance_size);
207 
208  default:
209  UNREACHABLE();
210  return kVisitorIdCount;
211  }
212 }
213 
214 } } // namespace v8::internal
const uint32_t kShortcutTypeTag
Definition: objects.h:656
#define EXTERNAL_ARRAY_CASE(Type, type, TYPE, ctype, size)
static VisitorId GetVisitorIdForSize(VisitorId base, VisitorId generic, int object_size)
static const int kSize
Definition: objects.h:9678
const uint32_t kStringRepresentationMask
Definition: objects.h:615
static const int kSize
Definition: objects.h:9789
static const int kSize
Definition: objects.h:9740
#define MAKE_STRUCT_CASE(NAME, Name, name)
#define UNREACHABLE()
Definition: checks.h:52
const uint32_t kShortcutTypeMask
Definition: objects.h:652
static const int kSize
Definition: objects.h:9768
#define STRUCT_LIST(V)
Definition: objects.h:590
#define TYPED_ARRAYS(V)
Definition: objects.h:4663
const uint32_t kOneByteStringTag
Definition: objects.h:611
static VisitorId GetVisitorId(int instance_type, int instance_size)
static const int kSize
Definition: objects.h:10010
const uint32_t kStringEncodingMask
Definition: objects.h:609