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_H_ | 5 #ifndef V8_OBJECTS_VISITING_H_ |
6 #define V8_OBJECTS_VISITING_H_ | 6 #define V8_OBJECTS_VISITING_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 | 9 |
10 // This file provides base classes and auxiliary methods for defining | 10 // This file provides base classes and auxiliary methods for defining |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 | 132 |
133 template<typename Callback> | 133 template<typename Callback> |
134 class VisitorDispatchTable { | 134 class VisitorDispatchTable { |
135 public: | 135 public: |
136 void CopyFrom(VisitorDispatchTable* other) { | 136 void CopyFrom(VisitorDispatchTable* other) { |
137 // We are not using memcpy to guarantee that during update | 137 // We are not using memcpy to guarantee that during update |
138 // every element of callbacks_ array will remain correct | 138 // every element of callbacks_ array will remain correct |
139 // pointer (memcpy might be implemented as a byte copying loop). | 139 // pointer (memcpy might be implemented as a byte copying loop). |
140 for (int i = 0; i < StaticVisitorBase::kVisitorIdCount; i++) { | 140 for (int i = 0; i < StaticVisitorBase::kVisitorIdCount; i++) { |
141 NoBarrier_Store(&callbacks_[i], other->callbacks_[i]); | 141 base::NoBarrier_Store(&callbacks_[i], other->callbacks_[i]); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 inline Callback GetVisitorById(StaticVisitorBase::VisitorId id) { | 145 inline Callback GetVisitorById(StaticVisitorBase::VisitorId id) { |
146 return reinterpret_cast<Callback>(callbacks_[id]); | 146 return reinterpret_cast<Callback>(callbacks_[id]); |
147 } | 147 } |
148 | 148 |
149 inline Callback GetVisitor(Map* map) { | 149 inline Callback GetVisitor(Map* map) { |
150 return reinterpret_cast<Callback>(callbacks_[map->visitor_id()]); | 150 return reinterpret_cast<Callback>(callbacks_[map->visitor_id()]); |
151 } | 151 } |
152 | 152 |
153 void Register(StaticVisitorBase::VisitorId id, Callback callback) { | 153 void Register(StaticVisitorBase::VisitorId id, Callback callback) { |
154 ASSERT(id < StaticVisitorBase::kVisitorIdCount); // id is unsigned. | 154 ASSERT(id < StaticVisitorBase::kVisitorIdCount); // id is unsigned. |
155 callbacks_[id] = reinterpret_cast<AtomicWord>(callback); | 155 callbacks_[id] = reinterpret_cast<base::AtomicWord>(callback); |
156 } | 156 } |
157 | 157 |
158 template<typename Visitor, | 158 template<typename Visitor, |
159 StaticVisitorBase::VisitorId base, | 159 StaticVisitorBase::VisitorId base, |
160 StaticVisitorBase::VisitorId generic, | 160 StaticVisitorBase::VisitorId generic, |
161 int object_size_in_words> | 161 int object_size_in_words> |
162 void RegisterSpecialization() { | 162 void RegisterSpecialization() { |
163 static const int size = object_size_in_words * kPointerSize; | 163 static const int size = object_size_in_words * kPointerSize; |
164 Register(StaticVisitorBase::GetVisitorIdForSize(base, generic, size), | 164 Register(StaticVisitorBase::GetVisitorIdForSize(base, generic, size), |
165 &Visitor::template VisitSpecialized<size>); | 165 &Visitor::template VisitSpecialized<size>); |
(...skipping 11 matching lines...) Expand all Loading... |
177 RegisterSpecialization<Visitor, base, generic, 4>(); | 177 RegisterSpecialization<Visitor, base, generic, 4>(); |
178 RegisterSpecialization<Visitor, base, generic, 5>(); | 178 RegisterSpecialization<Visitor, base, generic, 5>(); |
179 RegisterSpecialization<Visitor, base, generic, 6>(); | 179 RegisterSpecialization<Visitor, base, generic, 6>(); |
180 RegisterSpecialization<Visitor, base, generic, 7>(); | 180 RegisterSpecialization<Visitor, base, generic, 7>(); |
181 RegisterSpecialization<Visitor, base, generic, 8>(); | 181 RegisterSpecialization<Visitor, base, generic, 8>(); |
182 RegisterSpecialization<Visitor, base, generic, 9>(); | 182 RegisterSpecialization<Visitor, base, generic, 9>(); |
183 Register(generic, &Visitor::Visit); | 183 Register(generic, &Visitor::Visit); |
184 } | 184 } |
185 | 185 |
186 private: | 186 private: |
187 AtomicWord callbacks_[StaticVisitorBase::kVisitorIdCount]; | 187 base::AtomicWord callbacks_[StaticVisitorBase::kVisitorIdCount]; |
188 }; | 188 }; |
189 | 189 |
190 | 190 |
191 template<typename StaticVisitor> | 191 template<typename StaticVisitor> |
192 class BodyVisitorBase : public AllStatic { | 192 class BodyVisitorBase : public AllStatic { |
193 public: | 193 public: |
194 INLINE(static void IteratePointers(Heap* heap, | 194 INLINE(static void IteratePointers(Heap* heap, |
195 HeapObject* object, | 195 HeapObject* object, |
196 int start_offset, | 196 int start_offset, |
197 int end_offset)) { | 197 int end_offset)) { |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // the next element. Given the head of the list, this function removes dead | 467 // the next element. Given the head of the list, this function removes dead |
468 // elements from the list and if requested records slots for next-element | 468 // elements from the list and if requested records slots for next-element |
469 // pointers. The template parameter T is a WeakListVisitor that defines how to | 469 // pointers. The template parameter T is a WeakListVisitor that defines how to |
470 // access the next-element pointers. | 470 // access the next-element pointers. |
471 template <class T> | 471 template <class T> |
472 Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer); | 472 Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer); |
473 | 473 |
474 } } // namespace v8::internal | 474 } } // namespace v8::internal |
475 | 475 |
476 #endif // V8_OBJECTS_VISITING_H_ | 476 #endif // V8_OBJECTS_VISITING_H_ |
OLD | NEW |