Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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_counts_)); | |
|
Michael Starzinger
2012/07/12 20:12:26
Better use sizeof(object_sizes_) here.
danno
2012/07/12 21:18:16
Done.
| |
| 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 void Heap::CheckpointObjectStats() { | |
| 7242 Counters* counters = isolate()->counters(); | |
| 7243 #define ADJUST_LAST_TIME_OBJECT_COUNT(name) \ | |
| 7244 counters->count_of_##name()->Increment(object_counts_[name]); \ | |
|
Michael Starzinger
2012/07/12 20:12:26
Is there a particular reason we cannot use counter
danno
2012/07/12 21:18:16
Yes, the reason is that you can have multiple isol
| |
| 7245 counters->count_of_##name()->Decrement(object_counts_last_time_[name]); \ | |
| 7246 counters->size_of_##name()->Increment(object_sizes_[name]); \ | |
| 7247 counters->size_of_##name()->Decrement(object_sizes_last_time_[name]); | |
| 7248 INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | |
| 7249 #undef ADJUST_LAST_TIME_OBJECT_COUNT | |
| 7250 memcpy(object_counts_last_time_, object_counts_, | |
| 7251 sizeof(object_counts_)); | |
| 7252 memcpy(object_sizes_last_time_, object_sizes_, | |
| 7253 sizeof(object_sizes_)); | |
| 7254 ClearObjectStats(); | |
| 7255 } | |
| 7256 | |
| 7228 } } // namespace v8::internal | 7257 } } // namespace v8::internal |
| OLD | NEW |