| Index: src/heap/heap.cc
|
| diff --git a/src/heap/heap.cc b/src/heap/heap.cc
|
| index 61fab02894a90e8b843e51c6328ce06dacae35b3..c4a368ea5b87cf564a5263c56dc05de002966d93 100644
|
| --- a/src/heap/heap.cc
|
| +++ b/src/heap/heap.cc
|
| @@ -618,6 +618,7 @@ void Heap::GarbageCollectionEpilogue() {
|
| if (FLAG_gc_verbose) Print();
|
| if (FLAG_code_stats) ReportCodeStatistics("After GC");
|
| #endif
|
| + if (FLAG_check_handle_count) CheckHandleCount();
|
| if (FLAG_deopt_every_n_garbage_collections > 0) {
|
| // TODO(jkummerow/ulan/jarin): This is not safe! We can't assume that
|
| // the topmost optimized frame can be deoptimized safely, because it
|
| @@ -5652,6 +5653,24 @@ void Heap::PrintHandles() {
|
|
|
| #endif
|
|
|
| +class CheckHandleCountVisitor : public ObjectVisitor {
|
| + public:
|
| + CheckHandleCountVisitor() : handle_count_(0) {}
|
| + ~CheckHandleCountVisitor() { CHECK(handle_count_ < 2000); }
|
| + void VisitPointers(Object** start, Object** end) {
|
| + handle_count_ += end - start;
|
| + }
|
| +
|
| + private:
|
| + ptrdiff_t handle_count_;
|
| +};
|
| +
|
| +
|
| +void Heap::CheckHandleCount() {
|
| + CheckHandleCountVisitor v;
|
| + isolate_->handle_scope_implementer()->Iterate(&v);
|
| +}
|
| +
|
|
|
| Space* AllSpaces::next() {
|
| switch (counter_++) {
|
|
|