| 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" // Needed here to get TARGET_ARCH_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 7 | 7 |
| 8 #include "vm/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
| 9 | 9 |
| 10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 | 135 |
| 136 // Allocate a GrowableObjectArray using the backing array specified. | 136 // Allocate a GrowableObjectArray using the backing array specified. |
| 137 // On stack: type argument (+1), data (+0). | 137 // On stack: type argument (+1), data (+0). |
| 138 void Intrinsifier::GrowableList_Allocate(Assembler* assembler) { | 138 void Intrinsifier::GrowableList_Allocate(Assembler* assembler) { |
| 139 // The newly allocated object is returned in V0. | 139 // The newly allocated object is returned in V0. |
| 140 const intptr_t kTypeArgumentsOffset = 1 * kWordSize; | 140 const intptr_t kTypeArgumentsOffset = 1 * kWordSize; |
| 141 const intptr_t kArrayOffset = 0 * kWordSize; | 141 const intptr_t kArrayOffset = 0 * kWordSize; |
| 142 Label fall_through; | 142 Label fall_through; |
| 143 | 143 |
| 144 // Compute the size to be allocated, it is based on the array length | 144 // Try allocating in new space. |
| 145 // and is computed as: | |
| 146 // RoundedAllocationSize(sizeof(RawGrowableObjectArray)) + | |
| 147 intptr_t fixed_size = GrowableObjectArray::InstanceSize(); | |
| 148 | |
| 149 Isolate* isolate = Isolate::Current(); | |
| 150 Heap* heap = isolate->heap(); | |
| 151 | |
| 152 __ LoadImmediate(T2, heap->TopAddress()); | |
| 153 __ lw(V0, Address(T2, 0)); | |
| 154 __ AddImmediate(T1, V0, fixed_size); | |
| 155 | |
| 156 // Check if the allocation fits into the remaining space. | |
| 157 // V0: potential new backing array object start. | |
| 158 // T1: potential next object start. | |
| 159 __ LoadImmediate(T3, heap->EndAddress()); | |
| 160 __ lw(T3, Address(T3, 0)); | |
| 161 __ BranchUnsignedGreaterEqual(T1, T3, &fall_through); | |
| 162 | |
| 163 // Successfully allocated the object(s), now update top to point to | |
| 164 // next object start and initialize the object. | |
| 165 __ sw(T1, Address(T2, 0)); | |
| 166 __ AddImmediate(V0, kHeapObjectTag); | |
| 167 | |
| 168 // Initialize the tags. | |
| 169 // V0: new growable array object start as a tagged pointer. | |
| 170 const Class& cls = Class::Handle( | 145 const Class& cls = Class::Handle( |
| 171 isolate->object_store()->growable_object_array_class()); | 146 Isolate::Current()->object_store()->growable_object_array_class()); |
| 172 uword tags = 0; | 147 __ TryAllocate(cls, &fall_through, V0, T1); |
| 173 tags = RawObject::SizeTag::update(fixed_size, tags); | |
| 174 tags = RawObject::ClassIdTag::update(cls.id(), tags); | |
| 175 __ LoadImmediate(T1, tags); | |
| 176 __ sw(T1, FieldAddress(V0, GrowableObjectArray::tags_offset())); | |
| 177 | 148 |
| 178 // Store backing array object in growable array object. | 149 // Store backing array object in growable array object. |
| 179 __ lw(T1, Address(SP, kArrayOffset)); // Data argument. | 150 __ lw(T1, Address(SP, kArrayOffset)); // Data argument. |
| 180 // V0 is new, no barrier needed. | 151 // V0 is new, no barrier needed. |
| 181 __ StoreIntoObjectNoBarrier( | 152 __ StoreIntoObjectNoBarrier( |
| 182 V0, | 153 V0, |
| 183 FieldAddress(V0, GrowableObjectArray::data_offset()), | 154 FieldAddress(V0, GrowableObjectArray::data_offset()), |
| 184 T1); | 155 T1); |
| 185 | 156 |
| 186 // V0: new growable array object start as a tagged pointer. | 157 // V0: new growable array object start as a tagged pointer. |
| (...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 Isolate* isolate = Isolate::Current(); | 1787 Isolate* isolate = Isolate::Current(); |
| 1817 __ LoadImmediate(V0, reinterpret_cast<uword>(isolate)); | 1788 __ LoadImmediate(V0, reinterpret_cast<uword>(isolate)); |
| 1818 // Set return value. | 1789 // Set return value. |
| 1819 __ Ret(); | 1790 __ Ret(); |
| 1820 __ delay_slot()->lw(V0, Address(V0, Isolate::current_tag_offset())); | 1791 __ delay_slot()->lw(V0, Address(V0, Isolate::current_tag_offset())); |
| 1821 } | 1792 } |
| 1822 | 1793 |
| 1823 } // namespace dart | 1794 } // namespace dart |
| 1824 | 1795 |
| 1825 #endif // defined TARGET_ARCH_MIPS | 1796 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |