Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index cd8a03e3a6ddf90af03129d78a17e060f6385927..81fda47d37947ec83bfb76862dc7abc7e4a2589a 100644 |
--- a/src/heap.cc |
+++ b/src/heap.cc |
@@ -5062,8 +5062,37 @@ void Heap::Verify() { |
cell_space_->Verify(&no_dirty_regions_visitor); |
lo_space_->Verify(); |
-} |
+ // TODO(svenpanne) We should enable this when our fast->slow->fast-mode dance |
+ // for setting accessor properties is fixed. |
+ // VerifyNoAccessorPairSharing(); |
+} |
+ |
+ |
+void Heap::VerifyNoAccessorPairSharing() { |
+ // Verification is done in 2 phases: First we mark all AccessorPairs, checking |
+ // that we mark only unmarked pairs, then we clear all marks, restoring the |
+ // initial state. We use the LSB of the AccessorPair's getter as the marking |
Michael Starzinger
2012/02/17 13:33:28
Actually we want to use the "Smi tag" which happen
Sven Panne
2012/02/20 08:26:03
Done.
|
+ // bit, because we can never see a Smi as the getter. |
+ for (int phase = 0; phase < 2; phase++) { |
+ HeapObjectIterator iter(map_space()); |
+ for (HeapObject* obj = iter.Next(); obj != NULL; obj = iter.Next()) { |
+ if (obj->IsMap()) { |
+ DescriptorArray* descs = Map::cast(obj)->instance_descriptors(); |
+ for (int i = 0; i < descs->number_of_descriptors(); i++) { |
+ if (descs->GetType(i) == CALLBACKS && |
+ descs->GetValue(i)->IsAccessorPair()) { |
+ AccessorPair* accessors = AccessorPair::cast(descs->GetValue(i)); |
+ uintptr_t before = reinterpret_cast<intptr_t>(accessors->getter()); |
+ uintptr_t after = (phase == 0) ? (before & ~1) : (before | 1); |
Michael Starzinger
2012/02/17 13:33:28
Please use the kHeapObjectTag[Mask] and kSmiTag[Ma
Sven Panne
2012/02/20 08:26:03
Done.
|
+ CHECK(before != after); |
+ accessors->set_getter(reinterpret_cast<Object*>(after)); |
+ } |
+ } |
+ } |
+ } |
+ } |
+} |
#endif // DEBUG |