| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 base + (object_size >> kPointerSizeLog2) - kMinObjectSizeInWords); | 134 base + (object_size >> kPointerSizeLog2) - kMinObjectSizeInWords); |
| 135 | 135 |
| 136 return Min(specialization, generic); | 136 return Min(specialization, generic); |
| 137 } | 137 } |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 | 140 |
| 141 template<typename Callback> | 141 template<typename Callback> |
| 142 class VisitorDispatchTable { | 142 class VisitorDispatchTable { |
| 143 public: | 143 public: |
| 144 void CopyFrom(VisitorDispatchTable* other) { | |
| 145 // We are not using memcpy to guarantee that during update | |
| 146 // every element of callbacks_ array will remain correct | |
| 147 // pointer (memcpy might be implemented as a byte copying loop). | |
| 148 for (int i = 0; i < StaticVisitorBase::kVisitorIdCount; i++) { | |
| 149 NoBarrier_Store(&callbacks_[i], other->callbacks_[i]); | |
| 150 } | |
| 151 } | |
| 152 | |
| 153 inline Callback GetVisitor(Map* map) { | 144 inline Callback GetVisitor(Map* map) { |
| 154 return reinterpret_cast<Callback>(callbacks_[map->visitor_id()]); | 145 return callbacks_[map->visitor_id()]; |
| 155 } | 146 } |
| 156 | 147 |
| 157 void Register(StaticVisitorBase::VisitorId id, Callback callback) { | 148 void Register(StaticVisitorBase::VisitorId id, Callback callback) { |
| 158 ASSERT(id < StaticVisitorBase::kVisitorIdCount); // id is unsigned. | 149 ASSERT(id < StaticVisitorBase::kVisitorIdCount); // id is unsigned. |
| 159 callbacks_[id] = reinterpret_cast<AtomicWord>(callback); | 150 callbacks_[id] = callback; |
| 160 } | 151 } |
| 161 | 152 |
| 162 template<typename Visitor, | 153 template<typename Visitor, |
| 163 StaticVisitorBase::VisitorId base, | 154 StaticVisitorBase::VisitorId base, |
| 164 StaticVisitorBase::VisitorId generic, | 155 StaticVisitorBase::VisitorId generic, |
| 165 int object_size_in_words> | 156 int object_size_in_words> |
| 166 void RegisterSpecialization() { | 157 void RegisterSpecialization() { |
| 167 static const int size = object_size_in_words * kPointerSize; | 158 static const int size = object_size_in_words * kPointerSize; |
| 168 Register(StaticVisitorBase::GetVisitorIdForSize(base, generic, size), | 159 Register(StaticVisitorBase::GetVisitorIdForSize(base, generic, size), |
| 169 &Visitor::template VisitSpecialized<size>); | 160 &Visitor::template VisitSpecialized<size>); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 181 RegisterSpecialization<Visitor, base, generic, 4>(); | 172 RegisterSpecialization<Visitor, base, generic, 4>(); |
| 182 RegisterSpecialization<Visitor, base, generic, 5>(); | 173 RegisterSpecialization<Visitor, base, generic, 5>(); |
| 183 RegisterSpecialization<Visitor, base, generic, 6>(); | 174 RegisterSpecialization<Visitor, base, generic, 6>(); |
| 184 RegisterSpecialization<Visitor, base, generic, 7>(); | 175 RegisterSpecialization<Visitor, base, generic, 7>(); |
| 185 RegisterSpecialization<Visitor, base, generic, 8>(); | 176 RegisterSpecialization<Visitor, base, generic, 8>(); |
| 186 RegisterSpecialization<Visitor, base, generic, 9>(); | 177 RegisterSpecialization<Visitor, base, generic, 9>(); |
| 187 Register(generic, &Visitor::Visit); | 178 Register(generic, &Visitor::Visit); |
| 188 } | 179 } |
| 189 | 180 |
| 190 private: | 181 private: |
| 191 AtomicWord callbacks_[StaticVisitorBase::kVisitorIdCount]; | 182 Callback callbacks_[StaticVisitorBase::kVisitorIdCount]; |
| 192 }; | 183 }; |
| 193 | 184 |
| 194 | 185 |
| 195 template<typename StaticVisitor> | 186 template<typename StaticVisitor> |
| 196 class BodyVisitorBase : public AllStatic { | 187 class BodyVisitorBase : public AllStatic { |
| 197 public: | 188 public: |
| 198 INLINE(static void IteratePointers(Heap* heap, | 189 INLINE(static void IteratePointers(Heap* heap, |
| 199 HeapObject* object, | 190 HeapObject* object, |
| 200 int start_offset, | 191 int start_offset, |
| 201 int end_offset)) { | 192 int end_offset)) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 404 |
| 414 for (; !it.done(); it.next()) { | 405 for (; !it.done(); it.next()) { |
| 415 it.rinfo()->template Visit<StaticVisitor>(heap); | 406 it.rinfo()->template Visit<StaticVisitor>(heap); |
| 416 } | 407 } |
| 417 } | 408 } |
| 418 | 409 |
| 419 | 410 |
| 420 } } // namespace v8::internal | 411 } } // namespace v8::internal |
| 421 | 412 |
| 422 #endif // V8_OBJECTS_VISITING_H_ | 413 #endif // V8_OBJECTS_VISITING_H_ |
| OLD | NEW |