| 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_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 locs->set_out(0, Location::RegisterLocation(V0)); | 2018 locs->set_out(0, Location::RegisterLocation(V0)); |
| 2019 return locs; | 2019 return locs; |
| 2020 } | 2020 } |
| 2021 | 2021 |
| 2022 | 2022 |
| 2023 // Inlines array allocation for known constant values. | 2023 // Inlines array allocation for known constant values. |
| 2024 static void InlineArrayAllocation(FlowGraphCompiler* compiler, | 2024 static void InlineArrayAllocation(FlowGraphCompiler* compiler, |
| 2025 intptr_t num_elements, | 2025 intptr_t num_elements, |
| 2026 Label* slow_path, | 2026 Label* slow_path, |
| 2027 Label* done) { | 2027 Label* done) { |
| 2028 const int kInlineArraySize = 12; // Same as kInlineInstanceSize. |
| 2028 const Register kLengthReg = A1; | 2029 const Register kLengthReg = A1; |
| 2029 const Register kElemTypeReg = A0; | 2030 const Register kElemTypeReg = A0; |
| 2030 const intptr_t instance_size = Array::InstanceSize(num_elements); | 2031 const intptr_t instance_size = Array::InstanceSize(num_elements); |
| 2031 | 2032 |
| 2032 __ TryAllocateArray(kArrayCid, instance_size, slow_path, | 2033 __ TryAllocateArray(kArrayCid, instance_size, slow_path, |
| 2033 V0, // instance | 2034 V0, // instance |
| 2034 T1, // end address | 2035 T1, // end address |
| 2035 T2, | 2036 T2, |
| 2036 T3); | 2037 T3); |
| 2037 // V0: new object start as a tagged pointer. | 2038 // V0: new object start as a tagged pointer. |
| 2038 // T1: new object end address. | 2039 // T1: new object end address. |
| 2039 | 2040 |
| 2040 // Store the type argument field. | 2041 // Store the type argument field. |
| 2041 __ StoreIntoObjectNoBarrier(V0, | 2042 __ StoreIntoObjectNoBarrier(V0, |
| 2042 FieldAddress(V0, Array::type_arguments_offset()), | 2043 FieldAddress(V0, Array::type_arguments_offset()), |
| 2043 kElemTypeReg); | 2044 kElemTypeReg); |
| 2044 | 2045 |
| 2045 // Set the length field. | 2046 // Set the length field. |
| 2046 __ StoreIntoObjectNoBarrier(V0, | 2047 __ StoreIntoObjectNoBarrier(V0, |
| 2047 FieldAddress(V0, Array::length_offset()), | 2048 FieldAddress(V0, Array::length_offset()), |
| 2048 kLengthReg); | 2049 kLengthReg); |
| 2049 | 2050 |
| 2050 // Initialize all array elements to raw_null. | 2051 // Initialize all array elements to raw_null. |
| 2051 // V0: new object start as a tagged pointer. | 2052 // V0: new object start as a tagged pointer. |
| 2052 // T1: new object end address. | 2053 // T1: new object end address. |
| 2053 // T2: iterator which initially points to the start of the variable | 2054 // T2: iterator which initially points to the start of the variable |
| 2054 // data area to be initialized. | 2055 // data area to be initialized. |
| 2055 // T7: null. | 2056 // T7: null. |
| 2056 if (num_elements > 0) { | 2057 if (num_elements > 0) { |
| 2058 const intptr_t array_size = instance_size - sizeof(RawArray); |
| 2057 __ LoadImmediate(T7, reinterpret_cast<int32_t>(Object::null())); | 2059 __ LoadImmediate(T7, reinterpret_cast<int32_t>(Object::null())); |
| 2058 __ AddImmediate(T2, V0, sizeof(RawArray) - kHeapObjectTag); | 2060 __ AddImmediate(T2, V0, sizeof(RawArray) - kHeapObjectTag); |
| 2059 | 2061 if (array_size < (kInlineArraySize * kWordSize)) { |
| 2060 Label init_loop; | 2062 intptr_t current_offset = 0; |
| 2061 __ Bind(&init_loop); | 2063 while (current_offset < array_size) { |
| 2062 __ sw(T7, Address(T2, 0)); | 2064 __ sw(T7, Address(T2, current_offset)); |
| 2063 __ addiu(T2, T2, Immediate(kWordSize)); | 2065 current_offset += kWordSize; |
| 2064 __ BranchUnsignedLess(T2, T1, &init_loop); | 2066 } |
| 2067 } else { |
| 2068 Label init_loop; |
| 2069 __ Bind(&init_loop); |
| 2070 __ sw(T7, Address(T2, 0)); |
| 2071 __ addiu(T2, T2, Immediate(kWordSize)); |
| 2072 __ BranchUnsignedLess(T2, T1, &init_loop); |
| 2073 } |
| 2065 } | 2074 } |
| 2066 __ b(done); | 2075 __ b(done); |
| 2067 } | 2076 } |
| 2068 | 2077 |
| 2069 | 2078 |
| 2070 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2079 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2071 __ TraceSimMsg("CreateArrayInstr"); | 2080 __ TraceSimMsg("CreateArrayInstr"); |
| 2072 const Register kLengthReg = A1; | 2081 const Register kLengthReg = A1; |
| 2073 const Register kElemTypeReg = A0; | 2082 const Register kElemTypeReg = A0; |
| 2074 const Register kResultReg = V0; | 2083 const Register kResultReg = V0; |
| (...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4919 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 4928 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
| 4920 #if defined(DEBUG) | 4929 #if defined(DEBUG) |
| 4921 __ LoadImmediate(S4, kInvalidObjectPointer); | 4930 __ LoadImmediate(S4, kInvalidObjectPointer); |
| 4922 __ LoadImmediate(S5, kInvalidObjectPointer); | 4931 __ LoadImmediate(S5, kInvalidObjectPointer); |
| 4923 #endif | 4932 #endif |
| 4924 } | 4933 } |
| 4925 | 4934 |
| 4926 } // namespace dart | 4935 } // namespace dart |
| 4927 | 4936 |
| 4928 #endif // defined TARGET_ARCH_MIPS | 4937 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |