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

Side by Side Diff: src/profile-generator.cc

Issue 9632020: V8 crashes when profile generator is trying to allocate a raw_entries_ buffer more than 2Gb. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fixed problems with x64, ia32 etc. Created 8 years, 9 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
« src/profile-generator.h ('K') | « src/profile-generator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 case kArray: return "/array/"; 1089 case kArray: return "/array/";
1090 case kRegExp: return "/regexp/"; 1090 case kRegExp: return "/regexp/";
1091 case kHeapNumber: return "/number/"; 1091 case kHeapNumber: return "/number/";
1092 case kNative: return "/native/"; 1092 case kNative: return "/native/";
1093 case kSynthetic: return "/synthetic/"; 1093 case kSynthetic: return "/synthetic/";
1094 default: return "???"; 1094 default: return "???";
1095 } 1095 }
1096 } 1096 }
1097 1097
1098 1098
1099 int HeapEntry::EntriesSize(int entries_count, 1099 size_t HeapEntry::EntriesSize(int entries_count,
1100 int children_count, 1100 int children_count,
1101 int retainers_count) { 1101 int retainers_count) {
1102 return sizeof(HeapEntry) * entries_count // NOLINT 1102 return sizeof(HeapEntry) * entries_count // NOLINT
1103 + sizeof(HeapGraphEdge) * children_count // NOLINT 1103 + sizeof(HeapGraphEdge) * children_count // NOLINT
1104 + sizeof(HeapGraphEdge*) * retainers_count; // NOLINT 1104 + sizeof(HeapGraphEdge*) * retainers_count; // NOLINT
1105 } 1105 }
1106 1106
1107 1107
1108 // It is very important to keep objects that form a heap snapshot 1108 // It is very important to keep objects that form a heap snapshot
1109 // as small as possible. 1109 // as small as possible.
1110 namespace { // Avoid littering the global namespace. 1110 namespace { // Avoid littering the global namespace.
1111 1111
1112 template <size_t ptr_size> struct SnapshotSizeConstants; 1112 template <size_t ptr_size> struct SnapshotSizeConstants;
1113 1113
1114 template <> struct SnapshotSizeConstants<4> { 1114 template <> struct SnapshotSizeConstants<4> {
1115 static const int kExpectedHeapGraphEdgeSize = 12; 1115 static const int kExpectedHeapGraphEdgeSize = 12;
1116 static const int kExpectedHeapEntrySize = 36; 1116 static const int kExpectedHeapEntrySize = 36;
1117 static const int kMaxSerializableSnapshotRawSize = 256 * MB; 1117 static const size_t kMaxSerializableSnapshotRawSize = 256 * MB;
1118 }; 1118 };
1119 1119
1120 template <> struct SnapshotSizeConstants<8> { 1120 template <> struct SnapshotSizeConstants<8> {
1121 static const int kExpectedHeapGraphEdgeSize = 24; 1121 static const int kExpectedHeapGraphEdgeSize = 24;
1122 static const int kExpectedHeapEntrySize = 48; 1122 static const int kExpectedHeapEntrySize = 48;
1123 static const int kMaxSerializableSnapshotRawSize = 768 * MB; 1123 static const uint64_t kMaxSerializableSnapshotRawSize =
1124 static_cast<uint64_t>(6000) * MB;
alexeif 2012/03/11 14:30:04 nit: V8_UINT64_C(6000)
1124 }; 1125 };
1125 1126
1126 } // namespace 1127 } // namespace
1127 1128
1128 HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection, 1129 HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection,
1129 HeapSnapshot::Type type, 1130 HeapSnapshot::Type type,
1130 const char* title, 1131 const char* title,
1131 unsigned uid) 1132 unsigned uid)
1132 : collection_(collection), 1133 : collection_(collection),
1133 type_(type), 1134 type_(type),
(...skipping 2296 matching lines...) Expand 10 before | Expand all | Expand 10 after
3430 3431
3431 HeapSnapshot* HeapSnapshotJSONSerializer::CreateFakeSnapshot() { 3432 HeapSnapshot* HeapSnapshotJSONSerializer::CreateFakeSnapshot() {
3432 HeapSnapshot* result = new HeapSnapshot(snapshot_->collection(), 3433 HeapSnapshot* result = new HeapSnapshot(snapshot_->collection(),
3433 HeapSnapshot::kFull, 3434 HeapSnapshot::kFull,
3434 snapshot_->title(), 3435 snapshot_->title(),
3435 snapshot_->uid()); 3436 snapshot_->uid());
3436 result->AllocateEntries(2, 1, 0); 3437 result->AllocateEntries(2, 1, 0);
3437 HeapEntry* root = result->AddRootEntry(1); 3438 HeapEntry* root = result->AddRootEntry(1);
3438 const char* text = snapshot_->collection()->names()->GetFormatted( 3439 const char* text = snapshot_->collection()->names()->GetFormatted(
3439 "The snapshot is too big. " 3440 "The snapshot is too big. "
3440 "Maximum snapshot size is %d MB. " 3441 "Maximum snapshot size is %" V8_PTR_PREFIX "u MB. "
3441 "Actual snapshot size is %d MB.", 3442 "Actual snapshot size is %" V8_PTR_PREFIX "u MB.",
3442 SnapshotSizeConstants<kPointerSize>::kMaxSerializableSnapshotRawSize / MB, 3443 SnapshotSizeConstants<kPointerSize>::kMaxSerializableSnapshotRawSize / MB,
3443 (snapshot_->raw_entries_size() + MB - 1) / MB); 3444 (snapshot_->raw_entries_size() + MB - 1) / MB);
3444 HeapEntry* message = result->AddEntry( 3445 HeapEntry* message = result->AddEntry(
3445 HeapEntry::kString, text, 0, 4, 0, 0); 3446 HeapEntry::kString, text, 0, 4, 0, 0);
3446 root->SetUnidirElementReference(0, 1, message); 3447 root->SetUnidirElementReference(0, 1, message);
3447 result->SetDominatorsToSelf(); 3448 result->SetDominatorsToSelf();
3448 return result; 3449 return result;
3449 } 3450 }
3450 3451
3451 3452
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
3735 3736
3736 3737
3737 void HeapSnapshotJSONSerializer::SortHashMap( 3738 void HeapSnapshotJSONSerializer::SortHashMap(
3738 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3739 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3739 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3740 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3740 sorted_entries->Add(p); 3741 sorted_entries->Add(p);
3741 sorted_entries->Sort(SortUsingEntryValue); 3742 sorted_entries->Sort(SortUsingEntryValue);
3742 } 3743 }
3743 3744
3744 } } // namespace v8::internal 3745 } } // namespace v8::internal
OLDNEW
« src/profile-generator.h ('K') | « src/profile-generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698