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 7830036: Optimize isFinite and isNaN. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Made the change general by moving putting it in the NUMBER_IS_FINITE macro. Created 9 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/profile-generator.h ('k') | src/regexp.js » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 void HeapSnapshot::Delete() { 1188 void HeapSnapshot::Delete() {
1189 collection_->RemoveSnapshot(this); 1189 collection_->RemoveSnapshot(this);
1190 delete this; 1190 delete this;
1191 } 1191 }
1192 1192
1193 1193
1194 void HeapSnapshot::AllocateEntries(int entries_count, 1194 void HeapSnapshot::AllocateEntries(int entries_count,
1195 int children_count, 1195 int children_count,
1196 int retainers_count) { 1196 int retainers_count) {
1197 ASSERT(raw_entries_ == NULL); 1197 ASSERT(raw_entries_ == NULL);
1198 raw_entries_ = NewArray<char>(
1199 HeapEntry::EntriesSize(entries_count, children_count, retainers_count));
1200 #ifdef DEBUG
1198 raw_entries_size_ = 1201 raw_entries_size_ =
1199 HeapEntry::EntriesSize(entries_count, children_count, retainers_count); 1202 HeapEntry::EntriesSize(entries_count, children_count, retainers_count);
1200 raw_entries_ = NewArray<char>(raw_entries_size_); 1203 #endif
1201 } 1204 }
1202 1205
1203 1206
1204 static void HeapEntryClearPaint(HeapEntry** entry_ptr) { 1207 static void HeapEntryClearPaint(HeapEntry** entry_ptr) {
1205 (*entry_ptr)->clear_paint(); 1208 (*entry_ptr)->clear_paint();
1206 } 1209 }
1207 1210
1208 void HeapSnapshot::ClearPaint() { 1211 void HeapSnapshot::ClearPaint() {
1209 entries_.Iterate(HeapEntryClearPaint); 1212 entries_.Iterate(HeapEntryClearPaint);
1210 } 1213 }
(...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 v8::OutputStream::kAbort) aborted_ = true; 2977 v8::OutputStream::kAbort) aborted_ = true;
2975 } 2978 }
2976 2979
2977 v8::OutputStream* stream_; 2980 v8::OutputStream* stream_;
2978 int chunk_size_; 2981 int chunk_size_;
2979 ScopedVector<char> chunk_; 2982 ScopedVector<char> chunk_;
2980 int chunk_pos_; 2983 int chunk_pos_;
2981 bool aborted_; 2984 bool aborted_;
2982 }; 2985 };
2983 2986
2984 const int HeapSnapshotJSONSerializer::kMaxSerializableSnapshotRawSize =
2985 256 * MB;
2986
2987 void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) { 2987 void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) {
2988 ASSERT(writer_ == NULL); 2988 ASSERT(writer_ == NULL);
2989 writer_ = new OutputStreamWriter(stream); 2989 writer_ = new OutputStreamWriter(stream);
2990 2990
2991 HeapSnapshot* original_snapshot = NULL;
2992 if (snapshot_->raw_entries_size() >= kMaxSerializableSnapshotRawSize) {
2993 // The snapshot is too big. Serialize a fake snapshot.
2994 original_snapshot = snapshot_;
2995 snapshot_ = CreateFakeSnapshot();
2996 }
2997 // Since nodes graph is cyclic, we need the first pass to enumerate 2991 // Since nodes graph is cyclic, we need the first pass to enumerate
2998 // them. Strings can be serialized in one pass. 2992 // them. Strings can be serialized in one pass.
2999 EnumerateNodes(); 2993 EnumerateNodes();
3000 SerializeImpl(); 2994 SerializeImpl();
3001 2995
3002 delete writer_; 2996 delete writer_;
3003 writer_ = NULL; 2997 writer_ = NULL;
3004
3005 if (original_snapshot != NULL) {
3006 delete snapshot_;
3007 snapshot_ = original_snapshot;
3008 }
3009 } 2998 }
3010 2999
3011 3000
3012 HeapSnapshot* HeapSnapshotJSONSerializer::CreateFakeSnapshot() {
3013 HeapSnapshot* result = new HeapSnapshot(snapshot_->collection(),
3014 HeapSnapshot::kFull,
3015 snapshot_->title(),
3016 snapshot_->uid());
3017 result->AllocateEntries(2, 1, 0);
3018 HeapEntry* root = result->AddRootEntry(1);
3019 HeapEntry* message = result->AddEntry(
3020 HeapEntry::kString, "The snapshot is too big", 0, 4, 0, 0);
3021 root->SetUnidirElementReference(0, 1, message);
3022 result->SetDominatorsToSelf();
3023 return result;
3024 }
3025
3026
3027 void HeapSnapshotJSONSerializer::SerializeImpl() { 3001 void HeapSnapshotJSONSerializer::SerializeImpl() {
3028 writer_->AddCharacter('{'); 3002 writer_->AddCharacter('{');
3029 writer_->AddString("\"snapshot\":{"); 3003 writer_->AddString("\"snapshot\":{");
3030 SerializeSnapshot(); 3004 SerializeSnapshot();
3031 if (writer_->aborted()) return; 3005 if (writer_->aborted()) return;
3032 writer_->AddString("},\n"); 3006 writer_->AddString("},\n");
3033 writer_->AddString("\"nodes\":["); 3007 writer_->AddString("\"nodes\":[");
3034 SerializeNodes(); 3008 SerializeNodes();
3035 if (writer_->aborted()) return; 3009 if (writer_->aborted()) return;
3036 writer_->AddString("],\n"); 3010 writer_->AddString("],\n");
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
3294 3268
3295 3269
3296 void HeapSnapshotJSONSerializer::SortHashMap( 3270 void HeapSnapshotJSONSerializer::SortHashMap(
3297 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3271 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3298 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3272 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3299 sorted_entries->Add(p); 3273 sorted_entries->Add(p);
3300 sorted_entries->Sort(SortUsingEntryValue); 3274 sorted_entries->Sort(SortUsingEntryValue);
3301 } 3275 }
3302 3276
3303 } } // namespace v8::internal 3277 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | src/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698