Index: src/objects-visiting.h |
diff --git a/src/objects-visiting.h b/src/objects-visiting.h |
index 42f90608c35032452fc83b909ef13cd7d9000f61..da955da614f42cd7148f92794afa7b9f9339408e 100644 |
--- a/src/objects-visiting.h |
+++ b/src/objects-visiting.h |
@@ -141,13 +141,22 @@ class StaticVisitorBase : public AllStatic { |
template<typename Callback> |
class VisitorDispatchTable { |
public: |
+ void CopyFrom(VisitorDispatchTable* other) { |
+ // We are not using memcpy to guarantee that during update |
+ // every element of callbacks_ array will remain correct |
+ // pointer (memcpy might be implemented as a byte copying loop). |
+ for (int i = 0; i < StaticVisitorBase::kVisitorIdCount; i++) { |
+ NoBarrier_Store(&callbacks_[i], other->callbacks_[i]); |
+ } |
+ } |
+ |
inline Callback GetVisitor(Map* map) { |
- return callbacks_[map->visitor_id()]; |
+ return reinterpret_cast<Callback>(callbacks_[map->visitor_id()]); |
} |
void Register(StaticVisitorBase::VisitorId id, Callback callback) { |
ASSERT(id < StaticVisitorBase::kVisitorIdCount); // id is unsigned. |
- callbacks_[id] = callback; |
+ callbacks_[id] = reinterpret_cast<AtomicWord>(callback); |
} |
template<typename Visitor, |
@@ -179,7 +188,7 @@ class VisitorDispatchTable { |
} |
private: |
- Callback callbacks_[StaticVisitorBase::kVisitorIdCount]; |
+ AtomicWord callbacks_[StaticVisitorBase::kVisitorIdCount]; |
}; |