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

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

Issue 24205004: Rollback trunk to 3.21.16.2 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: 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 | « src/heap-snapshot-generator.h ('k') | src/hydrogen.h » ('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 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 SerializeStrings(); 2465 SerializeStrings();
2466 if (writer_->aborted()) return; 2466 if (writer_->aborted()) return;
2467 writer_->AddCharacter(']'); 2467 writer_->AddCharacter(']');
2468 writer_->AddCharacter('}'); 2468 writer_->AddCharacter('}');
2469 writer_->Finalize(); 2469 writer_->Finalize();
2470 } 2470 }
2471 2471
2472 2472
2473 int HeapSnapshotJSONSerializer::GetStringId(const char* s) { 2473 int HeapSnapshotJSONSerializer::GetStringId(const char* s) {
2474 HashMap::Entry* cache_entry = strings_.Lookup( 2474 HashMap::Entry* cache_entry = strings_.Lookup(
2475 const_cast<char*>(s), StringHash(s), true); 2475 const_cast<char*>(s), ObjectHash(s), true);
2476 if (cache_entry->value == NULL) { 2476 if (cache_entry->value == NULL) {
2477 cache_entry->value = reinterpret_cast<void*>(next_string_id_++); 2477 cache_entry->value = reinterpret_cast<void*>(next_string_id_++);
2478 } 2478 }
2479 return static_cast<int>(reinterpret_cast<intptr_t>(cache_entry->value)); 2479 return static_cast<int>(reinterpret_cast<intptr_t>(cache_entry->value));
2480 } 2480 }
2481 2481
2482 2482
2483 static int utoa(unsigned value, const Vector<char>& buffer, int buffer_pos) { 2483 static int utoa(unsigned value, const Vector<char>& buffer, int buffer_pos) {
2484 int number_of_digits = 0; 2484 int number_of_digits = 0;
2485 unsigned t = value; 2485 unsigned t = value;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2686 writer_->AddCharacter('?'); 2686 writer_->AddCharacter('?');
2687 } 2687 }
2688 } 2688 }
2689 } 2689 }
2690 } 2690 }
2691 writer_->AddCharacter('\"'); 2691 writer_->AddCharacter('\"');
2692 } 2692 }
2693 2693
2694 2694
2695 void HeapSnapshotJSONSerializer::SerializeStrings() { 2695 void HeapSnapshotJSONSerializer::SerializeStrings() {
2696 ScopedVector<const unsigned char*> sorted_strings( 2696 List<HashMap::Entry*> sorted_strings;
2697 strings_.occupancy() + 1); 2697 SortHashMap(&strings_, &sorted_strings);
2698 for (HashMap::Entry* entry = strings_.Start();
2699 entry != NULL;
2700 entry = strings_.Next(entry)) {
2701 int index = static_cast<int>(reinterpret_cast<uintptr_t>(entry->value));
2702 sorted_strings[index] = reinterpret_cast<const unsigned char*>(entry->key);
2703 }
2704 writer_->AddString("\"<dummy>\""); 2698 writer_->AddString("\"<dummy>\"");
2705 for (int i = 1; i < sorted_strings.length(); ++i) { 2699 for (int i = 0; i < sorted_strings.length(); ++i) {
2706 writer_->AddCharacter(','); 2700 writer_->AddCharacter(',');
2707 SerializeString(sorted_strings[i]); 2701 SerializeString(
2702 reinterpret_cast<const unsigned char*>(sorted_strings[i]->key));
2708 if (writer_->aborted()) return; 2703 if (writer_->aborted()) return;
2709 } 2704 }
2710 } 2705 }
2711 2706
2712 2707
2708 template<typename T>
2709 inline static int SortUsingEntryValue(const T* x, const T* y) {
2710 uintptr_t x_uint = reinterpret_cast<uintptr_t>((*x)->value);
2711 uintptr_t y_uint = reinterpret_cast<uintptr_t>((*y)->value);
2712 if (x_uint > y_uint) {
2713 return 1;
2714 } else if (x_uint == y_uint) {
2715 return 0;
2716 } else {
2717 return -1;
2718 }
2719 }
2720
2721
2722 void HeapSnapshotJSONSerializer::SortHashMap(
2723 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2724 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2725 sorted_entries->Add(p);
2726 sorted_entries->Sort(SortUsingEntryValue);
2727 }
2728
2713 } } // namespace v8::internal 2729 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698