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/ic-inl.h" | 8 #include "src/ic-inl.h" |
8 #include "src/objects-visiting.h" | |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 | 13 |
14 StaticVisitorBase::VisitorId StaticVisitorBase::GetVisitorId( | 14 StaticVisitorBase::VisitorId StaticVisitorBase::GetVisitorId( |
15 int instance_type, | 15 int instance_type, int instance_size) { |
16 int instance_size) { | |
17 if (instance_type < FIRST_NONSTRING_TYPE) { | 16 if (instance_type < FIRST_NONSTRING_TYPE) { |
18 switch (instance_type & kStringRepresentationMask) { | 17 switch (instance_type & kStringRepresentationMask) { |
19 case kSeqStringTag: | 18 case kSeqStringTag: |
20 if ((instance_type & kStringEncodingMask) == kOneByteStringTag) { | 19 if ((instance_type & kStringEncodingMask) == kOneByteStringTag) { |
21 return kVisitSeqOneByteString; | 20 return kVisitSeqOneByteString; |
22 } else { | 21 } else { |
23 return kVisitSeqTwoByteString; | 22 return kVisitSeqTwoByteString; |
24 } | 23 } |
25 | 24 |
26 case kConsStringTag: | 25 case kConsStringTag: |
27 if (IsShortcutCandidate(instance_type)) { | 26 if (IsShortcutCandidate(instance_type)) { |
28 return kVisitShortcutCandidate; | 27 return kVisitShortcutCandidate; |
29 } else { | 28 } else { |
30 return kVisitConsString; | 29 return kVisitConsString; |
31 } | 30 } |
32 | 31 |
33 case kSlicedStringTag: | 32 case kSlicedStringTag: |
34 return kVisitSlicedString; | 33 return kVisitSlicedString; |
35 | 34 |
36 case kExternalStringTag: | 35 case kExternalStringTag: |
37 return GetVisitorIdForSize(kVisitDataObject, | 36 return GetVisitorIdForSize(kVisitDataObject, kVisitDataObjectGeneric, |
38 kVisitDataObjectGeneric, | |
39 instance_size); | 37 instance_size); |
40 } | 38 } |
41 UNREACHABLE(); | 39 UNREACHABLE(); |
42 } | 40 } |
43 | 41 |
44 switch (instance_type) { | 42 switch (instance_type) { |
45 case BYTE_ARRAY_TYPE: | 43 case BYTE_ARRAY_TYPE: |
46 return kVisitByteArray; | 44 return kVisitByteArray; |
47 | 45 |
48 case FREE_SPACE_TYPE: | 46 case FREE_SPACE_TYPE: |
(...skipping 17 matching lines...) Expand all Loading... |
66 case CODE_TYPE: | 64 case CODE_TYPE: |
67 return kVisitCode; | 65 return kVisitCode; |
68 | 66 |
69 case CELL_TYPE: | 67 case CELL_TYPE: |
70 return kVisitCell; | 68 return kVisitCell; |
71 | 69 |
72 case PROPERTY_CELL_TYPE: | 70 case PROPERTY_CELL_TYPE: |
73 return kVisitPropertyCell; | 71 return kVisitPropertyCell; |
74 | 72 |
75 case JS_SET_TYPE: | 73 case JS_SET_TYPE: |
76 return GetVisitorIdForSize(kVisitStruct, | 74 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, |
77 kVisitStructGeneric, | |
78 JSSet::kSize); | 75 JSSet::kSize); |
79 | 76 |
80 case JS_MAP_TYPE: | 77 case JS_MAP_TYPE: |
81 return GetVisitorIdForSize(kVisitStruct, | 78 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, |
82 kVisitStructGeneric, | |
83 JSMap::kSize); | 79 JSMap::kSize); |
84 | 80 |
85 case JS_WEAK_MAP_TYPE: | 81 case JS_WEAK_MAP_TYPE: |
86 case JS_WEAK_SET_TYPE: | 82 case JS_WEAK_SET_TYPE: |
87 return kVisitJSWeakCollection; | 83 return kVisitJSWeakCollection; |
88 | 84 |
89 case JS_REGEXP_TYPE: | 85 case JS_REGEXP_TYPE: |
90 return kVisitJSRegExp; | 86 return kVisitJSRegExp; |
91 | 87 |
92 case SHARED_FUNCTION_INFO_TYPE: | 88 case SHARED_FUNCTION_INFO_TYPE: |
93 return kVisitSharedFunctionInfo; | 89 return kVisitSharedFunctionInfo; |
94 | 90 |
95 case JS_PROXY_TYPE: | 91 case JS_PROXY_TYPE: |
96 return GetVisitorIdForSize(kVisitStruct, | 92 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, |
97 kVisitStructGeneric, | |
98 JSProxy::kSize); | 93 JSProxy::kSize); |
99 | 94 |
100 case JS_FUNCTION_PROXY_TYPE: | 95 case JS_FUNCTION_PROXY_TYPE: |
101 return GetVisitorIdForSize(kVisitStruct, | 96 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, |
102 kVisitStructGeneric, | |
103 JSFunctionProxy::kSize); | 97 JSFunctionProxy::kSize); |
104 | 98 |
105 case FOREIGN_TYPE: | 99 case FOREIGN_TYPE: |
106 return GetVisitorIdForSize(kVisitDataObject, | 100 return GetVisitorIdForSize(kVisitDataObject, kVisitDataObjectGeneric, |
107 kVisitDataObjectGeneric, | |
108 Foreign::kSize); | 101 Foreign::kSize); |
109 | 102 |
110 case SYMBOL_TYPE: | 103 case SYMBOL_TYPE: |
111 return kVisitSymbol; | 104 return kVisitSymbol; |
112 | 105 |
113 case FILLER_TYPE: | 106 case FILLER_TYPE: |
114 return kVisitDataObjectGeneric; | 107 return kVisitDataObjectGeneric; |
115 | 108 |
116 case JS_ARRAY_BUFFER_TYPE: | 109 case JS_ARRAY_BUFFER_TYPE: |
117 return kVisitJSArrayBuffer; | 110 return kVisitJSArrayBuffer; |
(...skipping 10 matching lines...) Expand all Loading... |
128 case JS_MODULE_TYPE: | 121 case JS_MODULE_TYPE: |
129 case JS_VALUE_TYPE: | 122 case JS_VALUE_TYPE: |
130 case JS_DATE_TYPE: | 123 case JS_DATE_TYPE: |
131 case JS_ARRAY_TYPE: | 124 case JS_ARRAY_TYPE: |
132 case JS_GLOBAL_PROXY_TYPE: | 125 case JS_GLOBAL_PROXY_TYPE: |
133 case JS_GLOBAL_OBJECT_TYPE: | 126 case JS_GLOBAL_OBJECT_TYPE: |
134 case JS_BUILTINS_OBJECT_TYPE: | 127 case JS_BUILTINS_OBJECT_TYPE: |
135 case JS_MESSAGE_OBJECT_TYPE: | 128 case JS_MESSAGE_OBJECT_TYPE: |
136 case JS_SET_ITERATOR_TYPE: | 129 case JS_SET_ITERATOR_TYPE: |
137 case JS_MAP_ITERATOR_TYPE: | 130 case JS_MAP_ITERATOR_TYPE: |
138 return GetVisitorIdForSize(kVisitJSObject, | 131 return GetVisitorIdForSize(kVisitJSObject, kVisitJSObjectGeneric, |
139 kVisitJSObjectGeneric, | |
140 instance_size); | 132 instance_size); |
141 | 133 |
142 case JS_FUNCTION_TYPE: | 134 case JS_FUNCTION_TYPE: |
143 return kVisitJSFunction; | 135 return kVisitJSFunction; |
144 | 136 |
145 case HEAP_NUMBER_TYPE: | 137 case HEAP_NUMBER_TYPE: |
146 case MUTABLE_HEAP_NUMBER_TYPE: | 138 case MUTABLE_HEAP_NUMBER_TYPE: |
147 #define EXTERNAL_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 139 #define EXTERNAL_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
148 case EXTERNAL_##TYPE##_ARRAY_TYPE: | 140 case EXTERNAL_##TYPE##_ARRAY_TYPE: |
149 | 141 |
150 TYPED_ARRAYS(EXTERNAL_ARRAY_CASE) | 142 TYPED_ARRAYS(EXTERNAL_ARRAY_CASE) |
151 return GetVisitorIdForSize(kVisitDataObject, | 143 return GetVisitorIdForSize(kVisitDataObject, kVisitDataObjectGeneric, |
152 kVisitDataObjectGeneric, | |
153 instance_size); | 144 instance_size); |
154 #undef EXTERNAL_ARRAY_CASE | 145 #undef EXTERNAL_ARRAY_CASE |
155 | 146 |
156 case FIXED_UINT8_ARRAY_TYPE: | 147 case FIXED_UINT8_ARRAY_TYPE: |
157 case FIXED_INT8_ARRAY_TYPE: | 148 case FIXED_INT8_ARRAY_TYPE: |
158 case FIXED_UINT16_ARRAY_TYPE: | 149 case FIXED_UINT16_ARRAY_TYPE: |
159 case FIXED_INT16_ARRAY_TYPE: | 150 case FIXED_INT16_ARRAY_TYPE: |
160 case FIXED_UINT32_ARRAY_TYPE: | 151 case FIXED_UINT32_ARRAY_TYPE: |
161 case FIXED_INT32_ARRAY_TYPE: | 152 case FIXED_INT32_ARRAY_TYPE: |
162 case FIXED_FLOAT32_ARRAY_TYPE: | 153 case FIXED_FLOAT32_ARRAY_TYPE: |
163 case FIXED_UINT8_CLAMPED_ARRAY_TYPE: | 154 case FIXED_UINT8_CLAMPED_ARRAY_TYPE: |
164 return kVisitFixedTypedArray; | 155 return kVisitFixedTypedArray; |
165 | 156 |
166 case FIXED_FLOAT64_ARRAY_TYPE: | 157 case FIXED_FLOAT64_ARRAY_TYPE: |
167 return kVisitFixedFloat64Array; | 158 return kVisitFixedFloat64Array; |
168 | 159 |
169 #define MAKE_STRUCT_CASE(NAME, Name, name) \ | 160 #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: |
170 case NAME##_TYPE: | |
171 STRUCT_LIST(MAKE_STRUCT_CASE) | 161 STRUCT_LIST(MAKE_STRUCT_CASE) |
172 #undef MAKE_STRUCT_CASE | 162 #undef MAKE_STRUCT_CASE |
173 if (instance_type == ALLOCATION_SITE_TYPE) { | 163 if (instance_type == ALLOCATION_SITE_TYPE) { |
174 return kVisitAllocationSite; | 164 return kVisitAllocationSite; |
175 } | 165 } |
176 | 166 |
177 return GetVisitorIdForSize(kVisitStruct, | 167 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, |
178 kVisitStructGeneric, | 168 instance_size); |
179 instance_size); | |
180 | 169 |
181 default: | 170 default: |
182 UNREACHABLE(); | 171 UNREACHABLE(); |
183 return kVisitorIdCount; | 172 return kVisitorIdCount; |
184 } | 173 } |
185 } | 174 } |
186 | 175 |
187 | 176 |
188 // We don't record weak slots during marking or scavenges. Instead we do it | 177 // We don't record weak slots during marking or scavenges. Instead we do it |
189 // once when we complete mark-compact cycle. Note that write barrier has no | 178 // once when we complete mark-compact cycle. Note that write barrier has no |
190 // effect if we are already in the middle of compacting mark-sweep cycle and we | 179 // effect if we are already in the middle of compacting mark-sweep cycle and we |
191 // have to record slots manually. | 180 // have to record slots manually. |
192 static bool MustRecordSlots(Heap* heap) { | 181 static bool MustRecordSlots(Heap* heap) { |
193 return heap->gc_state() == Heap::MARK_COMPACT && | 182 return heap->gc_state() == Heap::MARK_COMPACT && |
194 heap->mark_compact_collector()->is_compacting(); | 183 heap->mark_compact_collector()->is_compacting(); |
195 } | 184 } |
196 | 185 |
197 | 186 |
198 template <class T> | 187 template <class T> |
199 struct WeakListVisitor; | 188 struct WeakListVisitor; |
200 | 189 |
201 | 190 |
202 template <class T> | 191 template <class T> |
203 Object* VisitWeakList(Heap* heap, | 192 Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer) { |
204 Object* list, | |
205 WeakObjectRetainer* retainer) { | |
206 Object* undefined = heap->undefined_value(); | 193 Object* undefined = heap->undefined_value(); |
207 Object* head = undefined; | 194 Object* head = undefined; |
208 T* tail = NULL; | 195 T* tail = NULL; |
209 MarkCompactCollector* collector = heap->mark_compact_collector(); | 196 MarkCompactCollector* collector = heap->mark_compact_collector(); |
210 bool record_slots = MustRecordSlots(heap); | 197 bool record_slots = MustRecordSlots(heap); |
211 while (list != undefined) { | 198 while (list != undefined) { |
212 // Check whether to keep the candidate in the list. | 199 // Check whether to keep the candidate in the list. |
213 T* candidate = reinterpret_cast<T*>(list); | 200 T* candidate = reinterpret_cast<T*>(list); |
214 Object* retained = retainer->RetainAs(list); | 201 Object* retained = retainer->RetainAs(list); |
215 if (retained != NULL) { | 202 if (retained != NULL) { |
216 if (head == undefined) { | 203 if (head == undefined) { |
217 // First element in the list. | 204 // First element in the list. |
218 head = retained; | 205 head = retained; |
219 } else { | 206 } else { |
220 // Subsequent elements in the list. | 207 // Subsequent elements in the list. |
221 DCHECK(tail != NULL); | 208 DCHECK(tail != NULL); |
222 WeakListVisitor<T>::SetWeakNext(tail, retained); | 209 WeakListVisitor<T>::SetWeakNext(tail, retained); |
223 if (record_slots) { | 210 if (record_slots) { |
224 Object** next_slot = | 211 Object** next_slot = |
225 HeapObject::RawField(tail, WeakListVisitor<T>::WeakNextOffset()); | 212 HeapObject::RawField(tail, WeakListVisitor<T>::WeakNextOffset()); |
226 collector->RecordSlot(next_slot, next_slot, retained); | 213 collector->RecordSlot(next_slot, next_slot, retained); |
227 } | 214 } |
228 } | 215 } |
229 // Retained object is new tail. | 216 // Retained object is new tail. |
230 DCHECK(!retained->IsUndefined()); | 217 DCHECK(!retained->IsUndefined()); |
231 candidate = reinterpret_cast<T*>(retained); | 218 candidate = reinterpret_cast<T*>(retained); |
232 tail = candidate; | 219 tail = candidate; |
233 | 220 |
234 | 221 |
235 // tail is a live object, visit it. | 222 // tail is a live object, visit it. |
236 WeakListVisitor<T>::VisitLiveObject(heap, tail, retainer); | 223 WeakListVisitor<T>::VisitLiveObject(heap, tail, retainer); |
237 } else { | 224 } else { |
238 WeakListVisitor<T>::VisitPhantomObject(heap, candidate); | 225 WeakListVisitor<T>::VisitPhantomObject(heap, candidate); |
239 } | 226 } |
240 | 227 |
241 // Move to next element in the list. | 228 // Move to next element in the list. |
242 list = WeakListVisitor<T>::WeakNext(candidate); | 229 list = WeakListVisitor<T>::WeakNext(candidate); |
243 } | 230 } |
244 | 231 |
245 // Terminate the list if there is one or more elements. | 232 // Terminate the list if there is one or more elements. |
246 if (tail != NULL) { | 233 if (tail != NULL) { |
247 WeakListVisitor<T>::SetWeakNext(tail, undefined); | 234 WeakListVisitor<T>::SetWeakNext(tail, undefined); |
248 } | 235 } |
249 return head; | 236 return head; |
250 } | 237 } |
251 | 238 |
252 | 239 |
253 template <class T> | 240 template <class T> |
254 static void ClearWeakList(Heap* heap, | 241 static void ClearWeakList(Heap* heap, Object* list) { |
255 Object* list) { | |
256 Object* undefined = heap->undefined_value(); | 242 Object* undefined = heap->undefined_value(); |
257 while (list != undefined) { | 243 while (list != undefined) { |
258 T* candidate = reinterpret_cast<T*>(list); | 244 T* candidate = reinterpret_cast<T*>(list); |
259 list = WeakListVisitor<T>::WeakNext(candidate); | 245 list = WeakListVisitor<T>::WeakNext(candidate); |
260 WeakListVisitor<T>::SetWeakNext(candidate, undefined); | 246 WeakListVisitor<T>::SetWeakNext(candidate, undefined); |
261 } | 247 } |
262 } | 248 } |
263 | 249 |
264 | 250 |
265 template<> | 251 template <> |
266 struct WeakListVisitor<JSFunction> { | 252 struct WeakListVisitor<JSFunction> { |
267 static void SetWeakNext(JSFunction* function, Object* next) { | 253 static void SetWeakNext(JSFunction* function, Object* next) { |
268 function->set_next_function_link(next); | 254 function->set_next_function_link(next); |
269 } | 255 } |
270 | 256 |
271 static Object* WeakNext(JSFunction* function) { | 257 static Object* WeakNext(JSFunction* function) { |
272 return function->next_function_link(); | 258 return function->next_function_link(); |
273 } | 259 } |
274 | 260 |
275 static int WeakNextOffset() { | 261 static int WeakNextOffset() { return JSFunction::kNextFunctionLinkOffset; } |
276 return JSFunction::kNextFunctionLinkOffset; | |
277 } | |
278 | 262 |
279 static void VisitLiveObject(Heap*, JSFunction*, WeakObjectRetainer*) {} | 263 static void VisitLiveObject(Heap*, JSFunction*, WeakObjectRetainer*) {} |
280 | 264 |
281 static void VisitPhantomObject(Heap*, JSFunction*) {} | 265 static void VisitPhantomObject(Heap*, JSFunction*) {} |
282 }; | 266 }; |
283 | 267 |
284 | 268 |
285 template<> | 269 template <> |
286 struct WeakListVisitor<Code> { | 270 struct WeakListVisitor<Code> { |
287 static void SetWeakNext(Code* code, Object* next) { | 271 static void SetWeakNext(Code* code, Object* next) { |
288 code->set_next_code_link(next); | 272 code->set_next_code_link(next); |
289 } | 273 } |
290 | 274 |
291 static Object* WeakNext(Code* code) { | 275 static Object* WeakNext(Code* code) { return code->next_code_link(); } |
292 return code->next_code_link(); | |
293 } | |
294 | 276 |
295 static int WeakNextOffset() { | 277 static int WeakNextOffset() { return Code::kNextCodeLinkOffset; } |
296 return Code::kNextCodeLinkOffset; | |
297 } | |
298 | 278 |
299 static void VisitLiveObject(Heap*, Code*, WeakObjectRetainer*) {} | 279 static void VisitLiveObject(Heap*, Code*, WeakObjectRetainer*) {} |
300 | 280 |
301 static void VisitPhantomObject(Heap*, Code*) {} | 281 static void VisitPhantomObject(Heap*, Code*) {} |
302 }; | 282 }; |
303 | 283 |
304 | 284 |
305 template<> | 285 template <> |
306 struct WeakListVisitor<Context> { | 286 struct WeakListVisitor<Context> { |
307 static void SetWeakNext(Context* context, Object* next) { | 287 static void SetWeakNext(Context* context, Object* next) { |
308 context->set(Context::NEXT_CONTEXT_LINK, | 288 context->set(Context::NEXT_CONTEXT_LINK, next, UPDATE_WRITE_BARRIER); |
309 next, | |
310 UPDATE_WRITE_BARRIER); | |
311 } | 289 } |
312 | 290 |
313 static Object* WeakNext(Context* context) { | 291 static Object* WeakNext(Context* context) { |
314 return context->get(Context::NEXT_CONTEXT_LINK); | 292 return context->get(Context::NEXT_CONTEXT_LINK); |
315 } | 293 } |
316 | 294 |
317 static int WeakNextOffset() { | 295 static int WeakNextOffset() { |
318 return FixedArray::SizeFor(Context::NEXT_CONTEXT_LINK); | 296 return FixedArray::SizeFor(Context::NEXT_CONTEXT_LINK); |
319 } | 297 } |
320 | 298 |
321 static void VisitLiveObject(Heap* heap, | 299 static void VisitLiveObject(Heap* heap, Context* context, |
322 Context* context, | |
323 WeakObjectRetainer* retainer) { | 300 WeakObjectRetainer* retainer) { |
324 // Process the three weak lists linked off the context. | 301 // Process the three weak lists linked off the context. |
325 DoWeakList<JSFunction>(heap, context, retainer, | 302 DoWeakList<JSFunction>(heap, context, retainer, |
326 Context::OPTIMIZED_FUNCTIONS_LIST); | 303 Context::OPTIMIZED_FUNCTIONS_LIST); |
327 DoWeakList<Code>(heap, context, retainer, Context::OPTIMIZED_CODE_LIST); | 304 DoWeakList<Code>(heap, context, retainer, Context::OPTIMIZED_CODE_LIST); |
328 DoWeakList<Code>(heap, context, retainer, Context::DEOPTIMIZED_CODE_LIST); | 305 DoWeakList<Code>(heap, context, retainer, Context::DEOPTIMIZED_CODE_LIST); |
329 } | 306 } |
330 | 307 |
331 template<class T> | 308 template <class T> |
332 static void DoWeakList(Heap* heap, | 309 static void DoWeakList(Heap* heap, Context* context, |
333 Context* context, | 310 WeakObjectRetainer* retainer, int index) { |
334 WeakObjectRetainer* retainer, | |
335 int index) { | |
336 // Visit the weak list, removing dead intermediate elements. | 311 // Visit the weak list, removing dead intermediate elements. |
337 Object* list_head = VisitWeakList<T>(heap, context->get(index), retainer); | 312 Object* list_head = VisitWeakList<T>(heap, context->get(index), retainer); |
338 | 313 |
339 // Update the list head. | 314 // Update the list head. |
340 context->set(index, list_head, UPDATE_WRITE_BARRIER); | 315 context->set(index, list_head, UPDATE_WRITE_BARRIER); |
341 | 316 |
342 if (MustRecordSlots(heap)) { | 317 if (MustRecordSlots(heap)) { |
343 // Record the updated slot if necessary. | 318 // Record the updated slot if necessary. |
344 Object** head_slot = HeapObject::RawField( | 319 Object** head_slot = |
345 context, FixedArray::SizeFor(index)); | 320 HeapObject::RawField(context, FixedArray::SizeFor(index)); |
346 heap->mark_compact_collector()->RecordSlot( | 321 heap->mark_compact_collector()->RecordSlot(head_slot, head_slot, |
347 head_slot, head_slot, list_head); | 322 list_head); |
348 } | 323 } |
349 } | 324 } |
350 | 325 |
351 static void VisitPhantomObject(Heap* heap, Context* context) { | 326 static void VisitPhantomObject(Heap* heap, Context* context) { |
352 ClearWeakList<JSFunction>(heap, | 327 ClearWeakList<JSFunction>(heap, |
353 context->get(Context::OPTIMIZED_FUNCTIONS_LIST)); | 328 context->get(Context::OPTIMIZED_FUNCTIONS_LIST)); |
354 ClearWeakList<Code>(heap, context->get(Context::OPTIMIZED_CODE_LIST)); | 329 ClearWeakList<Code>(heap, context->get(Context::OPTIMIZED_CODE_LIST)); |
355 ClearWeakList<Code>(heap, context->get(Context::DEOPTIMIZED_CODE_LIST)); | 330 ClearWeakList<Code>(heap, context->get(Context::DEOPTIMIZED_CODE_LIST)); |
356 } | 331 } |
357 }; | 332 }; |
358 | 333 |
359 | 334 |
360 template<> | 335 template <> |
361 struct WeakListVisitor<JSArrayBufferView> { | 336 struct WeakListVisitor<JSArrayBufferView> { |
362 static void SetWeakNext(JSArrayBufferView* obj, Object* next) { | 337 static void SetWeakNext(JSArrayBufferView* obj, Object* next) { |
363 obj->set_weak_next(next); | 338 obj->set_weak_next(next); |
364 } | 339 } |
365 | 340 |
366 static Object* WeakNext(JSArrayBufferView* obj) { | 341 static Object* WeakNext(JSArrayBufferView* obj) { return obj->weak_next(); } |
367 return obj->weak_next(); | |
368 } | |
369 | 342 |
370 static int WeakNextOffset() { | 343 static int WeakNextOffset() { return JSArrayBufferView::kWeakNextOffset; } |
371 return JSArrayBufferView::kWeakNextOffset; | |
372 } | |
373 | 344 |
374 static void VisitLiveObject(Heap*, JSArrayBufferView*, WeakObjectRetainer*) {} | 345 static void VisitLiveObject(Heap*, JSArrayBufferView*, WeakObjectRetainer*) {} |
375 | 346 |
376 static void VisitPhantomObject(Heap*, JSArrayBufferView*) {} | 347 static void VisitPhantomObject(Heap*, JSArrayBufferView*) {} |
377 }; | 348 }; |
378 | 349 |
379 | 350 |
380 template<> | 351 template <> |
381 struct WeakListVisitor<JSArrayBuffer> { | 352 struct WeakListVisitor<JSArrayBuffer> { |
382 static void SetWeakNext(JSArrayBuffer* obj, Object* next) { | 353 static void SetWeakNext(JSArrayBuffer* obj, Object* next) { |
383 obj->set_weak_next(next); | 354 obj->set_weak_next(next); |
384 } | 355 } |
385 | 356 |
386 static Object* WeakNext(JSArrayBuffer* obj) { | 357 static Object* WeakNext(JSArrayBuffer* obj) { return obj->weak_next(); } |
387 return obj->weak_next(); | |
388 } | |
389 | 358 |
390 static int WeakNextOffset() { | 359 static int WeakNextOffset() { return JSArrayBuffer::kWeakNextOffset; } |
391 return JSArrayBuffer::kWeakNextOffset; | |
392 } | |
393 | 360 |
394 static void VisitLiveObject(Heap* heap, | 361 static void VisitLiveObject(Heap* heap, JSArrayBuffer* array_buffer, |
395 JSArrayBuffer* array_buffer, | |
396 WeakObjectRetainer* retainer) { | 362 WeakObjectRetainer* retainer) { |
397 Object* typed_array_obj = | 363 Object* typed_array_obj = VisitWeakList<JSArrayBufferView>( |
398 VisitWeakList<JSArrayBufferView>( | 364 heap, array_buffer->weak_first_view(), retainer); |
399 heap, | |
400 array_buffer->weak_first_view(), | |
401 retainer); | |
402 array_buffer->set_weak_first_view(typed_array_obj); | 365 array_buffer->set_weak_first_view(typed_array_obj); |
403 if (typed_array_obj != heap->undefined_value() && MustRecordSlots(heap)) { | 366 if (typed_array_obj != heap->undefined_value() && MustRecordSlots(heap)) { |
404 Object** slot = HeapObject::RawField( | 367 Object** slot = HeapObject::RawField(array_buffer, |
405 array_buffer, JSArrayBuffer::kWeakFirstViewOffset); | 368 JSArrayBuffer::kWeakFirstViewOffset); |
406 heap->mark_compact_collector()->RecordSlot(slot, slot, typed_array_obj); | 369 heap->mark_compact_collector()->RecordSlot(slot, slot, typed_array_obj); |
407 } | 370 } |
408 } | 371 } |
409 | 372 |
410 static void VisitPhantomObject(Heap* heap, JSArrayBuffer* phantom) { | 373 static void VisitPhantomObject(Heap* heap, JSArrayBuffer* phantom) { |
411 Runtime::FreeArrayBuffer(heap->isolate(), phantom); | 374 Runtime::FreeArrayBuffer(heap->isolate(), phantom); |
412 } | 375 } |
413 }; | 376 }; |
414 | 377 |
415 | 378 |
416 template<> | 379 template <> |
417 struct WeakListVisitor<AllocationSite> { | 380 struct WeakListVisitor<AllocationSite> { |
418 static void SetWeakNext(AllocationSite* obj, Object* next) { | 381 static void SetWeakNext(AllocationSite* obj, Object* next) { |
419 obj->set_weak_next(next); | 382 obj->set_weak_next(next); |
420 } | 383 } |
421 | 384 |
422 static Object* WeakNext(AllocationSite* obj) { | 385 static Object* WeakNext(AllocationSite* obj) { return obj->weak_next(); } |
423 return obj->weak_next(); | |
424 } | |
425 | 386 |
426 static int WeakNextOffset() { | 387 static int WeakNextOffset() { return AllocationSite::kWeakNextOffset; } |
427 return AllocationSite::kWeakNextOffset; | |
428 } | |
429 | 388 |
430 static void VisitLiveObject(Heap*, AllocationSite*, WeakObjectRetainer*) {} | 389 static void VisitLiveObject(Heap*, AllocationSite*, WeakObjectRetainer*) {} |
431 | 390 |
432 static void VisitPhantomObject(Heap*, AllocationSite*) {} | 391 static void VisitPhantomObject(Heap*, AllocationSite*) {} |
433 }; | 392 }; |
434 | 393 |
435 | 394 |
436 template Object* VisitWeakList<Code>( | 395 template Object* VisitWeakList<Code>(Heap* heap, Object* list, |
437 Heap* heap, Object* list, WeakObjectRetainer* retainer); | 396 WeakObjectRetainer* retainer); |
438 | 397 |
439 | 398 |
440 template Object* VisitWeakList<JSFunction>( | 399 template Object* VisitWeakList<JSFunction>(Heap* heap, Object* list, |
441 Heap* heap, Object* list, WeakObjectRetainer* retainer); | 400 WeakObjectRetainer* retainer); |
442 | 401 |
443 | 402 |
444 template Object* VisitWeakList<Context>( | 403 template Object* VisitWeakList<Context>(Heap* heap, Object* list, |
445 Heap* heap, Object* list, WeakObjectRetainer* retainer); | 404 WeakObjectRetainer* retainer); |
446 | 405 |
447 | 406 |
448 template Object* VisitWeakList<JSArrayBuffer>( | 407 template Object* VisitWeakList<JSArrayBuffer>(Heap* heap, Object* list, |
449 Heap* heap, Object* list, WeakObjectRetainer* retainer); | 408 WeakObjectRetainer* retainer); |
450 | 409 |
451 | 410 |
452 template Object* VisitWeakList<AllocationSite>( | 411 template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list, |
453 Heap* heap, Object* list, WeakObjectRetainer* retainer); | 412 WeakObjectRetainer* retainer); |
454 | 413 } |
455 } } // namespace v8::internal | 414 } // namespace v8::internal |
OLD | NEW |