| 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/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 static bool ShouldInlineSimd() { | 56 static bool ShouldInlineSimd() { |
| 57 return FlowGraphCompiler::SupportsUnboxedSimd128(); | 57 return FlowGraphCompiler::SupportsUnboxedSimd128(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 static bool CanUnboxDouble() { | 61 static bool CanUnboxDouble() { |
| 62 return FlowGraphCompiler::SupportsUnboxedDoubles(); | 62 return FlowGraphCompiler::SupportsUnboxedDoubles(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 | 65 |
| 66 static bool ShouldInlineInt64ArrayOps() { |
| 67 #if defined(TARGET_ARCH_X64) |
| 68 return true; |
| 69 #endif |
| 70 return false; |
| 71 } |
| 72 |
| 66 static bool CanConvertUnboxedMintToDouble() { | 73 static bool CanConvertUnboxedMintToDouble() { |
| 67 #if defined(TARGET_ARCH_IA32) | 74 #if defined(TARGET_ARCH_IA32) |
| 68 return true; | 75 return true; |
| 69 #else | 76 #else |
| 70 // ARM does not have a short instruction sequence for converting int64 to | 77 // ARM does not have a short instruction sequence for converting int64 to |
| 71 // double. | 78 // double. |
| 72 // TODO(johnmccutchan): Investigate possibility on MIPS once | 79 // TODO(johnmccutchan): Investigate possibility on MIPS once |
| 73 // mints are implemented there. | 80 // mints are implemented there. |
| 74 return false; | 81 return false; |
| 75 #endif | 82 #endif |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 return kTypedDataUint16ArrayCid; | 1173 return kTypedDataUint16ArrayCid; |
| 1167 | 1174 |
| 1168 case MethodRecognizer::kInt32ArrayGetIndexed: | 1175 case MethodRecognizer::kInt32ArrayGetIndexed: |
| 1169 case MethodRecognizer::kInt32ArraySetIndexed: | 1176 case MethodRecognizer::kInt32ArraySetIndexed: |
| 1170 return kTypedDataInt32ArrayCid; | 1177 return kTypedDataInt32ArrayCid; |
| 1171 | 1178 |
| 1172 case MethodRecognizer::kUint32ArrayGetIndexed: | 1179 case MethodRecognizer::kUint32ArrayGetIndexed: |
| 1173 case MethodRecognizer::kUint32ArraySetIndexed: | 1180 case MethodRecognizer::kUint32ArraySetIndexed: |
| 1174 return kTypedDataUint32ArrayCid; | 1181 return kTypedDataUint32ArrayCid; |
| 1175 | 1182 |
| 1183 case MethodRecognizer::kInt64ArrayGetIndexed: |
| 1184 case MethodRecognizer::kInt64ArraySetIndexed: |
| 1185 return kTypedDataInt64ArrayCid; |
| 1186 |
| 1176 case MethodRecognizer::kFloat32x4ArrayGetIndexed: | 1187 case MethodRecognizer::kFloat32x4ArrayGetIndexed: |
| 1177 case MethodRecognizer::kFloat32x4ArraySetIndexed: | 1188 case MethodRecognizer::kFloat32x4ArraySetIndexed: |
| 1178 return kTypedDataFloat32x4ArrayCid; | 1189 return kTypedDataFloat32x4ArrayCid; |
| 1179 | 1190 |
| 1180 case MethodRecognizer::kInt32x4ArrayGetIndexed: | 1191 case MethodRecognizer::kInt32x4ArrayGetIndexed: |
| 1181 case MethodRecognizer::kInt32x4ArraySetIndexed: | 1192 case MethodRecognizer::kInt32x4ArraySetIndexed: |
| 1182 return kTypedDataInt32x4ArrayCid; | 1193 return kTypedDataInt32x4ArrayCid; |
| 1183 | 1194 |
| 1184 case MethodRecognizer::kFloat64x2ArrayGetIndexed: | 1195 case MethodRecognizer::kFloat64x2ArrayGetIndexed: |
| 1185 case MethodRecognizer::kFloat64x2ArraySetIndexed: | 1196 case MethodRecognizer::kFloat64x2ArraySetIndexed: |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 } | 1301 } |
| 1291 case kTypedDataInt8ArrayCid: | 1302 case kTypedDataInt8ArrayCid: |
| 1292 case kTypedDataUint8ArrayCid: | 1303 case kTypedDataUint8ArrayCid: |
| 1293 case kTypedDataUint8ClampedArrayCid: | 1304 case kTypedDataUint8ClampedArrayCid: |
| 1294 case kExternalTypedDataUint8ArrayCid: | 1305 case kExternalTypedDataUint8ArrayCid: |
| 1295 case kExternalTypedDataUint8ClampedArrayCid: | 1306 case kExternalTypedDataUint8ClampedArrayCid: |
| 1296 case kTypedDataInt16ArrayCid: | 1307 case kTypedDataInt16ArrayCid: |
| 1297 case kTypedDataUint16ArrayCid: | 1308 case kTypedDataUint16ArrayCid: |
| 1298 case kTypedDataInt32ArrayCid: | 1309 case kTypedDataInt32ArrayCid: |
| 1299 case kTypedDataUint32ArrayCid: | 1310 case kTypedDataUint32ArrayCid: |
| 1311 case kTypedDataInt64ArrayCid: |
| 1300 ASSERT(value_type.IsIntType()); | 1312 ASSERT(value_type.IsIntType()); |
| 1301 // Fall through. | 1313 // Fall through. |
| 1302 case kTypedDataFloat32ArrayCid: | 1314 case kTypedDataFloat32ArrayCid: |
| 1303 case kTypedDataFloat64ArrayCid: { | 1315 case kTypedDataFloat64ArrayCid: { |
| 1304 type_args = instantiator = flow_graph_->constant_null(); | 1316 type_args = instantiator = flow_graph_->constant_null(); |
| 1305 ASSERT((array_cid != kTypedDataFloat32ArrayCid && | 1317 ASSERT((array_cid != kTypedDataFloat32ArrayCid && |
| 1306 array_cid != kTypedDataFloat64ArrayCid) || | 1318 array_cid != kTypedDataFloat64ArrayCid) || |
| 1307 value_type.IsDoubleType()); | 1319 value_type.IsDoubleType()); |
| 1308 ASSERT(value_type.IsInstantiated()); | 1320 ASSERT(value_type.IsInstantiated()); |
| 1309 break; | 1321 break; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 case MethodRecognizer::kFloat64x2ArrayGetIndexed: | 1457 case MethodRecognizer::kFloat64x2ArrayGetIndexed: |
| 1446 if (!ShouldInlineSimd()) { | 1458 if (!ShouldInlineSimd()) { |
| 1447 return false; | 1459 return false; |
| 1448 } | 1460 } |
| 1449 return InlineGetIndexed(kind, call, receiver, ic_data, entry, last); | 1461 return InlineGetIndexed(kind, call, receiver, ic_data, entry, last); |
| 1450 case MethodRecognizer::kInt32ArrayGetIndexed: | 1462 case MethodRecognizer::kInt32ArrayGetIndexed: |
| 1451 case MethodRecognizer::kUint32ArrayGetIndexed: | 1463 case MethodRecognizer::kUint32ArrayGetIndexed: |
| 1452 if (!CanUnboxInt32()) return false; | 1464 if (!CanUnboxInt32()) return false; |
| 1453 return InlineGetIndexed(kind, call, receiver, ic_data, entry, last); | 1465 return InlineGetIndexed(kind, call, receiver, ic_data, entry, last); |
| 1454 | 1466 |
| 1467 case MethodRecognizer::kInt64ArrayGetIndexed: |
| 1468 if (!ShouldInlineInt64ArrayOps()) { |
| 1469 return false; |
| 1470 } |
| 1471 return InlineGetIndexed(kind, call, receiver, ic_data, entry, last); |
| 1455 // Recognized []= operators. | 1472 // Recognized []= operators. |
| 1456 case MethodRecognizer::kObjectArraySetIndexed: | 1473 case MethodRecognizer::kObjectArraySetIndexed: |
| 1457 case MethodRecognizer::kGrowableArraySetIndexed: | 1474 case MethodRecognizer::kGrowableArraySetIndexed: |
| 1458 if (ArgIsAlways(kSmiCid, ic_data, 2)) { | 1475 if (ArgIsAlways(kSmiCid, ic_data, 2)) { |
| 1459 value_check = ic_data.AsUnaryClassChecksForArgNr(2); | 1476 value_check = ic_data.AsUnaryClassChecksForArgNr(2); |
| 1460 } | 1477 } |
| 1461 return InlineSetIndexed(kind, target, call, receiver, token_pos, | 1478 return InlineSetIndexed(kind, target, call, receiver, token_pos, |
| 1462 &ic_data, value_check, entry, last); | 1479 &ic_data, value_check, entry, last); |
| 1463 case MethodRecognizer::kInt8ArraySetIndexed: | 1480 case MethodRecognizer::kInt8ArraySetIndexed: |
| 1464 case MethodRecognizer::kUint8ArraySetIndexed: | 1481 case MethodRecognizer::kUint8ArraySetIndexed: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1476 case MethodRecognizer::kInt32ArraySetIndexed: | 1493 case MethodRecognizer::kInt32ArraySetIndexed: |
| 1477 case MethodRecognizer::kUint32ArraySetIndexed: | 1494 case MethodRecognizer::kUint32ArraySetIndexed: |
| 1478 // Check that value is always smi or mint. We use Int32/Uint32 unboxing | 1495 // Check that value is always smi or mint. We use Int32/Uint32 unboxing |
| 1479 // which can only deal unbox these values. | 1496 // which can only deal unbox these values. |
| 1480 value_check = ic_data.AsUnaryClassChecksForArgNr(2); | 1497 value_check = ic_data.AsUnaryClassChecksForArgNr(2); |
| 1481 if (!HasOnlySmiOrMint(value_check)) { | 1498 if (!HasOnlySmiOrMint(value_check)) { |
| 1482 return false; | 1499 return false; |
| 1483 } | 1500 } |
| 1484 return InlineSetIndexed(kind, target, call, receiver, token_pos, | 1501 return InlineSetIndexed(kind, target, call, receiver, token_pos, |
| 1485 &ic_data, value_check, entry, last); | 1502 &ic_data, value_check, entry, last); |
| 1503 case MethodRecognizer::kInt64ArraySetIndexed: |
| 1504 if (!ShouldInlineInt64ArrayOps()) { |
| 1505 return false; |
| 1506 } |
| 1507 return InlineSetIndexed(kind, target, call, receiver, token_pos, |
| 1508 &ic_data, value_check, entry, last); |
| 1486 case MethodRecognizer::kFloat32ArraySetIndexed: | 1509 case MethodRecognizer::kFloat32ArraySetIndexed: |
| 1487 case MethodRecognizer::kFloat64ArraySetIndexed: | 1510 case MethodRecognizer::kFloat64ArraySetIndexed: |
| 1488 if (!CanUnboxDouble()) { | 1511 if (!CanUnboxDouble()) { |
| 1489 return false; | 1512 return false; |
| 1490 } | 1513 } |
| 1491 // Check that value is always double. | 1514 // Check that value is always double. |
| 1492 if (!ArgIsAlways(kDoubleCid, ic_data, 2)) { | 1515 if (!ArgIsAlways(kDoubleCid, ic_data, 2)) { |
| 1493 return false; | 1516 return false; |
| 1494 } | 1517 } |
| 1495 value_check = ic_data.AsUnaryClassChecksForArgNr(2); | 1518 value_check = ic_data.AsUnaryClassChecksForArgNr(2); |
| (...skipping 8624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10120 | 10143 |
| 10121 // Insert materializations at environment uses. | 10144 // Insert materializations at environment uses. |
| 10122 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 10145 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 10123 CreateMaterializationAt( | 10146 CreateMaterializationAt( |
| 10124 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); | 10147 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); |
| 10125 } | 10148 } |
| 10126 } | 10149 } |
| 10127 | 10150 |
| 10128 | 10151 |
| 10129 } // namespace dart | 10152 } // namespace dart |
| OLD | NEW |