Chromium Code Reviews| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1174 | 1174 |
| 1175 | 1175 |
| 1176 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1176 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1177 Register array = locs()->in(0).reg(); | 1177 Register array = locs()->in(0).reg(); |
| 1178 Location index = locs()->in(1); | 1178 Location index = locs()->in(1); |
| 1179 | 1179 |
| 1180 if (class_id() == kExternalUint8ArrayCid) { | 1180 if (class_id() == kExternalUint8ArrayCid) { |
| 1181 Register result = locs()->out().reg(); | 1181 Register result = locs()->out().reg(); |
| 1182 const Address& element_address = index.IsRegister() | 1182 const Address& element_address = index.IsRegister() |
| 1183 ? FlowGraphCompiler::ExternalElementAddressForRegIndex( | 1183 ? FlowGraphCompiler::ExternalElementAddressForRegIndex( |
| 1184 class_id(), result, index.reg()) | 1184 class_id(), index_scale(), result, index.reg()) |
| 1185 : FlowGraphCompiler::ExternalElementAddressForIntIndex( | 1185 : FlowGraphCompiler::ExternalElementAddressForIntIndex( |
| 1186 class_id(), result, Smi::Cast(index.constant()).Value()); | 1186 class_id(), index_scale(), result, |
| 1187 Smi::Cast(index.constant()).Value()); | |
| 1188 ASSERT(index_scale() == 1); | |
| 1187 if (index.IsRegister()) { | 1189 if (index.IsRegister()) { |
| 1188 __ SmiUntag(index.reg()); | 1190 __ SmiUntag(index.reg()); |
| 1189 } | 1191 } |
| 1190 __ movl(result, | 1192 __ movl(result, |
| 1191 FieldAddress(array, ExternalUint8Array::data_offset())); | 1193 FieldAddress(array, ExternalUint8Array::data_offset())); |
| 1192 __ movzxb(result, element_address); | 1194 __ movzxb(result, element_address); |
| 1193 __ SmiTag(result); | 1195 __ SmiTag(result); |
| 1194 if (index.IsRegister()) { | 1196 if (index.IsRegister()) { |
| 1195 __ SmiTag(index.reg()); // Re-tag. | 1197 __ SmiTag(index.reg()); // Re-tag. |
| 1196 } | 1198 } |
| 1197 return; | 1199 return; |
| 1198 } | 1200 } |
| 1199 | 1201 |
| 1200 FieldAddress element_address = index.IsRegister() | 1202 FieldAddress element_address = index.IsRegister() |
| 1201 ? FlowGraphCompiler::ElementAddressForRegIndex( | 1203 ? FlowGraphCompiler::ElementAddressForRegIndex( |
| 1202 class_id(), array, index.reg()) | 1204 class_id(), index_scale(), array, index.reg()) |
| 1203 : FlowGraphCompiler::ElementAddressForIntIndex( | 1205 : FlowGraphCompiler::ElementAddressForIntIndex( |
| 1204 class_id(), array, Smi::Cast(index.constant()).Value()); | 1206 class_id(), index_scale(), array, |
| 1207 Smi::Cast(index.constant()).Value()); | |
| 1205 | 1208 |
| 1206 if ((representation() == kUnboxedDouble) || | 1209 if ((representation() == kUnboxedDouble) || |
| 1207 (representation() == kUnboxedMint)) { | 1210 (representation() == kUnboxedMint)) { |
| 1208 XmmRegister result = locs()->out().fpu_reg(); | 1211 XmmRegister result = locs()->out().fpu_reg(); |
| 1212 if (index_scale() == 1 && index.IsRegister()) { | |
|
srdjan
2013/02/06 17:11:16
Use parenthesis, here and below.
Florian Schneider
2013/02/14 12:20:51
Done.
| |
| 1213 __ SmiUntag(index.reg()); | |
| 1214 } | |
| 1209 switch (class_id()) { | 1215 switch (class_id()) { |
| 1210 case kInt32ArrayCid: | 1216 case kInt32ArrayCid: |
| 1211 __ movss(result, element_address); | 1217 __ movss(result, element_address); |
| 1212 __ pmovsxdq(result, result); | 1218 __ pmovsxdq(result, result); |
| 1213 break; | 1219 break; |
| 1214 case kUint32ArrayCid: | 1220 case kUint32ArrayCid: |
| 1215 __ xorpd(result, result); | 1221 __ xorpd(result, result); |
| 1216 __ movss(result, element_address); | 1222 __ movss(result, element_address); |
| 1217 break; | 1223 break; |
| 1218 case kFloat32ArrayCid: | 1224 case kFloat32ArrayCid: |
| 1219 // Load single precision float and promote to double. | 1225 // Load single precision float and promote to double. |
| 1220 __ movss(result, element_address); | 1226 __ movss(result, element_address); |
| 1221 __ cvtss2sd(result, locs()->out().fpu_reg()); | 1227 __ cvtss2sd(result, locs()->out().fpu_reg()); |
| 1222 break; | 1228 break; |
| 1223 case kFloat64ArrayCid: | 1229 case kFloat64ArrayCid: |
| 1224 __ movsd(result, element_address); | 1230 __ movsd(result, element_address); |
| 1225 break; | 1231 break; |
| 1226 } | 1232 } |
| 1233 if (index_scale() == 1 && index.IsRegister()) { | |
| 1234 __ SmiTag(index.reg()); // Re-tag. | |
| 1235 } | |
| 1227 return; | 1236 return; |
| 1228 } | 1237 } |
| 1229 | 1238 |
| 1230 Register result = locs()->out().reg(); | 1239 Register result = locs()->out().reg(); |
| 1240 if (index_scale() == 1 && index.IsRegister()) { | |
| 1241 __ SmiUntag(index.reg()); | |
| 1242 } | |
| 1231 switch (class_id()) { | 1243 switch (class_id()) { |
| 1232 case kInt8ArrayCid: | 1244 case kInt8ArrayCid: |
| 1233 case kUint8ArrayCid: | 1245 case kUint8ArrayCid: |
| 1234 case kUint8ClampedArrayCid: | 1246 case kUint8ClampedArrayCid: |
| 1235 case kOneByteStringCid: | 1247 case kOneByteStringCid: |
| 1236 if (index.IsRegister()) { | 1248 ASSERT(index_scale() == 1); |
| 1237 __ SmiUntag(index.reg()); | |
| 1238 } | |
| 1239 if (class_id() == kInt8ArrayCid) { | 1249 if (class_id() == kInt8ArrayCid) { |
| 1240 __ movsxb(result, element_address); | 1250 __ movsxb(result, element_address); |
| 1241 } else { | 1251 } else { |
| 1242 __ movzxb(result, element_address); | 1252 __ movzxb(result, element_address); |
| 1243 } | 1253 } |
| 1244 __ SmiTag(result); | 1254 __ SmiTag(result); |
| 1245 if (index.IsRegister()) { | |
| 1246 __ SmiTag(index.reg()); // Re-tag. | |
| 1247 } | |
| 1248 break; | 1255 break; |
| 1249 case kInt16ArrayCid: | 1256 case kInt16ArrayCid: |
| 1250 __ movsxw(result, element_address); | 1257 __ movsxw(result, element_address); |
| 1251 __ SmiTag(result); | 1258 __ SmiTag(result); |
| 1252 break; | 1259 break; |
| 1253 case kUint16ArrayCid: | 1260 case kUint16ArrayCid: |
| 1254 case kTwoByteStringCid: | 1261 case kTwoByteStringCid: |
| 1255 __ movzxw(result, element_address); | 1262 __ movzxw(result, element_address); |
| 1256 __ SmiTag(result); | 1263 __ SmiTag(result); |
| 1257 break; | 1264 break; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1271 __ testl(result, Immediate(0xC0000000)); | 1278 __ testl(result, Immediate(0xC0000000)); |
| 1272 __ j(NOT_ZERO, deopt); | 1279 __ j(NOT_ZERO, deopt); |
| 1273 __ SmiTag(result); | 1280 __ SmiTag(result); |
| 1274 } | 1281 } |
| 1275 break; | 1282 break; |
| 1276 default: | 1283 default: |
| 1277 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); | 1284 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); |
| 1278 __ movl(result, element_address); | 1285 __ movl(result, element_address); |
| 1279 break; | 1286 break; |
| 1280 } | 1287 } |
| 1288 if (index_scale() == 1 && index.IsRegister()) { | |
| 1289 __ SmiTag(index.reg()); // Re-tag. | |
| 1290 } | |
| 1281 } | 1291 } |
| 1282 | 1292 |
| 1283 | 1293 |
| 1284 Representation StoreIndexedInstr::RequiredInputRepresentation( | 1294 Representation StoreIndexedInstr::RequiredInputRepresentation( |
| 1285 intptr_t idx) const { | 1295 intptr_t idx) const { |
| 1286 if ((idx == 0) || (idx == 1)) return kTagged; | 1296 if ((idx == 0) || (idx == 1)) return kTagged; |
| 1287 ASSERT(idx == 2); | 1297 ASSERT(idx == 2); |
| 1288 switch (class_id_) { | 1298 switch (class_id_) { |
| 1289 case kArrayCid: | 1299 case kArrayCid: |
| 1290 case kInt8ArrayCid: | 1300 case kInt8ArrayCid: |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1351 return NULL; | 1361 return NULL; |
| 1352 } | 1362 } |
| 1353 return locs; | 1363 return locs; |
| 1354 } | 1364 } |
| 1355 | 1365 |
| 1356 | 1366 |
| 1357 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1367 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1358 Register array = locs()->in(0).reg(); | 1368 Register array = locs()->in(0).reg(); |
| 1359 Location index = locs()->in(1); | 1369 Location index = locs()->in(1); |
| 1360 | 1370 |
| 1371 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id()); | |
| 1372 | |
| 1361 FieldAddress element_address = index.IsRegister() ? | 1373 FieldAddress element_address = index.IsRegister() ? |
| 1362 FlowGraphCompiler::ElementAddressForRegIndex( | 1374 FlowGraphCompiler::ElementAddressForRegIndex( |
| 1363 class_id(), array, index.reg()) : | 1375 class_id(), index_scale, array, index.reg()) : |
| 1364 FlowGraphCompiler::ElementAddressForIntIndex( | 1376 FlowGraphCompiler::ElementAddressForIntIndex( |
| 1365 class_id(), array, Smi::Cast(index.constant()).Value()); | 1377 class_id(), index_scale, array, Smi::Cast(index.constant()).Value()); |
| 1366 | 1378 |
| 1367 switch (class_id()) { | 1379 switch (class_id()) { |
| 1368 case kArrayCid: | 1380 case kArrayCid: |
| 1369 if (ShouldEmitStoreBarrier()) { | 1381 if (ShouldEmitStoreBarrier()) { |
| 1370 Register value = locs()->in(2).reg(); | 1382 Register value = locs()->in(2).reg(); |
| 1371 __ StoreIntoObject(array, element_address, value); | 1383 __ StoreIntoObject(array, element_address, value); |
| 1372 } else if (locs()->in(2).IsConstant()) { | 1384 } else if (locs()->in(2).IsConstant()) { |
| 1373 const Object& constant = locs()->in(2).constant(); | 1385 const Object& constant = locs()->in(2).constant(); |
| 1374 __ StoreIntoObjectNoBarrier(array, element_address, constant); | 1386 __ StoreIntoObjectNoBarrier(array, element_address, constant); |
| 1375 } else { | 1387 } else { |
| (...skipping 2023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3399 PcDescriptors::kOther, | 3411 PcDescriptors::kOther, |
| 3400 locs()); | 3412 locs()); |
| 3401 __ Drop(2); // Discard type arguments and receiver. | 3413 __ Drop(2); // Discard type arguments and receiver. |
| 3402 } | 3414 } |
| 3403 | 3415 |
| 3404 } // namespace dart | 3416 } // namespace dart |
| 3405 | 3417 |
| 3406 #undef __ | 3418 #undef __ |
| 3407 | 3419 |
| 3408 #endif // defined TARGET_ARCH_IA32 | 3420 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |