Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 | 621 |
| 622 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator); | 622 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator); |
| 623 }; | 623 }; |
| 624 | 624 |
| 625 class OutputStreamWriter; | 625 class OutputStreamWriter; |
| 626 | 626 |
| 627 class HeapSnapshotJSONSerializer { | 627 class HeapSnapshotJSONSerializer { |
| 628 public: | 628 public: |
| 629 explicit HeapSnapshotJSONSerializer(HeapSnapshot* snapshot) | 629 explicit HeapSnapshotJSONSerializer(HeapSnapshot* snapshot) |
| 630 : snapshot_(snapshot), | 630 : snapshot_(snapshot), |
| 631 strings_(ObjectsMatch), | 631 strings_(StringsMatch), |
| 632 next_node_id_(1), | 632 next_node_id_(1), |
| 633 next_string_id_(1), | 633 next_string_id_(1), |
| 634 writer_(NULL) { | 634 writer_(NULL) { |
| 635 } | 635 } |
| 636 void Serialize(v8::OutputStream* stream); | 636 void Serialize(v8::OutputStream* stream); |
| 637 | 637 |
| 638 private: | 638 private: |
| 639 INLINE(static bool ObjectsMatch(void* key1, void* key2)) { | 639 INLINE(static bool StringsMatch(void* key1, void* key2)) { |
| 640 return key1 == key2; | 640 return strcmp(reinterpret_cast<char*>(key1), |
| 641 reinterpret_cast<char*>(key2)) == 0; | |
| 641 } | 642 } |
| 642 | 643 |
| 643 INLINE(static uint32_t ObjectHash(const void* key)) { | 644 INLINE(static uint32_t StringHash(const void* string)) { |
| 644 return ComputeIntegerHash( | 645 const char* s = reinterpret_cast<const char*>(string); |
| 645 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key)), | 646 uint32_t len = strlen(s); |
|
alph
2013/09/16 08:23:49
Would be nice to have a type cast here. Otherwise
| |
| 646 v8::internal::kZeroHashSeed); | 647 return StringHasher::HashSequentialString( |
| 648 s, len, v8::internal::kZeroHashSeed); | |
| 647 } | 649 } |
| 648 | 650 |
| 649 int GetStringId(const char* s); | 651 int GetStringId(const char* s); |
| 650 int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; } | 652 int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; } |
| 651 void SerializeEdge(HeapGraphEdge* edge, bool first_edge); | 653 void SerializeEdge(HeapGraphEdge* edge, bool first_edge); |
| 652 void SerializeEdges(); | 654 void SerializeEdges(); |
| 653 void SerializeImpl(); | 655 void SerializeImpl(); |
| 654 void SerializeNode(HeapEntry* entry); | 656 void SerializeNode(HeapEntry* entry); |
| 655 void SerializeNodes(); | 657 void SerializeNodes(); |
| 656 void SerializeSnapshot(); | 658 void SerializeSnapshot(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 671 friend class HeapSnapshotJSONSerializerIterator; | 673 friend class HeapSnapshotJSONSerializerIterator; |
| 672 | 674 |
| 673 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 675 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
| 674 }; | 676 }; |
| 675 | 677 |
| 676 | 678 |
| 677 } } // namespace v8::internal | 679 } } // namespace v8::internal |
| 678 | 680 |
| 679 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ | 681 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ |
| 680 | 682 |
| OLD | NEW |