| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/freelist.h" | 5 #include "vm/freelist.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "vm/bit_set.h" | 10 #include "vm/bit_set.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 for (int i = 0; i < kNumLists; ++i) { | 156 for (int i = 0; i < kNumLists; ++i) { |
| 157 if (free_lists_[i] == NULL) { | 157 if (free_lists_[i] == NULL) { |
| 158 continue; | 158 continue; |
| 159 } | 159 } |
| 160 small_sizes += 1; | 160 small_sizes += 1; |
| 161 intptr_t list_length = Length(i); | 161 intptr_t list_length = Length(i); |
| 162 small_objects += list_length; | 162 small_objects += list_length; |
| 163 intptr_t list_bytes = list_length * i * kObjectAlignment; | 163 intptr_t list_bytes = list_length * i * kObjectAlignment; |
| 164 small_bytes += list_bytes; | 164 small_bytes += list_bytes; |
| 165 OS::Print("small %3d [%8d bytes] : " | 165 OS::Print("small %3d [%8d bytes] : " |
| 166 "%8"Pd" objs; %8.1f KB; %8.1f cum KB\n", | 166 "%8" Pd " objs; %8.1f KB; %8.1f cum KB\n", |
| 167 i, | 167 i, |
| 168 i * kObjectAlignment, | 168 i * kObjectAlignment, |
| 169 list_length, | 169 list_length, |
| 170 list_bytes / static_cast<double>(KB), | 170 list_bytes / static_cast<double>(KB), |
| 171 small_bytes / static_cast<double>(KB)); | 171 small_bytes / static_cast<double>(KB)); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 | 175 |
| 176 void FreeList::PrintLarge() const { | 176 void FreeList::PrintLarge() const { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 188 large_sizes += 1; | 188 large_sizes += 1; |
| 189 sorted.insert(std::make_pair(node->Size(), 1)); | 189 sorted.insert(std::make_pair(node->Size(), 1)); |
| 190 } | 190 } |
| 191 large_objects += 1; | 191 large_objects += 1; |
| 192 } | 192 } |
| 193 for (it = sorted.begin(); it != sorted.end(); ++it) { | 193 for (it = sorted.begin(); it != sorted.end(); ++it) { |
| 194 intptr_t size = it->first; | 194 intptr_t size = it->first; |
| 195 intptr_t list_length = it->second; | 195 intptr_t list_length = it->second; |
| 196 intptr_t list_bytes = list_length * size; | 196 intptr_t list_bytes = list_length * size; |
| 197 large_bytes += list_bytes; | 197 large_bytes += list_bytes; |
| 198 OS::Print("large %3"Pd" [%8"Pd" bytes] : " | 198 OS::Print("large %3" Pd " [%8" Pd " bytes] : " |
| 199 "%8"Pd" objs; %8.1f KB; %8.1f cum KB\n", | 199 "%8" Pd " objs; %8.1f KB; %8.1f cum KB\n", |
| 200 size / kObjectAlignment, | 200 size / kObjectAlignment, |
| 201 size, | 201 size, |
| 202 list_length, | 202 list_length, |
| 203 list_bytes / static_cast<double>(KB), | 203 list_bytes / static_cast<double>(KB), |
| 204 large_bytes / static_cast<double>(KB)); | 204 large_bytes / static_cast<double>(KB)); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 | 208 |
| 209 void FreeList::Print() const { | 209 void FreeList::Print() const { |
| 210 PrintSmall(); | 210 PrintSmall(); |
| 211 PrintLarge(); | 211 PrintLarge(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 | 214 |
| 215 void FreeList::SplitElementAfterAndEnqueue(FreeListElement* element, | 215 void FreeList::SplitElementAfterAndEnqueue(FreeListElement* element, |
| 216 intptr_t size) { | 216 intptr_t size) { |
| 217 intptr_t remainder_size = element->Size() - size; | 217 intptr_t remainder_size = element->Size() - size; |
| 218 if (remainder_size == 0) return; | 218 if (remainder_size == 0) return; |
| 219 | 219 |
| 220 element = FreeListElement::AsElement(reinterpret_cast<uword>(element) + size, | 220 element = FreeListElement::AsElement(reinterpret_cast<uword>(element) + size, |
| 221 remainder_size); | 221 remainder_size); |
| 222 intptr_t remainder_index = IndexForSize(remainder_size); | 222 intptr_t remainder_index = IndexForSize(remainder_size); |
| 223 EnqueueElement(element, remainder_index); | 223 EnqueueElement(element, remainder_index); |
| 224 } | 224 } |
| 225 | 225 |
| 226 } // namespace dart | 226 } // namespace dart |
| OLD | NEW |