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" // NOLINT | 5 #include "vm/globals.h" // NOLINT |
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 3083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3094 bool near_jump, | 3094 bool near_jump, |
3095 Register instance_reg, | 3095 Register instance_reg, |
3096 Register temp) { | 3096 Register temp) { |
3097 ASSERT(failure != NULL); | 3097 ASSERT(failure != NULL); |
3098 if (FLAG_inline_alloc) { | 3098 if (FLAG_inline_alloc) { |
3099 // If this allocation is traced, program will jump to failure path | 3099 // If this allocation is traced, program will jump to failure path |
3100 // (i.e. the allocation stub) which will allocate the object and trace the | 3100 // (i.e. the allocation stub) which will allocate the object and trace the |
3101 // allocation call site. | 3101 // allocation call site. |
3102 NOT_IN_PRODUCT(MaybeTraceAllocation(cls.id(), failure, near_jump)); | 3102 NOT_IN_PRODUCT(MaybeTraceAllocation(cls.id(), failure, near_jump)); |
3103 const intptr_t instance_size = cls.instance_size(); | 3103 const intptr_t instance_size = cls.instance_size(); |
3104 Heap::Space space = Heap::kNew; | 3104 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
3105 movq(temp, Address(THR, Thread::heap_offset())); | 3105 movq(instance_reg, Address(THR, Thread::top_offset())); |
3106 movq(instance_reg, Address(temp, Heap::TopOffset(space))); | |
3107 addq(instance_reg, Immediate(instance_size)); | 3106 addq(instance_reg, Immediate(instance_size)); |
3108 // instance_reg: potential next object start. | 3107 // instance_reg: potential next object start. |
3109 cmpq(instance_reg, Address(temp, Heap::EndOffset(space))); | 3108 cmpq(instance_reg, Address(THR, Thread::end_offset())); |
3110 j(ABOVE_EQUAL, failure, near_jump); | 3109 j(ABOVE_EQUAL, failure, near_jump); |
3111 // Successfully allocated the object, now update top to point to | 3110 // Successfully allocated the object, now update top to point to |
3112 // next object start and store the class in the class field of object. | 3111 // next object start and store the class in the class field of object. |
3113 movq(Address(temp, Heap::TopOffset(space)), instance_reg); | 3112 movq(Address(THR, Thread::top_offset()), instance_reg); |
3114 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), space)); | 3113 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), space)); |
3115 ASSERT(instance_size >= kHeapObjectTag); | 3114 ASSERT(instance_size >= kHeapObjectTag); |
3116 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size)); | 3115 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size)); |
3117 uint32_t tags = 0; | 3116 uint32_t tags = 0; |
3118 tags = RawObject::SizeTag::update(instance_size, tags); | 3117 tags = RawObject::SizeTag::update(instance_size, tags); |
3119 ASSERT(cls.id() != kIllegalCid); | 3118 ASSERT(cls.id() != kIllegalCid); |
3120 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 3119 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
3121 // Extends the 32 bit tags with zeros, which is the uninitialized | 3120 // Extends the 32 bit tags with zeros, which is the uninitialized |
3122 // hash code. | 3121 // hash code. |
3123 MoveImmediate(FieldAddress(instance_reg, Object::tags_offset()), | 3122 MoveImmediate(FieldAddress(instance_reg, Object::tags_offset()), |
3124 Immediate(tags)); | 3123 Immediate(tags)); |
3125 } else { | 3124 } else { |
3126 jmp(failure); | 3125 jmp(failure); |
3127 } | 3126 } |
3128 } | 3127 } |
3129 | 3128 |
3130 void Assembler::TryAllocateArray(intptr_t cid, | 3129 void Assembler::TryAllocateArray(intptr_t cid, |
3131 intptr_t instance_size, | 3130 intptr_t instance_size, |
3132 Label* failure, | 3131 Label* failure, |
3133 bool near_jump, | 3132 bool near_jump, |
3134 Register instance, | 3133 Register instance, |
3135 Register end_address, | 3134 Register end_address, |
3136 Register temp) { | 3135 Register temp) { |
3137 ASSERT(failure != NULL); | 3136 ASSERT(failure != NULL); |
3138 if (FLAG_inline_alloc) { | 3137 if (FLAG_inline_alloc) { |
3139 // If this allocation is traced, program will jump to failure path | 3138 // If this allocation is traced, program will jump to failure path |
3140 // (i.e. the allocation stub) which will allocate the object and trace the | 3139 // (i.e. the allocation stub) which will allocate the object and trace the |
3141 // allocation call site. | 3140 // allocation call site. |
3142 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, failure, near_jump)); | 3141 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, failure, near_jump)); |
3143 Heap::Space space = Heap::kNew; | 3142 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
3144 movq(temp, Address(THR, Thread::heap_offset())); | 3143 movq(instance, Address(THR, Thread::top_offset())); |
3145 movq(instance, Address(temp, Heap::TopOffset(space))); | |
3146 movq(end_address, instance); | 3144 movq(end_address, instance); |
3147 | 3145 |
3148 addq(end_address, Immediate(instance_size)); | 3146 addq(end_address, Immediate(instance_size)); |
3149 j(CARRY, failure); | 3147 j(CARRY, failure); |
3150 | 3148 |
3151 // Check if the allocation fits into the remaining space. | 3149 // Check if the allocation fits into the remaining space. |
3152 // instance: potential new object start. | 3150 // instance: potential new object start. |
3153 // end_address: potential next object start. | 3151 // end_address: potential next object start. |
3154 cmpq(end_address, Address(temp, Heap::EndOffset(space))); | 3152 cmpq(end_address, Address(THR, Thread::end_offset())); |
3155 j(ABOVE_EQUAL, failure); | 3153 j(ABOVE_EQUAL, failure); |
3156 | 3154 |
3157 // Successfully allocated the object(s), now update top to point to | 3155 // Successfully allocated the object(s), now update top to point to |
3158 // next object start and initialize the object. | 3156 // next object start and initialize the object. |
3159 movq(Address(temp, Heap::TopOffset(space)), end_address); | 3157 movq(Address(THR, Thread::top_offset()), end_address); |
3160 addq(instance, Immediate(kHeapObjectTag)); | 3158 addq(instance, Immediate(kHeapObjectTag)); |
3161 NOT_IN_PRODUCT(UpdateAllocationStatsWithSize(cid, instance_size, space)); | 3159 NOT_IN_PRODUCT(UpdateAllocationStatsWithSize(cid, instance_size, space)); |
3162 | 3160 |
3163 // Initialize the tags. | 3161 // Initialize the tags. |
3164 // instance: new object start as a tagged pointer. | 3162 // instance: new object start as a tagged pointer. |
3165 uint32_t tags = 0; | 3163 uint32_t tags = 0; |
3166 tags = RawObject::ClassIdTag::update(cid, tags); | 3164 tags = RawObject::ClassIdTag::update(cid, tags); |
3167 tags = RawObject::SizeTag::update(instance_size, tags); | 3165 tags = RawObject::SizeTag::update(instance_size, tags); |
3168 // Extends the 32 bit tags with zeros, which is the uninitialized | 3166 // Extends the 32 bit tags with zeros, which is the uninitialized |
3169 // hash code. | 3167 // hash code. |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3462 "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15"}; | 3460 "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15"}; |
3463 | 3461 |
3464 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3462 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3465 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3463 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3466 return xmm_reg_names[reg]; | 3464 return xmm_reg_names[reg]; |
3467 } | 3465 } |
3468 | 3466 |
3469 } // namespace dart | 3467 } // namespace dart |
3470 | 3468 |
3471 #endif // defined TARGET_ARCH_X64 | 3469 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |