OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 public: | 150 public: |
151 void CopyFrom(VisitorDispatchTable* other) { | 151 void CopyFrom(VisitorDispatchTable* other) { |
152 // We are not using memcpy to guarantee that during update | 152 // We are not using memcpy to guarantee that during update |
153 // every element of callbacks_ array will remain correct | 153 // every element of callbacks_ array will remain correct |
154 // pointer (memcpy might be implemented as a byte copying loop). | 154 // pointer (memcpy might be implemented as a byte copying loop). |
155 for (int i = 0; i < StaticVisitorBase::kVisitorIdCount; i++) { | 155 for (int i = 0; i < StaticVisitorBase::kVisitorIdCount; i++) { |
156 NoBarrier_Store(&callbacks_[i], other->callbacks_[i]); | 156 NoBarrier_Store(&callbacks_[i], other->callbacks_[i]); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
| 160 inline Callback GetVisitorById(StaticVisitorBase::VisitorId id) { |
| 161 return reinterpret_cast<Callback>(callbacks_[id]); |
| 162 } |
| 163 |
160 inline Callback GetVisitor(Map* map) { | 164 inline Callback GetVisitor(Map* map) { |
161 return reinterpret_cast<Callback>(callbacks_[map->visitor_id()]); | 165 return reinterpret_cast<Callback>(callbacks_[map->visitor_id()]); |
162 } | 166 } |
163 | 167 |
164 void Register(StaticVisitorBase::VisitorId id, Callback callback) { | 168 void Register(StaticVisitorBase::VisitorId id, Callback callback) { |
165 ASSERT(id < StaticVisitorBase::kVisitorIdCount); // id is unsigned. | 169 ASSERT(id < StaticVisitorBase::kVisitorIdCount); // id is unsigned. |
166 callbacks_[id] = reinterpret_cast<AtomicWord>(callback); | 170 callbacks_[id] = reinterpret_cast<AtomicWord>(callback); |
167 } | 171 } |
168 | 172 |
169 template<typename Visitor, | 173 template<typename Visitor, |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 | 343 |
340 | 344 |
341 template<typename StaticVisitor> | 345 template<typename StaticVisitor> |
342 VisitorDispatchTable<typename StaticNewSpaceVisitor<StaticVisitor>::Callback> | 346 VisitorDispatchTable<typename StaticNewSpaceVisitor<StaticVisitor>::Callback> |
343 StaticNewSpaceVisitor<StaticVisitor>::table_; | 347 StaticNewSpaceVisitor<StaticVisitor>::table_; |
344 | 348 |
345 | 349 |
346 } } // namespace v8::internal | 350 } } // namespace v8::internal |
347 | 351 |
348 #endif // V8_OBJECTS_VISITING_H_ | 352 #endif // V8_OBJECTS_VISITING_H_ |
OLD | NEW |