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 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 (representation() == kUnboxedFloat32x4) || | 1134 (representation() == kUnboxedFloat32x4) || |
1135 (representation() == kUnboxedInt32x4)) { | 1135 (representation() == kUnboxedInt32x4)) { |
1136 locs->set_out(0, Location::RequiresFpuRegister()); | 1136 locs->set_out(0, Location::RequiresFpuRegister()); |
1137 } else { | 1137 } else { |
1138 locs->set_out(0, Location::RequiresRegister()); | 1138 locs->set_out(0, Location::RequiresRegister()); |
1139 } | 1139 } |
1140 return locs; | 1140 return locs; |
1141 } | 1141 } |
1142 | 1142 |
1143 | 1143 |
1144 static Address ElementAddressForIntIndex(bool is_external, | |
1145 intptr_t cid, | |
1146 intptr_t index_scale, | |
1147 Register array, | |
1148 intptr_t index) { | |
1149 const int64_t offset = index * index_scale + | |
1150 (is_external ? 0 : (Instance::DataOffsetFor(cid) - kHeapObjectTag)); | |
1151 ASSERT(Utils::IsInt(32, offset)); | |
1152 ASSERT(Address::CanHoldOffset(offset)); | |
1153 return Address(array, static_cast<int32_t>(offset)); | |
1154 } | |
1155 | |
1156 | |
1157 static Address ElementAddressForRegIndex(Assembler* assembler, | |
1158 bool is_load, | |
1159 bool is_external, | |
1160 intptr_t cid, | |
1161 intptr_t index_scale, | |
1162 Register array, | |
1163 Register index) { | |
1164 // Note that index is expected smi-tagged, (i.e, LSL 1) for all arrays. | |
1165 const intptr_t shift = Utils::ShiftForPowerOfTwo(index_scale) - kSmiTagShift; | |
1166 const int32_t offset = | |
1167 is_external ? 0 : (Instance::DataOffsetFor(cid) - kHeapObjectTag); | |
1168 ASSERT(array != TMP); | |
1169 ASSERT(index != TMP); | |
1170 const Register base = is_load ? TMP : index; | |
1171 if (shift < 0) { | |
1172 ASSERT(shift == -1); | |
1173 assembler->sra(TMP, index, 1); | |
1174 assembler->addu(base, array, TMP); | |
1175 } else if (shift == 0) { | |
1176 assembler->addu(base, array, index); | |
1177 } else { | |
1178 assembler->sll(TMP, index, shift); | |
1179 assembler->addu(base, array, TMP); | |
1180 } | |
1181 ASSERT(Address::CanHoldOffset(offset)); | |
1182 return Address(base, offset); | |
1183 } | |
1184 | |
1185 | |
1186 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1144 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1187 __ TraceSimMsg("LoadIndexedInstr"); | 1145 __ TraceSimMsg("LoadIndexedInstr"); |
1188 // The array register points to the backing store for external arrays. | 1146 // The array register points to the backing store for external arrays. |
1189 const Register array = locs()->in(0).reg(); | 1147 const Register array = locs()->in(0).reg(); |
1190 const Location index = locs()->in(1); | 1148 const Location index = locs()->in(1); |
1191 | 1149 |
1192 Address element_address = index.IsRegister() | 1150 Address element_address = index.IsRegister() |
1193 ? ElementAddressForRegIndex(compiler->assembler(), | 1151 ? __ ElementAddressForRegIndex(true, // Load. |
1194 true, // Load. | 1152 IsExternal(), class_id(), index_scale(), |
1195 IsExternal(), class_id(), index_scale(), | 1153 array, index.reg()) |
1196 array, index.reg()) | 1154 : __ ElementAddressForIntIndex( |
1197 : ElementAddressForIntIndex(IsExternal(), class_id(), index_scale(), | 1155 IsExternal(), class_id(), index_scale(), |
1198 array, Smi::Cast(index.constant()).Value()); | 1156 array, Smi::Cast(index.constant()).Value()); |
1199 // Warning: element_address may use register TMP as base. | 1157 // Warning: element_address may use register TMP as base. |
1200 | 1158 |
1201 if ((representation() == kUnboxedDouble) || | 1159 if ((representation() == kUnboxedDouble) || |
1202 (representation() == kUnboxedMint) || | 1160 (representation() == kUnboxedMint) || |
1203 (representation() == kUnboxedFloat32x4) || | 1161 (representation() == kUnboxedFloat32x4) || |
1204 (representation() == kUnboxedInt32x4)) { | 1162 (representation() == kUnboxedInt32x4)) { |
1205 DRegister result = locs()->out(0).fpu_reg(); | 1163 DRegister result = locs()->out(0).fpu_reg(); |
1206 switch (class_id()) { | 1164 switch (class_id()) { |
1207 case kTypedDataInt32ArrayCid: | 1165 case kTypedDataInt32ArrayCid: |
1208 UNIMPLEMENTED(); | 1166 UNIMPLEMENTED(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 } | 1315 } |
1358 | 1316 |
1359 | 1317 |
1360 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1318 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1361 __ TraceSimMsg("StoreIndexedInstr"); | 1319 __ TraceSimMsg("StoreIndexedInstr"); |
1362 // The array register points to the backing store for external arrays. | 1320 // The array register points to the backing store for external arrays. |
1363 const Register array = locs()->in(0).reg(); | 1321 const Register array = locs()->in(0).reg(); |
1364 const Location index = locs()->in(1); | 1322 const Location index = locs()->in(1); |
1365 | 1323 |
1366 Address element_address = index.IsRegister() | 1324 Address element_address = index.IsRegister() |
1367 ? ElementAddressForRegIndex(compiler->assembler(), | 1325 ? __ ElementAddressForRegIndex(false, // Store. |
1368 false, // Store. | 1326 IsExternal(), class_id(), index_scale(), |
1369 IsExternal(), class_id(), index_scale(), | 1327 array, index.reg()) |
1370 array, index.reg()) | 1328 : __ ElementAddressForIntIndex( |
1371 : ElementAddressForIntIndex(IsExternal(), class_id(), index_scale(), | 1329 IsExternal(), class_id(), index_scale(), |
1372 array, Smi::Cast(index.constant()).Value()); | 1330 array, Smi::Cast(index.constant()).Value()); |
1373 | 1331 |
1374 switch (class_id()) { | 1332 switch (class_id()) { |
1375 case kArrayCid: | 1333 case kArrayCid: |
1376 if (ShouldEmitStoreBarrier()) { | 1334 if (ShouldEmitStoreBarrier()) { |
1377 Register value = locs()->in(2).reg(); | 1335 Register value = locs()->in(2).reg(); |
1378 __ StoreIntoObject(array, element_address, value); | 1336 __ StoreIntoObject(array, element_address, value); |
1379 } else if (locs()->in(2).IsConstant()) { | 1337 } else if (locs()->in(2).IsConstant()) { |
1380 const Object& constant = locs()->in(2).constant(); | 1338 const Object& constant = locs()->in(2).constant(); |
1381 __ StoreIntoObjectNoBarrier(array, element_address, constant); | 1339 __ StoreIntoObjectNoBarrier(array, element_address, constant); |
1382 } else { | 1340 } else { |
(...skipping 3464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4847 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 4805 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
4848 #if defined(DEBUG) | 4806 #if defined(DEBUG) |
4849 __ LoadImmediate(S4, kInvalidObjectPointer); | 4807 __ LoadImmediate(S4, kInvalidObjectPointer); |
4850 __ LoadImmediate(S5, kInvalidObjectPointer); | 4808 __ LoadImmediate(S5, kInvalidObjectPointer); |
4851 #endif | 4809 #endif |
4852 } | 4810 } |
4853 | 4811 |
4854 } // namespace dart | 4812 } // namespace dart |
4855 | 4813 |
4856 #endif // defined TARGET_ARCH_MIPS | 4814 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |