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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_allocator.h" | 10 #include "vm/flow_graph_allocator.h" |
| (...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1253 | 1253 |
| 1254 bool BinaryIntegerOpInstr::RightIsPowerOfTwoConstant() const { | 1254 bool BinaryIntegerOpInstr::RightIsPowerOfTwoConstant() const { |
| 1255 if (!right()->definition()->IsConstant()) return false; | 1255 if (!right()->definition()->IsConstant()) return false; |
| 1256 const Object& constant = right()->definition()->AsConstant()->value(); | 1256 const Object& constant = right()->definition()->AsConstant()->value(); |
| 1257 if (!constant.IsSmi()) return false; | 1257 if (!constant.IsSmi()) return false; |
| 1258 const intptr_t int_value = Smi::Cast(constant).Value(); | 1258 const intptr_t int_value = Smi::Cast(constant).Value(); |
| 1259 return Utils::IsPowerOfTwo(Utils::Abs(int_value)); | 1259 return Utils::IsPowerOfTwo(Utils::Abs(int_value)); |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 | 1262 |
| 1263 static intptr_t RepresentationBits(Representation r) { | |
| 1264 switch (r) { | |
| 1265 case kTagged: | |
| 1266 return kBitsPerWord - 1; | |
| 1267 case kUnboxedInt32: | |
| 1268 case kUnboxedUint32: | |
| 1269 return 32; | |
| 1270 case kUnboxedMint: | |
| 1271 return 64; | |
| 1272 default: | |
| 1273 UNREACHABLE(); | |
| 1274 return 0; | |
| 1275 } | |
| 1276 } | |
| 1277 | |
| 1278 | |
| 1279 static int64_t RepresentationMask(Representation r) { | |
| 1280 return static_cast<int64_t>( | |
| 1281 static_cast<uint64_t>(-1) >> (64 - RepresentationBits(r))); | |
| 1282 } | |
| 1283 | |
| 1284 | |
| 1263 static bool ToIntegerConstant(Value* value, int64_t* result) { | 1285 static bool ToIntegerConstant(Value* value, int64_t* result) { |
| 1264 if (!value->BindsToConstant()) { | 1286 if (!value->BindsToConstant()) { |
| 1265 UnboxInstr* unbox = value->definition()->AsUnbox(); | 1287 UnboxInstr* unbox = value->definition()->AsUnbox(); |
| 1266 if ((unbox != NULL) && (unbox->representation() == kUnboxedDouble)) { | 1288 if (unbox != NULL) { |
| 1267 return ToIntegerConstant(unbox->value(), result); | 1289 if (unbox->representation() == kUnboxedDouble) { |
| 1290 return ToIntegerConstant(unbox->value(), result); | |
| 1291 } else if (unbox->representation() == kUnboxedUint32) { | |
|
Florian Schneider
2014/11/10 16:10:47
Why are kUnboxedInt32 and kInboxedMint not handled
| |
| 1292 if (ToIntegerConstant(unbox->value(), result)) { | |
| 1293 *result &= RepresentationMask(kUnboxedUint32); | |
| 1294 return true; | |
| 1295 } | |
| 1296 return false; | |
| 1297 } | |
| 1268 } | 1298 } |
| 1269 return false; | 1299 return false; |
| 1270 } | 1300 } |
| 1271 | 1301 |
| 1272 const Object& constant = value->BoundConstant(); | 1302 const Object& constant = value->BoundConstant(); |
| 1273 if (constant.IsDouble()) { | 1303 if (constant.IsDouble()) { |
| 1274 const Double& double_constant = Double::Cast(constant); | 1304 const Double& double_constant = Double::Cast(constant); |
| 1275 *result = static_cast<int64_t>(double_constant.value()); | 1305 *result = static_cast<int64_t>(double_constant.value()); |
| 1276 return (static_cast<double>(*result) == double_constant.value()); | 1306 return (static_cast<double>(*result) == double_constant.value()); |
| 1277 } else if (constant.IsSmi()) { | 1307 } else if (constant.IsSmi()) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 case Token::kBIT_AND: | 1415 case Token::kBIT_AND: |
| 1386 case Token::kBIT_OR: | 1416 case Token::kBIT_OR: |
| 1387 case Token::kBIT_XOR: | 1417 case Token::kBIT_XOR: |
| 1388 return true; | 1418 return true; |
| 1389 default: | 1419 default: |
| 1390 return false; | 1420 return false; |
| 1391 } | 1421 } |
| 1392 } | 1422 } |
| 1393 | 1423 |
| 1394 | 1424 |
| 1395 static intptr_t RepresentationBits(Representation r) { | |
| 1396 switch (r) { | |
| 1397 case kTagged: | |
| 1398 return kBitsPerWord - 1; | |
| 1399 case kUnboxedInt32: | |
| 1400 case kUnboxedUint32: | |
| 1401 return 32; | |
| 1402 case kUnboxedMint: | |
| 1403 return 64; | |
| 1404 default: | |
| 1405 UNREACHABLE(); | |
| 1406 return 0; | |
| 1407 } | |
| 1408 } | |
| 1409 | |
| 1410 | |
| 1411 static int64_t RepresentationMask(Representation r) { | |
| 1412 return static_cast<int64_t>( | |
| 1413 static_cast<uint64_t>(-1) >> (64 - RepresentationBits(r))); | |
| 1414 } | |
| 1415 | |
| 1416 | |
| 1417 UnaryIntegerOpInstr* UnaryIntegerOpInstr::Make(Representation representation, | 1425 UnaryIntegerOpInstr* UnaryIntegerOpInstr::Make(Representation representation, |
| 1418 Token::Kind op_kind, | 1426 Token::Kind op_kind, |
| 1419 Value* value, | 1427 Value* value, |
| 1420 intptr_t deopt_id, | 1428 intptr_t deopt_id, |
| 1421 Range* range) { | 1429 Range* range) { |
| 1422 UnaryIntegerOpInstr* op = NULL; | 1430 UnaryIntegerOpInstr* op = NULL; |
| 1423 switch (representation) { | 1431 switch (representation) { |
| 1424 case kTagged: | 1432 case kTagged: |
| 1425 op = new UnarySmiOpInstr(op_kind, value, deopt_id); | 1433 op = new UnarySmiOpInstr(op_kind, value, deopt_id); |
| 1426 break; | 1434 break; |
| (...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3348 case Token::kTRUNCDIV: return 0; | 3356 case Token::kTRUNCDIV: return 0; |
| 3349 case Token::kMOD: return 1; | 3357 case Token::kMOD: return 1; |
| 3350 default: UNIMPLEMENTED(); return -1; | 3358 default: UNIMPLEMENTED(); return -1; |
| 3351 } | 3359 } |
| 3352 } | 3360 } |
| 3353 | 3361 |
| 3354 | 3362 |
| 3355 #undef __ | 3363 #undef __ |
| 3356 | 3364 |
| 3357 } // namespace dart | 3365 } // namespace dart |
| OLD | NEW |