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

Side by Side Diff: runtime/vm/class_table.cc

Issue 2117593002: Fuchsia: Initial check-in. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 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
« no previous file with comments | « runtime/vm/class_table.h ('k') | runtime/vm/cpuinfo_fuchsia.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 (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"
6
5 #include "vm/atomic.h" 7 #include "vm/atomic.h"
6 #include "vm/class_table.h"
7 #include "vm/flags.h" 8 #include "vm/flags.h"
8 #include "vm/freelist.h" 9 #include "vm/freelist.h"
9 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
10 #include "vm/heap.h" 11 #include "vm/heap.h"
11 #include "vm/object.h" 12 #include "vm/object.h"
12 #include "vm/raw_object.h" 13 #include "vm/raw_object.h"
13 #include "vm/visitor.h" 14 #include "vm/visitor.h"
14 15
15 namespace dart { 16 namespace dart {
16 17
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 228 }
228 cls = At(i); 229 cls = At(i);
229 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { 230 if (cls.raw() != reinterpret_cast<RawClass*>(0)) {
230 name = cls.Name(); 231 name = cls.Name();
231 OS::Print("%" Pd ": %s\n", i, name.ToCString()); 232 OS::Print("%" Pd ": %s\n", i, name.ToCString());
232 } 233 }
233 } 234 }
234 } 235 }
235 236
236 237
238 #ifndef PRODUCT
237 void ClassTable::PrintToJSONObject(JSONObject* object) { 239 void ClassTable::PrintToJSONObject(JSONObject* object) {
238 if (!FLAG_support_service) { 240 if (!FLAG_support_service) {
239 return; 241 return;
240 } 242 }
241 Class& cls = Class::Handle(); 243 Class& cls = Class::Handle();
242 object->AddProperty("type", "ClassList"); 244 object->AddProperty("type", "ClassList");
243 { 245 {
244 JSONArray members(object, "classes"); 246 JSONArray members(object, "classes");
245 for (intptr_t i = 1; i < top_; i++) { 247 for (intptr_t i = 1; i < top_; i++) {
246 if (HasValidClassAt(i)) { 248 if (HasValidClassAt(i)) {
247 cls = At(i); 249 cls = At(i);
248 members.AddValue(cls); 250 members.AddValue(cls);
249 } 251 }
250 } 252 }
251 } 253 }
252 } 254 }
255 #endif // PRODUCT
253 256
254 257
255 void ClassHeapStats::Initialize() { 258 void ClassHeapStats::Initialize() {
256 pre_gc.Reset(); 259 pre_gc.Reset();
257 post_gc.Reset(); 260 post_gc.Reset();
258 recent.Reset(); 261 recent.Reset();
259 accumulated.Reset(); 262 accumulated.Reset();
260 last_reset.Reset(); 263 last_reset.Reset();
261 promoted_count = 0; 264 promoted_count = 0;
262 promoted_size = 0; 265 promoted_size = 0;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 accumulated.Reset(); 325 accumulated.Reset();
323 } 326 }
324 327
325 328
326 void ClassHeapStats::UpdatePromotedAfterNewGC() { 329 void ClassHeapStats::UpdatePromotedAfterNewGC() {
327 promoted_count = recent.old_count - old_pre_new_gc_count_; 330 promoted_count = recent.old_count - old_pre_new_gc_count_;
328 promoted_size = recent.old_size - old_pre_new_gc_size_; 331 promoted_size = recent.old_size - old_pre_new_gc_size_;
329 } 332 }
330 333
331 334
335 #ifndef PRODUCT
332 void ClassHeapStats::PrintToJSONObject(const Class& cls, 336 void ClassHeapStats::PrintToJSONObject(const Class& cls,
333 JSONObject* obj) const { 337 JSONObject* obj) const {
334 if (!FLAG_support_service) { 338 if (!FLAG_support_service) {
335 return; 339 return;
336 } 340 }
337 obj->AddProperty("type", "ClassHeapStats"); 341 obj->AddProperty("type", "ClassHeapStats");
338 obj->AddProperty("class", cls); 342 obj->AddProperty("class", cls);
339 { 343 {
340 JSONArray new_stats(obj, "new"); 344 JSONArray new_stats(obj, "new");
341 new_stats.AddValue(pre_gc.new_count); 345 new_stats.AddValue(pre_gc.new_count);
(...skipping 16 matching lines...) Expand all
358 old_stats.AddValue(recent.old_count); 362 old_stats.AddValue(recent.old_count);
359 old_stats.AddValue(recent.old_size); 363 old_stats.AddValue(recent.old_size);
360 old_stats.AddValue64(accumulated.old_count + recent.old_count - 364 old_stats.AddValue64(accumulated.old_count + recent.old_count -
361 last_reset.old_count); 365 last_reset.old_count);
362 old_stats.AddValue64(accumulated.old_size + recent.old_size - 366 old_stats.AddValue64(accumulated.old_size + recent.old_size -
363 last_reset.old_size); 367 last_reset.old_size);
364 } 368 }
365 obj->AddProperty("promotedInstances", promoted_count); 369 obj->AddProperty("promotedInstances", promoted_count);
366 obj->AddProperty("promotedBytes", promoted_size); 370 obj->AddProperty("promotedBytes", promoted_size);
367 } 371 }
372 #endif
368 373
369 374
370 void ClassTable::UpdateAllocatedNew(intptr_t cid, intptr_t size) { 375 void ClassTable::UpdateAllocatedNew(intptr_t cid, intptr_t size) {
371 ClassHeapStats* stats = PreliminaryStatsAt(cid); 376 ClassHeapStats* stats = PreliminaryStatsAt(cid);
372 ASSERT(stats != NULL); 377 ASSERT(stats != NULL);
373 ASSERT(size != 0); 378 ASSERT(size != 0);
374 stats->recent.AddNew(size); 379 stats->recent.AddNew(size);
375 } 380 }
376 381
377 382
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 489
485 intptr_t ClassTable::SizeOffsetFor(intptr_t cid, bool is_new_space) { 490 intptr_t ClassTable::SizeOffsetFor(intptr_t cid, bool is_new_space) {
486 const uword class_offset = ClassOffsetFor(cid); 491 const uword class_offset = ClassOffsetFor(cid);
487 const uword size_field_offset = is_new_space 492 const uword size_field_offset = is_new_space
488 ? ClassHeapStats::allocated_size_since_gc_new_space_offset() 493 ? ClassHeapStats::allocated_size_since_gc_new_space_offset()
489 : ClassHeapStats::allocated_size_since_gc_old_space_offset(); 494 : ClassHeapStats::allocated_size_since_gc_old_space_offset();
490 return class_offset + size_field_offset; 495 return class_offset + size_field_offset;
491 } 496 }
492 497
493 498
499 #ifndef PRODUCT
494 void ClassTable::AllocationProfilePrintJSON(JSONStream* stream) { 500 void ClassTable::AllocationProfilePrintJSON(JSONStream* stream) {
495 if (!FLAG_support_service) { 501 if (!FLAG_support_service) {
496 return; 502 return;
497 } 503 }
498 Isolate* isolate = Isolate::Current(); 504 Isolate* isolate = Isolate::Current();
499 ASSERT(isolate != NULL); 505 ASSERT(isolate != NULL);
500 Heap* heap = isolate->heap(); 506 Heap* heap = isolate->heap();
501 ASSERT(heap != NULL); 507 ASSERT(heap != NULL);
502 JSONObject obj(stream); 508 JSONObject obj(stream);
503 obj.AddProperty("type", "AllocationProfile"); 509 obj.AddProperty("type", "AllocationProfile");
(...skipping 21 matching lines...) Expand all
525 for (intptr_t i = 1; i < top_; i++) { 531 for (intptr_t i = 1; i < top_; i++) {
526 const ClassHeapStats* stats = StatsWithUpdatedSize(i); 532 const ClassHeapStats* stats = StatsWithUpdatedSize(i);
527 if (stats != NULL) { 533 if (stats != NULL) {
528 JSONObject obj(&arr); 534 JSONObject obj(&arr);
529 cls = At(i); 535 cls = At(i);
530 stats->PrintToJSONObject(cls, &obj); 536 stats->PrintToJSONObject(cls, &obj);
531 } 537 }
532 } 538 }
533 } 539 }
534 } 540 }
541 #endif
535 542
536 543
537 void ClassTable::ResetAllocationAccumulators() { 544 void ClassTable::ResetAllocationAccumulators() {
538 for (intptr_t i = 1; i < top_; i++) { 545 for (intptr_t i = 1; i < top_; i++) {
539 ClassHeapStats* stats = StatsWithUpdatedSize(i); 546 ClassHeapStats* stats = StatsWithUpdatedSize(i);
540 if (stats != NULL) { 547 if (stats != NULL) {
541 stats->ResetAccumulator(); 548 stats->ResetAccumulator();
542 } 549 }
543 } 550 }
544 } 551 }
(...skipping 10 matching lines...) Expand all
555 562
556 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { 563 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) {
557 ClassHeapStats* stats = PreliminaryStatsAt(cid); 564 ClassHeapStats* stats = PreliminaryStatsAt(cid);
558 ASSERT(stats != NULL); 565 ASSERT(stats != NULL);
559 ASSERT(size >= 0); 566 ASSERT(size >= 0);
560 stats->post_gc.AddNew(size); 567 stats->post_gc.AddNew(size);
561 } 568 }
562 569
563 570
564 } // namespace dart 571 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_table.h ('k') | runtime/vm/cpuinfo_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698