OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_OBJECTS_VISITING_INL_H_ | 5 #ifndef V8_OBJECTS_VISITING_INL_H_ |
6 #define V8_OBJECTS_VISITING_INL_H_ | 6 #define V8_OBJECTS_VISITING_INL_H_ |
7 | 7 |
8 #include "src/heap/array-buffer-tracker.h" | 8 #include "src/heap/array-buffer-tracker.h" |
9 #include "src/heap/objects-visiting.h" | 9 #include "src/heap/objects-visiting.h" |
10 #include "src/ic/ic-state.h" | 10 #include "src/ic/ic-state.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 table_.Register(kVisitSeqOneByteString, &VisitSeqOneByteString); | 70 table_.Register(kVisitSeqOneByteString, &VisitSeqOneByteString); |
71 | 71 |
72 table_.Register(kVisitSeqTwoByteString, &VisitSeqTwoByteString); | 72 table_.Register(kVisitSeqTwoByteString, &VisitSeqTwoByteString); |
73 | 73 |
74 // Don't visit code entry. We are using this visitor only during scavenges. | 74 // Don't visit code entry. We are using this visitor only during scavenges. |
75 table_.Register( | 75 table_.Register( |
76 kVisitJSFunction, | 76 kVisitJSFunction, |
77 &FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 77 &FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
78 int>::Visit); | 78 int>::Visit); |
79 | 79 |
80 table_.Register( | 80 table_.Register(kVisitJSArrayBuffer, &VisitJSArrayBuffer); |
81 kVisitJSArrayBuffer, | |
82 &FlexibleBodyVisitor<StaticVisitor, JSArrayBuffer::BodyDescriptor, | |
83 int>::Visit); | |
84 | 81 |
85 table_.Register(kVisitFreeSpace, &VisitFreeSpace); | 82 table_.Register(kVisitFreeSpace, &VisitFreeSpace); |
86 | 83 |
87 table_.Register(kVisitJSWeakCollection, &JSObjectVisitor::Visit); | 84 table_.Register(kVisitJSWeakCollection, &JSObjectVisitor::Visit); |
88 | 85 |
89 table_.Register(kVisitJSRegExp, &JSObjectVisitor::Visit); | 86 table_.Register(kVisitJSRegExp, &JSObjectVisitor::Visit); |
90 | 87 |
91 table_.template RegisterSpecializations<DataObjectVisitor, kVisitDataObject, | 88 table_.template RegisterSpecializations<DataObjectVisitor, kVisitDataObject, |
92 kVisitDataObjectGeneric>(); | 89 kVisitDataObjectGeneric>(); |
93 | 90 |
94 table_.template RegisterSpecializations<JSObjectVisitor, kVisitJSObject, | 91 table_.template RegisterSpecializations<JSObjectVisitor, kVisitJSObject, |
95 kVisitJSObjectGeneric>(); | 92 kVisitJSObjectGeneric>(); |
96 | 93 |
97 // Not using specialized Api object visitor for newspace. | 94 // Not using specialized Api object visitor for newspace. |
98 table_.template RegisterSpecializations<JSObjectVisitor, kVisitJSApiObject, | 95 table_.template RegisterSpecializations<JSObjectVisitor, kVisitJSApiObject, |
99 kVisitJSApiObjectGeneric>(); | 96 kVisitJSApiObjectGeneric>(); |
100 | 97 |
101 table_.template RegisterSpecializations<StructVisitor, kVisitStruct, | 98 table_.template RegisterSpecializations<StructVisitor, kVisitStruct, |
102 kVisitStructGeneric>(); | 99 kVisitStructGeneric>(); |
103 } | 100 } |
104 | 101 |
| 102 |
| 103 template <typename StaticVisitor> |
| 104 int StaticNewSpaceVisitor<StaticVisitor>::VisitJSArrayBuffer( |
| 105 Map* map, HeapObject* object) { |
| 106 typedef FlexibleBodyVisitor<StaticVisitor, JSArrayBuffer::BodyDescriptor, int> |
| 107 JSArrayBufferBodyVisitor; |
| 108 |
| 109 if (!JSArrayBuffer::cast(object)->is_external()) { |
| 110 Heap* heap = map->GetHeap(); |
| 111 heap->array_buffer_tracker()->MarkLive(JSArrayBuffer::cast(object)); |
| 112 } |
| 113 return JSArrayBufferBodyVisitor::Visit(map, object); |
| 114 } |
| 115 |
| 116 |
105 template <typename StaticVisitor> | 117 template <typename StaticVisitor> |
106 int StaticNewSpaceVisitor<StaticVisitor>::VisitBytecodeArray( | 118 int StaticNewSpaceVisitor<StaticVisitor>::VisitBytecodeArray( |
107 Map* map, HeapObject* object) { | 119 Map* map, HeapObject* object) { |
108 VisitPointers( | 120 VisitPointers( |
109 map->GetHeap(), object, | 121 map->GetHeap(), object, |
110 HeapObject::RawField(object, BytecodeArray::kConstantPoolOffset), | 122 HeapObject::RawField(object, BytecodeArray::kConstantPoolOffset), |
111 HeapObject::RawField(object, BytecodeArray::kFrameSizeOffset)); | 123 HeapObject::RawField(object, BytecodeArray::kFrameSizeOffset)); |
112 return reinterpret_cast<BytecodeArray*>(object)->BytecodeArraySize(); | 124 return reinterpret_cast<BytecodeArray*>(object)->BytecodeArraySize(); |
113 } | 125 } |
114 | 126 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 &FixedBodyVisitor<StaticVisitor, Oddball::BodyDescriptor, void>::Visit); | 178 &FixedBodyVisitor<StaticVisitor, Oddball::BodyDescriptor, void>::Visit); |
167 | 179 |
168 table_.Register(kVisitMap, &VisitMap); | 180 table_.Register(kVisitMap, &VisitMap); |
169 | 181 |
170 table_.Register(kVisitCode, &VisitCode); | 182 table_.Register(kVisitCode, &VisitCode); |
171 | 183 |
172 table_.Register(kVisitSharedFunctionInfo, &VisitSharedFunctionInfo); | 184 table_.Register(kVisitSharedFunctionInfo, &VisitSharedFunctionInfo); |
173 | 185 |
174 table_.Register(kVisitJSFunction, &VisitJSFunction); | 186 table_.Register(kVisitJSFunction, &VisitJSFunction); |
175 | 187 |
176 table_.Register( | 188 table_.Register(kVisitJSArrayBuffer, &VisitJSArrayBuffer); |
177 kVisitJSArrayBuffer, | |
178 &FlexibleBodyVisitor<StaticVisitor, JSArrayBuffer::BodyDescriptor, | |
179 void>::Visit); | |
180 | 189 |
181 // Registration for kVisitJSRegExp is done by StaticVisitor. | 190 // Registration for kVisitJSRegExp is done by StaticVisitor. |
182 | 191 |
183 table_.Register( | 192 table_.Register( |
184 kVisitCell, | 193 kVisitCell, |
185 &FixedBodyVisitor<StaticVisitor, Cell::BodyDescriptor, void>::Visit); | 194 &FixedBodyVisitor<StaticVisitor, Cell::BodyDescriptor, void>::Visit); |
186 | 195 |
187 table_.Register(kVisitPropertyCell, &VisitPropertyCell); | 196 table_.Register(kVisitPropertyCell, &VisitPropertyCell); |
188 | 197 |
189 table_.Register(kVisitWeakCell, &VisitWeakCell); | 198 table_.Register(kVisitWeakCell, &VisitWeakCell); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 VisitJSFunctionStrongCode(map, object); | 513 VisitJSFunctionStrongCode(map, object); |
505 } | 514 } |
506 | 515 |
507 | 516 |
508 template <typename StaticVisitor> | 517 template <typename StaticVisitor> |
509 void StaticMarkingVisitor<StaticVisitor>::VisitJSRegExp(Map* map, | 518 void StaticMarkingVisitor<StaticVisitor>::VisitJSRegExp(Map* map, |
510 HeapObject* object) { | 519 HeapObject* object) { |
511 JSObjectVisitor::Visit(map, object); | 520 JSObjectVisitor::Visit(map, object); |
512 } | 521 } |
513 | 522 |
| 523 |
| 524 template <typename StaticVisitor> |
| 525 void StaticMarkingVisitor<StaticVisitor>::VisitJSArrayBuffer( |
| 526 Map* map, HeapObject* object) { |
| 527 Heap* heap = map->GetHeap(); |
| 528 |
| 529 typedef FlexibleBodyVisitor<StaticVisitor, JSArrayBuffer::BodyDescriptor, |
| 530 void> JSArrayBufferBodyVisitor; |
| 531 |
| 532 JSArrayBufferBodyVisitor::Visit(map, object); |
| 533 |
| 534 if (!JSArrayBuffer::cast(object)->is_external() && |
| 535 !heap->InNewSpace(object)) { |
| 536 heap->array_buffer_tracker()->MarkLive(JSArrayBuffer::cast(object)); |
| 537 } |
| 538 } |
| 539 |
| 540 |
514 template <typename StaticVisitor> | 541 template <typename StaticVisitor> |
515 void StaticMarkingVisitor<StaticVisitor>::VisitBytecodeArray( | 542 void StaticMarkingVisitor<StaticVisitor>::VisitBytecodeArray( |
516 Map* map, HeapObject* object) { | 543 Map* map, HeapObject* object) { |
517 StaticVisitor::VisitPointers( | 544 StaticVisitor::VisitPointers( |
518 map->GetHeap(), object, | 545 map->GetHeap(), object, |
519 HeapObject::RawField(object, BytecodeArray::kConstantPoolOffset), | 546 HeapObject::RawField(object, BytecodeArray::kConstantPoolOffset), |
520 HeapObject::RawField(object, BytecodeArray::kFrameSizeOffset)); | 547 HeapObject::RawField(object, BytecodeArray::kFrameSizeOffset)); |
521 } | 548 } |
522 | 549 |
523 | 550 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 732 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
706 void> JSFunctionWeakCodeBodyVisitor; | 733 void> JSFunctionWeakCodeBodyVisitor; |
707 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 734 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
708 } | 735 } |
709 | 736 |
710 | 737 |
711 } // namespace internal | 738 } // namespace internal |
712 } // namespace v8 | 739 } // namespace v8 |
713 | 740 |
714 #endif // V8_OBJECTS_VISITING_INL_H_ | 741 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |