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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 2298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2309 Label* done) { | 2309 Label* done) { |
2310 const int kInlineArraySize = 12; // Same as kInlineInstanceSize. | 2310 const int kInlineArraySize = 12; // Same as kInlineInstanceSize. |
2311 const Register kLengthReg = R2; | 2311 const Register kLengthReg = R2; |
2312 const Register kElemTypeReg = R1; | 2312 const Register kElemTypeReg = R1; |
2313 const intptr_t instance_size = Array::InstanceSize(num_elements); | 2313 const intptr_t instance_size = Array::InstanceSize(num_elements); |
2314 | 2314 |
2315 __ TryAllocateArray(kArrayCid, instance_size, slow_path, | 2315 __ TryAllocateArray(kArrayCid, instance_size, slow_path, |
2316 R0, // instance | 2316 R0, // instance |
2317 R3, // end address | 2317 R3, // end address |
2318 R6, | 2318 R6, |
2319 R8); | 2319 R9); |
2320 // R0: new object start as a tagged pointer. | 2320 // R0: new object start as a tagged pointer. |
2321 // R3: new object end address. | 2321 // R3: new object end address. |
2322 | 2322 |
2323 // Store the type argument field. | 2323 // Store the type argument field. |
2324 __ InitializeFieldNoBarrier(R0, | 2324 __ InitializeFieldNoBarrier(R0, |
2325 FieldAddress(R0, Array::type_arguments_offset()), | 2325 FieldAddress(R0, Array::type_arguments_offset()), |
2326 kElemTypeReg); | 2326 kElemTypeReg); |
2327 | 2327 |
2328 // Set the length field. | 2328 // Set the length field. |
2329 __ InitializeFieldNoBarrier(R0, | 2329 __ InitializeFieldNoBarrier(R0, |
2330 FieldAddress(R0, Array::length_offset()), | 2330 FieldAddress(R0, Array::length_offset()), |
2331 kLengthReg); | 2331 kLengthReg); |
2332 | 2332 |
2333 // Initialize all array elements to raw_null. | 2333 // Initialize all array elements to raw_null. |
2334 // R0: new object start as a tagged pointer. | 2334 // R0: new object start as a tagged pointer. |
2335 // R3: new object end address. | 2335 // R3: new object end address. |
2336 // R8: iterator which initially points to the start of the variable | 2336 // R9: iterator which initially points to the start of the variable |
2337 // data area to be initialized. | 2337 // data area to be initialized. |
2338 // R6: null | 2338 // R6: null |
2339 if (num_elements > 0) { | 2339 if (num_elements > 0) { |
2340 const intptr_t array_size = instance_size - sizeof(RawArray); | 2340 const intptr_t array_size = instance_size - sizeof(RawArray); |
2341 __ LoadImmediate(R6, reinterpret_cast<intptr_t>(Object::null())); | 2341 __ LoadImmediate(R6, reinterpret_cast<intptr_t>(Object::null())); |
2342 if (num_elements >= 2) { | 2342 if (num_elements >= 2) { |
2343 __ mov(R7, Operand(R6)); | 2343 __ mov(R7, Operand(R6)); |
2344 } else { | 2344 } else { |
2345 #if defined(DEBUG) | 2345 #if defined(DEBUG) |
2346 // Clobber R7 with an invalid pointer. | 2346 // Clobber R7 with an invalid pointer. |
2347 __ LoadImmediate(R7, 0x1); | 2347 __ LoadImmediate(R7, 0x1); |
2348 #endif // DEBUG | 2348 #endif // DEBUG |
2349 } | 2349 } |
2350 __ AddImmediate(R8, R0, sizeof(RawArray) - kHeapObjectTag); | 2350 __ AddImmediate(R9, R0, sizeof(RawArray) - kHeapObjectTag); |
2351 if (array_size < (kInlineArraySize * kWordSize)) { | 2351 if (array_size < (kInlineArraySize * kWordSize)) { |
2352 __ InitializeFieldsNoBarrierUnrolled(R0, R8, 0, num_elements * kWordSize, | 2352 __ InitializeFieldsNoBarrierUnrolled(R0, R9, 0, num_elements * kWordSize, |
2353 R6, R7); | 2353 R6, R7); |
2354 } else { | 2354 } else { |
2355 __ InitializeFieldsNoBarrier(R0, R8, R3, R6, R7); | 2355 __ InitializeFieldsNoBarrier(R0, R9, R3, R6, R7); |
2356 } | 2356 } |
2357 } | 2357 } |
2358 __ b(done); | 2358 __ b(done); |
2359 } | 2359 } |
2360 | 2360 |
2361 | 2361 |
2362 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2362 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2363 const Register kLengthReg = R2; | 2363 const Register kLengthReg = R2; |
2364 const Register kElemTypeReg = R1; | 2364 const Register kElemTypeReg = R1; |
2365 const Register kResultReg = R0; | 2365 const Register kResultReg = R0; |
(...skipping 4517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6883 1, | 6883 1, |
6884 locs()); | 6884 locs()); |
6885 __ Drop(1); | 6885 __ Drop(1); |
6886 __ Pop(result); | 6886 __ Pop(result); |
6887 } | 6887 } |
6888 | 6888 |
6889 | 6889 |
6890 } // namespace dart | 6890 } // namespace dart |
6891 | 6891 |
6892 #endif // defined TARGET_ARCH_ARM | 6892 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |