OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 } | 431 } |
432 | 432 |
433 const Operator* Float64Op(Node* node) { | 433 const Operator* Float64Op(Node* node) { |
434 return changer_->Float64OperatorFor(node->opcode()); | 434 return changer_->Float64OperatorFor(node->opcode()); |
435 } | 435 } |
436 | 436 |
437 bool CanLowerToInt32Binop(Node* node, MachineTypeUnion use) { | 437 bool CanLowerToInt32Binop(Node* node, MachineTypeUnion use) { |
438 return BothInputsAre(node, Type::Signed32()) && !CanObserveNonInt32(use); | 438 return BothInputsAre(node, Type::Signed32()) && !CanObserveNonInt32(use); |
439 } | 439 } |
440 | 440 |
441 bool IsSafeIntAdditiveOperand(Node* node) { | |
442 Type* type = NodeProperties::GetBounds(node).upper; | |
443 // TODO(jarin): Unfortunately, bitset types are not subtypes of larger | |
444 // range types, so we have to explicitly check for Integral32 here | |
445 // (in addition to the safe integer range). Once we fix subtyping for | |
446 // ranges, we should simplify this. | |
447 return type->Is(safe_int_additive_range_) || type->Is(Type::Integral32()); | |
448 } | |
449 | |
450 bool CanLowerToInt32AdditiveBinop(Node* node, MachineTypeUnion use) { | 441 bool CanLowerToInt32AdditiveBinop(Node* node, MachineTypeUnion use) { |
451 return IsSafeIntAdditiveOperand(node->InputAt(0)) && | 442 return BothInputsAre(node, safe_int_additive_range_) && |
452 IsSafeIntAdditiveOperand(node->InputAt(1)) && | |
453 !CanObserveNonInt32(use); | 443 !CanObserveNonInt32(use); |
454 } | 444 } |
455 | 445 |
456 bool CanLowerToUint32Binop(Node* node, MachineTypeUnion use) { | 446 bool CanLowerToUint32Binop(Node* node, MachineTypeUnion use) { |
457 return BothInputsAre(node, Type::Unsigned32()) && !CanObserveNonUint32(use); | 447 return BothInputsAre(node, Type::Unsigned32()) && !CanObserveNonUint32(use); |
458 } | 448 } |
459 | 449 |
460 bool CanLowerToUint32AdditiveBinop(Node* node, MachineTypeUnion use) { | 450 bool CanLowerToUint32AdditiveBinop(Node* node, MachineTypeUnion use) { |
461 return IsSafeIntAdditiveOperand(node->InputAt(0)) && | 451 return BothInputsAre(node, safe_int_additive_range_) && |
462 IsSafeIntAdditiveOperand(node->InputAt(1)) && | |
463 !CanObserveNonUint32(use); | 452 !CanObserveNonUint32(use); |
464 } | 453 } |
465 | 454 |
466 bool CanObserveNonWord32(MachineTypeUnion use) { | 455 bool CanObserveNonWord32(MachineTypeUnion use) { |
467 return (use & ~(kTypeUint32 | kTypeInt32)) != 0; | 456 return (use & ~(kTypeUint32 | kTypeInt32)) != 0; |
468 } | 457 } |
469 | 458 |
470 bool CanObserveNonInt32(MachineTypeUnion use) { | 459 bool CanObserveNonInt32(MachineTypeUnion use) { |
471 return (use & (kTypeUint32 | kTypeNumber | kTypeAny)) != 0; | 460 return (use & (kTypeUint32 | kTypeNumber | kTypeAny)) != 0; |
472 } | 461 } |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 | 1593 |
1605 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 1594 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
1606 node->set_op(machine()->IntLessThanOrEqual()); | 1595 node->set_op(machine()->IntLessThanOrEqual()); |
1607 node->ReplaceInput(0, StringComparison(node, true)); | 1596 node->ReplaceInput(0, StringComparison(node, true)); |
1608 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1597 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1609 } | 1598 } |
1610 | 1599 |
1611 } // namespace compiler | 1600 } // namespace compiler |
1612 } // namespace internal | 1601 } // namespace internal |
1613 } // namespace v8 | 1602 } // namespace v8 |
OLD | NEW |