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_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
(...skipping 3152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3163 | 3163 |
3164 void Assembler::TryAllocate(const Class& cls, | 3164 void Assembler::TryAllocate(const Class& cls, |
3165 Label* failure, | 3165 Label* failure, |
3166 Register instance_reg, | 3166 Register instance_reg, |
3167 Register temp_reg) { | 3167 Register temp_reg) { |
3168 ASSERT(failure != NULL); | 3168 ASSERT(failure != NULL); |
3169 if (FLAG_inline_alloc) { | 3169 if (FLAG_inline_alloc) { |
3170 ASSERT(instance_reg != temp_reg); | 3170 ASSERT(instance_reg != temp_reg); |
3171 ASSERT(temp_reg != IP); | 3171 ASSERT(temp_reg != IP); |
3172 const intptr_t instance_size = cls.instance_size(); | 3172 const intptr_t instance_size = cls.instance_size(); |
3173 | 3173 ASSERT(instance_size != 0); |
3174 LoadImmediate(temp_reg, Isolate::Current()->heap()->NewSpaceAddress()); | 3174 Heap* heap = Isolate::Current()->heap(); |
3175 | 3175 Heap::Space space = heap->SpaceForAllocation(cls.id()); |
3176 ldr(instance_reg, Address(temp_reg, Scavenger::top_offset())); | 3176 const uword top_address = heap->TopAddress(space); |
| 3177 LoadImmediate(temp_reg, top_address); |
| 3178 ldr(instance_reg, Address(temp_reg)); |
3177 AddImmediate(instance_reg, instance_size); | 3179 AddImmediate(instance_reg, instance_size); |
3178 | 3180 |
3179 // instance_reg: potential next object start. | 3181 // instance_reg: potential next object start. |
3180 ldr(IP, Address(temp_reg, Scavenger::end_offset())); | 3182 const uword end_address = heap->EndAddress(space); |
| 3183 ASSERT(top_address < end_address); |
| 3184 // Could use ldm to load (top, end), but no benefit seen experimentally. |
| 3185 ldr(IP, Address(temp_reg, end_address - top_address)); |
3181 cmp(IP, Operand(instance_reg)); | 3186 cmp(IP, Operand(instance_reg)); |
3182 // fail if heap end unsigned less than or equal to instance_reg. | 3187 // fail if heap end unsigned less than or equal to instance_reg. |
3183 b(failure, LS); | 3188 b(failure, LS); |
3184 | 3189 |
3185 // Successfully allocated the object, now update top to point to | 3190 // Successfully allocated the object, now update top to point to |
3186 // next object start and store the class in the class field of object. | 3191 // next object start and store the class in the class field of object. |
3187 str(instance_reg, Address(temp_reg, Scavenger::top_offset())); | 3192 str(instance_reg, Address(temp_reg)); |
3188 | 3193 |
3189 ASSERT(instance_size >= kHeapObjectTag); | 3194 ASSERT(instance_size >= kHeapObjectTag); |
3190 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); | 3195 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); |
3191 UpdateAllocationStats(cls.id(), temp_reg); | 3196 UpdateAllocationStats(cls.id(), temp_reg, space); |
3192 | 3197 |
3193 uword tags = 0; | 3198 uword tags = 0; |
3194 tags = RawObject::SizeTag::update(instance_size, tags); | 3199 tags = RawObject::SizeTag::update(instance_size, tags); |
3195 ASSERT(cls.id() != kIllegalCid); | 3200 ASSERT(cls.id() != kIllegalCid); |
3196 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 3201 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
3197 LoadImmediate(IP, tags); | 3202 LoadImmediate(IP, tags); |
3198 str(IP, FieldAddress(instance_reg, Object::tags_offset())); | 3203 str(IP, FieldAddress(instance_reg, Object::tags_offset())); |
3199 } else { | 3204 } else { |
3200 b(failure); | 3205 b(failure); |
3201 } | 3206 } |
3202 } | 3207 } |
3203 | 3208 |
3204 | 3209 |
3205 void Assembler::TryAllocateArray(intptr_t cid, | 3210 void Assembler::TryAllocateArray(intptr_t cid, |
3206 intptr_t instance_size, | 3211 intptr_t instance_size, |
3207 Label* failure, | 3212 Label* failure, |
3208 Register instance, | 3213 Register instance, |
3209 Register end_address, | 3214 Register end_address, |
3210 Register temp1, | 3215 Register temp1, |
3211 Register temp2) { | 3216 Register temp2) { |
3212 if (FLAG_inline_alloc) { | 3217 if (FLAG_inline_alloc) { |
3213 Isolate* isolate = Isolate::Current(); | 3218 Isolate* isolate = Isolate::Current(); |
3214 Heap* heap = isolate->heap(); | 3219 Heap* heap = isolate->heap(); |
3215 LoadImmediate(temp1, heap->TopAddress()); | 3220 Heap::Space space = heap->SpaceForAllocation(cid); |
| 3221 LoadImmediate(temp1, heap->TopAddress(space)); |
3216 ldr(instance, Address(temp1, 0)); // Potential new object start. | 3222 ldr(instance, Address(temp1, 0)); // Potential new object start. |
3217 AddImmediate(end_address, instance, instance_size); | 3223 AddImmediate(end_address, instance, instance_size); |
3218 b(failure, VS); | 3224 b(failure, VS); |
3219 | 3225 |
3220 // Check if the allocation fits into the remaining space. | 3226 // Check if the allocation fits into the remaining space. |
3221 // instance: potential new object start. | 3227 // instance: potential new object start. |
3222 // end_address: potential next object start. | 3228 // end_address: potential next object start. |
3223 LoadImmediate(temp2, heap->EndAddress()); | 3229 LoadImmediate(temp2, heap->EndAddress(space)); |
3224 ldr(temp2, Address(temp2, 0)); | 3230 ldr(temp2, Address(temp2, 0)); |
3225 cmp(end_address, Operand(temp2)); | 3231 cmp(end_address, Operand(temp2)); |
3226 b(failure, CS); | 3232 b(failure, CS); |
3227 | 3233 |
3228 // Successfully allocated the object(s), now update top to point to | 3234 // Successfully allocated the object(s), now update top to point to |
3229 // next object start and initialize the object. | 3235 // next object start and initialize the object. |
3230 str(end_address, Address(temp1, 0)); | 3236 str(end_address, Address(temp1, 0)); |
3231 add(instance, instance, Operand(kHeapObjectTag)); | 3237 add(instance, instance, Operand(kHeapObjectTag)); |
3232 LoadImmediate(temp2, instance_size); | 3238 LoadImmediate(temp2, instance_size); |
3233 UpdateAllocationStatsWithSize(cid, temp2, temp1); | 3239 UpdateAllocationStatsWithSize(cid, temp2, temp1, space); |
3234 | 3240 |
3235 // Initialize the tags. | 3241 // Initialize the tags. |
3236 // instance: new object start as a tagged pointer. | 3242 // instance: new object start as a tagged pointer. |
3237 uword tags = 0; | 3243 uword tags = 0; |
3238 tags = RawObject::ClassIdTag::update(cid, tags); | 3244 tags = RawObject::ClassIdTag::update(cid, tags); |
3239 tags = RawObject::SizeTag::update(instance_size, tags); | 3245 tags = RawObject::SizeTag::update(instance_size, tags); |
3240 LoadImmediate(temp2, tags); | 3246 LoadImmediate(temp2, tags); |
3241 str(temp2, FieldAddress(instance, Array::tags_offset())); // Store tags. | 3247 str(temp2, FieldAddress(instance, Array::tags_offset())); // Store tags. |
3242 } else { | 3248 } else { |
3243 b(failure); | 3249 b(failure); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3388 | 3394 |
3389 | 3395 |
3390 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3396 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3391 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters)); | 3397 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters)); |
3392 return fpu_reg_names[reg]; | 3398 return fpu_reg_names[reg]; |
3393 } | 3399 } |
3394 | 3400 |
3395 } // namespace dart | 3401 } // namespace dart |
3396 | 3402 |
3397 #endif // defined TARGET_ARCH_ARM | 3403 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |