OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/class_table.h" | 5 #include "vm/class_table.h" |
6 #include "vm/flags.h" | 6 #include "vm/flags.h" |
7 #include "vm/freelist.h" | 7 #include "vm/freelist.h" |
8 #include "vm/growable_array.h" | 8 #include "vm/growable_array.h" |
9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 cls = At(i); | 217 cls = At(i); |
218 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { | 218 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { |
219 name = cls.Name(); | 219 name = cls.Name(); |
220 OS::Print("%" Pd ": %s\n", i, name.ToCString()); | 220 OS::Print("%" Pd ": %s\n", i, name.ToCString()); |
221 } | 221 } |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 | 225 |
226 void ClassTable::PrintToJSONObject(JSONObject* object) { | 226 void ClassTable::PrintToJSONObject(JSONObject* object) { |
| 227 if (!FLAG_support_service) { |
| 228 return; |
| 229 } |
227 Class& cls = Class::Handle(); | 230 Class& cls = Class::Handle(); |
228 object->AddProperty("type", "ClassList"); | 231 object->AddProperty("type", "ClassList"); |
229 { | 232 { |
230 JSONArray members(object, "classes"); | 233 JSONArray members(object, "classes"); |
231 for (intptr_t i = 1; i < top_; i++) { | 234 for (intptr_t i = 1; i < top_; i++) { |
232 if (HasValidClassAt(i)) { | 235 if (HasValidClassAt(i)) { |
233 cls = At(i); | 236 cls = At(i); |
234 members.AddValue(cls); | 237 members.AddValue(cls); |
235 } | 238 } |
236 } | 239 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 313 |
311 | 314 |
312 void ClassHeapStats::UpdatePromotedAfterNewGC() { | 315 void ClassHeapStats::UpdatePromotedAfterNewGC() { |
313 promoted_count = recent.old_count - old_pre_new_gc_count_; | 316 promoted_count = recent.old_count - old_pre_new_gc_count_; |
314 promoted_size = recent.old_size - old_pre_new_gc_size_; | 317 promoted_size = recent.old_size - old_pre_new_gc_size_; |
315 } | 318 } |
316 | 319 |
317 | 320 |
318 void ClassHeapStats::PrintToJSONObject(const Class& cls, | 321 void ClassHeapStats::PrintToJSONObject(const Class& cls, |
319 JSONObject* obj) const { | 322 JSONObject* obj) const { |
| 323 if (!FLAG_support_service) { |
| 324 return; |
| 325 } |
320 obj->AddProperty("type", "ClassHeapStats"); | 326 obj->AddProperty("type", "ClassHeapStats"); |
321 obj->AddProperty("class", cls); | 327 obj->AddProperty("class", cls); |
322 { | 328 { |
323 JSONArray new_stats(obj, "new"); | 329 JSONArray new_stats(obj, "new"); |
324 new_stats.AddValue(pre_gc.new_count); | 330 new_stats.AddValue(pre_gc.new_count); |
325 new_stats.AddValue(pre_gc.new_size); | 331 new_stats.AddValue(pre_gc.new_size); |
326 new_stats.AddValue(post_gc.new_count); | 332 new_stats.AddValue(post_gc.new_count); |
327 new_stats.AddValue(post_gc.new_size); | 333 new_stats.AddValue(post_gc.new_size); |
328 new_stats.AddValue(recent.new_count); | 334 new_stats.AddValue(recent.new_count); |
329 new_stats.AddValue(recent.new_size); | 335 new_stats.AddValue(recent.new_size); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 intptr_t ClassTable::SizeOffsetFor(intptr_t cid, bool is_new_space) { | 471 intptr_t ClassTable::SizeOffsetFor(intptr_t cid, bool is_new_space) { |
466 const uword class_offset = ClassOffsetFor(cid); | 472 const uword class_offset = ClassOffsetFor(cid); |
467 const uword size_field_offset = is_new_space | 473 const uword size_field_offset = is_new_space |
468 ? ClassHeapStats::allocated_size_since_gc_new_space_offset() | 474 ? ClassHeapStats::allocated_size_since_gc_new_space_offset() |
469 : ClassHeapStats::allocated_size_since_gc_old_space_offset(); | 475 : ClassHeapStats::allocated_size_since_gc_old_space_offset(); |
470 return class_offset + size_field_offset; | 476 return class_offset + size_field_offset; |
471 } | 477 } |
472 | 478 |
473 | 479 |
474 void ClassTable::AllocationProfilePrintJSON(JSONStream* stream) { | 480 void ClassTable::AllocationProfilePrintJSON(JSONStream* stream) { |
| 481 if (!FLAG_support_service) { |
| 482 return; |
| 483 } |
475 Isolate* isolate = Isolate::Current(); | 484 Isolate* isolate = Isolate::Current(); |
476 ASSERT(isolate != NULL); | 485 ASSERT(isolate != NULL); |
477 Heap* heap = isolate->heap(); | 486 Heap* heap = isolate->heap(); |
478 ASSERT(heap != NULL); | 487 ASSERT(heap != NULL); |
479 JSONObject obj(stream); | 488 JSONObject obj(stream); |
480 obj.AddProperty("type", "AllocationProfile"); | 489 obj.AddProperty("type", "AllocationProfile"); |
481 obj.AddPropertyF( | 490 obj.AddPropertyF( |
482 "dateLastAccumulatorReset", | 491 "dateLastAccumulatorReset", |
483 "%" Pd64 "", | 492 "%" Pd64 "", |
484 isolate->last_allocationprofile_accumulator_reset_timestamp()); | 493 isolate->last_allocationprofile_accumulator_reset_timestamp()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 | 541 |
533 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { | 542 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { |
534 ClassHeapStats* stats = PreliminaryStatsAt(cid); | 543 ClassHeapStats* stats = PreliminaryStatsAt(cid); |
535 ASSERT(stats != NULL); | 544 ASSERT(stats != NULL); |
536 ASSERT(size >= 0); | 545 ASSERT(size >= 0); |
537 stats->post_gc.AddNew(size); | 546 stats->post_gc.AddNew(size); |
538 } | 547 } |
539 | 548 |
540 | 549 |
541 } // namespace dart | 550 } // namespace dart |
OLD | NEW |