| 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/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
| 6 #include "src/compiler/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
| 7 #include "src/compiler/js-builtin-reducer.h" | 7 #include "src/compiler/js-builtin-reducer.h" |
| 8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
| 9 #include "src/compiler/node-aux-data-inl.h" | 9 #include "src/compiler/node-aux-data-inl.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // TODO(jarin): Propagate frame state input from non-primitive input node to | 260 // TODO(jarin): Propagate frame state input from non-primitive input node to |
| 261 // JSToNumber node. | 261 // JSToNumber node. |
| 262 r.ConvertInputsToNumber(); | 262 r.ConvertInputsToNumber(); |
| 263 return r.ChangeToPureOperator(simplified()->NumberMultiply()); | 263 return r.ChangeToPureOperator(simplified()->NumberMultiply()); |
| 264 } | 264 } |
| 265 // TODO(turbofan): relax/remove the effects of this operator in other cases. | 265 // TODO(turbofan): relax/remove the effects of this operator in other cases. |
| 266 return NoChange(); | 266 return NoChange(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 | 269 |
| 270 Reduction JSTypedLowering::ReduceJSModulus(Node* node) { |
| 271 JSBinopReduction r(this, node); |
| 272 if (r.left_type()->Is(NodeProperties::GetBounds(node).upper)) { |
| 273 Node* const value = r.left(); |
| 274 NodeProperties::ReplaceWithValue(node, value); |
| 275 return Changed(value); |
| 276 } |
| 277 if (r.BothInputsAre(Type::Primitive())) { |
| 278 r.ConvertInputsToNumber(); |
| 279 return r.ChangeToPureOperator(simplified()->NumberModulus()); |
| 280 } |
| 281 // TODO(turbofan): relax/remove the effects of this operator in other cases. |
| 282 return NoChange(); |
| 283 } |
| 284 |
| 285 |
| 270 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, | 286 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, |
| 271 const Operator* numberOp) { | 287 const Operator* numberOp) { |
| 272 JSBinopReduction r(this, node); | 288 JSBinopReduction r(this, node); |
| 273 if (r.BothInputsAre(Type::Primitive())) { | 289 if (r.BothInputsAre(Type::Primitive())) { |
| 274 r.ConvertInputsToNumber(); | 290 r.ConvertInputsToNumber(); |
| 275 return r.ChangeToPureOperator(numberOp); | 291 return r.ChangeToPureOperator(numberOp); |
| 276 } | 292 } |
| 277 #if 0 | 293 #if 0 |
| 278 // TODO(turbofan): General ToNumber disabled for now because: | 294 // TODO(turbofan): General ToNumber disabled for now because: |
| 279 // a) The inserted ToNumber operation screws up observability of valueOf. | 295 // a) The inserted ToNumber operation screws up observability of valueOf. |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 return ReduceI32Shift(node, false, machine()->Word32Shr()); | 755 return ReduceI32Shift(node, false, machine()->Word32Shr()); |
| 740 case IrOpcode::kJSAdd: | 756 case IrOpcode::kJSAdd: |
| 741 return ReduceJSAdd(node); | 757 return ReduceJSAdd(node); |
| 742 case IrOpcode::kJSSubtract: | 758 case IrOpcode::kJSSubtract: |
| 743 return ReduceNumberBinop(node, simplified()->NumberSubtract()); | 759 return ReduceNumberBinop(node, simplified()->NumberSubtract()); |
| 744 case IrOpcode::kJSMultiply: | 760 case IrOpcode::kJSMultiply: |
| 745 return ReduceJSMultiply(node); | 761 return ReduceJSMultiply(node); |
| 746 case IrOpcode::kJSDivide: | 762 case IrOpcode::kJSDivide: |
| 747 return ReduceNumberBinop(node, simplified()->NumberDivide()); | 763 return ReduceNumberBinop(node, simplified()->NumberDivide()); |
| 748 case IrOpcode::kJSModulus: | 764 case IrOpcode::kJSModulus: |
| 749 return ReduceNumberBinop(node, simplified()->NumberModulus()); | 765 return ReduceJSModulus(node); |
| 750 case IrOpcode::kJSUnaryNot: { | 766 case IrOpcode::kJSUnaryNot: { |
| 751 Reduction result = ReduceJSToBooleanInput(node->InputAt(0)); | 767 Reduction result = ReduceJSToBooleanInput(node->InputAt(0)); |
| 752 Node* value; | 768 Node* value; |
| 753 if (result.Changed()) { | 769 if (result.Changed()) { |
| 754 // JSUnaryNot(x:boolean) => BooleanNot(x) | 770 // JSUnaryNot(x:boolean) => BooleanNot(x) |
| 755 value = | 771 value = |
| 756 graph()->NewNode(simplified()->BooleanNot(), result.replacement()); | 772 graph()->NewNode(simplified()->BooleanNot(), result.replacement()); |
| 757 NodeProperties::ReplaceWithValue(node, value); | 773 NodeProperties::ReplaceWithValue(node, value); |
| 758 return Changed(value); | 774 return Changed(value); |
| 759 } else { | 775 } else { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 782 return JSBuiltinReducer(jsgraph()).Reduce(node); | 798 return JSBuiltinReducer(jsgraph()).Reduce(node); |
| 783 default: | 799 default: |
| 784 break; | 800 break; |
| 785 } | 801 } |
| 786 return NoChange(); | 802 return NoChange(); |
| 787 } | 803 } |
| 788 | 804 |
| 789 } // namespace compiler | 805 } // namespace compiler |
| 790 } // namespace internal | 806 } // namespace internal |
| 791 } // namespace v8 | 807 } // namespace v8 |
| OLD | NEW |