OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/heap/objects-visiting.h" | 7 #include "src/heap/objects-visiting.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 | 11 |
12 | 12 |
13 StaticVisitorBase::VisitorId StaticVisitorBase::GetVisitorId( | 13 StaticVisitorBase::VisitorId StaticVisitorBase::GetVisitorId( |
14 int instance_type, int instance_size) { | 14 int instance_type, int instance_size, bool has_unboxed_fields) { |
15 if (instance_type < FIRST_NONSTRING_TYPE) { | 15 if (instance_type < FIRST_NONSTRING_TYPE) { |
16 switch (instance_type & kStringRepresentationMask) { | 16 switch (instance_type & kStringRepresentationMask) { |
17 case kSeqStringTag: | 17 case kSeqStringTag: |
18 if ((instance_type & kStringEncodingMask) == kOneByteStringTag) { | 18 if ((instance_type & kStringEncodingMask) == kOneByteStringTag) { |
19 return kVisitSeqOneByteString; | 19 return kVisitSeqOneByteString; |
20 } else { | 20 } else { |
21 return kVisitSeqTwoByteString; | 21 return kVisitSeqTwoByteString; |
22 } | 22 } |
23 | 23 |
24 case kConsStringTag: | 24 case kConsStringTag: |
25 if (IsShortcutCandidate(instance_type)) { | 25 if (IsShortcutCandidate(instance_type)) { |
26 return kVisitShortcutCandidate; | 26 return kVisitShortcutCandidate; |
27 } else { | 27 } else { |
28 return kVisitConsString; | 28 return kVisitConsString; |
29 } | 29 } |
30 | 30 |
31 case kSlicedStringTag: | 31 case kSlicedStringTag: |
32 return kVisitSlicedString; | 32 return kVisitSlicedString; |
33 | 33 |
34 case kExternalStringTag: | 34 case kExternalStringTag: |
35 return GetVisitorIdForSize(kVisitDataObject, kVisitDataObjectGeneric, | 35 return GetVisitorIdForSize(kVisitDataObject, kVisitDataObjectGeneric, |
36 instance_size); | 36 instance_size, has_unboxed_fields); |
37 } | 37 } |
38 UNREACHABLE(); | 38 UNREACHABLE(); |
39 } | 39 } |
40 | 40 |
41 switch (instance_type) { | 41 switch (instance_type) { |
42 case BYTE_ARRAY_TYPE: | 42 case BYTE_ARRAY_TYPE: |
43 return kVisitByteArray; | 43 return kVisitByteArray; |
44 | 44 |
45 case FREE_SPACE_TYPE: | 45 case FREE_SPACE_TYPE: |
46 return kVisitFreeSpace; | 46 return kVisitFreeSpace; |
(...skipping 20 matching lines...) Expand all Loading... |
67 return kVisitCell; | 67 return kVisitCell; |
68 | 68 |
69 case PROPERTY_CELL_TYPE: | 69 case PROPERTY_CELL_TYPE: |
70 return kVisitPropertyCell; | 70 return kVisitPropertyCell; |
71 | 71 |
72 case WEAK_CELL_TYPE: | 72 case WEAK_CELL_TYPE: |
73 return kVisitWeakCell; | 73 return kVisitWeakCell; |
74 | 74 |
75 case JS_SET_TYPE: | 75 case JS_SET_TYPE: |
76 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, | 76 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, |
77 JSSet::kSize); | 77 JSSet::kSize, has_unboxed_fields); |
78 | 78 |
79 case JS_MAP_TYPE: | 79 case JS_MAP_TYPE: |
80 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, | 80 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, |
81 JSMap::kSize); | 81 JSMap::kSize, has_unboxed_fields); |
82 | 82 |
83 case JS_WEAK_MAP_TYPE: | 83 case JS_WEAK_MAP_TYPE: |
84 case JS_WEAK_SET_TYPE: | 84 case JS_WEAK_SET_TYPE: |
85 return kVisitJSWeakCollection; | 85 return kVisitJSWeakCollection; |
86 | 86 |
87 case JS_REGEXP_TYPE: | 87 case JS_REGEXP_TYPE: |
88 return kVisitJSRegExp; | 88 return kVisitJSRegExp; |
89 | 89 |
90 case SHARED_FUNCTION_INFO_TYPE: | 90 case SHARED_FUNCTION_INFO_TYPE: |
91 return kVisitSharedFunctionInfo; | 91 return kVisitSharedFunctionInfo; |
92 | 92 |
93 case JS_PROXY_TYPE: | 93 case JS_PROXY_TYPE: |
94 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, | 94 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, |
95 JSProxy::kSize); | 95 JSProxy::kSize, has_unboxed_fields); |
96 | 96 |
97 case JS_FUNCTION_PROXY_TYPE: | 97 case JS_FUNCTION_PROXY_TYPE: |
98 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, | 98 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, |
99 JSFunctionProxy::kSize); | 99 JSFunctionProxy::kSize, has_unboxed_fields); |
100 | 100 |
101 case FOREIGN_TYPE: | 101 case FOREIGN_TYPE: |
102 return GetVisitorIdForSize(kVisitDataObject, kVisitDataObjectGeneric, | 102 return GetVisitorIdForSize(kVisitDataObject, kVisitDataObjectGeneric, |
103 Foreign::kSize); | 103 Foreign::kSize, has_unboxed_fields); |
104 | 104 |
105 case SYMBOL_TYPE: | 105 case SYMBOL_TYPE: |
106 return kVisitSymbol; | 106 return kVisitSymbol; |
107 | 107 |
108 case FILLER_TYPE: | 108 case FILLER_TYPE: |
109 return kVisitDataObjectGeneric; | 109 return kVisitDataObjectGeneric; |
110 | 110 |
111 case JS_ARRAY_BUFFER_TYPE: | 111 case JS_ARRAY_BUFFER_TYPE: |
112 return kVisitJSArrayBuffer; | 112 return kVisitJSArrayBuffer; |
113 | 113 |
(...skipping 10 matching lines...) Expand all Loading... |
124 case JS_VALUE_TYPE: | 124 case JS_VALUE_TYPE: |
125 case JS_DATE_TYPE: | 125 case JS_DATE_TYPE: |
126 case JS_ARRAY_TYPE: | 126 case JS_ARRAY_TYPE: |
127 case JS_GLOBAL_PROXY_TYPE: | 127 case JS_GLOBAL_PROXY_TYPE: |
128 case JS_GLOBAL_OBJECT_TYPE: | 128 case JS_GLOBAL_OBJECT_TYPE: |
129 case JS_BUILTINS_OBJECT_TYPE: | 129 case JS_BUILTINS_OBJECT_TYPE: |
130 case JS_MESSAGE_OBJECT_TYPE: | 130 case JS_MESSAGE_OBJECT_TYPE: |
131 case JS_SET_ITERATOR_TYPE: | 131 case JS_SET_ITERATOR_TYPE: |
132 case JS_MAP_ITERATOR_TYPE: | 132 case JS_MAP_ITERATOR_TYPE: |
133 return GetVisitorIdForSize(kVisitJSObject, kVisitJSObjectGeneric, | 133 return GetVisitorIdForSize(kVisitJSObject, kVisitJSObjectGeneric, |
134 instance_size); | 134 instance_size, has_unboxed_fields); |
135 | 135 |
136 case JS_FUNCTION_TYPE: | 136 case JS_FUNCTION_TYPE: |
137 return kVisitJSFunction; | 137 return kVisitJSFunction; |
138 | 138 |
139 case HEAP_NUMBER_TYPE: | 139 case HEAP_NUMBER_TYPE: |
140 case MUTABLE_HEAP_NUMBER_TYPE: | 140 case MUTABLE_HEAP_NUMBER_TYPE: |
141 #define EXTERNAL_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 141 #define EXTERNAL_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
142 case EXTERNAL_##TYPE##_ARRAY_TYPE: | 142 case EXTERNAL_##TYPE##_ARRAY_TYPE: |
143 | 143 |
144 TYPED_ARRAYS(EXTERNAL_ARRAY_CASE) | 144 TYPED_ARRAYS(EXTERNAL_ARRAY_CASE) |
145 return GetVisitorIdForSize(kVisitDataObject, kVisitDataObjectGeneric, | 145 return GetVisitorIdForSize(kVisitDataObject, kVisitDataObjectGeneric, |
146 instance_size); | 146 instance_size, has_unboxed_fields); |
147 #undef EXTERNAL_ARRAY_CASE | 147 #undef EXTERNAL_ARRAY_CASE |
148 | 148 |
149 case FIXED_UINT8_ARRAY_TYPE: | 149 case FIXED_UINT8_ARRAY_TYPE: |
150 case FIXED_INT8_ARRAY_TYPE: | 150 case FIXED_INT8_ARRAY_TYPE: |
151 case FIXED_UINT16_ARRAY_TYPE: | 151 case FIXED_UINT16_ARRAY_TYPE: |
152 case FIXED_INT16_ARRAY_TYPE: | 152 case FIXED_INT16_ARRAY_TYPE: |
153 case FIXED_UINT32_ARRAY_TYPE: | 153 case FIXED_UINT32_ARRAY_TYPE: |
154 case FIXED_INT32_ARRAY_TYPE: | 154 case FIXED_INT32_ARRAY_TYPE: |
155 case FIXED_FLOAT32_ARRAY_TYPE: | 155 case FIXED_FLOAT32_ARRAY_TYPE: |
156 case FIXED_UINT8_CLAMPED_ARRAY_TYPE: | 156 case FIXED_UINT8_CLAMPED_ARRAY_TYPE: |
157 return kVisitFixedTypedArray; | 157 return kVisitFixedTypedArray; |
158 | 158 |
159 case FIXED_FLOAT64_ARRAY_TYPE: | 159 case FIXED_FLOAT64_ARRAY_TYPE: |
160 return kVisitFixedFloat64Array; | 160 return kVisitFixedFloat64Array; |
161 | 161 |
162 #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: | 162 #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: |
163 STRUCT_LIST(MAKE_STRUCT_CASE) | 163 STRUCT_LIST(MAKE_STRUCT_CASE) |
164 #undef MAKE_STRUCT_CASE | 164 #undef MAKE_STRUCT_CASE |
165 if (instance_type == ALLOCATION_SITE_TYPE) { | 165 if (instance_type == ALLOCATION_SITE_TYPE) { |
166 return kVisitAllocationSite; | 166 return kVisitAllocationSite; |
167 } | 167 } |
168 | 168 |
169 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, | 169 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, |
170 instance_size); | 170 instance_size, has_unboxed_fields); |
171 | 171 |
172 default: | 172 default: |
173 UNREACHABLE(); | 173 UNREACHABLE(); |
174 return kVisitorIdCount; | 174 return kVisitorIdCount; |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 | 178 |
179 // We don't record weak slots during marking or scavenges. Instead we do it | 179 // We don't record weak slots during marking or scavenges. Instead we do it |
180 // once when we complete mark-compact cycle. Note that write barrier has no | 180 // once when we complete mark-compact cycle. Note that write barrier has no |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 407 |
408 | 408 |
409 template Object* VisitWeakList<JSArrayBuffer>(Heap* heap, Object* list, | 409 template Object* VisitWeakList<JSArrayBuffer>(Heap* heap, Object* list, |
410 WeakObjectRetainer* retainer); | 410 WeakObjectRetainer* retainer); |
411 | 411 |
412 | 412 |
413 template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list, | 413 template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list, |
414 WeakObjectRetainer* retainer); | 414 WeakObjectRetainer* retainer); |
415 } | 415 } |
416 } // namespace v8::internal | 416 } // namespace v8::internal |
OLD | NEW |