Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: src/heap-snapshot-generator.h

Issue 24120006: HeapProfiler: Make strings unique in HeapProfile. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments addressed Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/heap-snapshot-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 int len = static_cast<int>(strlen(s));
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
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
OLDNEW
« no previous file with comments | « no previous file | src/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698