OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_ | 5 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_ |
6 #define V8_HEAP_SNAPSHOT_GENERATOR_H_ | 6 #define V8_HEAP_SNAPSHOT_GENERATOR_H_ |
7 | 7 |
8 #include "src/profile-generator-inl.h" | 8 #include "src/profile-generator-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 10 matching lines...) Expand all Loading... | |
21 enum Type { | 21 enum Type { |
22 kContextVariable = v8::HeapGraphEdge::kContextVariable, | 22 kContextVariable = v8::HeapGraphEdge::kContextVariable, |
23 kElement = v8::HeapGraphEdge::kElement, | 23 kElement = v8::HeapGraphEdge::kElement, |
24 kProperty = v8::HeapGraphEdge::kProperty, | 24 kProperty = v8::HeapGraphEdge::kProperty, |
25 kInternal = v8::HeapGraphEdge::kInternal, | 25 kInternal = v8::HeapGraphEdge::kInternal, |
26 kHidden = v8::HeapGraphEdge::kHidden, | 26 kHidden = v8::HeapGraphEdge::kHidden, |
27 kShortcut = v8::HeapGraphEdge::kShortcut, | 27 kShortcut = v8::HeapGraphEdge::kShortcut, |
28 kWeak = v8::HeapGraphEdge::kWeak | 28 kWeak = v8::HeapGraphEdge::kWeak |
29 }; | 29 }; |
30 | 30 |
31 HeapGraphEdge() { } | |
32 HeapGraphEdge(Type type, const char* name, int from, int to); | 31 HeapGraphEdge(Type type, const char* name, int from, int to); |
33 HeapGraphEdge(Type type, int index, int from, int to); | 32 HeapGraphEdge(Type type, int index, int from, int to); |
34 void ReplaceToIndexWithEntry(HeapSnapshot* snapshot); | 33 void ReplaceToIndexWithEntry(HeapSnapshot* snapshot); |
35 | 34 |
36 Type type() const { return static_cast<Type>(type_); } | 35 Type type() const { return TypeField::decode(bit_field_); } |
37 int index() const { | 36 int index() const { |
38 DCHECK(type_ == kElement || type_ == kHidden); | 37 DCHECK(type() == kElement || type() == kHidden); |
39 return index_; | 38 return index_; |
40 } | 39 } |
41 const char* name() const { | 40 const char* name() const { |
42 DCHECK(type_ == kContextVariable | 41 DCHECK(type() == kContextVariable || type() == kProperty || |
43 || type_ == kProperty | 42 type() == kInternal || type() == kShortcut || type() == kWeak); |
44 || type_ == kInternal | |
45 || type_ == kShortcut | |
46 || type_ == kWeak); | |
47 return name_; | 43 return name_; |
48 } | 44 } |
49 INLINE(HeapEntry* from() const); | 45 INLINE(HeapEntry* from() const); |
50 HeapEntry* to() const { return to_entry_; } | 46 HeapEntry* to() const { return to_entry_; } |
51 | 47 |
52 private: | 48 private: |
53 INLINE(HeapSnapshot* snapshot() const); | 49 INLINE(HeapSnapshot* snapshot() const); |
50 int from_index() const { return FromIndexField::decode(bit_field_); } | |
54 | 51 |
55 unsigned type_ : 3; | 52 class TypeField : public BitField<Type, 0, 3> {}; |
56 int from_index_ : 29; | 53 class FromIndexField : public BitField<int, 3, 29> {}; |
brucedawson
2014/11/05 01:33:17
FWIW, I believe that this usage of bit fields is p
| |
54 uint32_t bit_field_; | |
57 union { | 55 union { |
58 // During entries population |to_index_| is used for storing the index, | 56 // During entries population |to_index_| is used for storing the index, |
59 // afterwards it is replaced with a pointer to the entry. | 57 // afterwards it is replaced with a pointer to the entry. |
60 int to_index_; | 58 int to_index_; |
61 HeapEntry* to_entry_; | 59 HeapEntry* to_entry_; |
62 }; | 60 }; |
63 union { | 61 union { |
64 int index_; | 62 int index_; |
65 const char* name_; | 63 const char* name_; |
66 }; | 64 }; |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 friend class HeapSnapshotJSONSerializerEnumerator; | 599 friend class HeapSnapshotJSONSerializerEnumerator; |
602 friend class HeapSnapshotJSONSerializerIterator; | 600 friend class HeapSnapshotJSONSerializerIterator; |
603 | 601 |
604 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 602 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
605 }; | 603 }; |
606 | 604 |
607 | 605 |
608 } } // namespace v8::internal | 606 } } // namespace v8::internal |
609 | 607 |
610 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ | 608 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ |
OLD | NEW |