| 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 3077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3088 } | 3088 } |
| 3089 | 3089 |
| 3090 | 3090 |
| 3091 void Assembler::LeaveStubFrame() { | 3091 void Assembler::LeaveStubFrame() { |
| 3092 LeaveFrame((1 << PP) | (1 << FP) | (1 << LR)); | 3092 LeaveFrame((1 << PP) | (1 << FP) | (1 << LR)); |
| 3093 // Adjust SP for null PC pushed in EnterStubFrame. | 3093 // Adjust SP for null PC pushed in EnterStubFrame. |
| 3094 AddImmediate(SP, kWordSize); | 3094 AddImmediate(SP, kWordSize); |
| 3095 } | 3095 } |
| 3096 | 3096 |
| 3097 | 3097 |
| 3098 void Assembler::UpdateAllocationStats(intptr_t cid, | 3098 void Assembler::LoadAllocationStatsAddress(Register dest, |
| 3099 Register temp_reg, | 3099 intptr_t cid, |
| 3100 Heap::Space space) { | 3100 Heap::Space space) { |
| 3101 ASSERT(temp_reg != kNoRegister); | 3101 ASSERT(dest != kNoRegister); |
| 3102 ASSERT(temp_reg != TMP); | 3102 ASSERT(dest != TMP); |
| 3103 ASSERT(cid > 0); | 3103 ASSERT(cid > 0); |
| 3104 Isolate* isolate = Isolate::Current(); | 3104 Isolate* isolate = Isolate::Current(); |
| 3105 ClassTable* class_table = isolate->class_table(); | 3105 ClassTable* class_table = isolate->class_table(); |
| 3106 if (cid < kNumPredefinedCids) { | 3106 if (cid < kNumPredefinedCids) { |
| 3107 const uword class_heap_stats_table_address = | 3107 const uword class_heap_stats_table_address = |
| 3108 class_table->PredefinedClassHeapStatsTableAddress(); | 3108 class_table->PredefinedClassHeapStatsTableAddress(); |
| 3109 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT | 3109 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 3110 const uword count_field_offset = (space == Heap::kNew) ? | 3110 LoadImmediate(dest, class_heap_stats_table_address + class_offset); |
| 3111 ClassHeapStats::allocated_since_gc_new_space_offset() : | |
| 3112 ClassHeapStats::allocated_since_gc_old_space_offset(); | |
| 3113 LoadImmediate(temp_reg, class_heap_stats_table_address + class_offset); | |
| 3114 const Address& count_address = Address(temp_reg, count_field_offset); | |
| 3115 ldr(TMP, count_address); | |
| 3116 AddImmediate(TMP, 1); | |
| 3117 str(TMP, count_address); | |
| 3118 } else { | 3111 } else { |
| 3119 ASSERT(temp_reg != kNoRegister); | |
| 3120 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT | 3112 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 3121 const uword count_field_offset = (space == Heap::kNew) ? | 3113 LoadImmediate(dest, class_table->ClassStatsTableAddress()); |
| 3122 ClassHeapStats::allocated_since_gc_new_space_offset() : | 3114 ldr(dest, Address(dest, 0)); |
| 3123 ClassHeapStats::allocated_since_gc_old_space_offset(); | 3115 AddImmediate(dest, class_offset); |
| 3124 LoadImmediate(temp_reg, class_table->ClassStatsTableAddress()); | |
| 3125 ldr(temp_reg, Address(temp_reg, 0)); | |
| 3126 AddImmediate(temp_reg, class_offset); | |
| 3127 ldr(TMP, Address(temp_reg, count_field_offset)); | |
| 3128 AddImmediate(TMP, 1); | |
| 3129 str(TMP, Address(temp_reg, count_field_offset)); | |
| 3130 } | 3116 } |
| 3131 } | 3117 } |
| 3132 | 3118 |
| 3133 | 3119 |
| 3134 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, | 3120 void Assembler::IncrementAllocationStats(Register stats_addr_reg, |
| 3135 Register size_reg, | 3121 intptr_t cid, |
| 3136 Register temp_reg, | 3122 Heap::Space space) { |
| 3137 Heap::Space space) { | 3123 ASSERT(stats_addr_reg != kNoRegister); |
| 3138 ASSERT(temp_reg != kNoRegister); | 3124 ASSERT(stats_addr_reg != TMP); |
| 3139 ASSERT(temp_reg != TMP); | |
| 3140 ASSERT(cid > 0); | 3125 ASSERT(cid > 0); |
| 3141 Isolate* isolate = Isolate::Current(); | 3126 const uword count_field_offset = (space == Heap::kNew) ? |
| 3142 ClassTable* class_table = isolate->class_table(); | 3127 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 3143 if (cid < kNumPredefinedCids) { | 3128 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 3144 const uword class_heap_stats_table_address = | 3129 const Address& count_address = Address(stats_addr_reg, count_field_offset); |
| 3145 class_table->PredefinedClassHeapStatsTableAddress(); | 3130 ldr(TMP, count_address); |
| 3146 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT | 3131 AddImmediate(TMP, 1); |
| 3147 const uword count_field_offset = (space == Heap::kNew) ? | 3132 str(TMP, count_address); |
| 3148 ClassHeapStats::allocated_since_gc_new_space_offset() : | 3133 } |
| 3149 ClassHeapStats::allocated_since_gc_old_space_offset(); | 3134 |
| 3150 const uword size_field_offset = (space == Heap::kNew) ? | 3135 |
| 3151 ClassHeapStats::allocated_size_since_gc_new_space_offset() : | 3136 void Assembler::IncrementAllocationStatsWithSize(Register stats_addr_reg, |
| 3152 ClassHeapStats::allocated_size_since_gc_old_space_offset(); | 3137 Register size_reg, |
| 3153 LoadImmediate(temp_reg, class_heap_stats_table_address + class_offset); | 3138 intptr_t cid, |
| 3154 const Address& count_address = Address(temp_reg, count_field_offset); | 3139 Heap::Space space) { |
| 3155 const Address& size_address = Address(temp_reg, size_field_offset); | 3140 ASSERT(stats_addr_reg != kNoRegister); |
| 3156 ldr(TMP, count_address); | 3141 ASSERT(stats_addr_reg != TMP); |
| 3157 AddImmediate(TMP, 1); | 3142 ASSERT(cid > 0); |
| 3158 str(TMP, count_address); | 3143 const uword count_field_offset = (space == Heap::kNew) ? |
| 3159 ldr(TMP, size_address); | 3144 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 3160 add(TMP, TMP, Operand(size_reg)); | 3145 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 3161 str(TMP, size_address); | 3146 const uword size_field_offset = (space == Heap::kNew) ? |
| 3162 } else { | 3147 ClassHeapStats::allocated_size_since_gc_new_space_offset() : |
| 3163 ASSERT(temp_reg != kNoRegister); | 3148 ClassHeapStats::allocated_size_since_gc_old_space_offset(); |
| 3164 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT | 3149 const Address& count_address = Address(stats_addr_reg, count_field_offset); |
| 3165 const uword count_field_offset = (space == Heap::kNew) ? | 3150 const Address& size_address = Address(stats_addr_reg, size_field_offset); |
| 3166 ClassHeapStats::allocated_since_gc_new_space_offset() : | 3151 ldr(TMP, count_address); |
| 3167 ClassHeapStats::allocated_since_gc_old_space_offset(); | 3152 AddImmediate(TMP, 1); |
| 3168 const uword size_field_offset = (space == Heap::kNew) ? | 3153 str(TMP, count_address); |
| 3169 ClassHeapStats::allocated_size_since_gc_new_space_offset() : | 3154 ldr(TMP, size_address); |
| 3170 ClassHeapStats::allocated_size_since_gc_old_space_offset(); | 3155 add(TMP, TMP, Operand(size_reg)); |
| 3171 LoadImmediate(temp_reg, class_table->ClassStatsTableAddress()); | 3156 str(TMP, size_address); |
| 3172 ldr(temp_reg, Address(temp_reg, 0)); | |
| 3173 AddImmediate(temp_reg, class_offset); | |
| 3174 ldr(TMP, Address(temp_reg, count_field_offset)); | |
| 3175 AddImmediate(TMP, 1); | |
| 3176 str(TMP, Address(temp_reg, count_field_offset)); | |
| 3177 ldr(TMP, Address(temp_reg, size_field_offset)); | |
| 3178 add(TMP, TMP, Operand(size_reg)); | |
| 3179 str(TMP, Address(temp_reg, size_field_offset)); | |
| 3180 } | |
| 3181 } | 3157 } |
| 3182 | 3158 |
| 3183 | 3159 |
| 3184 void Assembler::TryAllocate(const Class& cls, | 3160 void Assembler::TryAllocate(const Class& cls, |
| 3185 Label* failure, | 3161 Label* failure, |
| 3186 Register instance_reg, | 3162 Register instance_reg, |
| 3187 Register temp_reg) { | 3163 Register temp_reg) { |
| 3188 ASSERT(failure != NULL); | 3164 ASSERT(failure != NULL); |
| 3189 if (FLAG_inline_alloc) { | 3165 if (FLAG_inline_alloc) { |
| 3190 ASSERT(instance_reg != temp_reg); | 3166 ASSERT(instance_reg != temp_reg); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3204 // Could use ldm to load (top, end), but no benefit seen experimentally. | 3180 // Could use ldm to load (top, end), but no benefit seen experimentally. |
| 3205 ldr(IP, Address(temp_reg, end_address - top_address)); | 3181 ldr(IP, Address(temp_reg, end_address - top_address)); |
| 3206 cmp(IP, Operand(instance_reg)); | 3182 cmp(IP, Operand(instance_reg)); |
| 3207 // fail if heap end unsigned less than or equal to instance_reg. | 3183 // fail if heap end unsigned less than or equal to instance_reg. |
| 3208 b(failure, LS); | 3184 b(failure, LS); |
| 3209 | 3185 |
| 3210 // Successfully allocated the object, now update top to point to | 3186 // Successfully allocated the object, now update top to point to |
| 3211 // next object start and store the class in the class field of object. | 3187 // next object start and store the class in the class field of object. |
| 3212 str(instance_reg, Address(temp_reg)); | 3188 str(instance_reg, Address(temp_reg)); |
| 3213 | 3189 |
| 3190 LoadAllocationStatsAddress(temp_reg, cls.id(), space); |
| 3191 |
| 3214 ASSERT(instance_size >= kHeapObjectTag); | 3192 ASSERT(instance_size >= kHeapObjectTag); |
| 3215 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); | 3193 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); |
| 3216 UpdateAllocationStats(cls.id(), temp_reg, space); | |
| 3217 | 3194 |
| 3218 uword tags = 0; | 3195 uword tags = 0; |
| 3219 tags = RawObject::SizeTag::update(instance_size, tags); | 3196 tags = RawObject::SizeTag::update(instance_size, tags); |
| 3220 ASSERT(cls.id() != kIllegalCid); | 3197 ASSERT(cls.id() != kIllegalCid); |
| 3221 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 3198 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 3222 LoadImmediate(IP, tags); | 3199 LoadImmediate(IP, tags); |
| 3223 str(IP, FieldAddress(instance_reg, Object::tags_offset())); | 3200 str(IP, FieldAddress(instance_reg, Object::tags_offset())); |
| 3201 |
| 3202 IncrementAllocationStats(temp_reg, cls.id(), space); |
| 3224 } else { | 3203 } else { |
| 3225 b(failure); | 3204 b(failure); |
| 3226 } | 3205 } |
| 3227 } | 3206 } |
| 3228 | 3207 |
| 3229 | 3208 |
| 3230 void Assembler::TryAllocateArray(intptr_t cid, | 3209 void Assembler::TryAllocateArray(intptr_t cid, |
| 3231 intptr_t instance_size, | 3210 intptr_t instance_size, |
| 3232 Label* failure, | 3211 Label* failure, |
| 3233 Register instance, | 3212 Register instance, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3244 b(failure, VS); | 3223 b(failure, VS); |
| 3245 | 3224 |
| 3246 // Check if the allocation fits into the remaining space. | 3225 // Check if the allocation fits into the remaining space. |
| 3247 // instance: potential new object start. | 3226 // instance: potential new object start. |
| 3248 // end_address: potential next object start. | 3227 // end_address: potential next object start. |
| 3249 LoadImmediate(temp2, heap->EndAddress(space)); | 3228 LoadImmediate(temp2, heap->EndAddress(space)); |
| 3250 ldr(temp2, Address(temp2, 0)); | 3229 ldr(temp2, Address(temp2, 0)); |
| 3251 cmp(end_address, Operand(temp2)); | 3230 cmp(end_address, Operand(temp2)); |
| 3252 b(failure, CS); | 3231 b(failure, CS); |
| 3253 | 3232 |
| 3233 LoadAllocationStatsAddress(temp2, cid, space); |
| 3234 |
| 3254 // Successfully allocated the object(s), now update top to point to | 3235 // Successfully allocated the object(s), now update top to point to |
| 3255 // next object start and initialize the object. | 3236 // next object start and initialize the object. |
| 3256 str(end_address, Address(temp1, 0)); | 3237 str(end_address, Address(temp1, 0)); |
| 3257 add(instance, instance, Operand(kHeapObjectTag)); | 3238 add(instance, instance, Operand(kHeapObjectTag)); |
| 3258 LoadImmediate(temp2, instance_size); | |
| 3259 UpdateAllocationStatsWithSize(cid, temp2, temp1, space); | |
| 3260 | 3239 |
| 3261 // Initialize the tags. | 3240 // Initialize the tags. |
| 3262 // instance: new object start as a tagged pointer. | 3241 // instance: new object start as a tagged pointer. |
| 3263 uword tags = 0; | 3242 uword tags = 0; |
| 3264 tags = RawObject::ClassIdTag::update(cid, tags); | 3243 tags = RawObject::ClassIdTag::update(cid, tags); |
| 3265 tags = RawObject::SizeTag::update(instance_size, tags); | 3244 tags = RawObject::SizeTag::update(instance_size, tags); |
| 3266 LoadImmediate(temp2, tags); | 3245 LoadImmediate(temp1, tags); |
| 3267 str(temp2, FieldAddress(instance, Array::tags_offset())); // Store tags. | 3246 str(temp1, FieldAddress(instance, Array::tags_offset())); // Store tags. |
| 3247 |
| 3248 LoadImmediate(temp1, instance_size); |
| 3249 IncrementAllocationStatsWithSize(temp2, temp1, cid, space); |
| 3268 } else { | 3250 } else { |
| 3269 b(failure); | 3251 b(failure); |
| 3270 } | 3252 } |
| 3271 } | 3253 } |
| 3272 | 3254 |
| 3273 | 3255 |
| 3274 void Assembler::Stop(const char* message) { | 3256 void Assembler::Stop(const char* message) { |
| 3275 if (FLAG_print_stop_message) { | 3257 if (FLAG_print_stop_message) { |
| 3276 StubCode* stub_code = Isolate::Current()->stub_code(); | 3258 StubCode* stub_code = Isolate::Current()->stub_code(); |
| 3277 PushList((1 << R0) | (1 << IP) | (1 << LR)); // Preserve R0, IP, LR. | 3259 PushList((1 << R0) | (1 << IP) | (1 << LR)); // Preserve R0, IP, LR. |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3414 | 3396 |
| 3415 | 3397 |
| 3416 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3398 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
| 3417 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters)); | 3399 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters)); |
| 3418 return fpu_reg_names[reg]; | 3400 return fpu_reg_names[reg]; |
| 3419 } | 3401 } |
| 3420 | 3402 |
| 3421 } // namespace dart | 3403 } // namespace dart |
| 3422 | 3404 |
| 3423 #endif // defined TARGET_ARCH_ARM | 3405 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |