| OLD | NEW |
| 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 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 } | 850 } |
| 851 | 851 |
| 852 | 852 |
| 853 void Assembler::TryAllocate(const Class& cls, | 853 void Assembler::TryAllocate(const Class& cls, |
| 854 Label* failure, | 854 Label* failure, |
| 855 Register instance_reg, | 855 Register instance_reg, |
| 856 Register temp_reg) { | 856 Register temp_reg) { |
| 857 ASSERT(!in_delay_slot_); | 857 ASSERT(!in_delay_slot_); |
| 858 ASSERT(failure != NULL); | 858 ASSERT(failure != NULL); |
| 859 if (FLAG_inline_alloc) { | 859 if (FLAG_inline_alloc) { |
| 860 const intptr_t instance_size = cls.instance_size(); |
| 860 Heap* heap = Isolate::Current()->heap(); | 861 Heap* heap = Isolate::Current()->heap(); |
| 861 const intptr_t instance_size = cls.instance_size(); | 862 Heap::Space space = heap->SpaceForAllocation(cls.id()); |
| 862 | 863 const uword top_address = heap->TopAddress(space); |
| 863 LoadImmediate(temp_reg, heap->NewSpaceAddress()); | 864 LoadImmediate(temp_reg, top_address); |
| 864 lw(instance_reg, Address(temp_reg, Scavenger::top_offset())); | 865 lw(instance_reg, Address(temp_reg)); |
| 865 AddImmediate(instance_reg, instance_size); | 866 AddImmediate(instance_reg, instance_size); |
| 866 | 867 |
| 867 // instance_reg: potential next object start. | 868 // instance_reg: potential next object start. |
| 868 lw(TMP, Address(temp_reg, Scavenger::end_offset())); | 869 const uword end_address = heap->EndAddress(space); |
| 870 ASSERT(top_address < end_address); |
| 871 lw(TMP, Address(temp_reg, end_address - top_address)); |
| 869 // Fail if heap end unsigned less than or equal to instance_reg. | 872 // Fail if heap end unsigned less than or equal to instance_reg. |
| 870 BranchUnsignedLessEqual(TMP, instance_reg, failure); | 873 BranchUnsignedLessEqual(TMP, instance_reg, failure); |
| 871 | 874 |
| 872 // Successfully allocated the object, now update top to point to | 875 // Successfully allocated the object, now update top to point to |
| 873 // next object start and store the class in the class field of object. | 876 // next object start and store the class in the class field of object. |
| 874 sw(instance_reg, Address(temp_reg, Scavenger::top_offset())); | 877 sw(instance_reg, Address(temp_reg)); |
| 875 | 878 |
| 876 ASSERT(instance_size >= kHeapObjectTag); | 879 ASSERT(instance_size >= kHeapObjectTag); |
| 877 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); | 880 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); |
| 878 UpdateAllocationStats(cls.id(), temp_reg); | 881 UpdateAllocationStats(cls.id(), temp_reg, space); |
| 879 uword tags = 0; | 882 uword tags = 0; |
| 880 tags = RawObject::SizeTag::update(instance_size, tags); | 883 tags = RawObject::SizeTag::update(instance_size, tags); |
| 881 ASSERT(cls.id() != kIllegalCid); | 884 ASSERT(cls.id() != kIllegalCid); |
| 882 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 885 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 883 LoadImmediate(TMP, tags); | 886 LoadImmediate(TMP, tags); |
| 884 sw(TMP, FieldAddress(instance_reg, Object::tags_offset())); | 887 sw(TMP, FieldAddress(instance_reg, Object::tags_offset())); |
| 885 } else { | 888 } else { |
| 886 b(failure); | 889 b(failure); |
| 887 } | 890 } |
| 888 } | 891 } |
| 889 | 892 |
| 890 | 893 |
| 891 void Assembler::TryAllocateArray(intptr_t cid, | 894 void Assembler::TryAllocateArray(intptr_t cid, |
| 892 intptr_t instance_size, | 895 intptr_t instance_size, |
| 893 Label* failure, | 896 Label* failure, |
| 894 Register instance, | 897 Register instance, |
| 895 Register end_address, | 898 Register end_address, |
| 896 Register temp1, | 899 Register temp1, |
| 897 Register temp2) { | 900 Register temp2) { |
| 898 if (FLAG_inline_alloc) { | 901 if (FLAG_inline_alloc) { |
| 899 Isolate* isolate = Isolate::Current(); | 902 Isolate* isolate = Isolate::Current(); |
| 900 Heap* heap = isolate->heap(); | 903 Heap* heap = isolate->heap(); |
| 901 | 904 Heap::Space space = heap->SpaceForAllocation(cid); |
| 902 LoadImmediate(temp1, heap->TopAddress()); | 905 LoadImmediate(temp1, heap->TopAddress(space)); |
| 903 lw(instance, Address(temp1, 0)); // Potential new object start. | 906 lw(instance, Address(temp1, 0)); // Potential new object start. |
| 904 // Potential next object start. | 907 // Potential next object start. |
| 905 AddImmediateDetectOverflow(end_address, instance, instance_size, CMPRES1); | 908 AddImmediateDetectOverflow(end_address, instance, instance_size, CMPRES1); |
| 906 bltz(CMPRES1, failure); // CMPRES1 < 0 on overflow. | 909 bltz(CMPRES1, failure); // CMPRES1 < 0 on overflow. |
| 907 | 910 |
| 908 // Check if the allocation fits into the remaining space. | 911 // Check if the allocation fits into the remaining space. |
| 909 // instance: potential new object start. | 912 // instance: potential new object start. |
| 910 // end_address: potential next object start. | 913 // end_address: potential next object start. |
| 911 LoadImmediate(temp2, heap->EndAddress()); | 914 LoadImmediate(temp2, heap->EndAddress(space)); |
| 912 lw(temp2, Address(temp2, 0)); | 915 lw(temp2, Address(temp2, 0)); |
| 913 BranchUnsignedGreaterEqual(end_address, temp2, failure); | 916 BranchUnsignedGreaterEqual(end_address, temp2, failure); |
| 914 | 917 |
| 915 | 918 |
| 916 // Successfully allocated the object(s), now update top to point to | 919 // Successfully allocated the object(s), now update top to point to |
| 917 // next object start and initialize the object. | 920 // next object start and initialize the object. |
| 918 sw(end_address, Address(temp1, 0)); | 921 sw(end_address, Address(temp1, 0)); |
| 919 addiu(instance, instance, Immediate(kHeapObjectTag)); | 922 addiu(instance, instance, Immediate(kHeapObjectTag)); |
| 920 LoadImmediate(temp1, instance_size); | 923 LoadImmediate(temp1, instance_size); |
| 921 UpdateAllocationStatsWithSize(cid, temp1, temp2); | 924 UpdateAllocationStatsWithSize(cid, temp1, temp2, space); |
| 922 | 925 |
| 923 // Initialize the tags. | 926 // Initialize the tags. |
| 924 // instance: new object start as a tagged pointer. | 927 // instance: new object start as a tagged pointer. |
| 925 uword tags = 0; | 928 uword tags = 0; |
| 926 tags = RawObject::ClassIdTag::update(cid, tags); | 929 tags = RawObject::ClassIdTag::update(cid, tags); |
| 927 tags = RawObject::SizeTag::update(instance_size, tags); | 930 tags = RawObject::SizeTag::update(instance_size, tags); |
| 928 LoadImmediate(temp1, tags); | 931 LoadImmediate(temp1, tags); |
| 929 sw(temp1, FieldAddress(instance, Array::tags_offset())); // Store tags. | 932 sw(temp1, FieldAddress(instance, Array::tags_offset())); // Store tags. |
| 930 } else { | 933 } else { |
| 931 b(failure); | 934 b(failure); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 Emit(reinterpret_cast<int32_t>(message)); | 1232 Emit(reinterpret_cast<int32_t>(message)); |
| 1230 Bind(&msg); | 1233 Bind(&msg); |
| 1231 break_(Instr::kMsgMessageCode); | 1234 break_(Instr::kMsgMessageCode); |
| 1232 } | 1235 } |
| 1233 #endif | 1236 #endif |
| 1234 } | 1237 } |
| 1235 | 1238 |
| 1236 } // namespace dart | 1239 } // namespace dart |
| 1237 | 1240 |
| 1238 #endif // defined TARGET_ARCH_MIPS | 1241 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |