blob: 7e94f2c00c60e06916796e3a71a88ac919a9bdb8 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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
12namespace v8 {
13namespace internal {
14
15class 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
Ben Murdochc5610432016-08-08 18:44:38 +010032 SerializerReferenceMap reference_map_;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000033 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_