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_X64) | 6 #if defined(TARGET_ARCH_X64) |
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/heap.h" | 10 #include "vm/heap.h" |
(...skipping 3194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3205 | 3205 |
3206 void Assembler::TryAllocate(const Class& cls, | 3206 void Assembler::TryAllocate(const Class& cls, |
3207 Label* failure, | 3207 Label* failure, |
3208 bool near_jump, | 3208 bool near_jump, |
3209 Register instance_reg, | 3209 Register instance_reg, |
3210 Register pp) { | 3210 Register pp) { |
3211 ASSERT(failure != NULL); | 3211 ASSERT(failure != NULL); |
3212 if (FLAG_inline_alloc) { | 3212 if (FLAG_inline_alloc) { |
3213 Heap* heap = Isolate::Current()->heap(); | 3213 Heap* heap = Isolate::Current()->heap(); |
3214 const intptr_t instance_size = cls.instance_size(); | 3214 const intptr_t instance_size = cls.instance_size(); |
3215 LoadImmediate(TMP, Immediate(heap->TopAddress()), pp); | 3215 Heap::Space space = heap->SpaceForAllocation(cls.id()); |
| 3216 LoadImmediate(TMP, Immediate(heap->TopAddress(space)), pp); |
3216 movq(instance_reg, Address(TMP, 0)); | 3217 movq(instance_reg, Address(TMP, 0)); |
3217 AddImmediate(instance_reg, Immediate(instance_size), pp); | 3218 AddImmediate(instance_reg, Immediate(instance_size), pp); |
3218 // instance_reg: potential next object start. | 3219 // instance_reg: potential next object start. |
3219 LoadImmediate(TMP, Immediate(heap->EndAddress()), pp); | 3220 LoadImmediate(TMP, Immediate(heap->EndAddress(space)), pp); |
3220 cmpq(instance_reg, Address(TMP, 0)); | 3221 cmpq(instance_reg, Address(TMP, 0)); |
3221 j(ABOVE_EQUAL, failure, near_jump); | 3222 j(ABOVE_EQUAL, failure, near_jump); |
3222 // Successfully allocated the object, now update top to point to | 3223 // Successfully allocated the object, now update top to point to |
3223 // next object start and store the class in the class field of object. | 3224 // next object start and store the class in the class field of object. |
3224 LoadImmediate(TMP, Immediate(heap->TopAddress()), pp); | 3225 LoadImmediate(TMP, Immediate(heap->TopAddress(space)), pp); |
3225 movq(Address(TMP, 0), instance_reg); | 3226 movq(Address(TMP, 0), instance_reg); |
3226 UpdateAllocationStats(cls.id()); | 3227 UpdateAllocationStats(cls.id(), space); |
3227 ASSERT(instance_size >= kHeapObjectTag); | 3228 ASSERT(instance_size >= kHeapObjectTag); |
3228 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size), pp); | 3229 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size), pp); |
3229 uword tags = 0; | 3230 uword tags = 0; |
3230 tags = RawObject::SizeTag::update(instance_size, tags); | 3231 tags = RawObject::SizeTag::update(instance_size, tags); |
3231 ASSERT(cls.id() != kIllegalCid); | 3232 ASSERT(cls.id() != kIllegalCid); |
3232 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 3233 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
3233 LoadImmediate(FieldAddress(instance_reg, Object::tags_offset()), | 3234 LoadImmediate(FieldAddress(instance_reg, Object::tags_offset()), |
3234 Immediate(tags), pp); | 3235 Immediate(tags), pp); |
3235 } else { | 3236 } else { |
3236 jmp(failure); | 3237 jmp(failure); |
3237 } | 3238 } |
3238 } | 3239 } |
3239 | 3240 |
3240 | 3241 |
3241 void Assembler::TryAllocateArray(intptr_t cid, | 3242 void Assembler::TryAllocateArray(intptr_t cid, |
3242 intptr_t instance_size, | 3243 intptr_t instance_size, |
3243 Label* failure, | 3244 Label* failure, |
3244 bool near_jump, | 3245 bool near_jump, |
3245 Register instance, | 3246 Register instance, |
3246 Register end_address) { | 3247 Register end_address) { |
3247 ASSERT(failure != NULL); | 3248 ASSERT(failure != NULL); |
3248 if (FLAG_inline_alloc) { | 3249 if (FLAG_inline_alloc) { |
3249 Isolate* isolate = Isolate::Current(); | 3250 Isolate* isolate = Isolate::Current(); |
3250 Heap* heap = isolate->heap(); | 3251 Heap* heap = isolate->heap(); |
3251 | 3252 Heap::Space space = heap->SpaceForAllocation(kArrayCid); |
3252 movq(instance, Immediate(heap->TopAddress())); | 3253 movq(instance, Immediate(heap->TopAddress(space))); |
3253 movq(instance, Address(instance, 0)); | 3254 movq(instance, Address(instance, 0)); |
3254 movq(end_address, RAX); | 3255 movq(end_address, RAX); |
3255 | 3256 |
3256 addq(end_address, Immediate(instance_size)); | 3257 addq(end_address, Immediate(instance_size)); |
3257 j(CARRY, failure); | 3258 j(CARRY, failure); |
3258 | 3259 |
3259 // Check if the allocation fits into the remaining space. | 3260 // Check if the allocation fits into the remaining space. |
3260 // instance: potential new object start. | 3261 // instance: potential new object start. |
3261 // end_address: potential next object start. | 3262 // end_address: potential next object start. |
3262 movq(TMP, Immediate(heap->EndAddress())); | 3263 movq(TMP, Immediate(heap->EndAddress(space))); |
3263 cmpq(end_address, Address(TMP, 0)); | 3264 cmpq(end_address, Address(TMP, 0)); |
3264 j(ABOVE_EQUAL, failure); | 3265 j(ABOVE_EQUAL, failure); |
3265 | 3266 |
3266 // Successfully allocated the object(s), now update top to point to | 3267 // Successfully allocated the object(s), now update top to point to |
3267 // next object start and initialize the object. | 3268 // next object start and initialize the object. |
3268 movq(TMP, Immediate(heap->TopAddress())); | 3269 movq(TMP, Immediate(heap->TopAddress(space))); |
3269 movq(Address(TMP, 0), end_address); | 3270 movq(Address(TMP, 0), end_address); |
3270 addq(instance, Immediate(kHeapObjectTag)); | 3271 addq(instance, Immediate(kHeapObjectTag)); |
3271 UpdateAllocationStatsWithSize(kArrayCid, instance_size); | 3272 UpdateAllocationStatsWithSize(kArrayCid, instance_size, space); |
3272 | 3273 |
3273 // Initialize the tags. | 3274 // Initialize the tags. |
3274 // instance: new object start as a tagged pointer. | 3275 // instance: new object start as a tagged pointer. |
3275 uword tags = 0; | 3276 uword tags = 0; |
3276 tags = RawObject::ClassIdTag::update(cid, tags); | 3277 tags = RawObject::ClassIdTag::update(cid, tags); |
3277 tags = RawObject::SizeTag::update(instance_size, tags); | 3278 tags = RawObject::SizeTag::update(instance_size, tags); |
3278 movq(FieldAddress(instance, Array::tags_offset()), Immediate(tags)); | 3279 movq(FieldAddress(instance, Array::tags_offset()), Immediate(tags)); |
3279 } else { | 3280 } else { |
3280 jmp(failure); | 3281 jmp(failure); |
3281 } | 3282 } |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3558 | 3559 |
3559 | 3560 |
3560 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3561 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3561 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3562 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3562 return xmm_reg_names[reg]; | 3563 return xmm_reg_names[reg]; |
3563 } | 3564 } |
3564 | 3565 |
3565 } // namespace dart | 3566 } // namespace dart |
3566 | 3567 |
3567 #endif // defined TARGET_ARCH_X64 | 3568 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |