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

Side by Side Diff: src/heap.cc

Issue 10702168: Add counters that automatically track object sizes and counts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Whitespace change Created 8 years, 5 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.h ('k') | src/mark-compact.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 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 } 173 }
174 174
175 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); 175 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength);
176 global_contexts_list_ = NULL; 176 global_contexts_list_ = NULL;
177 mark_compact_collector_.heap_ = this; 177 mark_compact_collector_.heap_ = this;
178 external_string_table_.heap_ = this; 178 external_string_table_.heap_ = this;
179 // Put a dummy entry in the remembered pages so we can find the list the 179 // Put a dummy entry in the remembered pages so we can find the list the
180 // minidump even if there are no real unmapped pages. 180 // minidump even if there are no real unmapped pages.
181 RememberUnmappedPage(NULL, false); 181 RememberUnmappedPage(NULL, false);
182
183 ClearObjectStats(true);
182 } 184 }
183 185
184 186
185 intptr_t Heap::Capacity() { 187 intptr_t Heap::Capacity() {
186 if (!HasBeenSetUp()) return 0; 188 if (!HasBeenSetUp()) return 0;
187 189
188 return new_space_.Capacity() + 190 return new_space_.Capacity() +
189 old_pointer_space_->Capacity() + 191 old_pointer_space_->Capacity() +
190 old_data_space_->Capacity() + 192 old_data_space_->Capacity() +
191 code_space_->Capacity() + 193 code_space_->Capacity() +
(...skipping 7026 matching lines...) Expand 10 before | Expand all | Expand 10 after
7218 p ^= 0xc1ead & (Page::kPageSize - 1); // Cleared. 7220 p ^= 0xc1ead & (Page::kPageSize - 1); // Cleared.
7219 } else { 7221 } else {
7220 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. 7222 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died.
7221 } 7223 }
7222 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = 7224 remembered_unmapped_pages_[remembered_unmapped_pages_index_] =
7223 reinterpret_cast<Address>(p); 7225 reinterpret_cast<Address>(p);
7224 remembered_unmapped_pages_index_++; 7226 remembered_unmapped_pages_index_++;
7225 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages; 7227 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages;
7226 } 7228 }
7227 7229
7230
7231 void Heap::ClearObjectStats(bool clear_last_time_stats) {
7232 memset(object_counts_, 0, sizeof(object_counts_));
7233 memset(object_sizes_, 0, sizeof(object_sizes_));
7234 if (clear_last_time_stats) {
7235 memset(object_counts_last_time_, 0, sizeof(object_counts_last_time_));
7236 memset(object_sizes_last_time_, 0, sizeof(object_sizes_last_time_));
7237 }
7238 }
7239
7240
7241 static LazyMutex checkpoint_object_stats_mutex = LAZY_MUTEX_INITIALIZER;
7242
7243
7244 void Heap::CheckpointObjectStats() {
7245 ScopedLock lock(checkpoint_object_stats_mutex.Pointer());
7246 Counters* counters = isolate()->counters();
7247 #define ADJUST_LAST_TIME_OBJECT_COUNT(name) \
7248 counters->count_of_##name()->Increment(object_counts_[name]); \
7249 counters->count_of_##name()->Decrement(object_counts_last_time_[name]); \
7250 counters->size_of_##name()->Increment(object_sizes_[name]); \
7251 counters->size_of_##name()->Decrement(object_sizes_last_time_[name]);
7252 INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7253 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7254 memcpy(object_counts_last_time_, object_counts_,
7255 sizeof(object_counts_));
7256 memcpy(object_sizes_last_time_, object_sizes_,
7257 sizeof(object_sizes_));
7258 ClearObjectStats();
7259 }
7260
7228 } } // namespace v8::internal 7261 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698