1 // Copyright 2015 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_CONTEXT_MEASURE_H_ 6 #define V8_CONTEXT_MEASURE_H_ 7 8 #include "src/address-map.h" 9 #include "src/assert-scope.h" 10 #include "src/objects.h" 11 12 namespace v8 { 13 namespace internal { 14 15 class ContextMeasure : public ObjectVisitor { 16 public: 17 explicit ContextMeasure(Context* context); 18 19 int Size() { return size_; } 20 int Count() { return count_; } 21 22 void VisitPointers(Object** start, Object** end) override; 23 24 private: 25 void MeasureObject(HeapObject* object); 26 void MeasureDeferredObjects(); 27 void MeasureAndRecurse(HeapObject* object); 28 bool IsShared(HeapObject* object); 29 30 Context* context_; 31 32 BackReferenceMap back_reference_map_; 33 RootIndexMap root_index_map_; 34 35 static const int kMaxRecursion = 16; 36 int recursion_depth_; 37 List<HeapObject*> deferred_objects_; 38 39 int count_; 40 int size_; 41 42 DisallowHeapAllocation no_gc_; 43 44 DISALLOW_COPY_AND_ASSIGN(ContextMeasure); 45 }; 46 } // namespace internal 47 } // namespace v8 48 49 #endif // V8_CONTEXT_MEASURE_H_ 50