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

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

Issue 51653006: Track live instance and allocation counts for classes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | « runtime/vm/assembler_mips.h ('k') | runtime/vm/assembler_x64.h » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/longjump.h" 9 #include "vm/longjump.h"
10 #include "vm/runtime_entry.h" 10 #include "vm/runtime_entry.h"
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 void Assembler::LeaveStubFrameAndReturn(Register ra) { 674 void Assembler::LeaveStubFrameAndReturn(Register ra) {
675 addiu(SP, FP, Immediate(-1 * kWordSize)); 675 addiu(SP, FP, Immediate(-1 * kWordSize));
676 lw(RA, Address(SP, 2 * kWordSize)); 676 lw(RA, Address(SP, 2 * kWordSize));
677 lw(FP, Address(SP, 1 * kWordSize)); 677 lw(FP, Address(SP, 1 * kWordSize));
678 lw(PP, Address(SP, 0 * kWordSize)); 678 lw(PP, Address(SP, 0 * kWordSize));
679 jr(ra); 679 jr(ra);
680 delay_slot()->addiu(SP, SP, Immediate(4 * kWordSize)); 680 delay_slot()->addiu(SP, SP, Immediate(4 * kWordSize));
681 } 681 }
682 682
683 683
684 void Assembler::UpdateAllocationStats(intptr_t cid,
685 Register temp_reg,
686 Heap::Space space) {
687 ASSERT(temp_reg != kNoRegister);
688 ASSERT(temp_reg != TMP);
689 ASSERT(cid > 0);
690 Isolate* isolate = Isolate::Current();
691 ClassTable* class_table = isolate->class_table();
692 if (cid < kNumPredefinedCids) {
693 const uword class_heap_stats_table_address =
694 class_table->PredefinedClassHeapStatsTableAddress();
695 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
696 const uword count_field_offset = (space == Heap::kNew) ?
697 ClassHeapStats::allocated_since_gc_new_space_offset() :
698 ClassHeapStats::allocated_since_gc_old_space_offset();
699 LoadImmediate(temp_reg, class_heap_stats_table_address + class_offset);
700 const Address& count_address = Address(temp_reg, count_field_offset);
701 lw(TMP, count_address);
702 AddImmediate(TMP, 1);
703 sw(TMP, count_address);
704 } else {
705 ASSERT(temp_reg != kNoRegister);
706 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
707 const uword count_field_offset = (space == Heap::kNew) ?
708 ClassHeapStats::allocated_since_gc_new_space_offset() :
709 ClassHeapStats::allocated_since_gc_old_space_offset();
710 LoadImmediate(temp_reg, class_table->ClassStatsTableAddress());
711 lw(temp_reg, Address(temp_reg, 0));
712 AddImmediate(temp_reg, class_offset);
713 lw(TMP, Address(temp_reg, count_field_offset));
714 AddImmediate(TMP, 1);
715 sw(TMP, Address(temp_reg, count_field_offset));
716 }
717 }
718
719
720 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
721 Register size_reg,
722 Register temp_reg,
723 Heap::Space space) {
724 ASSERT(temp_reg != kNoRegister);
725 ASSERT(cid > 0);
726 ASSERT(temp_reg != TMP);
727 Isolate* isolate = Isolate::Current();
728 ClassTable* class_table = isolate->class_table();
729 if (cid < kNumPredefinedCids) {
730 const uword class_heap_stats_table_address =
731 class_table->PredefinedClassHeapStatsTableAddress();
732 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
733 const uword count_field_offset = (space == Heap::kNew) ?
734 ClassHeapStats::allocated_since_gc_new_space_offset() :
735 ClassHeapStats::allocated_since_gc_old_space_offset();
736 const uword size_field_offset = (space == Heap::kNew) ?
737 ClassHeapStats::allocated_size_since_gc_new_space_offset() :
738 ClassHeapStats::allocated_size_since_gc_old_space_offset();
739 LoadImmediate(temp_reg, class_heap_stats_table_address + class_offset);
740 const Address& count_address = Address(temp_reg, count_field_offset);
741 const Address& size_address = Address(temp_reg, size_field_offset);
742 lw(TMP, count_address);
743 AddImmediate(TMP, 1);
744 sw(TMP, count_address);
745 lw(TMP, size_address);
746 addu(TMP, TMP, size_reg);
747 sw(TMP, size_address);
748 } else {
749 ASSERT(temp_reg != kNoRegister);
750 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
751 const uword count_field_offset = (space == Heap::kNew) ?
752 ClassHeapStats::allocated_since_gc_new_space_offset() :
753 ClassHeapStats::allocated_since_gc_old_space_offset();
754 const uword size_field_offset = (space == Heap::kNew) ?
755 ClassHeapStats::allocated_size_since_gc_new_space_offset() :
756 ClassHeapStats::allocated_size_since_gc_old_space_offset();
757 LoadImmediate(temp_reg, class_table->ClassStatsTableAddress());
758 lw(temp_reg, Address(temp_reg, 0));
759 AddImmediate(temp_reg, class_offset);
760 lw(TMP, Address(temp_reg, count_field_offset));
761 AddImmediate(TMP, 1);
762 sw(TMP, Address(temp_reg, count_field_offset));
763 lw(TMP, Address(temp_reg, size_field_offset));
764 addu(TMP, TMP, size_reg);
765 sw(TMP, Address(temp_reg, size_field_offset));
766 }
767 }
768
769
684 void Assembler::TryAllocate(const Class& cls, 770 void Assembler::TryAllocate(const Class& cls,
685 Label* failure, 771 Label* failure,
686 Register instance_reg) { 772 Register instance_reg,
773 Register temp_reg) {
687 ASSERT(failure != NULL); 774 ASSERT(failure != NULL);
688 if (FLAG_inline_alloc) { 775 if (FLAG_inline_alloc) {
689 Heap* heap = Isolate::Current()->heap(); 776 Heap* heap = Isolate::Current()->heap();
690 const intptr_t instance_size = cls.instance_size(); 777 const intptr_t instance_size = cls.instance_size();
691 LoadImmediate(instance_reg, heap->TopAddress()); 778 LoadImmediate(instance_reg, heap->TopAddress());
692 lw(instance_reg, Address(instance_reg, 0)); 779 lw(instance_reg, Address(instance_reg, 0));
693 AddImmediate(instance_reg, instance_size); 780 AddImmediate(instance_reg, instance_size);
694 781
695 // instance_reg: potential next object start. 782 // instance_reg: potential next object start.
696 LoadImmediate(TMP, heap->EndAddress()); 783 LoadImmediate(TMP, heap->EndAddress());
697 lw(TMP, Address(TMP, 0)); 784 lw(TMP, Address(TMP, 0));
698 // Fail if heap end unsigned less than or equal to instance_reg. 785 // Fail if heap end unsigned less than or equal to instance_reg.
699 BranchUnsignedLessEqual(TMP, instance_reg, failure); 786 BranchUnsignedLessEqual(TMP, instance_reg, failure);
700 787
701 // Successfully allocated the object, now update top to point to 788 // Successfully allocated the object, now update top to point to
702 // next object start and store the class in the class field of object. 789 // next object start and store the class in the class field of object.
703 LoadImmediate(TMP, heap->TopAddress()); 790 LoadImmediate(TMP, heap->TopAddress());
704 sw(instance_reg, Address(TMP, 0)); 791 sw(instance_reg, Address(TMP, 0));
705 792
706 ASSERT(instance_size >= kHeapObjectTag); 793 ASSERT(instance_size >= kHeapObjectTag);
707 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); 794 AddImmediate(instance_reg, -instance_size + kHeapObjectTag);
708 795 UpdateAllocationStats(cls.id(), temp_reg);
709 uword tags = 0; 796 uword tags = 0;
710 tags = RawObject::SizeTag::update(instance_size, tags); 797 tags = RawObject::SizeTag::update(instance_size, tags);
711 ASSERT(cls.id() != kIllegalCid); 798 ASSERT(cls.id() != kIllegalCid);
712 tags = RawObject::ClassIdTag::update(cls.id(), tags); 799 tags = RawObject::ClassIdTag::update(cls.id(), tags);
713 LoadImmediate(TMP, tags); 800 LoadImmediate(TMP, tags);
714 sw(TMP, FieldAddress(instance_reg, Object::tags_offset())); 801 sw(TMP, FieldAddress(instance_reg, Object::tags_offset()));
715 } else { 802 } else {
716 b(failure); 803 b(failure);
717 } 804 }
718 } 805 }
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 Emit(reinterpret_cast<int32_t>(message)); 1053 Emit(reinterpret_cast<int32_t>(message));
967 Bind(&msg); 1054 Bind(&msg);
968 break_(Instr::kMsgMessageCode); 1055 break_(Instr::kMsgMessageCode);
969 } 1056 }
970 #endif 1057 #endif
971 } 1058 }
972 1059
973 } // namespace dart 1060 } // namespace dart
974 1061
975 #endif // defined TARGET_ARCH_MIPS 1062 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/assembler_mips.h ('k') | runtime/vm/assembler_x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698